Skip to main content

Translate chinese chars to pinyin based on Mandarin.dat

Project description

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('你 好')
 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.

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

pinyin-0.4.0.tar.gz (3.6 MB view details)

Uploaded Source

File details

Details for the file pinyin-0.4.0.tar.gz.

File metadata

  • Download URL: pinyin-0.4.0.tar.gz
  • Upload date:
  • Size: 3.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pinyin-0.4.0.tar.gz
Algorithm Hash digest
SHA256 8842ae53cb7a81c8c3ec03d1cd7dba9aedb20d8d6962aebc620fad74da0868f5
MD5 8f38b91fa71bfb594f894bf63ebc2607
BLAKE2b-256 3295d2969f1071b7bc0afff407d1d7b4b3f445e8e6b59df7921c9c09e35ee375

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