A fast converter between Japanese hankaku and zenkaku characters
Project description
A fast converter between Japanese hankaku and zenkaku characters.
Installation
$ pip install mojimoji
Examples
Zenkaku to Hankaku
>>> import mojimoji
>>> print mojimoji.zen_to_han(u'アイウabc012')
アイウabc012
>>> print mojimoji.zen_to_han(u'アイウabc012', kana=False)
アイウabc012
>>> print mojimoji.zen_to_han(u'アイウabc012', digit=False)
アイウabc012
>>> print mojimoji.zen_to_han(u'アイウabc012', ascii=False)
アイウabc012
Hankaku to Zenkaku
>>> import mojimoji
>>> print mojimoji.han_to_zen(u'アイウabc012')
アイウabc012
>>> print mojimoji.han_to_zen(u'アイウabc012', kana=False)
アイウabc012
>>> print mojimoji.han_to_zen(u'アイウabc012', digit=False)
アイウabc012
>>> print mojimoji.han_to_zen(u'アイウabc012', ascii=False)
アイウabc012
Benchmarks
Library versions
mojimoji: 0.0.1
zenhan: 0.4
unicodedata: Bundled with Python 2.7.3
Results
In [19]: s = u'ABCDEFG012345' * 10
In [20]: %time for n in range(1000000): mojimoji.zen_to_han(s)
CPU times: user 2.86 s, sys: 0.10 s, total: 2.97 s
Wall time: 2.88 s
In [21]: %time for n in range(1000000): unicodedata.normalize('NFKC', s)
CPU times: user 5.43 s, sys: 0.12 s, total: 5.55 s
Wall time: 5.44 s
In [22]: %time for n in range(1000000): zenhan.z2h(s)
CPU times: user 69.18 s, sys: 0.11 s, total: 69.29 s
Wall time: 69.48 s
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mojimoji-0.0.10.dev0.tar.gz
(42.6 kB
view hashes)
Built Distributions
Close
Hashes for mojimoji-0.0.10.dev0-cp38-cp38-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c313fbe855c6b35705ebe8097369db06c683358a140f5f463476bf2f4e8206aa |
|
MD5 | b6275d8967969f31dd2dd2a013d0b770 |
|
BLAKE2b-256 | f3fd57d1929990f9169adb02edbbea3500c72af8f09b39e8cc5508216b951557 |
Close
Hashes for mojimoji-0.0.10.dev0-cp37-cp37m-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3055525642a4794e47a881551b022ec2e4347fe6d26c8c66698282c72dce79e0 |
|
MD5 | 31d01fbb028260440e8400597891436e |
|
BLAKE2b-256 | 454b2a985f77c3483986f5aab746aa2c2bd8078e8c7e88375942b29ec7386a10 |
Close
Hashes for mojimoji-0.0.10.dev0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1573438831a5052030f8450f400c00a97c43c42b60d3d22a98f4f7597029aea |
|
MD5 | e140cf2f96dfad2c1f34c4d54f0497fc |
|
BLAKE2b-256 | 4aca02acd77a537a2e33f0b678b109416b61aeaa34ffd172f2a77fbcef3d1267 |
Close
Hashes for mojimoji-0.0.10.dev0-cp35-cp35m-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb7b430158fca9b0cec2c654cd0af58ff469d420e4c34095bd09a2a88ec82ea9 |
|
MD5 | f31ec6c4a96790b01c46bd13b287c818 |
|
BLAKE2b-256 | 0be007ff4b2d88d320cac4fae89f404a3ce07c538b54f34fcb5bcbec893b0437 |