<?php
/**
* Chinese word processing method
*+---------------------------------
* @param stirng $string The string to be processed
* @param boolers $sort =false The reverse according to value
* @param Numbers $top = 0 Returns the specified number, returning all by default
*+---------------------------------
* @return void
*/
function Scws ($text, $top = 5, $return _array = false, $sep = ', ') {
Include ('./pscws4/pscws4.php ');//go to the URL below to download the PSCWS4
$CWS = new Pscws4 (' Utf-8 ');
$CWS-Set_charset (' utf-8 ');
$CWS-Set_dict ('./pscws4/etc/dict.utf8.xdb ');
$CWS-Set_rule ('./pscws4/etc/rules.utf8.ini ');
$CWS->set_multi (3);
$CWS-Set_ignore (true);
$cws->set_debug (TRUE);
$cws->set_duality (TRUE);
$CWS-Send_text ($text);
$ret = $cws-Get_tops ($top, ' r,v,p ');
$result = null;
foreach ($ret as $value) {
if (false = = = $return _array) {
$result. = $sep. $value [' word '];
} else {
$result [] = $value [' word '];
}
}
return false = = = $return _array? SUBSTR ($result, 1): $result;
}
Print_r (SCWS (' Baidu Security '));
?>
SCWS Download: http://www.xunsearch.com/scws/download.php
PSCWS4 Download: http://download.csdn.net/detail/pzp_118/5412639
Installation method of SCWS participle extension under unix/linux