mirror of
https://github.com/rspeer/wordfreq.git
synced 2024-12-23 17:31:41 +00:00
Merge pull request #10 from LuminosoInsight/returns-none-bugfix
word_frequency no longer returns None if it does not detect tokens
Former-commit-id: 97bbb97f63
This commit is contained in:
commit
f8ac142bcf
@ -227,7 +227,12 @@ def word_frequency(word, lang, wordlist='combined', default=0.):
|
||||
"""
|
||||
freqs = get_frequency_dict(lang, wordlist)
|
||||
combined_value = None
|
||||
for token in tokenize(word, lang):
|
||||
tokens = tokenize(word, lang)
|
||||
|
||||
if len(tokens) == 0:
|
||||
return default
|
||||
|
||||
for token in tokens:
|
||||
if token not in freqs:
|
||||
# If any word is missing, just return the default value
|
||||
return default
|
||||
|
Loading…
Reference in New Issue
Block a user