mirror of
https://github.com/rspeer/wordfreq.git
synced 2024-12-25 10:15:23 +00:00
Merge pull request #6 from LuminosoInsight/code-review-leftovers
Code review leftovers
This commit is contained in:
commit
30de0ff17f
@ -50,10 +50,17 @@ CONFIG = {
|
|||||||
|
|
||||||
|
|
||||||
def data_filename(filename):
|
def data_filename(filename):
|
||||||
|
"""
|
||||||
|
Convert a relative filename to a path inside the configured data_dir.
|
||||||
|
"""
|
||||||
return os.path.join(CONFIG['data_dir'], filename)
|
return os.path.join(CONFIG['data_dir'], filename)
|
||||||
|
|
||||||
|
|
||||||
def wordlist_filename(source, language, extension='txt'):
|
def wordlist_filename(source, language, extension='txt'):
|
||||||
|
"""
|
||||||
|
Get the path where a particular built wordlist should go, parameterized by
|
||||||
|
its language and its file extension.
|
||||||
|
"""
|
||||||
path = CONFIG['wordlist_paths'][source].format(
|
path = CONFIG['wordlist_paths'][source].format(
|
||||||
lang=language, ext=extension
|
lang=language, ext=extension
|
||||||
)
|
)
|
||||||
@ -64,11 +71,15 @@ def source_names(language):
|
|||||||
"""
|
"""
|
||||||
Get the names of data sources that supply data for the given language.
|
Get the names of data sources that supply data for the given language.
|
||||||
"""
|
"""
|
||||||
return sorted([key for key in CONFIG['sources']
|
return sorted(key for key in CONFIG['sources']
|
||||||
if language in CONFIG['sources'][key]])
|
if language in CONFIG['sources'][key])
|
||||||
|
|
||||||
|
|
||||||
def all_languages():
|
def all_languages():
|
||||||
|
"""
|
||||||
|
Get all languages that should have their data built, which is those that
|
||||||
|
are supported by at least `min_sources` sources.
|
||||||
|
"""
|
||||||
languages = set()
|
languages = set()
|
||||||
for langlist in CONFIG['sources'].values():
|
for langlist in CONFIG['sources'].values():
|
||||||
languages |= set(langlist)
|
languages |= set(langlist)
|
||||||
|
Loading…
Reference in New Issue
Block a user