def _load_reromanizer(self, table, decompose):
path = os.path.join('data', 'reromanize', table + '.csv')
try:
path = pkg_resources.resource_filename(__name__, path)
except:
print('Could not locate {}.'.format(path), file=sys.stderr)
if os.path.isfile(path):
mapping = {}
with open(path, 'rb') as f:
reader = csv.reader(f, encoding='utf-8')
next(reader)
for ipa, rom in reader:
rom = normalize('NFD', rom) if decompose else normalize('NFC', rom)
mapping[ipa] = rom
return mapping
else:
print('File {} does not exist.'.format(path), file=sys.stderr)
return {}
评论列表
文章目录