def _load_gazetteers(language_resources_path, language):
gazetteers_path = os.path.join(language_resources_path, "gazetteers")
if not os.path.isdir(gazetteers_path):
return dict()
gazetteers = dict()
for filename in os.listdir(gazetteers_path):
gazetteer_name = os.path.splitext(filename)[0]
gazetteer_path = os.path.join(gazetteers_path, filename)
with io.open(gazetteer_path, encoding="utf8") as f:
gazetteers[gazetteer_name] = set()
for line in f:
normalized = normalize(line.strip())
After Change
def _load_gazetteers(gazetteers_path, language):
if not gazetteers_path.is_dir():
return dict()
gazetteers = dict()