Python library for manipulating Jim Breen's JMdict & KanjiDic2
Project description
Python library for manipulating Jim Breen's JMdict & KanjiDic2
Main features
- Query JMDict and KanjiDic2 in XML format directly (but slow)
- Convert JMDict and KanjiDic2 into SQLite format for faster access
- Basic console lookup tool
- jamdol (jamdict-online) - REST API using Python/Flask (jamdol-flask)
Installation
Homepage: 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)
Data
XML files (JMdict_e.xml, kanjidic2.xml) must be downloaded and copy into ~/.jamdict/data
I have mirrored these files to Google Drive so you can download there too: https://drive.google.com/drive/folders/1z4zF9ImZlNeTZZplflvvnpZfJp3WVLPk
Official website
- JMdict: http://edrdg.org/jmdict/edict_doc.html
- kanjidic2: http://www.edrdg.org/kanjidic/kanjd2index.html
- KRADFILE: http://www.edrdg.org/krad/kradinf.html
Sample codes
>>> from jamdict import Jamdict
>>> jmd = Jamdict()
# use wildcard matching to find anything starts with 食べ and ends with る
>>> result = jmd.lookup('食べ%る')
# print all found word entries
>>> for entry in result.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
>>> for c in result.chars:
... print(repr(c))
...
食:9:eat,food
喰:12:eat,drink,receive (a blow),(kokuji)
過:12:overdo,exceed,go beyond,error
付:5:adhere,attach,refer to,append
始:8:commence,begin
掛:11:hang,suspend,depend,arrive at,tax,pour
慣:14:accustomed,get used to,become experienced
比: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('食べる')
>>> for entry in result.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
See jamdict_demo.py
and jamdict/tools.py
for more information.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
jamdict-0.1a6.tar.gz
(188.7 kB
view details)
File details
Details for the file jamdict-0.1a6.tar.gz
.
File metadata
- Download URL: jamdict-0.1a6.tar.gz
- Upload date:
- Size: 188.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.2 pkginfo/1.4.2 requests/2.20.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.37.0 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec0e6542b85ce37e473f84a3d9e7fa314895f36fe16880199c45ad48322133bc |
|
MD5 | d1a4e38f477643f5f36d13d301b3d8c7 |
|
BLAKE2b-256 | 806cc9fa24290c3123dd507ebd32d5aaa890eff3f02c80080fc068bbb5e824d3 |