Skip to main content

Parser for Jitendex dictionary files for Yomitan

Project description

jitendex-py

Parse Jitendex dictionary files for Yomitan (JSON) and convert HTML-structured content to semantic dictionaries.

Useful if you want to use Jitendex without parsing mdict format files.

Installation

pip install jitendex-py

If you are using uv,

uv add jitendex-py

Quick Start

from jitendex_py import parse_terms

# Parse from JSON string
with open('term_bank.json', 'r', encoding='utf-8') as f:
    data = f.read()
terms = parse_terms(data)

# Parse from file object
with open('term_bank.json', 'r', encoding='utf-8') as f:
    terms = parse_terms(f)

# Process results
for term in terms:
    print(f"{term['text']} [{term['reading']}]: {len(term['definitions'])} definitions")

Input Format

Accepts Yomitan term bank v3 JSON files with entries as 8-element arrays:

[
  ["text", "reading", "def_tags", "rules", score, [definitions], sequence, "term_tags"],
  ...
]

Output Format

Returns list of dictionaries:

{
    "text": str | None,           # Headword
    "reading": str | None,        # Reading (kana)
    "definition_tags": [str],     # Tags split by whitespace
    "rules": [str],               # Inflection rules
    "score": int,                 # Priority score
    "definitions": [dict],        # Parsed definitions
    "sequence": int,              # Entry ID
    "term_tags": [str]            # Term-level tags
}

Definition Types

Definitions can be one of:

Text:

{"type": "text", "content": "gloss text"}

Structured (HTML stripped):

{
    "type": "structured",
    "content": [
        {"type": "sense-group", "content": [...]},
        {"type": "part-of-speech-info", "tag": "noun", "code": "n", "content": "n"},
        {"type": "glossary", "content": "gloss text"},
        {"type": "cross-reference", "href": "?query=...", "text": "見る"}
    ]
}

Image:

{"type": "image", "path": "image.png", "width": 100, "height": 200}

Deinflection:

{
    "type": "deinflection",
    "source_term": "食べた",
    "source_rules": "past",
    "inflection_rules": "v1",
    "definition": {...}
}

Features

  • HTML stripping: Converts HTML tags to semantic types (sense-group, glossary, part-of-speech-info, etc.)
  • Ruby parsing: Extracts kanji readings from <ruby> annotations as 一(いち)
  • Cross-references: Internal links (?query=...) become structured references
  • Flexible input: Accepts JSON strings or file objects

Example: Processing Entries

from jitendex_py import parse_terms

with open('term_bank.json', 'r', encoding='utf-8') as f:
    terms = parse_terms(f)

# Extract glossary
for term in terms:
    text = term['text']
    for def_obj in term['definitions']:
        if def_obj['type'] == 'structured':
            content = def_obj['content']
            if isinstance(content, list):
                for item in content:
                    if item.get('type') == 'glossary':
                        print(f"{text}: {item['content']}")

License

MIT License

Copyright (c) 2026 Perch Labs Pte Ltd

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jitendex_py-0.1.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jitendex_py-0.1.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file jitendex_py-0.1.0.tar.gz.

File metadata

  • Download URL: jitendex_py-0.1.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.6

File hashes

Hashes for jitendex_py-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9eea1d02eaec22efb186c83b3ec8aa7ccc51b6218c72383be947867a4eb6992a
MD5 1a5db497a54c2349fcc68fd0d0863926
BLAKE2b-256 c0838ab61c05a16ff619d706a2e57b557d950cdfc25bca590526ddd734fc9530

See more details on using hashes here.

File details

Details for the file jitendex_py-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: jitendex_py-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.6

File hashes

Hashes for jitendex_py-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3e83385c047cf59af62fc2c000dc8cf352fcd10cf5c2f4a96b8d162dd2d36892
MD5 d457083397230e0ffe93f424c66a0520
BLAKE2b-256 9dea373299e29566687061d535a7d8192898a99cb62564026626bdb051dfeb4d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page