Medie
Medie is a pure-Python reader for MeCab's Double-Array Trie dictionary format.
It looks up entries in MeCab dictionary files (.dic) by exact match or by prefix.
Medie uses mmap for efficient, low-memory lookups.
Installation
python -m pip install medie
Usage
Python library
from medie import Medie
medie = Medie(dic_path="path_to_sys.dic")
tokens = medie.search("私") # Exact search
tokens
# => [{'surface': '私', 'feature': '接頭詞,名詞接続,*,*,*,*,私,シ,シ', 'cost': 9771, 'lid': 560, 'rid': 560}]
tokens = medie.search("私", limit=3) # Specify number of search results
tokens
# => [{'surface': '私', 'feature': '接頭詞,名詞接続,*,*,*,*,私,シ,シ', 'cost': 9771, 'lid': 560, 'rid': 560}, {'surface': '私', 'feature': '名詞,代名詞,一般,*,*,*,私,ワタシ,ワタシ', 'cost': 3480, 'lid': 1306, 'rid': 1306}, {'surface': '私', 'feature': '名詞,代名詞,一般,*,*,*,私,ワタクシ,ワタクシ', 'cost': 7802, 'lid': 1306, 'rid': 1306}]
tokens = medie.search_prefix("群馬") # Common prefix search (default value of `limit`: 5)
print(tokens)
# => [{'surface': '群馬', 'feature': '名詞,固有名詞,地域,一般,*,*,群馬,グンマ,グンマ', 'cost': 7489, 'lid': 1293, 'rid': 1293}, {'surface': '群馬大', 'feature': '名詞,固有名詞,組織,*,*,*,群馬大,グンマダイ,グンマダイ', 'cost': 6832, 'lid': 1292, 'rid': 1292}, {'surface': '群馬岳', 'feature': '名詞,固有名詞,一般,*,*,*,群馬岳,グンマタケ,グンマタケ', 'cost': 8538, 'lid': 1288, 'rid': 1288}, {'surface': '群馬八幡', 'feature': '名詞,固有名詞,一般,*,*,*,群馬八幡,グンマヤワタ,グンマヤワタ', 'cost': 8538, 'lid': 1288, 'rid': 1288}, {'surface': '群馬原町', 'feature': '名詞,固有名詞,一般,*,*,*,群馬原町,グンマハラマチ,グンマハラマチ', 'cost': 8538, 'lid': 1288, 'rid': 1288}]
tokens = medie.search_prefix("群馬", limit=3) # Also, search_prefix API have `limit` parameter.
print(tokens)
# => [{'surface': '群馬', 'feature': '名詞,固有名詞,地域,一般,*,*,群馬,グンマ,グンマ', 'cost': 7489, 'lid': 1293, 'rid': 1293}, {'surface': '群馬大', 'feature': '名詞,固有名詞,組織,*,*,*,群馬大,グンマダイ,グンマダイ', 'cost': 6832, 'lid': 1292, 'rid': 1292}, {'surface': '群馬岳', 'feature': '名詞,固有名詞,一般,*,*,*,群馬岳,グンマタケ,グンマタケ', 'cost': 8538, 'lid': 1288, 'rid': 1288}]
with Medie(dic_path="path_to_sys.dic") as medie: # support `with` clause
pass
Tips
If you specify the correct dictionary but the result is empty, specifying the character encoding may solve the problem.
with Medie(dic_path="path_to_sys.dic") as medie:
medie.charset = "utf8"
Command Line Interface (CLI)
medie or python -m medie
| Parameter | Type | Default value | Description |
|---|---|---|---|
--dicpath |
str | Path to the "sys.dic" (Required) | |
--prefix |
Enable prefix search. | ||
--limit |
int | 10 | Limit number of results. |
--charset |
str | Specify the charset of the "sys.dic" |
Example: Exact match
echo 群馬 | medie --dicpath path_to_sys.dic
群馬,1293,1293,7489,名詞,固有名詞,地域,一般,*,*,群馬,グンマ,グンマ
Example: Prefix search
echo 群馬 | medie --dicpath path_to_sys.dic --prefix --limit 3
群馬,1293,1293,7489,名詞,固有名詞,地域,一般,*,*,群馬,グンマ,グンマ
群馬大,1292,1292,6832,名詞,固有名詞,組織,*,*,*,群馬大,グンマダイ,グンマダイ
群馬岳,1288,1288,8538,名詞,固有名詞,一般,*,*,*,群馬岳,グンマタケ,グンマタケ
License
MIT license
CHANGES
0.1.2 (2026-10-19)
Initial release.
Metadata
Release files for medie 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| medie-0.1.2.tar.gz | 8.2 kB | Without provenance | Details for medie-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| medie-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for medie-0.1.2-py3-none-any.whl |
Total release size: 16.7 kB
Release files / medie-0.1.2.tar.gz
| Download URL | medie-0.1.2.tar.gz |
|---|---|
| Size | 8.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
baf4cd9ee8d26634bdeaa97dc1a100752d5faeb2abe68fb331a96c55b86d9016
|
|
BLAKE2b-256 checksum How to use checksums |
6c3c5e647201f2a14262eec287edbac8c71d51b4e50672d34b22473e521a5029
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.9
|
Release files / medie-0.1.2-py3-none-any.whl
| Download URL | medie-0.1.2-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
508782780fc0b59a6d1c199a305a6836ab00aaef39e2f861716996b902ee9d88
|
|
BLAKE2b-256 checksum How to use checksums |
c372bea60c02b99cbcf369945a42d7c8037f2d372be068002b6b5a251bebf46f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.9
|
Security for medie 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.