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))