Registry / ai-ml / python-mecab-ko

python-mecab-ko

JSON →
library1.3.7pypypi✓ verified 87d ago

A Python binding for mecab-ko, the Korean morphological analyzer based on MeCab. Provides part-of-speech tagging, lemmatization, and tokenization for Korean text. Version 1.3.7 requires Python >=3.7. Released irregularly.

pip install python-mecab-ko
INSTALL
IMPORT
SIG · PYTHON-MECAB-KO
P
python-mecab-ko
ai-mlpythonv1.3.7
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

Mecab
✓ from mecab import MeCab
✗ from python_mecab_ko import Mecab
The package name has a dash, but the import uses 'mecab' (no dash).

Basic usage: parse Korean text into morphemes with POS tags.

from mecab import MeCab mecab = MeCab() text = "안녕하세요. 저는 한국어입니다." parsed = mecab.pos(text) print(parsed) # [('안녕하세요', 'MAG'), ('.', 'SF'), ('저', 'NP'), ('는', 'JX'), ('한국어', 'NNG'), ('입니다', 'VCP+EC'), ('.', 'SF')]
Debug
Known issues
brokenThe package is named 'python-mecab-ko' but import is 'mecab'. Using 'python_mecab_ko' will raise ImportError.
fix
Use 'from mecab import MeCab' instead.
affects: all
gotchaMeCab() constructor does not accept arguments in this binding. Some users try to pass mecabrc path, which is not supported.
fix
Use default constructor. To customize, set environment variable MECABRC before import.
affects: all
gotchamecab-ko dictionary must be installed separately. The Python package only wraps the binary. Without the dictionary, you'll get runtime errors about missing resources.
fix
Install mecab-ko and mecab-ko-dic via your system package manager (e.g., apt, brew) or follow instructions at https://github.com/jonghwanhyeon/python-mecab-ko#installation.
affects: all
Errors
Common errors & fixes
ImportError: No module named 'python_mecab_ko'
Trying to import the package name with underscores instead of the correct module name 'mecab'.
fix
Use 'from mecab import MeCab'.
RuntimeError: mecab: failed to create mecab instance!
The mecab-ko dictionary is not installed or MECABRC environment variable is not set.
fix
Install mecab-ko and mecab-ko-dic (e.g., 'apt-get install mecab mecab-ko-dic'). Then set MECABRC to the dictionary path if necessary.
Upgrade
Version history
1.3.7latest on PyPI · released Jul 14, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
OpenAI (training)
1
Resources
python-mecab-ko — pip install python-mecab-ko · libregistry