fin
This commit is contained in:
parent
007674c96b
commit
01ecb88aa5
@ -3,6 +3,11 @@ from collections import Counter
|
|||||||
|
|
||||||
|
|
||||||
def count_words(text):
|
def count_words(text):
|
||||||
pattern = r"\w+(?:'\w+)?"
|
text = text.replace("_", " ")
|
||||||
|
text = text.replace("’", "'")
|
||||||
|
pattern = r"[^\W_]+(?:'[^\W_]+)?"
|
||||||
words = re.findall(pattern, text.lower())
|
words = re.findall(pattern, text.lower())
|
||||||
return dict(Counter(words))
|
return dict(Counter(words))
|
||||||
|
|
||||||
|
|
||||||
|
word_count = count_words
|
||||||
Loading…
Reference in New Issue
Block a user