This commit is contained in:
Oleksandr Mateshchuk 2026-10-06 12:34:11 +00:00
parent 007674c96b
commit 01ecb88aa5

View File

@ -3,6 +3,11 @@ from collections import Counter
def count_words(text):
pattern = r"\w+(?:'\w+)?"
text = text.replace("_", " ")
text = text.replace("’", "'")
pattern = r"[^\W_]+(?:'[^\W_]+)?"
words = re.findall(pattern, text.lower())
return dict(Counter(words))
word_count = count_words