使用方法
- //中文分词
- public function scws(){
- Vendor('scws.pscws4');
- $pscws = new \PSCWS4();
- $pscws->set_dict(VENDOR_PATH.'scws/lib/dict.utf8.xdb');
- $pscws->set_rule(VENDOR_PATH.'scws/lib/rules.utf8.ini');
- $title='第三方中文分词';
- $pscws->set_ignore(true);
- $pscws->send_text($title);
- $words = $pscws->get_tops(5);
- $tags = array();
- foreach ($words as $val) {
- $tags[] = $val['word'];
- }
- $pscws->close();
- var_dump($tags);
- //结果
- // array (size=3)
- // 0 => string '分词' (length=6)
- // 1 => string '中文' (length=6)
- // 2 => string '第三方' (length=9)
- }