Installation and use of morphological analysis (PHP)
Installation Environment: Centos7 Basic, php7
yum install gcc-c++ java-1.7.0-openjdk-devel python-devel zlib-devel openssl openssl-devel git -y
wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz
tar xf Python-3.*
cd Python-3.*
./configure
make
make altinstall
pip3.6 install JPype1-py3
pip3.6 install konlpy
cd ..
wget https://bitbucket.org/eunjeon/mecab-ko/downloads/mecab-0.996-ko-0.9.2.tar.gz
tar zxfv mecab-0.996-ko-0.9.2.tar.gz
cd mecab-0.996-ko-0.9.2
./configure
make
make install
cd ..
wget https://bitbucket.org/eunjeon/mecab-ko-dic/downloads/mecab-ko-dic-2.0.1-20150920.tar.gz
tar zxfv mecab-ko-dic-2.0.1-20150920.tar.gz
cd mecab-ko-dic-2.0.1-20150920
./autogen.sh
./configure
make
make install
cd /usr/local/src/
git clone https://github.com/rsky/php-mecab.git
cd /usr/local/src/php-mecab/mecab
phpize
./configure --with-php-config=/usr/bin/php-config --with-mecab=/usr/local/bin/mecab-config
make
make test
make install
echo "extension = mecab.so" > /etc/php.d/mecab.ini
systemctl restart httpd.service
In PHP, you can use it as shown below.
<?
$ mecab = new mecabtagger ();
Echo $ mecab-> parse ('Hello? Nice to meet you');
?>
Reference
http://qiita.com/yudaifuijta0121/items/1787d70b9cfca3e43d12
http://eunjeon.blogspot.kr/
https://bitbucket.org/eunjeon/mecab-ko-dic
https://github.com/rsky/php-mecab
Leave a Reply