LoginSignup
7
7

More than 5 years have passed since last update.

CircleCI で MeCab (mecab-ruby) を使う

Last updated at Posted at 2015-10-07

CircleCI で、mecab-ruby を使う方法のメモです。
mecab-ruby をソースから入れるとうまくいかなかったのですが、mecab gem を使えば大丈夫でした。


.ruby-version
2.2.3
Gemfile
gem 'mecab'
circle.yml
dependencies:
  pre:
    - sh circle/install_mecab.sh
  cache_directories:
    - vendor/mecab
circle/install_mecab.sh
# Thanks to: http://qiita.com/saicologic/items/933e2f27b3e32c199248

set -x
set -e

BASE_DIR="$PWD/vendor/mecab"

sudo apt-get remove mecab

if [ ! -d "$BASE_DIR" ]
then
    mkdir $BASE_DIR
fi

if [ ! -f "$BASE_DIR/mecab-0.996.tar.gz" ]
then
    cd $BASE_DIR
    wget "https://drive.google.com/uc?export=download&id=0B4y35FiV1wh7cENtOXlicTFaRUE" -O mecab-0.996.tar.gz
    tar zxvf mecab-0.996.tar.gz
    cd mecab-0.996
    ./configure
    make
fi
cd $BASE_DIR/mecab-0.996
sudo make install
sudo sh -c "echo '/usr/local/lib' >> /etc/ld.so.conf"
sudo ldconfig

if [ ! -f "$BASE_DIR/mecab-ipadic-2.7.0-20070801.tar.gz" ]
then
    cd $BASE_DIR
    wget "https://drive.google.com/uc?export=download&id=0B4y35FiV1wh7MWVlSDBCSXZMTXM" -O mecab-ipadic-2.7.0-20070801.tar.gz
    tar zxvf mecab-ipadic-2.7.0-20070801.tar.gz
    cd mecab-ipadic-2.7.0-20070801
    ./configure --with-charset=utf8
    make
fi
cd $BASE_DIR/mecab-ipadic-2.7.0-20070801
sudo make install

mecab gem を使うことについては、@taka222 さんに教えていただきました。
https://twitter.com/taka222/status/650531175614709760
ありがとうございます!

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