8 lines
174 B
Python
8 lines
174 B
Python
import re
|
|
from collections import Counter
|
|
|
|
|
|
def count_words(text):
|
|
pattern = r"\w+(?:'\w+)?"
|
|
words = re.findall(pattern, text.lower())
|
|
return dict(Counter(words)) |