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