Skip to main content

Pure-Python Japanese character interconverter for Hiragana, Katakana, Hankaku, Zenkaku, as well as Zenkaku or Hankaku Tester

Project description

jaconvV2

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

jaconvV2 (Japanese Converter) can detect whether a character is Zenkaku or Hankaku, and also support interconvertion for Hiragana, Katakana, Hankaku (half-width character) and Zenkaku (full-width character)

Japanese README is available.

INSTALLATION

$ pip install jaconvV2

USAGE

See also document

import jaconvV2


# Test if Zenkaku
jaconvV2.is_zen('D')
# => True

# Test if Hankaku
jaconvV2.is_han('D')
# => True


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

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

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

# half-width character to full-width character
# default parameters are followings: kana=True, ascii=False, digit=False
jaconvV2.h2z('ティロ・フィナーレ')
# => 'ティロ・フィナーレ'

# half-width character to full-width character
# but only ascii characters
jaconvV2.h2z('abc', kana=False, ascii=True, digit=False)
# => 'abc'

# half-width character to full-width character
# but only digit characters
jaconvV2.h2z('123', kana=False, ascii=False, digit=True)
# => '123'

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

# an alias of h2z
jaconvV2.hankaku2zenkaku('ティロ・フィナーレabc123')
# => 'ティロ・フィナーレabc123'

# full-width character to half-width character
# default parameters are followings: kana=True, ascii=False, digit=False
jaconvV2.z2h('ティロ・フィナーレ')
# => 'ティロ・フィナーレ'

# full-width character to half-width character
# but only ascii characters
jaconvV2.z2h('abc', kana=False, ascii=True, digit=False)
# => 'abc'

# full-width character to half-width character
# but only digit characters
jaconvV2.z2h('123', kana=False, ascii=False, digit=True)
# => '123'

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

# an alias of z2h
jaconvV2.zenkaku2hankaku('ティロ・フィナーレabc123')
# => 'ティロ・フィナーレabc123'

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

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

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

# Katakana to Alphabet
jaconvV2.kata2alphabet('ケツイ')
# => 'ketsui'

# Alphabet to Katakana
jaconvV2.alphabet2kata('namba')
# => 'ナンバ'

# Hiragana to Julius's phoneme format
jaconvV2.hiragana2julius('てんきすごくいいいいいい')
# => 't e N k i s u g o k u i:'

NOTE

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

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

CHANGES

0.4 (2021-08-24)

  • Add functions: is_han(char): Check if character is Hankaku

  • Add Function: is_zen(char): Check if character is Zenkaku

0.3 (2021-03-29)

  • Fix bug (alphabet2kana) thanks @Cuddlemuffin007

  • Support Python 3.8 and 3.9

  • Add handy functions: alphabet2kata and kata2alphabet. thanks @kokimame

  • Add function for julius: hiragana2julius

0.2.4 (2018-02-04)

  • Fix bug (kana2alphabet)

  • Support Python 3.7

  • No longer support Python 2.6

  • Add aliases of z2h -> zenkaku2hankaku and h2z -> hankaku2zenkaku

0.2.3 (2018-02-03)

  • Fix bugs (alphabet2kana, kana2alphabet) thanks @letuananh

0.2.2 (2018-01-22)

  • Fix bug (kana2alphabet) thanks @kokimame

  • Support Python 3.6

0.2.1 (2017-09-14)

  • Fix bugs (alphabet2kana, kana2alphabet)

0.2 (2015-04-02)

  • Change module name jctconv -> jaconv

  • Add alphabet and hiragana interconvert (alphabet2kana, kana2alphabet)

0.1.1 (2015-03-12)

  • Support Windows

  • Support Python 3.5

0.1 (2014-11-24)

  • Add some Japanese characters to convert table (ゝゞ・「」。、)

  • Decresing memory usage

  • Some function names are deprecated (hankaku2zenkaku, zenkaku2hankaku, H2K, H2hK, K2H)

0.0.7 (2014-03-22)

z2h and h2z allow mojimoji-like target character type determination. Bug fix about Half Kana conversion.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jaconvV2-0.4-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file jaconvV2-0.4-py3-none-any.whl.

File metadata

  • Download URL: jaconvV2-0.4-py3-none-any.whl
  • Upload date:
  • Size: 16.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.10

File hashes

Hashes for jaconvV2-0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 015bcd37fb740e30f444d2c89df6219ce74ed8f1835af5ebd6c74b06de5e4d5c
MD5 883391436e71fc0328402c54d39ba17d
BLAKE2b-256 ff15d55b1df868a8a9ba5953c07be41f4742dca787652a28d5fe860d1b177a22

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page