Skip to content

Instantly share code, notes, and snippets.

@ukyo
Created July 25, 2011 13:30
Show Gist options
  • Save ukyo/1104115 to your computer and use it in GitHub Desktop.
Save ukyo/1104115 to your computer and use it in GitHub Desktop.
python-mecab wakachi gaki patch
from MeCab import Tagger
'''
Example:
>>> import MeCab
>>> import mecab_wakachi_patch.py
>>> m = Mecab.Tagger()
>>> m.wakachi('僕と契約して魔法少女になってよ')
'''
def wakachi(self, text):
return [line.split('\t')[0] for line in self.parse(text).split('\n')[:-2]]
setattr(Tagger, 'wakachi', wakachi)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment