Skip to main content
http://img.shields.io/pypi/v/pinyin.svg?style=flat http://img.shields.io/travis/lxyu/pinyin/master.svg?style=flat

Translate chinese chars to pinyin based on Mandarin.dat

Install

$ pip install pinyin

Usage

>>> import pinyin
>>> print pinyin.get('你 好')
nǐ hǎo

>>> print pinyin.get('你好', format="strip", delimiter=" ")
ni hao

>>> print pinyin.get('你好', format="numerical")
ni3hao3

>>> print pinyin.get_initial('你好')
n h

Prototype Chinese->English

>>> import pinyin.cedict
>>> pinyin.cedict.translate_word('你')
['you (informal, as opposed to courteous 您[nin2])']
>>> pinyin.cedict.translate_word('你好')
['Hello!', 'Hi!', 'How are you?']
>>> list(pinyin.cedict.all_phrase_translations('你好'))
[['你', ['you (informal, as opposed to courteous 您[nin2])']], ['你好', ['Hello!', 'Hi!', 'How are you?']], ['好', ['to be fond of', 'to have a tendency to', 'to be prone to']]]

Note that this is a prototype, and only functions from Python 3.

License

pinyin is free software, under an MIT-style license. See LICENSE for details.

The data file for translations is the CC-BY-SA 3.0.

The translations are from the CC-CE-DICT project (https://cc-cedict.org/wiki/), by Denisowski, Peterson, Brelsford, and others.

Metadata

Release files for pinyin 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pinyin 0.4.0
File Size Uploaded Provenance
pinyin-0.4.0.tar.gz 3.6 MB Without provenance Details

Release files / pinyin-0.4.0.tar.gz

Download URL pinyin-0.4.0.tar.gz
Size 3.6 MB
Tags Source
SHA-256 checksum
How to use checksums
8842ae53cb7a81c8c3ec03d1cd7dba9aedb20d8d6962aebc620fad74da0868f5
BLAKE2b-256 checksum
How to use checksums
3295d2969f1071b7bc0afff407d1d7b4b3f445e8e6b59df7921c9c09e35ee375
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for pinyin 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page