mirror of
https://github.com/rspeer/wordfreq.git
synced 2024-12-24 09:51:38 +00:00
parent
f1e71839ea
commit
16494f1869
@ -291,6 +291,11 @@ def word_frequency(word, lang, wordlist='combined', default=0.):
|
||||
|
||||
@lru_cache(maxsize=100)
|
||||
def top_n_list(lang, n, wordlist='combined', ascii_only=False):
|
||||
"""
|
||||
Return a frequency list of length `n` in descending order of frequency.
|
||||
This list contains words from `wordlist`, of the given language.
|
||||
If `ascii_only`, then only ascii words are considered.
|
||||
"""
|
||||
results = []
|
||||
for word in iter_wordlist(lang, wordlist):
|
||||
if (not ascii_only) or max(word) <= '~':
|
||||
|
Loading…
Reference in New Issue
Block a user