Skip to content

jdillworth/pycedict

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages