To use the CC-CEDICT Chinese to English dictionary in Python.
pip install pycccedict
- Get an entry
from pycccedict.cccedict import CcCedict
cccedict = CcCedict()
cccedict.get_entry('猫')
{
"traditional": "貓",
"simplified": "猫",
"pinyin": "mao1",
"definitions": [
"cat",
"CL:隻|只[zhi1]",
"(dialect) to hide oneself",
"(coll.) modem"
]
}
>>> cccedict.get_entry('猫')
{
"traditional": "貓",
"simplified": "猫",
"pinyin": "mao1",
"definitions": [
"cat",
"CL:隻|只[zhi1]",
"(dialect) to hide oneself",
"(coll.) modem"
]
}
>>> cccedict.get_entries()[:2]
[{'traditional': '%', 'simplified': '%', 'pinyin': 'pa1', 'definitions': ['percent (Tw)']}, {'traditional': '2019冠狀病毒病', 'simplified': '2019冠状病毒病', 'pinyin': 'er4 ling2 yi1 jiu3 guan1 zhuang4 bing4 du2 bing4', 'definitions': ['COVID-19, the coronavirus disease identified in 2019']}]
>>> cccedict.get_traditional('猫')
'貓'
>>> cccedict.get_simplified('貓')
'猫'
>>> cccedict.get_pinyin('猫')
'mao1'
>>> cccedict.get_definitions('猫')
['cat', 'CL:隻|只[zhi1]', '(dialect) to hide oneself', '(coll.) modem']