Skip to main content

MeCab binding for many OSs (Windows, macOS, and Linux)

Project description

Unofficial MeCab binding Python module for many OSs (Windows, macOS, and Linux)

Official Japanese document about MeCab is available: https://taku910.github.io/mecab/

Japanese document about this Python wrapper is available: https://qiita.com/yukinoi/items/990b6933d9f21ba0fb43

Installation

$ pip install mecab

or

$ python -m pip install mecab

NOTE: If you use Python 64-bit on Windows, MeCab 64-bit binary is required.

If you encountered the error such as MeCab_wrap.cxx:178:11: fatal error: ‘Python.h’ file not found, please try the following command:

$ CPLUS_INCLUDE_PATH=`python-config –prefix`/Headers:$CPLUS_INCLUDE_PATH pip install mecab

Usage

>>> import MeCab
>>> t = MeCab.Tagger()
>>> sentence = "太郎はこの本を女性に渡した。"
>>> print(t.parse(sentence))
太郎    名詞,固有名詞,人名,,*,*,太郎,タロウ,タロー
      助詞,係助詞,*,*,*,*,,,
この    連体詞,*,*,*,*,*,この,コノ,コノ
      名詞,一般,*,*,*,*,,ホン,ホン
      助詞,格助詞,一般,*,*,*,,,
女性    名詞,一般,*,*,*,*,女性,ジョセイ,ジョセイ
      助詞,格助詞,一般,*,*,*,,,
渡し    動詞,自立,*,*,五段サ行,連用形,渡す,ワタシ,ワタシ
      助動詞,*,*,*,特殊,基本形,,,
      記号,句点,*,*,*,*,,,
EOS
>>> n = t.parseToNode(sentence)
>>> while n:
>>>     print(n.surface, "\t", n.feature)
>>>     m = m.next
           BOS/EOS,*,*,*,*,*,*,*,*
太郎     名詞,固有名詞,人名,,*,*,太郎,タロウ,タロー
       助詞,係助詞,*,*,*,*,,,
この     連体詞,*,*,*,*,*,この,コノ,コノ
       名詞,一般,*,*,*,*,,ホン,ホン
       助詞,格助詞,一般,*,*,*,,,
女性     名詞,一般,*,*,*,*,女性,ジョセイ,ジョセイ
       助詞,格助詞,一般,*,*,*,,,
渡し     動詞,自立,*,*,五段サ行,連用形,渡す,ワタシ,ワタシ
       助動詞,*,*,*,特殊,基本形,,,
       記号,句点,*,*,*,*,,,
         BOS/EOS,*,*,*,*,*,*,*,*

License

MeCab is copyrighted free software by Taku Kudo <taku@chasen.org> and Nippon Telegraph and Telephone Corporation, and is released under any of the GPL (see the file GPL), the LGPL (see the file LGPL), or the BSD License (see the file BSD).

Also, this Python binding is under any of the GPL, the LGPL, or the BSD License.

Changes

0.996.2 (2020/02/11)

  • Bugfix: memory leak for MeCab.Tagger().parseToNode()

Contributing

See https://github.com/ikegami-yukino/mecab/blob/master/mecab/python/CONTRIBUTING.md

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

mecab-0.996.3.tar.gz (62.6 kB view hashes)

Uploaded Source

Built Distributions

mecab-0.996.3-cp310-cp310-win_amd64.whl (507.2 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

mecab-0.996.3-cp310-cp310-win32.whl (735.5 kB view hashes)

Uploaded CPython 3.10 Windows x86

mecab-0.996.3-cp39-cp39-win_amd64.whl (500.9 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

mecab-0.996.3-cp39-cp39-win32.whl (731.1 kB view hashes)

Uploaded CPython 3.9 Windows x86

mecab-0.996.3-cp38-cp38-win_amd64.whl (500.8 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

mecab-0.996.3-cp38-cp38-win32.whl (731.3 kB view hashes)

Uploaded CPython 3.8 Windows x86

mecab-0.996.3-cp37-cp37m-win_amd64.whl (510.8 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

mecab-0.996.3-cp37-cp37m-win32.whl (739.8 kB view hashes)

Uploaded CPython 3.7m Windows x86

mecab-0.996.3-cp36-cp36m-win_amd64.whl (510.8 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

mecab-0.996.3-cp36-cp36m-win32.whl (739.8 kB view hashes)

Uploaded CPython 3.6m Windows x86

mecab-0.996.3-cp27-cp27m-win_amd64.whl (500.6 kB view hashes)

Uploaded CPython 2.7m Windows x86-64

mecab-0.996.3-cp27-cp27m-win32.whl (730.4 kB view hashes)

Uploaded CPython 2.7m Windows x86

Supported by

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