rspeer / wordfreq

Access a database of word frequencies, in various natural languages.
Other
1.4k stars 101 forks source link

Suggestion: allow function for `minimum` #72

Closed gezakerecsenyi closed 5 years ago

gezakerecsenyi commented 5 years ago

I am very grateful for the current minimum argument: it has helped me on many occasions. However, I am wondering if it would be possible for minimum to also accept a function/lamda, since this would simplify a lot of things? For instance, something like:

zipf_frequency("dog", "en", minimum=lambda word: math.log10(len(word)))
rspeer commented 5 years ago

Thanks for the suggestion. But it appears to me that this could be done in a shorter, simpler way with no extra code needed in wordfreq:

max(zipf_frequency("dog", "en"), math.log10(len(word)))