Update u4/word_count.py

This commit is contained in:
Roman Dmytruk 2026-10-26 23:46:14 +00:00
parent a9053e5f7d
commit c12445eceb

View File

@ -4,6 +4,6 @@ from collections import Counter
def count_words(text: str) -> dict[str, int]: def count_words(text: str) -> dict[str, int]:
text = text.lower() text = text.lower()
words = re.findall(r"[a-z0-9áäčďéíľňóôŕšťúýž]+(?:'[a-z0-9áäčďéíľňóôŕšťúýž]+)?", text) words = re.findall(r"\b[a-z0-9áäčďéíľňóôŕšťúýž]+(?:'[a-z0-9áäčďéíľňóôŕšťúýž]+)?\b", text)
return dict(Counter(words)) return dict(Counter(words))