Giter VIP home page Giter VIP logo

pinyin's Introduction

Pinyin

image

image

image

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

Note

format must be one of: numerical/diacritical/strip

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.

pinyin's People

Contributors

iccanobif avatar lxyu avatar pmitros avatar

Forkers

digideskio

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.