You can easily convert kanji, hiragana, and katakana by using pykakasi.
You can install the library by entering the following command at the command prompt.
pip install pykakasi
Example of use
test.py
from pykakasi import kakasi
kakasi = kakasi()
kakasi.setMode('J', 'H') #Convert from kanji to hiragana
kakasi.setMode("K", "H") #Convert from katakana to hiragana
conv = kakasi.getConverter()
str = 'Tokyo Tower'
print(conv.do(str))
Execution result
python test.py
Tokyo Tower
You can convert it like this, so if you have a chance, please use it.
Recommended Posts