A nlp tool to convert numbers to chinese characters
Project description
num2chinese
A nlp tool to transform numbers to Chinese
num2chinese
uses regular expression to parse alphanumeric literals and transform them into readable Chinese charaters.
Why it matters
- Chinese's pronuncication has lots of exceptions.
- For Chinese numbers, a character is uttered dependent of context.
- Lots of rules are required to handle messy Chinese number pronunciation. Dont' reinvent the wheel!
Examples
- $120 : 美金一百二十
- 200塊 : 兩百塊
- 12121212個蘋果 : 一千兩百一十二萬一千兩百一十二個蘋果
- 2002002支 : 兩百萬兩千零二支
- 9487 : 九四八七
- 080080123 : 零八零零八零一二
Usage
text = '12121212個蘋果''
normalizer = InverseNormalizer()
text_normalized = normalizer.normalize(text)
print(text_normalized)
# result is '一千兩百萬十二萬一千兩百一十二個蘋果'
Installation
pip install num2chinese
Requirements
python>=3.2,<4.0
License
MIT license
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
num2chinese-0.0.0.tar.gz
(2.7 kB
view details)
Built Distribution
File details
Details for the file num2chinese-0.0.0.tar.gz
.
File metadata
- Download URL: num2chinese-0.0.0.tar.gz
- Upload date:
- Size: 2.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab0f8840df1591eeb2fa41499a88956e85e839ab0c5272a6c3755d37de8d5556 |
|
MD5 | a5ec1c5e51d0f53f97b25f2da5fe7923 |
|
BLAKE2b-256 | c6e27bdc8016d3dae0bc538f71a83744f19e7b52e33c70aec65c591e5f2aba66 |
File details
Details for the file num2chinese-0.0.0-py3-none-any.whl
.
File metadata
- Download URL: num2chinese-0.0.0-py3-none-any.whl
- Upload date:
- Size: 2.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b81a2f8cd69ea8f9faafcfe62b652021b45b144379fdf387e1d3042ddd6eac70 |
|
MD5 | e46a71b8976ca1f0474beee7a8ba2c33 |
|
BLAKE2b-256 | 2ff3622f1c554cc020c1c3e3e5b08e77f5bd5acc42b8b1211b67c7cbcf3f3360 |