Juillermo / pycedict

A library for parsing CEDict and adding tone marks to pinyin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PyCEDict

A library made for working with CC-CEDICT and pinyin.

Installation

pip install pycedict

Quick Start

Download CC-CEDICT and gunzip it, save as cedict.txt.

$ python
...
>>> import cedict
>>> infile = open('cedict.txt')
>>> for ch, chs, pinyin, defs, variants, mw in cedict.iter_cedict(infile):
...     print chs, pinyin, defs # or probably load this info into your database

iter_cedict will parse "CL:" (classifier/measure word) and "see also" entries in cedict and provide this information in the variants and mw variables above, respectively.

You can also add tone marks to pinyin with tone numbers (or remove the tone marks)

>>> print cedict.pinyinize('ni3hao3')
nǐhǎo
>>> print cedict.depinyinize('nǐhǎo')
ni3hao3

About

A library for parsing CEDict and adding tone marks to pinyin

License:Other


Languages

Language:Jupyter Notebook 80.3%Language:Python 19.7%