5
11

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.

root権限なしでCaboChaをインストールする.

Last updated at Posted at 2017-09-01

root権限がない状況でCaboCha1をインストールする方法です.Cabochaをインストールするためには

  • CRF++ (0.55以降)2
  • MeCab (0.993以降)3

が必要なので事前に併せてインストールしています.

検証環境

  • Ubuntu 16.04.3 LTS

インストール場所の作成

CRF++,MeCab,CaboChaをインストールするための場所を~/usrに作ります.

echo "export PATH=$HOME/usr/bin:$PATH" >> ~/.bashrc
echo "export LD_LIBRARY_PATH=${HOME}/usr/lib" >> ~/.bashrc
source ~/.bashrc
mkdir $HOME/usr

CRF++のインストール

wget 'https://docs.google.com/uc?export=download&id=0B4y35FiV1wh7QVR6VXJ5dWExSTQ' -O CRF++-0.58.tar.gz
tar xf CRF++-0.58.tar.gz
cd CRF++-0.58/
./configure --prefix=$HOME/usr
make
make install

MeCabのインストール

git clone https://github.com/taku910/mecab.git
cd mecab/mecab
./configure --prefix=$HOME/usr --with-charset=UTF8 
make
make install

IPA辞書のダウンロード

wget 'https://drive.google.com/uc?export=download&id=0B4y35FiV1wh7MWVlSDBCSXZMTXM' -O mecab-ipadic-2.7.0-20070801.tar.gz
tar xvzf mecab-ipadic-2.7.0-20070801.tar.gz
cd mecab-ipadic-2.7.0-20070801/
./configure --with-mecab-config=$HOME/usr/bin/mecab-config --with-charset=UTF8 --prefix=$HOME/usr 
make
make install

動作確認

$ echo "すもももももももものうち" | ~/usr/bin/mecab
すもも	名詞,一般,*,*,*,*,すもも,スモモ,スモモ
も	助詞,係助詞,*,*,*,*,も,モ,モ
もも	名詞,一般,*,*,*,*,もも,モモ,モモ
も	助詞,係助詞,*,*,*,*,も,モ,モ
もも	名詞,一般,*,*,*,*,もも,モモ,モモ
の	助詞,連体化,*,*,*,*,の,ノ,ノ
うち	名詞,非自立,副詞可能,*,*,*,うち,ウチ,ウチ
EOS

CaboChaのインストール

cabocha-0.69.tar.bz2をダウンロードします.最新版をダウンロードしたい場合は下記から探してください.

curl -sc /tmp/gcokie "https://drive.google.com/uc?export=download&id=0B4y35FiV1wh7SDd1Q1dUQkZQaUU" > /dev/null
getcode="$(awk '/_warning_/ {print $NF}' /tmp/gcokie)"  
curl -Lb /tmp/gcokie "https://drive.google.com/uc?export=download&confirm=${getcode}&id=0B4y35FiV1wh7SDd1Q1dUQkZQaUU" -o cabocha-0.69.tar.bz2
tar xvf cabocha-0.69.tar.bz2
cd cabocha-0.69
export LDFLAGS="-L$HOME/usr/lib"
export CPPFLAGS="-I$HOME/usr/include"
./configure --with-mecab-config=$HOME/usr/bin/mecab-config --with-charset=UTF8 --prefix=$HOME/usr
make
make install
cd python
python setup.py build
python setup.py --user install

動作確認

$ echo "貴社の記者が汽車で帰社した" | cabocha
  貴社の-D    
    記者が---D
      汽車で-D
      帰社した
EOS

References

  1. Kudo et al., CaboCha/南瓜: Yet Another Japanese Dependency Structure Analyzer

  2. Kudo, CRF++: Yet Another CRF toolkit, 2005.

  3. Kudo et al., MeCab: Yet Another Part-of-Speech and Morphological Analyzer

5
11
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
5
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?