10 lines
213 B
Python
10 lines
213 B
Python
import re
|
|
|
|
def count_words(text):
|
|
words = re.findall(r"\b[\w]+(?:'[\w]+)?\b", text.lower(), re.UNICODE)
|
|
result = {}
|
|
|
|
for word in words:
|
|
result[word] = result.get(word, 0) + 1
|
|
|
|
return result |