用于操作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

官方网站

示例代码

>>>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.pyjamdict/tools.py

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何使用jaxb整理集合?   java改装添加带有令牌和id的标头   Java Webstart在启动应用程序之前停止   mysql将请求主体作为JSON存储到Java数据库中   春天3。从Java 7更新到Java 8后x应用程序不工作   java如何为我的mock实例化unirest HttpResponse<JsonNode>?   java两个servlet在同一场战争中与两场独立战争中的利弊?   java Mockito验证未失败   GWT中的java文件读取器   java避免代码重复   java谁将设置saml cookie,其中包含凭证信息   java如何修改jar包代码,然后重新导出更新的jar包?   BST数据结构中的java递归差异   java如何从文本文件中读取存储的哈希表?   带有quercus的java php comet   java从SeleniumWebDriver写入json变量   javascript如何在同一个action类中对方法调用action?