?基于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
$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.’
’;?}}??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”, “>”, ““”, “””,”
”);$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(“/
function cutstr_html($string, $sublen)???
?{
? $string = strip_tags($string);
? $string = preg_replace (‘/n/is’, ”, $string);
? $string = preg_replace (‘/ | /is’, ”, $string);
? $string = preg_replace (‘/ /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;
?}
?>