基于discuz在线分词批量优化Dedecms文章关键词

作者:乐购科技 来源: 2011-12-22 09:15:31 阅读 我要评论 直达商品

  dedecms本身自带tag(keywords)提取功能,但分词总是不够精确。当然,对于日更新十数篇且对seo精确执行的用户来说,手工输入能更好的控制。但对于主题比较宽泛、内容更新量大的用户来说,dede split是不大完美的。

  discuz在线分词是一个在线免费的提词接口。后有数十万中文论坛、supsite用户,对于语境、细胞词库的完善有更多的数据。 这个小程序是基于discuz在线分词批量更新已发内容的keywords(tag),如果数据量大(大于5万)的或者虚拟主机用户的话,最好环境搭到本地。速度会快一点。

  使用方法,cms安装目录,新建c.php,拷入以下内容,自己对应编码用notepad设置相应gbk或utf8。运行 yourwebsite/c.php?id=1

<?php
require_once(dirname(__FILE__).”/include/common.inc.php”);

$id = isset($id) && is_numeric($id) ? $id : 0;

for ($a=$id; $a<$id+10; $a++){

 $row = $dsql->GetOne(” SELECT arc.title,tp.body FROM `@__archives` arc LEFT JOIN `@__addonarticle` tp ON arc.id=tp.aid where arc.id=’$a’ “);
 if(is_array($row))
 {
  $title = $row['title'];
  $body = $row['body'];
  $keywords=zhgetkey($title.$body);
  $dsql->ExecuteNoneQuery(” Update `@__archives` set keywords=’$keywords’ where id=’$a’ “);
  echo $a.’:’.$keywords.’<br />’;
 }
}
 
 if ($a>80000){break;}

echo “<script>”;
echo “setTimeout(”location.replace(‘c.php?id=$a’)”,0)”;
echo “</script>”;

function zhgetkey($contents){
$rows = strip_tags($contents);
$arr = array(‘ ‘,’ ‘,”s”, “rn”, “n”, “r”, “t”, “>”, ““”, “””,”<br />”);
$qc_rows = str_replace($arr, ”, $rows);
if(strlen($qc_rows)>2400){
$qc_rows = substr($qc_rows, ’0′, ’2400′);
}
$data = @implode(”, file(“http://keyword.discuz.com/related_kw.html?title=$qc_rows&ics=gbk&ocs=gbk”));
preg_match_all(“/<kw>(.*)A[(.*)]](.*)></kw>/”,$data, $out, PREG_SET_ORDER);
$key=”";
for($i=0;$i<5;$i++){
$key=$key.$out[$i][2];
if($out[$i][2])$key=$key.”,”;
}
return $key;
}

function cutstr_html($string, $sublen)   

 {

  $string = strip_tags($string);

  $string = preg_replace (‘/n/is’, ”, $string);

  $string = preg_replace (‘/ | /is’, ”, $string);

  $string = preg_replace (‘/&nbsp;/is’, ”, $string);

    preg_match_all(“/[x01-x7f]|[xc2-xdf][x80-xbf]|xe0[xa0-xbf][x80-xbf]|[xe1-xef][x80-xbf][x80-xbf]|xf0[x90-xbf][x80-xbf][x80-xbf]|[xf1-xf7][x80-xbf][x80-xbf][x80-xbf]/”, $string, $t_string);  

  if(count($t_string[0]) – 0 > $sublen) $string = join(”, array_slice($t_string[0], 0, $sublen)).”…”;  

  else $string = join(”, array_slice($t_string[0], 0, $sublen));

    return $string;

 }

?>


  推荐阅读

  怎么样看网站百度相关域判断网站是否被K

看网站什么时候成立,然后什么时候被百度收录。就能从历史记录里面看到网站是什么原因被K。 1、如果网站是3个月以内的网站,历史记录收录超过5000,(6个月以内的网站收录超过1W)网站就很有可能因为购买链接被K。要么>>>详细阅读


本文标题:基于discuz在线分词批量优化Dedecms文章关键词

地址:http://www.lgo100.com/a/34/20111222/20331.html

乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

网友点评
我的评论: 人参与评论
验证码: 匿名回答
网友评论(点击查看更多条评论)
友情提示: 登录后发表评论,可以直接从评论中的用户名进入您的个人空间,让更多网友认识您。
自媒体专栏

评论

热度