diff --git a/tests/test_queries.py b/tests/test_queries.py index a86f6e8..8b44a23 100644 --- a/tests/test_queries.py +++ b/tests/test_queries.py @@ -1,6 +1,7 @@ from __future__ import unicode_literals from nose.tools import eq_, assert_almost_equal, assert_greater -from wordfreq.query import (word_frequency, average_frequency, wordlist_size, +from wordfreq import word_frequency +from wordfreq.query import (average_frequency, wordlist_size, wordlist_info) diff --git a/wordfreq/__init__.py b/wordfreq/__init__.py index 0768d0d..959be05 100644 --- a/wordfreq/__init__.py +++ b/wordfreq/__init__.py @@ -1,2 +1,16 @@ -# Import some methods from wordfreq.query at the top level. -from wordfreq.query import word_frequency, iter_wordlist, random_words +# Make wordfreq.query available at the top level when needed. + +def word_frequency(word, lang, wordlist='multi', offset=0.): + """ + Get the frequency of `word` in the language with code `lang`, from the + specified `wordlist`. + + The offset gets added to all values, to monotonically account for the + fact that we have not observed all possible words. + + This is a wrapper for the real word_frequency function, so that it can + be imported at the top level instead of from `wordfreq.query`. + """ + from wordfreq.query import word_frequency as _real_word_frequency + return _real_word_frequency(word, lang, wordlist=wordlist, offset=offset) +