stems_paths = glob.glob(os.path.join(RESOURCES_PATH, "stems_*.json"))
for path in stems_paths:
_, filename = os.path.split(path)
lang = os.path.splitext(filename)[0].split("_")[-1]
with io.open(path, encoding="utf8") as f:
_LANGUAGE_STEMS[lang] = ujson.load(f)
After Change
def language_stems(language):
global _LANGUAGE_STEMS
if language.iso_code not in _LANGUAGE_STEMS:
_LANGUAGE_STEMS[language.iso_code] = verbs_stems(language)
return _LANGUAGE_STEMS[language.iso_code]