當試圖計算的內容的字符串的單個關鍵字的關鍵字密度,該公式是非常簡單的:KWD =(關鍵詞計數/總字數)* 100關鍵字詞組的關鍵字密度計算?
然而,應該式是我們時正在尋找關鍵字詞組的關鍵字密度?
例如,如何計算以下字符串中短語「藍色小部件」的關鍵字密度?
$myContent = "Blue widgets in a field
of widgets blue makes for lots of widgets, true. But
if a widget is blue, is it still a
\"blue widget\" or just a lone widget in a sea
of blue?";
這是我當前的功能
function my_keyword_density($post)
{
$word_count = my_word_count($post);
$keyword_count = my_keyword_count($post);
$density = ($keyword_count/$word_count) * 100;
$density = number_format($density, 1);
return $density;
}
我怎樣才能得到的單詞數的計數的關鍵字詞組?
@Jacob:謝謝你逃脫報價! – 2011-02-13 00:26:43
關鍵字數/總字數,當然? – aaz 2011-02-13 00:30:46
@aaz:失讀症復發:) – 2011-02-13 00:35:07