7
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

railsとmongoとmecab 環境構築編

Last updated at Posted at 2014-03-06

rubyとrailsから、入力フォームに検索文字を入力し、
検索文字をmecabを使って、形態素解析を行い、名詞だけ抽出してmongoに検索をかけにいく
サンプルを作ってみた。

今回は環境構築編。

参考にした記事を貼付けておきます。

##まずは、rbenv ruby rails インストール。
※複数のバージョンを考慮してrbenvもインストール。

下記を参考にさせてもらいました。
http://qiita.com/checkpoint/items/f8e65380d9cb0182218d
http://qiita.com/pakiln/items/661a8a1c3ee13d9dbca3

##mecabのインストール
下記を参考にさせてもらいました。
http://www.waseda-nishimura.jp/~kanzaki/diary/2012/07/03/mecab-ruby%E3%81%A7%E5%BD%A2%E6%85%8B%E7%B4%A0%E8%A7%A3%E6%9E%90%E3%81%97%E3%81%A6%E3%81%BF%E3%82%8B/
http://mecab.googlecode.com/svn/trunk/mecab/doc/index.html#install

インストール手順

 % tar zxfv mecab-X.X.tar.gz
 % cd mecab-X.X
 % ./configure --with-charset=utf8
 % make
 % make check
 % su
 # make install

辞書のインストール

% tar zxfv mecab-ipadic-2.7.0-XXXX.tar.gz
% mecab-ipadic-2.7.0-XXXX
% ./configure --with-charset=utf8
% make
% su
# make install

rubyとmecabを連携するためにSWIGが必要となるので、下記のURLからDLします。
http://www.swig.org/download.html

tar -xvzof swig-2.0.1.tar.gz
cd swig-2.0.1
./configure
make
sudo make install

次にmecab-rubyのインストールです。
これはファイルを解凍するとこまでいったら

$ cd mecab-ruby-0.994
$ ruby extconf.rb
$ make
$ ruby test.rb
$ sudo make install

##mongoインストール
下記を参考にさせてもらいました。

$ brew install mongodb

これで、簡単ですが、環境構築は終了!

たぶん。

7
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?