kingerq
中级会员
 
老会员
UID 19868
精华
0
积分 479
帖子 485
金钱 479 喜悦币
威望 0
人脉 0
阅读权限 30
注册 2003-4-25 来自 浙江温州
状态 离线
|
[广告]: Enom域名自助付费 自助注册 自助PUSH 主流域名COM等一律57.99元年
比较文章相似度
问题是太慢了。我的目录里有1000个文章,几个小时都比较不出结果来。
大家看看有没有好方法。。
<?php //检查内容重复情况 $content = $repeat = array(); $num = 0; $dir = "cs/";
if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if ( is_dir( $dir.$file) ) continue; $f = file( $dir.$file ) ; unset($f[0]); unset($f[1]); unset($f[2]); $text = str_replace(array(" ", "n", " ", "t"), array("","","", ""), trim(strip_tags(join("", $f))) ); $lenText = strlen($text); //echo $text;exit; foreach( $content as $key => $val ) { $similar = similar_text( $val, $text ); if( $similar/$lenText > 0.9 ) { $repeat[$key][] = $file; $num++; continue 2; } } $content[$file] = $text; } closedir($dh); } } echo "Repeat:".$num." "; echo "content:".count($content); print_r($repeat); ?>
|  资料:Kingerq's PHP |
|