Pure-Python Japanese character interconverter for Hiragana, Katakana, Hankaku and Zenkaku
Python
Latest commit 55d95b5 Feb 20, 2017 @ikegami-yukino committed on GitHub Merge pull request #2 from nemu626/master
[fix] fix bug in kana<=>alphabet converion function
Permalink
Failed to load latest commit information.
jaconv
.gitignore
.travis.yml
CHANGES.rst v0.2 Apr 2, 2016
LICENSE First commit Mar 22, 2014
MANIFEST.in
README.rst
README_JP.rst
setup.py
test_jaconv.py

README.rst

jaconv

travis-ci.org coveralls.io pyversion latest version license

jaconv (Japanese Converter) is interconverter for Hiragana, Katakana, Hankaku (half-width character) and Zenkaku (full-width character)

INSTALLATION

$ pip install jaconv

USAGE

import jaconv

# Hiragana to Katakana
jaconv.hira2kata(u'ともえまみ')
# => u'トモエマミ'

# Hiragana to half-width Katakana
jaconv.hira2hkata(u'ともえまみ')
# => u'トモエマミ'

# Katakana to Hiragana
jaconv.kata2hira(u'巴マミ')
# => u'巴まみ'

# half-width character to full-width character
jaconv.h2z(u'ティロ・フィナーレ')
# => u'ティロ・フィナーレ'

# half-width character to full-width character
# but only ascii characters
jaconv.h2z(u'abc', ascii=True)
# => u'abc'

# half-width character to full-width character
# but only digit characters
jaconv.h2z(u'123', digit=True)
# => u'123'

# half-width character to full-width character
# except half-width Katakana
jaconv.h2z(u'アabc123', kana=False, digit=True, ascii=True)
# => u'アabc123'

# full-width character to half-width character
jaconv.z2h(u'ティロ・フィナーレ')
# => u'ティロ・フィナーレ'

# full-width character to half-width character
# but only ascii characters
jaconv.z2h(u'abc', ascii=True)
# => u'abc'

# full-width character to half-width character
# but only digit characters
jaconv.z2h(u'123', digit=True)
# => u'123'

# full-width character to half-width character
# except full-width Katakana
jaconv.z2h(u'アabc123', kana=False, digit=True, ascii=True)
# => u'アabc123'

# normalize
jaconv.normalize(u'ティロ・フィナ〜レ', 'NFKC')
# => u'ティロ・フィナーレ'

# Hiragana to alphabet
jaconv.kana2alphabet(u'じゃぱん')
# => japan

# Alphabet to Hiragana
jaconv.alphabet2kana(u'japan')
# => じゃぱん

NOTE

jaconv.normalize method expand unicodedata.normalize for Japanese language processing.

'〜' => 'ー'
'~' => 'ー'
"’" => "'"
'”'=> '"'
'“' => '``'
'―' => '-'
'‐' => '-'
'˗' => '-'
'֊' => '-'
'‐' => '-'
'‑' => '-'
'‒' => '-'
'–' => '-'
'⁃' => '-'
'⁻' => '-'
'₋' => '-'
'−' => '-'
'﹣' => 'ー'
'-' => 'ー'
'—' => 'ー'
'―' => 'ー'
'━' => 'ー'
'─' => 'ー'