Skip to main content

Chinese text to Jyutping conversion library in Python

Project description

PyJyutping

Chinese text to Jyutping (粵拼; a standard of Cantonese romanization) conversion library in Python. Conversion is based on an officially published Cantonese Pronunciation List. This library performs the conversion using the Jyutping romanization table prepared by Dr. Samuel Cheng, which has been further converted to a dictionary file in JSON format.

Installation

pip install pyjyutping

Usage

Python

>>> from pyjyutping import jyutping
>>> jyutping.convert("我係香港人")
'ngo5 hai6 hoeng1 gong2 jan4'

Tone number in output can be disabled:

>>> jyutping.convert("我係香港人", tone=False)
'ngo hai hoeng gong jan'

Alphabets and digits are preserved in the conversion:

>>> jyutping.convert("香港嘅英文係Hong Kong")
'hoeng1 gong2 ge3 jing1 man4 hai6 Hong Kong'
>>> jyutping.convert("1841年1月25號香港開埠")
'1841 nin4 1 jyut6 25 hou6 hoeng1 gong2 hoi1 bou6'

Command-Line Interface Tool

$ pyjyutping 我係香港人
ngo5 hai6 hoeng1 gong2 jan4

License

MIT

Project details


Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pyjyutping, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size pyjyutping-1.0.0-py3-none-any.whl (143.7 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size pyjyutping-1.0.0.tar.gz (140.7 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page