Help us understand the problem. What is going on with this article?

CircleCI で MeCab (mecab-ruby) を使う

More than 3 years have passed since last update.

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
ありがとうございます!

milk1000cc
ウェブサービスを作っています
https://milk1000.cc/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away