分词、获取关键词类库phpanalysis
/**
* 关键字提取方法
*
* @param $title string
* 进行分词的标题
* @param $content string
* 进行分词的内容
* @return array 得到的关键词数组
*/
public function getKeywords( ) {
$title = input('post.title');
$content = input('post.content');
Vendor('phpanalysis.phpanalysis');
debug('run');
$str = $content;
$pa = new \PhpAnalysis('utf-8','utf-8',true);
$pa::$loadInit = false;
$pa->LoadDict();
$pa->SetSource($str);
$pa->StartAnalysis( false );
$tags = $pa->GetFinallyResult();
$tags = $pa->GetFinallyKeywords();
var_dump($tags);
// return $tags;
echo '分词完成,耗时:'.debug('run','end').'s';
}