[備忘]CentOS7.4 php7.1 にmecab入れたときのメモ

rpm -ivh http://packages.groonga.org/centos/groonga-release-1.1.0-1.noarch.rpm
yum makecache
yum install mecab mecab-ipadic

yum install mecab-devel
git clone https://github.com/rsky/php-mecab.git
cd php-mecab/mecab/
phpize
./configure
make
make test
make install
vi /etc/php.d/40-mecab.ini

git clone –depth 1 https://github.com/neologd/mecab-ipadic-neologd.git
cd mecab-ipadic-neologd
./bin/install-mecab-ipadic-neologd -n

mecab -d /usr/lib64/mecab/dic/mecab-ipadic-neologd


<?php
$sstr = ‘適当な文字列’;
$opts = [‘-d’=>’/usr/lib64/mecab/dic/mecab-ipadic-neologd’];

$cMT = new \MeCab\Tagger($opts);
$nodes = $cMT->parseToNode($sstr);

foreach ($nodes as $datum) {
echo $datum->getSurface(), “\n”;
echo $datum->getFeature(), “\n”;
}