ははは、まだキーワードの問題がありますが、これは私が作成しているコードです。
貧弱なコードですが、私の作成です:
<?php
$url = 'http://es.wikipedia.org/wiki/Animalia';
Keys($url);
function Keys($url) {
$listanegra = array("a", "ante", "bajo", "con", "contra", "de", "desde", "mediante", "durante", "hasta", "hacia", "para", "por", "que", "qué", "cuán", "cuan", "los", "las", "una", "unos", "unas", "donde", "dónde", "como", "cómo", "cuando", "porque", "por", "para", "según", "sin", "tras", "con", "mas", "más", "pero", "del");
$doc = new DOMDocument();
libxml_use_internal_errors(true);
$doc->loadHTMLFile($url);
$webhtml = $doc->getElementsByTagName('p');
$webhtml = $webhtml ->item(0)->nodeValue;
$webhtml = strip_tags($webhtml);
$webhtml = explode(" ", $webhtml);
foreach($listanegra as $key=> $ln) {
$webhtml = str_replace($ln, " ", $webhtml);
}
$palabras = str_word_count ("$webhtml", 1 );
$frq = array_count_values ($palabras);
$frq = asort($frq);
$ffrq = count($frq);
$i=1;
while ($i < $ffrq) {
print $frqq[$i];
print '<br />';
$i++;
}
}
?>
ウェブサイトのキーワードを抽出しようとするコード。Webの最初の段落を抽出し、変数「$listanegra」の単語を削除します。次に、繰り返し単語を数え、すべての単語を「配列」に保存します。配列を呼び出した後、これで単語が表示されます。
問題は...機能しないコード=(。
コードを使用すると、空白が表示されます。
コードを完成させるのを手伝ってもらえますか?「tf-idf」の使用を勧めていましたが、後で使用します。