时间:2021-07-01 10:21:17 帮助过:13人阅读
function hasSimilarText($string)
{
$lineArr = explode("\n",$string);
$arrStr = $arrLen = array();
foreach($lineArr as $k => $v)
{
$arrLen[] = strlen($v);
$arrStr[] = $v;
}
foreach($arrStr as $k1 => $v1)
{
foreach($arrStr as $k2 => $v2)
{
if($k1 == $k2) continue;
if($arrLen[$k2] < 30 || abs($arrLen[$k2] - $arrLen[$k1]) > 100) continue;
similar_text($v1, $v2, $pct);
if($pct > 90) return true;
}
}
return false;
}
/* 重复段落检测 */
function hasRepeatLine($string)
{
$string = str_replace(array("\t"," ","@","#","。",",",".",","),'',$string);
//$string = str_replace("\r","\n",$string);
$lineArr = explode("\n",$string);
$countShort = $countMiddle = $countLong = 0;
$arr = array();
foreach($lineArr as $lineString)
{
$length = strlen( $lineString );
if($length < 1) continue;
if(in_array($lineString,$arr))
{
if($length < 13)
{
$countShort++;
if($countShort > 4) return true;//5次
} elseif($length>12 && $length < 51) {
$countMiddle++;
if($countMiddle > 3) return true; //4次
} elseif($length>50 && $length < 101) {
$countLong++;
if($countLong > 2) return true; //3次