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.9.post0.tar.gz
(39.6 kB
view details)
File details
Details for the file mojimoji-0.0.9.post0.tar.gz
.
File metadata
- Download URL: mojimoji-0.0.9.post0.tar.gz
- Upload date:
- Size: 39.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/18.2 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e07191fb74e24c741c7c9408b12c238e27b604cfaaf28ee5cd3947f89fde5d5 |
|
MD5 | a5570d62a3978cd37382d69b20d6093b |
|
BLAKE2b-256 | 102df5d58e74af1c1b4eeea66ecc14f35ae8f275f39bc7158ba51a6e8a86dfdf |