Skip to main content

Zhon provides constants used in Chinese text processing.

Project description

Zhon is a Python library that provides constants commonly used in Chinese text processing:

  • CJK characters and radicals

  • Chinese punctuation marks

  • Chinese sentence regular expression pattern

  • Pinyin vowels, consonants, lowercase, uppercase, and punctuation

  • Pinyin syllable, word, and sentence regular expression patterns

  • Zhuyin characters and marks

  • Zhuyin syllable regular expression pattern

  • CC-CEDICT characters

Some quick examples:

  • Find CJK characters in a string:

    >>> re.findall('[%s]' % zhon.hanzi.characters, 'I broke a plate: 我打破了一个盘子.')
    ['我', '打', '破', '了', '一', '个', '盘', '子']
  • Validate Pinyin syllables, words, or sentences:

    >>> re.findall(zhon.pinyin.syllable, 'Yuànzi lǐ tíngzhe yí liàng chē.', re.I)
    ['Yuàn', 'zi', 'lǐ', 'tíng', 'zhe', 'yí', 'liàng', 'chē']
    
    >>> re.findall(zhon.pinyin.word, 'Yuànzi lǐ tíngzhe yí liàng chē.', re.I)
    ['Yuànzi', 'lǐ', 'tíngzhe', 'yí', 'liàng', 'chē']
    
    >>> re.findall(zhon.pinyin.sentence, 'Yuànzi lǐ tíngzhe yí liàng chē.', re.I)
    ['Yuànzi lǐ tíngzhe yí liàng chē.']

Documentation

Zhon has complete documentation. Check it out if you want to find out how to use Zhon.

Name

Zhon is short for ZHongwen cONstants. It is pronounced like the name ‘John’.

Install

Zhon supports Python 2.7 and 3. Install using pip:

$ pip install zhon

Bugs and Feature Requests

Zhon uses its GitHub Issues page to track bugs, feature requests, and support questions.

License

Zhon is released under the OSI-approved MIT License. See the file LICENSE.txt for more information.

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

zhon-1.1.2.tar.gz (97.9 kB view details)

Uploaded Source

File details

Details for the file zhon-1.1.2.tar.gz.

File metadata

  • Download URL: zhon-1.1.2.tar.gz
  • Upload date:
  • Size: 97.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for zhon-1.1.2.tar.gz
Algorithm Hash digest
SHA256 04268eccd02f283f128c6a6da6ab3d0107df042ba2a96040e7150a2729590161
MD5 ed432c51d90e9289d407df8e1bcae9f6
BLAKE2b-256 f00c2d63c1f71050706883b41f8eeb4394191b2a2abe4efbf1fa5021db73ad3e

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