<?php |
/** |
* 将etc.rar解压缩,复制到/APP/Common/Conf/目录中 |
* 将Pscws.rar解压缩,复制到/ThinkPHP/Library/Org/目录中(如果更换目录需要将解压缩得到的命名空间改变) |
* |
*/ |
namespace Home\Controller; |
use Think\Controller; |
class IndexController extends Controller |
{ |
public function index() |
{ |
$num = 10; //控制分词数量 |
$str = '“作为一个新兴市场国家,中国做了很多积极的事情。因此人们会想,让中国变得更好的事情只会给世界带来积极影响。”虽远隔万里,但在德国柏林街头接受采访的退休老人玛丽昂·史密斯也感受到了中国变革的影响力。' ; |
$pscws = new \Org\Pscws\Pscws4(); |
$pscws ->set_dict(CONF_PATH . 'etc/dict.utf8.xdb' ); //实际路径:/APP/Common/Conf/etc/dict.utf8.xdb |
$pscws ->set_rule(CONF_PATH . 'etc/rules.utf8.ini' ); //实际路径:/APP/Common/Conf/etc/rules.utf8.ini |
$pscws ->set_ignore(true); |
$pscws ->send_text( $str ); |
$words = $pscws ->get_tops( $num ); |
$pscws ->close(); |
$tags = array (); |
foreach ( $words as $val ) |
{ |
$tags [] = $val [ 'word' ]; |
} |
dump( '分词前:' . $str ); |
dump( '分词后:' .implode( ',' , $tags )); |
} |
} |
高级设计师
by: 小蜜锋 发表于:2014-03-16 16:14:08 顶(0) | 踩(0) 回复
最新版的,赞一个!!
回复评论