polm / cutlet

Japanese to romaji converter in Python
https://polm.github.io/cutlet/
MIT License
286 stars 20 forks source link

KeyError: 'ー' #13

Closed ykim closed 4 years ago

ykim commented 4 years ago

It looks like 'ー' causes an issue on 0.1.10. Here is an example:

% cutlet
押忍! ハト☆マツ学園男子寮! DC (12) プラトーーーン の巻
Traceback (most recent call last):
  File "/Users/ykim/.local/share/virtualenvs/sandbox-nIHPi2Hu/bin/cutlet", line 8, in <module>
    sys.exit(main())
  File "/Users/ykim/.local/share/virtualenvs/sandbox-nIHPi2Hu/lib/python3.8/site-packages/cutlet/cli.py", line 16, in main
    print(katsu.romaji(line.strip()))
  File "/Users/ykim/.local/share/virtualenvs/sandbox-nIHPi2Hu/lib/python3.8/site-packages/cutlet/cutlet.py", line 129, in romaji
    roma = self.romaji_word(word)
  File "/Users/ykim/.local/share/virtualenvs/sandbox-nIHPi2Hu/lib/python3.8/site-packages/cutlet/cutlet.py", line 193, in romaji_word
    return self.map_kana(kana)
  File "/Users/ykim/.local/share/virtualenvs/sandbox-nIHPi2Hu/lib/python3.8/site-packages/cutlet/cutlet.py", line 233, in map_kana
    out += self.get_single_mapping(pk, char, nk)
  File "/Users/ykim/.local/share/virtualenvs/sandbox-nIHPi2Hu/lib/python3.8/site-packages/cutlet/cutlet.py", line 249, in get_single_mapping
    if pk: return self.table[pk][-1]
KeyError: 'ー'

I'm guessing that a repeated sequence of ー is the issue :/

polm commented 4 years ago

Nice catch, repeated 長音符 does indeed seem to have been the issue. I'll put out a release with the fix soon.

Out of curiosity, are you using cutlet at Crunchyroll?