Python wrapper for the MeCab-ko morphological analyzer for Korean
Project description
This is a Python wrapper for the MeCab-ko morphological analyzer for Korean text. It works with Python 3.6 and greater.
There are several implementations of python binding or wrapper for MeCab-ko, but they are generally not well maintained.
I made it to stand on the shoulders of giants(well-maintained open-source projects like MeCab, mecab-ko and mecab-python3) with minimum modifications.
I initially named it mecab-ko-python3
because the package name referenced for development was mecab-python3,
it may seem a little arrogant, but to reduce confusion in the PyPI, the name was changed to 'mecab-ko'.
(The repository is named 'pymecab-ko' to distinguish it from original mecab-ko)
Note: If using MacOS Big Sur, you'll need to upgrade pip to version 20.3 or higher to use wheels due to a pip issue.
issue를 영어로 작성할 필요는 없습니다.
Note that Windows wheels require a Microsoft Visual C++ Redistributable, so be sure to install that.
Basic usage
>>> import mecab_ko as MeCab
>>> tagger = MeCab.Tagger("-Owakati")
>>> tagger.parse("아버지가방에들어가신다").split()
['아버지', '가', '방', '에', '들어가', '신다']
>>> tagger = MeCab.Tagger()
>>> print(tagger.parse("아버지가방에들어가신다"))
아버지 NNG,*,F,아버지,*,*,*,*
가 JKS,*,F,가,*,*,*,*
방 NNG,*,T,방,*,*,*,*
에 JKB,*,F,에,*,*,*,*
들어가 VV,*,F,들어가,*,*,*,*
신다 EP+EC,*,F,신다,Inflect,EP,EC,시/EP/*+ㄴ다/EC/*
EOS
The API for pymecab-ko
closely follows the API for MeCab itself,
even when this makes it not very “Pythonic.” Please consult the official MeCab
documentation for more information.
Installation
Binary wheels are available for MacOS X, Linux, and Windows (64bit) are
installed by default when you use pip
:
pip install mecab-ko
These wheels include a copy of the MeCab-ko library and a dictionary.
There is a unique dictionary available for MeCab-ko. mecab-ko-dic
is automatically installed when installing pymacab-ko.
To build from source using pip,
pip install --no-binary :all: mecab-ko
Dictionaries
In order to use MeCab-ko, you must install a dictionary. There are 2 dictionaries available for MeCab-ko.
These packages, which include slight modifications for ease of use, are recommended:
- mecab-ko-dic: The pre-built mecab-ko-dic 2.1.1-20180720 based on ipadic-py. It will be installed along with pymecab-ko.
- openkorpos-dic: a dictionary trained with OpenKorPOS(Free and open alternative to the Sejong corpus)
Common Issues
If you get a RuntimeError
when you try to run MeCab, here are some things to check:
Windows Redistributable
You have to install this to use this package on Windows.
Specifying a mecabrc
If you get this error:
error message: [ifs] no such file or directory: /usr/local/etc/mecabrc
You need to specify a mecabrc
file. It's OK to specify an empty file, it just
has to exist. You can specify a mecabrc
with -r
. This may be necessary on
Debian or Ubuntu, where the mecabrc
is in /etc/mecabrc
.
You can specify an empty mecabrc
like this:
tagger = MeCab.Tagger('-r/dev/null -d/home/hoge/mydic')
Using Unsupported Output Modes like -Ochasen
Chasen output is not a built-in feature of MeCab, you must specify it in your
dicrc
or mecabrc
. Notably, mecab-ko-dic does not include Chasen output format.
Please see the MeCab documentation.
Alternatives
- python-mecab-ko is a Python binding for MeCab-ko
- mecab-python-msvc is a mecab-python for mecab-ko-msvc
- KoNLPy is a library for Korean NLP that includes a MeCab wrapper
Licensing
Like MeCab and mecab-python3, pymecab-ko
is copyrighted free software by
Taku Kudo taku@chasen.org and Nippon Telegraph and Telephone Corporation,
and is distributed under a 3-clause BSD license (see the file BSD
).
Alternatively, it may be redistributed under the terms of the
GNU General Public License, version 2 (see the file GPL
) or the
GNU Lesser General Public License, version 2.1 (see the file LGPL
).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for mecab_ko-1.0.1-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 016ffa232cd40c82bebeeaaae74050f7901f586e52b44c056ca2928168022f04 |
|
MD5 | 2a556a4f390e6fcbbc3669e140068a1f |
|
BLAKE2b-256 | 16f0f580e3ebf94b98c0f5cd42a9eada0760e59f6382677b125f8b021e58fc9d |
Hashes for mecab_ko-1.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4cdcf1568f29814d1c68af7f38f9d6bb566ea65497136ec0e207eb063d46cc67 |
|
MD5 | b5469512b71b5fba580872b71bb4643f |
|
BLAKE2b-256 | 830abf50834de0ee589f7ec7c47980ff7dfa296eb516f812d5ab2ef4cf78e021 |
Hashes for mecab_ko-1.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07fb4b1a95135f2d12156719af712f98405976862f5b98c164a368f512b395dc |
|
MD5 | 0bae21699f884a852884318f055fe462 |
|
BLAKE2b-256 | 9d57354dc8589763302212b4b3500522c592de998229b5a961aa457d0a465eeb |
Hashes for mecab_ko-1.0.1-cp311-cp311-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c345ecf7005bc7bbd1f57cc17cb7a047e3d1e59269625d4c6fc60120000233da |
|
MD5 | 4a8c170356dec0081db1eaaf53b0c55a |
|
BLAKE2b-256 | 18c62551530685a1afbd4be7848ca0830c5f0f0846f69b9cd7101ccdf424bffa |
Hashes for mecab_ko-1.0.1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab92f6a4601d76500d3aff34bfd19f181dcab493ae481eaca42265e9aa5b74ad |
|
MD5 | 2cc92ebe3b27353fcb5cb430d62d99a2 |
|
BLAKE2b-256 | 446c1ca8cd727ee07ac1e8cd0dff49fa879730c333e576e6b41f65f551d20a5d |
Hashes for mecab_ko-1.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16a762171d41afa0d937fad13428b07d8d6f677ea52c185d0a73f02e6dba5988 |
|
MD5 | a6aa27441782a3d03c7652135cd98e76 |
|
BLAKE2b-256 | 93a481f845502f5e1b57aa3ad3affa7d99d85e1ad6501a6610f6072ea4a37566 |
Hashes for mecab_ko-1.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91e037e2be3b4d61496d0546f68fa7eef745bc7ca645c41d0a4c0bb88d6ac836 |
|
MD5 | e42cc03ad36c2dc5ee63edc3fb986c19 |
|
BLAKE2b-256 | 013c8157a7881190260d2d58ffaa0e3c0b36348679377001ff50be3806296f49 |
Hashes for mecab_ko-1.0.1-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 453aa072bb42e982391fa8c7b07d262346d09aa3552dc2d1c50986cdd341a12a |
|
MD5 | f1e9ebfabd7a74860747895869830f99 |
|
BLAKE2b-256 | 4bba599a9815a161ae66bea29ee058cabbf2b1ce32e2828f9c84fd0acbcc073a |
Hashes for mecab_ko-1.0.1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e19367e157c9cd912cbf9bbbb93fddb07f38a636d1c1364eda878ebe7f52d94d |
|
MD5 | e8bbaabb055ef0edb57666d43fffbf40 |
|
BLAKE2b-256 | c63af7965ed0d3848d6292f0c3ecf0d05138fdcd3e71b283cafd1989cea8f793 |
Hashes for mecab_ko-1.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbc6f0fa30dcfded65e65c6295a6cbd1a6a7f2ba33f710ac3e4921361c3623f7 |
|
MD5 | 912b3878b98e6f6f4d4e210889fbf436 |
|
BLAKE2b-256 | b041c23d56282c7b57abef12d7760158a867a93663a2fbd7ca69cda208210498 |
Hashes for mecab_ko-1.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d0675359d82a26e381441376a1400e87144f1ca1180046df91a48261077e248 |
|
MD5 | 8da4cae41c7d1581aaf86caba1edeeae |
|
BLAKE2b-256 | 67ea290760aa4f65a0f3d09a07b4624813e348415a2da8f8a64b4742bc650219 |
Hashes for mecab_ko-1.0.1-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec5029cafeaf684c8d16a37038eadc1fdbfa8daf96c49583801ec7b9859ed27d |
|
MD5 | c3854f33c53185aaa5912a64faf870ae |
|
BLAKE2b-256 | 9097d317aa5d4a0e923c3d7d5b6869e9853c3103ed6a2ceb8e3163c9da7b2701 |
Hashes for mecab_ko-1.0.1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f03885c4c306f21e840627fbfe0bbab7b3d5607ff9243daa8cd725ee8320615f |
|
MD5 | d9937f8b6f5f25cab216039c5a41c7f7 |
|
BLAKE2b-256 | 3ab984e839c148150e45390547c01b558c7cb59d46235e7bc33e08fc5a565653 |
Hashes for mecab_ko-1.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6c55cf3079e0578aec0e29a72aa1d21125a119dbf7cd57059b01b2523fe26cf |
|
MD5 | 7bca04798d4e8002ab48ab7745510c5c |
|
BLAKE2b-256 | 8e529fc11aca449360ebbe747b89e44725a65a5755b20c33dd1e251865ab42c7 |
Hashes for mecab_ko-1.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb10a7e1da1e66a16798d3d96d7c4b52c1290e57c8d38922b0f6f72ddc3915bc |
|
MD5 | 4e3bd6315ef7ea3d29023ea92e824020 |
|
BLAKE2b-256 | b627ca1de908b5ed46b13a4349a6675d274aadb83ca57005fd8fbbdc19cdbb53 |
Hashes for mecab_ko-1.0.1-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f4172ed0cee3615ef6f93312e344e39e4424622191253bc9483b7cc7dff98e9 |
|
MD5 | e8987b7310182ce9295aa3a439d6f036 |
|
BLAKE2b-256 | 19c7e0f0c8ebb6d593d8cd5800e82be1986024581bf1d0d6ce0b91cb79c99295 |
Hashes for mecab_ko-1.0.1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ef9588fcd7ad9c28bffc4520194718bf193a5e7d017cc0ebb75332c0eebf7db |
|
MD5 | b8cbd3638aef34a8fa8557ae62f10f1c |
|
BLAKE2b-256 | e68e9b6ed091a78e3db570e9efc4ef2bbc2c48eeb8f90e81d5487c2292008e71 |
Hashes for mecab_ko-1.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b380495c4f43306b9f6fa8e030d2d86286ce75c364c84393e7d5043f7093a5b2 |
|
MD5 | accfd4a341b63be94ceed00dade90dbc |
|
BLAKE2b-256 | d954a56f3e32789b4dd56ba2055cf78f4f7d19e5657a3c691bd789f18c73d36d |
Hashes for mecab_ko-1.0.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee71ad251c57526af54cf005b2803e1df3e0ffe8b350464d8f75f936e2470087 |
|
MD5 | 5b8cb8cc37072d485bd59221e8e19561 |
|
BLAKE2b-256 | 39970dc413ed4ae546784cd649d002f8356602dfcde74c2357bbee22a74c3b80 |
Hashes for mecab_ko-1.0.1-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd19106d5f9ea1b5ee847ed56d0bddd261685e10b15db852848bfd233c9ae579 |
|
MD5 | 69a2fa2ecd3e991a6a86fa319575c3f5 |
|
BLAKE2b-256 | 098e186b080a6f0e2bda63be129aba83f6e96ff7cdb97aead38f9a716a388d5f |
Hashes for mecab_ko-1.0.1-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1bfa1394b65c19a0a8a61655e806a73b6421aba500e9b57cc2cc7bd2dccc97aa |
|
MD5 | c3782d2a186caf3cd4af3cf1aa842b8b |
|
BLAKE2b-256 | 5768b6b817d0165025ca7c7c299a153fb1c772f3aaa2b8b9e0fd17d1f87999fe |
Hashes for mecab_ko-1.0.1-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cdc9d64e92bfb415f8c1e695a6dd1287b4c4a9e8a455b0d15dadffd33ce7d115 |
|
MD5 | 087ca3b2d7c90995d74fc6d194cb3724 |
|
BLAKE2b-256 | a18d6e0a70d721a329d7924df118fdb6c6b35665d00a81794267ee2d2480fdd1 |