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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mojimoji2-0.1.3.tar.gz
(42.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mojimoji2-0.1.3.tar.gz.
File metadata
- Download URL: mojimoji2-0.1.3.tar.gz
- Upload date:
- Size: 42.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba392713e8d1174da18d47df5616b43e9e08a18470953a3b36a3d979697026f9
|
|
| MD5 |
5d5836c41dadbdbfdef42f2c2b067e7f
|
|
| BLAKE2b-256 |
092614efb8cea62a4975ca271a62f30399f60dffa5fba3df9966920a46ef5a84
|
File details
Details for the file mojimoji2-0.1.3-cp37-cp37m-macosx_10_14_x86_64.whl.
File metadata
- Download URL: mojimoji2-0.1.3-cp37-cp37m-macosx_10_14_x86_64.whl
- Upload date:
- Size: 41.8 kB
- Tags: CPython 3.7m, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d7fe621832d175c700659ce216a1b7db264e3369fffb1987a0940450d0ffc51
|
|
| MD5 |
72f5464ea73b3fa3be1d8e6ea28213b1
|
|
| BLAKE2b-256 |
366e6de23f03c769029956327c429c5fc5c6724fed1b6d45a94af02f40a5cdb6
|