Created
July 25, 2011 13:30
-
-
Save ukyo/1104115 to your computer and use it in GitHub Desktop.
python-mecab wakachi gaki patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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