Mecabをソースからインストールする
- http://mecab.sourceforge.jp/
- http://www.asahi-net.or.jp/~yw3t-trns/namazu/mecab/index.htm
- http://www.kaede-software.com/2006/02/post_393.html
UTF-8専用にして軽いのを作るぞ。
ダウンロード
http://mecab.sourceforge.jp/src/にアクセス。下記の3つをダウンロード。
辞書は11.5MBと少々重たい。
解凍する
# tar -zxvf mecab-0.93.tar.gz
# tar -zxvf mecab-ipadic-2.7.0-20060707.tar.gz
# tar -zxvf mecab-perl-0.93.tar.gz
ipadicの解凍時に、所有者の書き換えができない、とエラーがでるがスルー。
Mecabのインストール
# cd /data/mecab-0.93
Cコンパイラーが見つからないとエラー。
# ./configure --enable-utf8-only
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking whether make sets $(MAKE)... yes
checking for working aclocal-1.4... missing
checking for working autoconf... missing
checking for working automake-1.4... missing
checking for working autoheader... missing
checking for working makeinfo... missing
checking for gcc... no
checking for cc... no
checking for cc... no
checking for cl... no
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
いろいろとインストール。
# apt-get install autoconf automake gcc
autoheaderとaclocalも入る。makeinfoはなかった。
しかしこれでもエラーはなくならず。
Cコンパイラの出力ファイル名に原因があるとのこと。
configure.logを見ると、下記のような記述。
/usr/bin/ld: crt1.o: No such file: No such file or directory
libc6-devを入れるといいらしい。
# apt-get install libc6-dev
コンパイルは走ったが途中でエラー。
今度は,g++がない、とのこと。
# apt-get install g++
インストール後、ようやく成功。
# ./configure --enable-utf8-only
# make
# make install
mecab-ipadicのインストール
# cd /data/mecab-ipadic-2.7.0-20060707
# ./configure --with-charset=utf8
# make
# make install
あっさり終了。
ちょっと動作確認。
# echo "この橋渡るべからず" | mecab
この 連体詞,*,*,*,*,*,この,コノ,コノ
橋 名詞,一般,*,*,*,*,橋,ハシ,ハシ
渡る 動詞,自立,*,*,五段・ラ行,基本形,渡る,ワタル,ワタル
べから 助動詞,*,*,*,文語・ベシ,未然形,べし,ベカラ,ベカラ
ず 助動詞,*,*,*,特殊・ヌ,連用ニ接続,ぬ,ズ,ズ
EOS
動作確認
- test.pl
use utf8;
use MeCab;
$m = new MeCab::Tagger("") || die $!;
print $m->parse("この橋渡るべからず");
これは動く。が、
だと、
# perl test.pl
RuntimeError tagger.cpp(146) [writer_.open(param)] writer.cpp(62)
[! std::string(param.getProfileString(nfk.c_str())).empty()] unknown format type [xml]
...propagated at est.pl line 3.
XML形式なんて知らない、と言われてしまう。
これがなかったら生きていけない(大げさ