Home

Awesome

This project has been moved to https://github.com/jeongukjae/mecab-bind


python-mecab

Run Test Status codecov Codacy Badge

Py Versions PyPi Versions License

A repository to bind mecab for Python 3.5+. Not using swig nor pybind.

Support only Linux, macOS

Original source codes: taku910/mecab

Installation

pip install python-mecab

Usage

Tagger

with eunjeon/mecab-ko-dic.

>>> from mecab import Tagger
>>> tagger = Tagger() # or Tagger('path/to/dic')
>>> tagger.parse("안녕하세요. 이 프로젝트는 python-mecab입니다.")
(('안녕', 'NNG,행위,T,안녕,*,*,*,*'), ('하', 'XSV,*,F,하,*,*,*,*'), ('세요', 'EP+EF,*,F,세요,Inflect,EP,EF,시/EP/*+어요/EF/*'), ('.', 'SF,*,*,*,*,*,*,*'), ('이', 'MM,~명사,F,이,*,*,*,*'), ('프로젝트', 'NNG,*,F,프로젝트,*,*,*,*'), ('는', 'JX,*,T,는,*,*,*,*'), ('python', 'SL,*,*,*,*,*,*,*'), ('-', 'SY,*,*,*,*,*,*,*'), ('mecab', 'SL,*,*,*,*,*,*,*'), ('입니다', 'VCP+EF,*,F,입니다,Inflect,VCP,EF,이/VCP/*+ᄇ니다/EF/*'), ('.', 'SF,*,*,*,*,*,*,*'))
>>> parsed = tagger.parse("안녕하세요. 이 프로젝트는 python-mecab입니다.")
>>> print(*parsed, sep='\n')
('안녕', 'NNG,행위,T,안녕,*,*,*,*')
('하', 'XSV,*,F,하,*,*,*,*')
('세요', 'EP+EF,*,F,세요,Inflect,EP,EF,시/EP/*+어요/EF/*')
('.', 'SF,*,*,*,*,*,*,*')
('이', 'MM,~명사,F,이,*,*,*,*')
('프로젝트', 'NNG,*,F,프로젝트,*,*,*,*')
('는', 'JX,*,T,는,*,*,*,*')
('python', 'SL,*,*,*,*,*,*,*')
('-', 'SY,*,*,*,*,*,*,*')
('mecab', 'SL,*,*,*,*,*,*,*')
('입니다', 'VCP+EF,*,F,입니다,Inflect,VCP,EF,이/VCP/*+ᄇ니다/EF/*')
('.', 'SF,*,*,*,*,*,*,*')

binded cli commands