hightman / xunsearch

免费开源的中文搜索引擎,采用 C/C++ 编写 (基于 xapian 和 scws),提供 PHP 的开发接口和丰富文档
http://www.xunsearch.com
Other
1.65k stars 391 forks source link

自定义分词报错 #42

Open herenet opened 7 years ago

herenet commented 7 years ago

Fatal error: Uncaught [XSException] ../../ThinkPHP/Library/Vendor/Xunsearch/XS.php(2439): Task is canceled due to timeout/error(S#514) thrown in /data/wwwroot/www.hongren.com/ThinkPHP/Library/Vendor/Xunsearch/XS.php on line 2439

在配置文件中配置了 [nickname] type = title tokenizer = duality

在XS中实现了方法。把父类的private变量改成了protected了。 class XSTokenizerDuality extends XSTokenizerScws {

public function __construct($arg = null)
{
    parent::__construct($arg);
}

public function getTokens($value, XSDocument $doc = null)
{
    $tokens = array();
    $this->setIgnore(true);
    $this->setDuality(false);
    $_charset = self::$_charset;
    self::$_charset = 'UTF-8';
    $words = $this->getResult($value);
    foreach ($words as $word) {
        $tokens[] = $word['word'];
    }
    self::$_charset = $_charset;
    return $tokens;
}

}