Skip to main content

Zhon provides constants used in Chinese text processing.

Project description

https://badge.fury.io/py/zhon.svg https://github.com/tsroten/zhon/actions/workflows/ci.yml/badge.svg

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

About

Zhon’s constants can be used in Chinese text processing, for example:

  • Find CJK characters in a string:

    >>> re.findall('[{}]'.format(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ē.']

Features

Zhon includes the following commonly-used constants:

  • 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

Getting Started

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-2.1.1.tar.gz (84.4 kB view details)

Uploaded Source

Built Distribution

zhon-2.1.1-py3-none-any.whl (83.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: zhon-2.1.1.tar.gz
  • Upload date:
  • Size: 84.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.2

File hashes

Hashes for zhon-2.1.1.tar.gz
Algorithm Hash digest
SHA256 c8da424fad4aa698ddd3e1735515b49ff522c84dd1091e8fafd986ac7c6898f0
MD5 0a76747d186de6a60b8c8fdef42c5903
BLAKE2b-256 2a8de6c8ee4df75940ddecb6f5e7b2753a9a3914e6cd357e7238987661723d81

See more details on using hashes here.

File details

Details for the file zhon-2.1.1-py3-none-any.whl.

File metadata

  • Download URL: zhon-2.1.1-py3-none-any.whl
  • Upload date:
  • Size: 83.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.2

File hashes

Hashes for zhon-2.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9ec0d42229ae60708a045270f755ccefb48f2689f2a6ce0bc6597abf6c4a9871
MD5 dc7ab2199e4095e133f2ecec9c0e4073
BLAKE2b-256 be13b8d6ca3a41bf5959bc3915678837385bf668162a7295140d81ccae0b96b7

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