python-romkan is a Romaji/Kana conversion library for Python, which is used to convert a Japanese Romaji (ローマ字) string to a Japanese Kana (仮名) string or vice versa.
It is the Pythonic port of Ruby/Romkan, originally authored by Satoru Takabayashi and ported by Masato Hagiwara.
python-romkan works on Python 2 and Python 3. It handles both Katakana (片仮名) and Hiragana (平仮名) with the Hepburn (ヘボン式) romanization system, as well as the modern Kunrei-shiki (訓令式) romanization system.
Project homepage: https://github.com/soimort/python-romkan
Why am I making this?
The original Ruby/Romkan can only handle Hiragana, while the original Python port Python/Romkan only handles Katakana. I need a library which can handle both of them.
I’d like to use the library as a standard Python Package.
I want to use Python 3.
PyPI homepage: http://pypi.python.org/pypi/romkan
Installation
Install via Pip:
$ pip install romkan
Install via EasyInstall:
$ easy_install romkan
Install from Git:
$ git clone git://github.com/soimort/python-romkan.git$ ninja install
Usage
Python 3.x:
$ python>>> import romkan>>> print(romkan.to_roma("にんじゃ"))ninja>>> print(romkan.to_hepburn("にんじゃ"))ninja>>> print(romkan.to_kunrei("にんじゃ"))ninzya>>> print(romkan.to_hiragana("ninja"))にんじゃ>>> print(romkan.to_katakana("ninja"))ニンジャ
Python 2.x:
$ python2>>> import romkan>>> print romkan.to_roma(u"にんじゃ")ninja>>> print romkan.to_hepburn(u"にんじゃ")ninja>>> print romkan.to_kunrei(u"にんじゃ")ninzya>>> print romkan.to_hiragana("ninja")にんじゃ>>> print romkan.to_katakana("ninja")ニンジャ
API Referenceto_katakana(string)
Convert a Romaji (ローマ字) to a Katakana (片仮名).
to_hiragana(string)
Convert a Romaji (ローマ字) to a Hiragana (平仮名).
to_kana(string)
Convert a Romaji (ローマ字) to a Katakana (片仮名). (same as to_katakana)
to_hepburn(string)
Convert a Kana (仮名) or a Kunrei-shiki Romaji (訓令式ローマ字) to a Hepburn Romaji (ヘボン式ローマ字).
to_kunrei(string)
Convert a Kana (仮名) or a Hepburn Romaji (ヘボン式ローマ字) to a Kunrei-shiki Romaji (訓令式ローマ字).
to_roma(string)
Convert a Kana (仮名) to a Hepburn Romaji (ヘボン式ローマ字).
License
python-romkan is licensed under the BSD license.
Acknowledgement
高林哲さん(Ruby/Romkan)と、萩原正人さん(Python/Romkan)に感謝申し上げます。