/Remove repeated words in the string and generate an index string. The string parameter is the string that has been word segmented
//------------------- ----------------------------------
function getindextext($okstr,$ilen=-1)
{
if($okstr=="") return "";
$ws = explode(" ",$okstr);
$okstr = "";
$wks = "";
foreach($ws as $w)
{
$w = trim($w);
//Exclude characters less than 2
if(strlen($w)<2) continue;
//Exclude numbers or dates
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." ";
($okstr);
}?>
www.bkjia.com