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
for c in result.chars: ... print(repr(c))
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.1a5.tar.gz
(34.9 kB
view details)
File details
Details for the file jamdict-0.1a5.tar.gz
.
File metadata
- Download URL: jamdict-0.1a5.tar.gz
- Upload date:
- Size: 34.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e5d51463b6ec6da0c8a91650290831dc7437c0002cf45813d49a765de070555 |
|
MD5 | 1a09ae5e73c6b412ca990844766fc687 |
|
BLAKE2b-256 | cb7f1d477a16ace42f124c978baa3c6e1f41c91b6dce704dc85687f0195b805d |