Macへのmecabインストール

形態素解析で日本語をごにょごにょしたいので、mecabを入れてみる。従来はchasenとかを使っていたんだけど、こちらの方がメモリ効率がいいという話を聞いたので試してみる。

例によって環境は以下の通り

  • MacOS10.5.8
  • mecab-0.98pre3
  • mecab-ipadic-2.7.0-20070801

mecabのサイトから本体と辞書をダウンロードしてくる。
http://mecab.sourceforge.net/

まずは、mecab本体をインストール。

$tar zxvf mecab-0.98pre3.tar.gz
$ ./configure --prefix=/Users/名前/App/mecab
$ make
$ make install

続いて辞書を登録。辞書はmecabのインストールディレクトリが標準でない場合、オプションでmecab-configの場所を教えてやらないとうまくいかない。あと、ディフォルトの文字コードeucなので変えたい場合は、--with-charsetをつけておくのが大事

$ tar zxvf mecab-ipadic-2.7.0-20070801.tar.gz
$ cd mecab-ipadic-2.7.0-20070801
$ ./configure --with-mecab-config=/Users/名前/App/mecab/bin/mecab-config 
  --with-charset=utf8
$ make
$ make install

これだけでさっくりインストール終了。ちゃんと機能しているかmecab/bin配下に移動して日本語入力してみる。

$ ./mecab
日本語入力
日本語     名詞,一般,*,*,*,*,日本語,ニホンゴ,ニホンゴ
入力     名詞,サ変接続,*,*,*,*,入力,ニュウリョク,ニューリョク
EOS

正常に分析されてる。あとはRubyバインディングからの使い方と単語登録だな。

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy