# Jamdict
[Jamdict](https://github.com/neocl/jamdict) is a Python 3 library for manipulating Jim Breen's JMdict, KanjiDic2, JMnedict and kanji-radical mappings.
[![ReadTheDocs Badge](https://readthedocs.org/projects/jamdict/badge/?version=latest&style=plastic)](https://jamdict.readthedocs.io/)
**Documentation:** https://jamdict.readthedocs.io/
# Main features
* Support querying different Japanese language resources
- Japanese-English dictionary JMDict
- Kanji dictionary KanjiDic2
- Kanji-radical and radical-kanji maps KRADFILE/RADKFILE
- Japanese Proper Names Dictionary (JMnedict)
* Fast look up (dictionaries are stored in SQLite databases)
* Command-line lookup tool [(Example)](#command-line-tools)
[Contributors](#contributors) are welcome! π. If you want to help, please see [Contributing](https://jamdict.readthedocs.io/en/latest/contributing.html) page.
# Try Jamdict out
Jamdict is used in [Jamdict-web](https://jamdict.herokuapp.com/) - a web-based free and open-source Japanese reading assistant software.
Please try out the demo instance online at:
https://jamdict.herokuapp.com/
There also is a demo [Jamdict virtual machine](https://replit.com/@tuananhle/jamdict-demo) online for trying out Jamdict Python code on Repl.it:
https://replit.com/@tuananhle/jamdict-demo
# Installation
Jamdict & Jamdict database are both available on [PyPI](https://pypi.org/project/jamdict/) and can be installed using pip
```bash
pip install --upgrade jamdict jamdict-data
```
# Sample jamdict Python code
```python
from jamdict import Jamdict
jam = Jamdict()
# use wildcard matching to find anything starts with ι£γΉ and ends with γ
result = jam.lookup('ι£γΉ%γ')
# print all 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
```
## Command line tools
To make sure that jamdict is configured properly, try to look up a word using command line
```bash
python3 -m jamdict lookup θ¨θͺε¦
========================================
Found entries
========================================
Entry: 1264430 | Kj: θ¨θͺε¦ | Kn: γγγγγ
--------------------
1. linguistics ((noun (common) (futsuumeishi)))
========================================
Found characters
========================================
Char: θ¨ | Strokes: 7
--------------------
Readings: yan2, eon, μΈ, NgΓ΄n, NgΓ’n, γ²γ³, γ΄γ³, γ.γ, γγ¨
Meanings: say, word
Char: θͺ | Strokes: 14
--------------------
Readings: yu3, yu4, eo, μ΄, Ngα»―, Ngα»©, γ΄, γγ.γ, γγ.γγ
Meanings: word, speech, language
Char: ε¦ | Strokes: 8
--------------------
Readings: xue2, hag, ν, HoΜ£c, γ¬γ―, γΎγͺ.γΆ
Meanings: study, learning, science
No name was found.
```
## Using KRAD/RADK mapping
Jamdict has built-in support for KRAD/RADK (i.e. kanji-radical and radical-kanji mapping).
The terminology of radicals/components used by Jamdict can be different from else where.
- A radical in Jamdict is a principal component, each character has only one radical.
- A character may be decomposed into several writing components.
By default jamdict provides two maps:
- jam.krad is a Python dict that maps characters to list of components.
- jam.radk is a Python dict that maps each available components to a list of characters.
```python
# Find all writing components (often called "radicals") of the character ι²
print(jam.krad['ι²'])
# ['δΈ', 'ι¨', 'δΊ', 'εΆ']
# Find all characters with the component ιΌ
chars = jam.radk['ιΌ']
print(chars)
# {'ιΌ', 'ιΌ', 'ιΌ', 'ιΌ', 'ιΌ'}
# look up the characters info
result = jam.lookup(''.join(chars))
for c in result.chars:
print(c, c.meanings())
# ιΌ ['cover of tripod cauldron']
# ιΌ ['large tripod cauldron with small']
# ιΌ ['incense tripod']
# ιΌ ['three legged kettle']
# ιΌ []
```
## Finding name entities
```bash
# Find all names with ι΄ζ¨ inside
result = jam.lookup('%ι΄ζ¨%')
for name in result.names:
print(name)
# [id#5025685] γγ₯γΌγγ£γΌγγγ (γγ₯γΌγγ£γΌι΄ζ¨) : Kyu-ti- Suzuki (1969.10-) (full name of a particular person)
# [id#5064867] γγγ€γ€γγγ (γγγ€γ€ι΄ζ¨) : Papaiya Suzuki (full name of a particular person)
# [id#5089076] γ©γΈγ«γ«γγγ (γ©γΈγ«γ«ι΄ζ¨) : Rajikaru Suzuki (full name of a particular person)
# [id#5259356] γγ€γγγγγγγ²γͺγ (ηε΄ι΄ζ¨ζ₯ε) : Kitsunezakisuzukihinata (place name)
# [id#5379158] γγγγ (ε°ι΄ζ¨) : Kosuzuki (family or surname)
# [id#5398812] γγΏγγγ (δΈι΄ζ¨) : Kamisuzuki (family or surname)
# [id#5465787] γγγγγ (ε·ι΄ζ¨) : Kawasuzuki (family or surname)
# [id#5499409] γγγγγ (倧ι΄ζ¨) : Oosuzuki (family or surname)
# [id#5711308] γγγ (ι΄ζ¨) : Susuki (family or surname)
# ...
```
## Exact matching
Use exact matching for faster search.
Find the word θ±η« by idseq (1194580)
```python
>>> result = jam.lookup('id#1194580')
>>> print(result.names[0])
[id#1194580] γ―γͺγ³ (θ±η«) : fireworks ((noun (common) (futsuumeishi)))
```
Find an exact name θ±η« by idseq (5170462)
```python
>>> result = jam.lookup('id#5170462')
>>> print(result.names[0])
[id#5170462] γ―γͺγ³ (θ±η«) : Hanabi (female given name or forename)
```
See `jamdict_demo.py` and `jamdict/tools.py` for more information.
# Useful links
* JMdict: [http://edrdg.org/jmdict/edict_doc.html](http://edrdg.org/jmdict/edict_doc.html)
* kanjidic2: [https://www.edrdg.org/wiki/index.php/KANJIDIC_Project](https://www.edrdg.org/wiki/index.php/KANJIDIC_Project)
* JMnedict: [https://www.edrdg.org/enamdict/enamdict_doc.html](https://www.edrdg.org/enamdict/enamdict_doc.html)
* KRADFILE: [http://www.edrdg.org/krad/kradinf.html](http://www.edrdg.org/krad/kradinf.html)
# Contributors
- [Le Tuan Anh](https://github.com/letuananh) (Maintainer)
- [alt-romes](https://github.com/alt-romes)
- [Matteo Fumagalli](https://github.com/matteofumagalli1275)
- [Reem Alghamdi](https://github.com/reem-codes)
- [Techno-coder](https://github.com/Techno-coder)
Raw data
{
"_id": null,
"home_page": "https://github.com/neocl/jamdict",
"name": "jamdict",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "dictionary,japanese,kanji,japanese-language,jmdict,japanese-study,kanjidic2,japanese-dictionary,jamdict",
"author": "Le Tuan Anh",
"author_email": "tuananh.ke@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/1c/20/98bcf088707850f0c9104b6499b9afff7a4db2e5849a9a99e436400e0a6d/jamdict-0.1a11.post2.tar.gz",
"platform": "any",
"description": "# Jamdict\n\n[Jamdict](https://github.com/neocl/jamdict) is a Python 3 library for manipulating Jim Breen's JMdict, KanjiDic2, JMnedict and kanji-radical mappings.\n\n[![ReadTheDocs Badge](https://readthedocs.org/projects/jamdict/badge/?version=latest&style=plastic)](https://jamdict.readthedocs.io/)\n\n**Documentation:** https://jamdict.readthedocs.io/ \n\n# Main features\n\n* Support querying different Japanese language resources\n - Japanese-English dictionary JMDict\n - Kanji dictionary KanjiDic2\n - Kanji-radical and radical-kanji maps KRADFILE/RADKFILE\n - Japanese Proper Names Dictionary (JMnedict) \n* Fast look up (dictionaries are stored in SQLite databases)\n* Command-line lookup tool [(Example)](#command-line-tools)\n\n[Contributors](#contributors) are welcome! \ud83d\ude47. If you want to help, please see [Contributing](https://jamdict.readthedocs.io/en/latest/contributing.html) page.\n\n# Try Jamdict out\n\nJamdict is used in [Jamdict-web](https://jamdict.herokuapp.com/) - a web-based free and open-source Japanese reading assistant software.\nPlease try out the demo instance online at:\n\nhttps://jamdict.herokuapp.com/\n\nThere also is a demo [Jamdict virtual machine](https://replit.com/@tuananhle/jamdict-demo) online for trying out Jamdict Python code on Repl.it:\n\nhttps://replit.com/@tuananhle/jamdict-demo\n\n# Installation\n\nJamdict & Jamdict database are both available on [PyPI](https://pypi.org/project/jamdict/) and can be installed using pip\n\n```bash\npip install --upgrade jamdict jamdict-data\n```\n\n# Sample jamdict Python code\n\n```python\nfrom jamdict import Jamdict\njam = Jamdict()\n\n# use wildcard matching to find anything starts with \u98df\u3079 and ends with \u308b\nresult = jam.lookup('\u98df\u3079%\u308b')\n\n# print all word entries\nfor entry in result.entries:\n print(entry)\n\n# [id#1358280] \u305f\u3079\u308b (\u98df\u3079\u308b) : 1. to eat ((Ichidan verb|transitive verb)) 2. to live on (e.g. a salary)/to live off/to subsist on\n# [id#1358300] \u305f\u3079\u3059\u304e\u308b (\u98df\u3079\u904e\u304e\u308b) : to overeat ((Ichidan verb|transitive verb))\n# [id#1852290] \u305f\u3079\u3064\u3051\u308b (\u98df\u3079\u4ed8\u3051\u308b) : to be used to eating ((Ichidan verb|transitive verb))\n# [id#2145280] \u305f\u3079\u306f\u3058\u3081\u308b (\u98df\u3079\u59cb\u3081\u308b) : to start eating ((Ichidan verb))\n# [id#2449430] \u305f\u3079\u304b\u3051\u308b (\u98df\u3079\u639b\u3051\u308b) : to start eating ((Ichidan verb))\n# [id#2671010] \u305f\u3079\u306a\u308c\u308b (\u98df\u3079\u6163\u308c\u308b) : to be used to eating/to become used to eating/to be accustomed to eating/to acquire a taste for ((Ichidan verb))\n# [id#2765050] \u305f\u3079\u3089\u308c\u308b (\u98df\u3079\u3089\u308c\u308b) : 1. to be able to eat ((Ichidan verb|intransitive verb)) 2. to be edible/to be good to eat ((pre-noun adjectival (rentaishi)))\n# [id#2795790] \u305f\u3079\u304f\u3089\u3079\u308b (\u98df\u3079\u6bd4\u3079\u308b) : to taste and compare several dishes (or foods) of the same type ((Ichidan verb|transitive verb))\n# [id#2807470] \u305f\u3079\u3042\u308f\u305b\u308b (\u98df\u3079\u5408\u308f\u305b\u308b) : to eat together (various foods) ((Ichidan verb))\n\n# print all related characters\nfor c in result.chars:\n print(repr(c))\n\n# \u98df:9:eat,food\n# \u55b0:12:eat,drink,receive (a blow),(kokuji)\n# \u904e:12:overdo,exceed,go beyond,error\n# \u4ed8:5:adhere,attach,refer to,append\n# \u59cb:8:commence,begin\n# \u639b:11:hang,suspend,depend,arrive at,tax,pour\n# \u6163:14:accustomed,get used to,become experienced\n# \u6bd4:4:compare,race,ratio,Philippines\n# \u5408:6:fit,suit,join,0.1\n```\n\n## Command line tools\n\nTo make sure that jamdict is configured properly, try to look up a word using command line\n\n```bash\npython3 -m jamdict lookup \u8a00\u8a9e\u5b66\n========================================\nFound entries\n========================================\nEntry: 1264430 | Kj: \u8a00\u8a9e\u5b66 | Kn: \u3052\u3093\u3054\u304c\u304f\n--------------------\n1. linguistics ((noun (common) (futsuumeishi)))\n\n========================================\nFound characters\n========================================\nChar: \u8a00 | Strokes: 7\n--------------------\nReadings: yan2, eon, \uc5b8, Ng\u00f4n, Ng\u00e2n, \u30b2\u30f3, \u30b4\u30f3, \u3044.\u3046, \u3053\u3068\nMeanings: say, word\nChar: \u8a9e | Strokes: 14\n--------------------\nReadings: yu3, yu4, eo, \uc5b4, Ng\u1eef, Ng\u1ee9, \u30b4, \u304b\u305f.\u308b, \u304b\u305f.\u3089\u3046\nMeanings: word, speech, language\nChar: \u5b66 | Strokes: 8\n--------------------\nReadings: xue2, hag, \ud559, Ho\u0323c, \u30ac\u30af, \u307e\u306a.\u3076\nMeanings: study, learning, science\n\nNo name was found.\n```\n\n## Using KRAD/RADK mapping\n\nJamdict has built-in support for KRAD/RADK (i.e. kanji-radical and radical-kanji mapping).\nThe terminology of radicals/components used by Jamdict can be different from else where.\n\n- A radical in Jamdict is a principal component, each character has only one radical.\n- A character may be decomposed into several writing components.\n\nBy default jamdict provides two maps:\n\n- jam.krad is a Python dict that maps characters to list of components.\n- jam.radk is a Python dict that maps each available components to a list of characters.\n\n```python\n# Find all writing components (often called \"radicals\") of the character \u96f2\nprint(jam.krad['\u96f2'])\n# ['\u4e00', '\u96e8', '\u4e8c', '\u53b6']\n\n# Find all characters with the component \u9f0e\nchars = jam.radk['\u9f0e']\nprint(chars)\n# {'\u9f0f', '\u9f12', '\u9f10', '\u9f0e', '\u9f11'}\n\n# look up the characters info\nresult = jam.lookup(''.join(chars))\nfor c in result.chars:\n print(c, c.meanings())\n# \u9f0f ['cover of tripod cauldron']\n# \u9f12 ['large tripod cauldron with small']\n# \u9f10 ['incense tripod']\n# \u9f0e ['three legged kettle']\n# \u9f11 []\n```\n\n## Finding name entities\n\n```bash\n# Find all names with \u9234\u6728 inside\nresult = jam.lookup('%\u9234\u6728%')\nfor name in result.names:\n print(name)\n\n# [id#5025685] \u30ad\u30e5\u30fc\u30c6\u30a3\u30fc\u3059\u305a\u304d (\u30ad\u30e5\u30fc\u30c6\u30a3\u30fc\u9234\u6728) : Kyu-ti- Suzuki (1969.10-) (full name of a particular person)\n# [id#5064867] \u30d1\u30d1\u30a4\u30e4\u3059\u305a\u304d (\u30d1\u30d1\u30a4\u30e4\u9234\u6728) : Papaiya Suzuki (full name of a particular person)\n# [id#5089076] \u30e9\u30b8\u30ab\u30eb\u3059\u305a\u304d (\u30e9\u30b8\u30ab\u30eb\u9234\u6728) : Rajikaru Suzuki (full name of a particular person)\n# [id#5259356] \u304d\u3064\u306d\u3056\u304d\u3059\u305a\u304d\u3072\u306a\u305f (\u72d0\u5d0e\u9234\u6728\u65e5\u5411) : Kitsunezakisuzukihinata (place name)\n# [id#5379158] \u3053\u3059\u305a\u304d (\u5c0f\u9234\u6728) : Kosuzuki (family or surname)\n# [id#5398812] \u304b\u307f\u3059\u305a\u304d (\u4e0a\u9234\u6728) : Kamisuzuki (family or surname)\n# [id#5465787] \u304b\u308f\u3059\u305a\u304d (\u5ddd\u9234\u6728) : Kawasuzuki (family or surname)\n# [id#5499409] \u304a\u304a\u3059\u305a\u304d (\u5927\u9234\u6728) : Oosuzuki (family or surname)\n# [id#5711308] \u3059\u3059\u304d (\u9234\u6728) : Susuki (family or surname)\n# ...\n```\n\n## Exact matching\n\nUse exact matching for faster search.\n\nFind the word \u82b1\u706b by idseq (1194580)\n\n```python\n>>> result = jam.lookup('id#1194580')\n>>> print(result.names[0])\n[id#1194580] \u306f\u306a\u3073 (\u82b1\u706b) : fireworks ((noun (common) (futsuumeishi)))\n```\n\nFind an exact name \u82b1\u706b by idseq (5170462)\n\n```python\n>>> result = jam.lookup('id#5170462')\n>>> print(result.names[0])\n[id#5170462] \u306f\u306a\u3073 (\u82b1\u706b) : Hanabi (female given name or forename)\n```\n\nSee `jamdict_demo.py` and `jamdict/tools.py` for more information.\n\n# Useful links\n\n* JMdict: [http://edrdg.org/jmdict/edict_doc.html](http://edrdg.org/jmdict/edict_doc.html)\n* kanjidic2: [https://www.edrdg.org/wiki/index.php/KANJIDIC_Project](https://www.edrdg.org/wiki/index.php/KANJIDIC_Project)\n* JMnedict: [https://www.edrdg.org/enamdict/enamdict_doc.html](https://www.edrdg.org/enamdict/enamdict_doc.html)\n* KRADFILE: [http://www.edrdg.org/krad/kradinf.html](http://www.edrdg.org/krad/kradinf.html)\n\n# Contributors\n\n- [Le Tuan Anh](https://github.com/letuananh) (Maintainer)\n- [alt-romes](https://github.com/alt-romes)\n- [Matteo Fumagalli](https://github.com/matteofumagalli1275)\n- [Reem Alghamdi](https://github.com/reem-codes)\n- [Techno-coder](https://github.com/Techno-coder)",
"bugtrack_url": null,
"license": "MIT License",
"summary": "Python library for using Japanese dictionaries and resources (Jim Breen's JMdict, KanjiDic2, KRADFILE, JMnedict)",
"version": "0.1a11.post2",
"project_urls": {
"Bug Tracker": "https://github.com/neocl/jamdict/issues",
"Homepage": "https://github.com/neocl/jamdict",
"Source Code": "https://github.com/neocl/jamdict/"
},
"split_keywords": [
"dictionary",
"japanese",
"kanji",
"japanese-language",
"jmdict",
"japanese-study",
"kanjidic2",
"japanese-dictionary",
"jamdict"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "1c2098bcf088707850f0c9104b6499b9afff7a4db2e5849a9a99e436400e0a6d",
"md5": "9aa1cfcce3b2fa5c13614a5f4f5eb829",
"sha256": "fbb54de3d58ecdb9b53498ae873ab6519312c86bc848a9769d92b1b238d4c914"
},
"downloads": -1,
"filename": "jamdict-0.1a11.post2.tar.gz",
"has_sig": false,
"md5_digest": "9aa1cfcce3b2fa5c13614a5f4f5eb829",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 203716,
"upload_time": "2021-06-06T04:20:36",
"upload_time_iso_8601": "2021-06-06T04:20:36.947844Z",
"url": "https://files.pythonhosted.org/packages/1c/20/98bcf088707850f0c9104b6499b9afff7a4db2e5849a9a99e436400e0a6d/jamdict-0.1a11.post2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2021-06-06 04:20:36",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "neocl",
"github_project": "jamdict",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "jamdict"
}