基于discuz在線分詞批量?jī)?yōu)化Dedecms文章關(guān)鍵詞

2023-01-20    分類(lèi): 網(wǎng)站建設(shè)

基于discuz在線分詞批量?jī)?yōu)化Dedecms文章關(guān)鍵詞dedecms本身自帶tag(keywords)提取功能(成都網(wǎng)站制作),但分詞總是不夠精確。當(dāng)然,對(duì)于日更新十?dāng)?shù)篇且對(duì)seo精確執(zhí)行的用戶來(lái)說(shuō),手工輸入能更好的控制(高端網(wǎng)站建設(shè)

)。但對(duì)于主題比較寬泛、內(nèi)容更新量大的用戶來(lái)說(shuō),dede split是不大好的。

discuz在線分詞是一個(gè)在線免費(fèi)的提詞接口。后有數(shù)十萬(wàn)中文論壇、supsite用戶,對(duì)于語(yǔ)境、細(xì)胞詞庫(kù)的完善有更多的數(shù)據(jù)。 這個(gè)小程序是基于discuz在線分詞批量更新已發(fā)內(nèi)容的keywords(tag),如果數(shù)據(jù)量大(大于5萬(wàn))的或者虛擬主機(jī)用戶的話,好環(huán)境搭到本地。速度會(huì)快一點(diǎn)。

使用方法,cms安裝目錄,新建c.php,拷入以下內(nèi)容,自己對(duì)應(yīng)編碼用notepad設(shè)置相應(yīng)gbk或utf8。運(yùn)行 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;

}

?>

當(dāng)前文章:基于discuz在線分詞批量?jī)?yōu)化Dedecms文章關(guān)鍵詞
網(wǎng)站鏈接:http://www.bm7419.com/news25/231225.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供靜態(tài)網(wǎng)站、品牌網(wǎng)站制作、網(wǎng)站設(shè)計(jì)、網(wǎng)站改版手機(jī)網(wǎng)站建設(shè)、網(wǎng)站策劃

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

小程序開(kāi)發(fā)