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 <https://github.com/ikegami-yukino/mecab/releases>`_ 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
============

.. code:: python

  >>> 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.5 (2024/10/15)
----------------------------

- Update MeCab_wrap.cxx by SWIG 4.2.1 for support latest macOS


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
