Пример #1
0
 /**
  * 取文本的关键词
  * limit 默认取10个
  * xattr   条件:在返回结果的词性过滤, 多个词性之间用逗号分隔, 以~开头取反
  *            如: 设为 n,v 表示只返回名词和动词; 设为 ~n,v 则表示返回名词和动词以外的其它词
  * return 返回词汇数组, 每个词汇是包含 [times:次数,attr:词性,word:词]
  * */
 public function xs_get_keyword($text, $limit = 10, $xattr = '')
 {
     if (!$this->settings['App_textsearch']) {
         return array('errmsg' => '迅搜未安装');
     }
     @(include_once ROOT_PATH . 'lib/class/textsearch.class.php');
     if (class_exists('textsearch')) {
         $ts = new textsearch();
         $ret = $ts->get_keyword($text, $limit, $xattr);
         if (empty($ret)) {
             return array('errormsg' => '未取到关键字');
         }
         return $ret;
     }
 }