Registry / data / unidic

unidic

JSON →
library1.1.0pypypi✓ verified 87d ago

UniDic is a dictionary for the MeCab morphological analyzer, specifically designed for modern written Japanese. The `unidic` Python package provides this dictionary data, allowing it to be easily integrated with MeCab wrappers like `fugashi` or `mecab-python3`. The current version is 1.1.0, and it generally releases new versions to incorporate updated UniDic data or minor quality-of-life improvements.

pip install unidic
INSTALL
IMPORT
SIG · UNIDIC
U
unidic
datapythonv1.1.0
Install
3.2s avg
Import
79ms
Disk
21MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.1.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.084s · 23.6MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 3.2s · import 0.073s · 24MB
21MB installed
● package 21MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

unidic
import unidic
DICDIR
import unidic unidic.DICDIR
This constant provides the path to the installed UniDic dictionary, to be passed to a MeCab Tagger.

After installing `unidic` and a MeCab wrapper like `fugashi` (or `mecab-python3`), you must first download the actual dictionary data using `python -m unidic download`. Then, you can import `unidic` and pass `unidic.DICDIR` to your MeCab tagger to enable Japanese morphological analysis.

import unidic import fugashi # or mecab-python3 import subprocess import os # Ensure dictionary is downloaded (important step!) try: subprocess.run(['python', '-m', 'unidic', 'download'], check=True, capture_output=True) print("UniDic dictionary downloaded successfully.") except subprocess.CalledProcessError as e: if 'already exists' in e.stderr.decode(): print("UniDic dictionary already exists.") else: print(f"Error downloading UniDic dictionary: {e.stderr.decode()}") # Handle error or exit if download failed # Initialize MeCab Tagger with UniDic tagger = fugashi.Tagger(f'-d "{unidic.DICDIR}"') # Analyze a Japanese sentence sentence = "今日の天気は晴れです" result = tagger.parse(sentence) print(f"Sentence: {sentence}") print(f"Analysis: \n{result}") # Access individual tokens (fugashi specific) words = tagger.parseToNodeList(sentence) for word in words: if word.surface == '': # Skip empty node for EOS continue print(f"Surface: {word.surface}, Lemma: {word.lemma}, POS: {word.pos1}")
Debug
Known issues
breakingVersion 1.1.0 changed the 'latest' or default UniDic version from 2.3.0 to 3.1.0. If your application relied on the older default dictionary, its behavior may change.
fix
To use the previous default (UniDic 2.3.0), you need to explicitly install it using `pip install unidic['2.3.0+2020-10-08']` or specifically reference that version's DICDIR if multiple are installed.
affects: >=1.1.0
gotchaThe `unidic` package itself is small, but after `pip install`, you MUST run `python -m unidic download` to fetch the actual dictionary data. This download can be large (around 770MB-1GB on disk). If this step is skipped, the package will not function.
fix
Always execute `python -m unidic download` after installation and before first use. Consider `unidic-lite` if disk space is a major concern, as it's a smaller version of UniDic.
affects: All
gotchaUniDic is a dictionary, not an analyzer. It requires a separate MeCab wrapper like `fugashi` or `mecab-python3` to perform morphological analysis. Without one of these, `unidic` alone cannot process text.
fix
Install either `fugashi` (`pip install fugashi`) or `mecab-python3` (`pip install mecab-python3`) in addition to `unidic`.
affects: All
gotchaThe `unidic` dictionary is specifically for Japanese language processing. It is unnecessary and incorrect to install and use it if your application does not require Japanese text analysis.
fix
Only install `unidic` if Japanese NLP is a requirement for your project. Consider making it an optional dependency if your library supports multiple languages.
affects: All
Errors
Common errors & fixes
RuntimeError: Could not find dictionary. You may need to install unidic, unidic-lite, or use MeCabTagger(dic_path='...')
The `fugashi` library cannot locate a suitable MeCab dictionary, often because `unidic` (or `unidic-lite`) is not installed or discoverable in the environment.
fix
Install the `unidic` package via pip to provide the necessary dictionary data: `pip install unidic`
ModuleNotFoundError: No module named 'unidic'
The `unidic` Python package has not been installed in the current environment or is not accessible in the Python path.
fix
Install the `unidic` package using pip: `pip install unidic`
MeCab.Tagger.__init__: dictionary is not found. please check the location or install mecab-ipadic-neologd.
The `mecab-python3` library cannot locate a MeCab dictionary, usually because the provided dictionary path is incorrect or the dictionary itself is missing; `unidic.DICDIR` must be explicitly passed.
fix
Pass `unidic.DICDIR` to the `MeCab.Tagger` constructor to explicitly point to the installed UniDic dictionary: `import MeCab; import unidic; tagger = MeCab.Tagger(f'-d {unidic.DICDIR}')`
AttributeError: module 'unidic' has no attribute 'download'
The `unidic` package is a data package that provides dictionary files, and as such, it does not expose methods like `download` or `install` for runtime management.
fix
The dictionary is installed directly when you `pip install unidic`. To get its path for use with MeCab wrappers, refer to `unidic.DICDIR`.
Upgrade
Version history
1.1.0latest on PyPI · released Oct 10, 2021
Audit
Dependencies
mecab-python3optionalRequired for performing morphological analysis using the UniDic data. unidic provides the dictionary, not the analyzer.
fugashioptionalAlternative MeCab wrapper for performing morphological analysis using the UniDic data. unidic provides the dictionary, not the analyzer.
Agent activity
32 hits · last 30 days
node
28
OpenAI (training)
1
Resources
unidic — pip install unidic · libregistry