Last active
March 2, 2016 00:24
-
-
Save grachro/691855361e599c3e274f to your computer and use it in GitHub Desktop.
Python3で形態素解析エンジンMeCabを使えるようにする(2016年3月版) ref: http://qiita.com/grachro/items/4fbc9bf8174c5abb7bdd
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
git clone https://github.com/taku910/mecab.git | |
cd mecab/mecab | |
./configure --enable-utf8-only | |
make | |
make check | |
sudo make install |
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
/usr/local/etc/mecabrc | |
/usr/local/bin/mecab | |
/usr/local/bin/mecab-config |
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
今日 キョウ 今日 名詞-副詞可能 | |
も モ も 助詞-係助詞 | |
し シ する 動詞-自立 サ変・スル 未然形 | |
ない ナイ ない 助動詞 特殊・ナイ 基本形 | |
と ト と 助詞-接続助詞 | |
ね ネ ね 助詞-終助詞 | |
EOS |
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
tar zxfv mecab-ipadic-2.7.0-20070801.tar.gz | |
cd mecab-ipadic-2.7.0-20070801 | |
./configure --with-charset=utf8 | |
make | |
sudo make install | |
_2016/3/2追記その2 ここも飛ばしてください。 | |
ダウンロードしなくてもgitプロジェクトに含まれていました。 |
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
cd ../mecab-ipadic | |
./configure --with-charset=utf8 | |
make | |
sudo make install | |
_2016/3/2追記その2 こっちが最新 |
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
$ mecab | |
MeCab はフリーソフトウェアです | |
MeCab 名詞,固有名詞,組織,*,*,*,* | |
は 助詞,係助詞,*,*,*,*,は,ハ,ワ | |
フリー 名詞,一般,*,*,*,*,フリー,フリー,フリー | |
ソフトウェア 名詞,一般,*,*,*,*,ソフトウェア,ソフトウェア,ソフトウェア | |
です 助動詞,*,*,*,特殊・デス,基本形,です,デス,デス | |
EOS |
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
cd [MeCabのgitクローンしたディレクトリ] | |
cd mecab/mecab/python | |
#2016/3/2追記 ここは、飛ばしてください |
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
vi setup.py | |
def cmd2(str): | |
return string.split (cmd1(str)) | |
を以下に変更 | |
def cmd2(str): | |
return cmd1(str).split() | |
#2016/3/2追記 ここも、飛ばしてください |
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
python setup.py build | |
sudo python setup.py install | |
#2016/3/2追記 ここも、飛ばしてください |
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
pip install mecab-python3 |
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
import sys | |
import MeCab | |
m = MeCab.Tagger ("-Ochasen") | |
print(m.parse ("今日もしないとね")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment