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);
}