用于操作jim breen的jmdict和kanjidic2的python库
jamdict的Python项目详细描述
用于操作Jim Breen的jmdict&kanjidic2的Python库
主要功能
- 直接以XML格式查询JMDICT和Kanjidic2(但速度慢)
- 将jmdict和kanjidic2转换为sqlite格式以加快访问速度
- 基本控制台查找工具
- jamdol(jamdict online)-使用python/flask的rest api(jamdol flask)
安装
主页:https://github.com/neocl/jamdict
pip install jamdict # pip script sometimes doesn't work properly, so you may want to try this instead python3 -m pip install jamdict # initial setup (this command will create ~/.jamdict for you# it will also tell you where to copy the data files python3 -m jamdict.tools info # to look up a word using command line python3 -m jamdict.tools lookup たべる======================================== Found entries======================================== Entry: 1358280| Kj: 食べる, 喰べる | Kn: たべる -------------------- 1. to eat ((Ichidan verb|transitive verb))2. to live on (e.g. a salary)/to live off/to subsist on======================================== Found characters======================================== Char: 食 | Strokes: 9 -------------------- Readings: shi2, si4, sig, sa, 식, 사, Thực, Tự, ショク, ジキ, く.う, く.らう, た.べる, は.む Meanings: eat, food Char: 喰 | Strokes: 12 -------------------- Readings: shi2, si4, sig, 식, Thặc, Thực, Tự, く.う, く.らう Meanings: eat, drink, receive (a blow), (kokuji)
数据
XML文件(jmdict_e.xml,kanjidic2.xml)必须下载并复制到~/.jamdict/data
我已将这些文件镜像到Google Drive,因此您也可以在那里下载: https://drive.google.com/drive/folders/1z4zF9ImZlNeTZZplflvvnpZfJp3WVLPk
官方网站
- jmdict:http://edrdg.org/jmdict/edict_doc.html
- 看图2:http://www.edrdg.org/kanjidic/kanjd2index.html
- 克雷德维尔:http://www.edrdg.org/krad/kradinf.html
示例代码
>>>fromjamdictimportJamdict>>>jmd=Jamdict()# use wildcard matching to find anything starts with 食べ and ends with る>>>result=jmd.lookup('食べ%る')# print all found word entries>>>forentryinresult.entries:...print(entry)...[id#1358280] たべる (食べる) : 1. to eat ((Ichidan verb|transitive verb)) 2. to live on (e.g. a salary)/to live off/to subsist on[id#1358300] たべすぎる (食べ過ぎる) : to overeat ((Ichidan verb|transitive verb))[id#1852290] たべつける (食べ付ける) : to be used to eating ((Ichidan verb|transitive verb))[id#2145280] たべはじめる (食べ始める) : to start eating ((Ichidan verb))[id#2449430] たべかける (食べ掛ける) : to start eating ((Ichidan verb))[id#2671010] たべなれる (食べ慣れる) : to be used to eating/to become used to eating/to be accustomed to eating/to acquire a taste for ((Ichidan verb))[id#2765050] たべられる (食べられる) : 1. to be able to eat ((Ichidan verb|intransitive verb)) 2. to be edible/to be good to eat ((pre-noun adjectival (rentaishi)))[id#2795790] たべくらべる (食べ比べる) : to taste and compare several dishes (or foods) of the same type ((Ichidan verb|transitive verb))[id#2807470] たべあわせる (食べ合わせる) : to eat together (various foods) ((Ichidan verb))# print all related characters>>>forcinresult.chars:...print(repr(c))...食:9:eat,food喰:12:eat,drink,receive(ablow),(kokuji)過:12:overdo,exceed,gobeyond,error付:5:adhere,attach,referto,append始:8:commence,begin掛:11:hang,suspend,depend,arriveat,tax,pour慣:14:accustomed,getusedto,becomeexperienced比:4:compare,race,ratio,Philippines合:6:fit,suit,join,0.1# use exact matching to increase searching speed (thanks to @reem-codes)result=jmd.lookup('食べる')>>>forentryinresult.entries:...print(entry)...[id#1358280] たべる (食べる) : 1. to eat ((Ichidan verb|transitive verb)) 2. to live on (e.g. a salary)/to live off/to subsist on
for c in result.chars: ... print(repr(c))
有关详细信息,请参见jamdict_demo.py
和jamdict/tools.py
。