scws中文分词PHP

Linux下安装scws和安装PHP的scws扩展

wget http://www.xunsearch.com/scws/down/scws-1.2.3.tar.bz2
tar xvjf scws-1.2.3.tar.bz2
cd scws-1.2.3/
./configure --prefix=/usr/local/scws
make && make install
cd ../scws/
ls -al lib/libscws.la
/usr/local/scws/bin/scws -h
cd /usr/local/src/scws-1.2.3/phpext
/usr/bin/phpize
./configure --with-php-config=/usr/bin/php-config
make && make install
vim /etc/php.ini
填加extension = scws.so

scws使用代码

 

$cws = scws_new();

$cws->set_charset('utf8');

$cws->set_rule('./rules.utf8.ini');

$cws->set_dict('./dict.utf8.xdb');

$cws->set_duality(true);

$cws->set_ignore(true);

$cws->set_multi(14);

$cws->send_text($content);

$result = array(

    array('word' => $content)

);

while($tmp = $cws->get_result()){

 

    $result = array_merge($result, $tmp);

}

 

posted @ 2019-01-10 17:29  li先森  阅读(698)  评论(0编辑  收藏  举报