日期:2014-05-17 浏览次数:20466 次
require 'pscws4.class.php';
$text = '这里是标题测试文档';
$cws = new PSCWS4('gbk');
$cws->set_dict('etc/dict.xdb');
$cws->set_rule('etc/rules.ini');
$cws->send_text($text);
echo "<xmp>Top words stats:\n\n";
$ret = array();
$ret = $cws->get_tops(10,'r,v,p');
echo "No.\tWord\t\tAttr\tTimes\tRank\n------------------------------------------------------\n";
$i = 1;
foreach ($ret as $tmp)
{
printf("%02d.\t%-16s\t%s\t%d\t%.2f\n", $i++, $tmp['word'], $tmp['attr'], $tmp['times'], $tmp['weight']);
}
$cws->close();
Top words stats:
No. Word Attr Times Rank
------------------------------------------------------
01. 文档 n 1 4.80
02. 标题 n 1 4.76
03. 测试 vn 1 4.72