From 01ecb88aa5b79476359d388476dddb31cc47d92b Mon Sep 17 00:00:00 2001 From: Oleksandr Mateshchuk Date: Tue, 6 Oct 2026 12:34:11 +0000 Subject: [PATCH] fin --- u4/word_count.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/u4/word_count.py b/u4/word_count.py index 0e33fd9..d67cd90 100644 --- a/u4/word_count.py +++ b/u4/word_count.py @@ -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)) \ No newline at end of file + return dict(Counter(words)) + + +word_count = count_words \ No newline at end of file