加载中...

ThinkPHP 整合中文分词Scws


先按照图片放好路径
5858e3abcc519.jpg

使用方法

  1. //中文分词
  2. public function scws(){
  3. Vendor('scws.pscws4');
  4. $pscws = new \PSCWS4();
  5. $pscws->set_dict(VENDOR_PATH.'scws/lib/dict.utf8.xdb');
  6. $pscws->set_rule(VENDOR_PATH.'scws/lib/rules.utf8.ini');
  7. $title='第三方中文分词';
  8. $pscws->set_ignore(true);
  9. $pscws->send_text($title);
  10. $words = $pscws->get_tops(5);
  11. $tags = array();
  12. foreach ($words as $val) {
  13. $tags[] = $val['word'];
  14. }
  15. $pscws->close();
  16. var_dump($tags);
  17. //结果
  18. // array (size=3)
  19. // 0 => string '分词' (length=6)
  20. // 1 => string '中文' (length=6)
  21. // 2 => string '第三方' (length=9)
  22. }

下载地址


还没有评论.