polm / cutlet

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

Is it possible to generate furigana for Kanji using this library? #37

Closed FlippFuzz closed 10 months ago

FlippFuzz commented 11 months ago

It would be a nice feature. Hopefully, this is possible because we are already generating the romaji.

polm commented 10 months ago

If you want furigana, you don't need this library unless you want your furigana to be romaji, you can use fugashi directly. Something like this:

import fugashi

tagger = fugashi.Tagger()
kana = [nn.feature.kana for nn in tagger("吾輩は猫である")]
# => ['ワガハイ', 'ハ', 'ネコ', 'デ', 'アル']

The output will be katakana, not hiragana, but that can be easily converted.

polm commented 10 months ago

Closing since this should be resolved, but feel free to follow up if you still have questions.