最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
除去字串中的重复词,生成索引字符串,字符串参数为已经分词处理的串
时间:2022-06-24 18:33:21 编辑:袖梨 来源:一聚教程网
//--------------------------------------------------
function getindextext($okstr,$ilen=-1)
{
if($okstr=="") return "";
$ws = explode(" ",$okstr);
$okstr = "";
$wks = "";
foreach($ws as $w)
{
$w = trim($w);
//排除小于2的字符
if(strlen($w)<2) continue;
//排除数字或日期
if(!ereg("[^0-9:-]",$w)) continue;
if(strlen($w)==2&&ord($w[0])>0x80) continue;
if(isset($wks[$w])) $wks[$w]++;
else $wks[$w] = 1;
}
if(is_array($wks))
{
arsort($wks);
if($ilen==-1)
{ foreach($wks as $w=>$v) $okstr .= $w." "; }
else
{
foreach($wks as $w=>$v){
if((strlen($okstr)+strlen($w)+1)<$ilen) $okstr .= $w." ";
else break;
}
}
}
return trim($okstr);
}?>
相关文章
- boostprompt:AI Agent 工具实践指南 09-30
- ai-engineering-workflow:AI Agent 工具实践指南 09-30
- 魔兽世界12.1装等掉落一览 09-30
- 无畏契约官网入口直达-2026无畏契约官网最新地址速查 09-30
- steam官网网页版入口-steam网页端登录入口 09-30
- jm漫画网页版直达-jm官网最新入口 09-30