Code Monkey home page Code Monkey logo

python-romkan's Introduction

python-romkan

Build Status PyPI version

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 (fully tested on Python 2.6, 2.7, 3.2, 3.3 and PyPy). It handles both Katakana (片仮名) and Hiragana (平仮名) with the Hepburn (ヘボン式) romanization system, as well as the modern Kunrei-shiki (訓令式) romanization system.

Project homepage: http://www.soimort.org/python-romkan

Fork me on GitHub: https://github.com/soimort/python-romkan

Installation

1. Install via Pip:

$ pip install romkan

2. Install via EasyInstall:

$ easy_install romkan

3. Install from Git:

$ git clone git://github.com/soimort/python-romkan.git
$ python setup.py 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 Reference

  • to_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.

python-romkan's People

Contributors

crlotwhite avatar melissaboiko avatar soimort avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.