Skip to main content

A nlp tool to transform 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.6,<4.0

License

MIT license

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

num2chinese-0.0.1.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

num2chinese-0.0.1-py3-none-any.whl (2.6 kB view details)

Uploaded Python 3

File details

Details for the file num2chinese-0.0.1.tar.gz.

File metadata

  • Download URL: num2chinese-0.0.1.tar.gz
  • Upload date:
  • Size: 2.9 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

Hashes for num2chinese-0.0.1.tar.gz
Algorithm Hash digest
SHA256 c8a1723dead398b0f7c1b180a2973704e681a83d1287e8585bc5b92102be3944
MD5 bd760984b8f9355d304fdb623c87ebfa
BLAKE2b-256 145e829905c873d95d2f474590cecd183e1c16d3e92e551922a642b3b6b4163e

See more details on using hashes here.

File details

Details for the file num2chinese-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: num2chinese-0.0.1-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

Hashes for num2chinese-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ec9312eba995ec288296d5cf82321921006e197ae44f47716db431a4b1c9ad46
MD5 ebe1ce11879d55e11b9afe90489cb582
BLAKE2b-256 c1eca5b4068db8b57880839ac3e9d96b8c95a446fe860814d7cb54e800e94a5d

See more details on using hashes here.

Supported by

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