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

Uploaded Source

Built Distribution

zhon-2.0.2-py3-none-any.whl (84.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for zhon-2.0.2.tar.gz
Algorithm Hash digest
SHA256 c834df6b1b182f7e973e796ded80ed1f61f271fd25f6b0dc0c44f7c4ea467184
MD5 676494d53806a747173643e87837b126
BLAKE2b-256 cfda1ff0761d6c0d2fca7f19e65d19e960354dfe6cbc1664041e3c3e711d757a

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for zhon-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e868e8308766e04866eacf37e8cf054a089d4b07cac62179b03f90a80757afe6
MD5 1abb6819c657b0d3b0250fedb1624c48
BLAKE2b-256 cfe1fedce8230b9f4b07d34f2a25ea5f08071712ea512f959d831f32d257aee9

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