こんにちは、tf-idf に問題があります。コードは私を示しています:「0」
これはコードです:
$terms = array_count_values( explode( ' ', $frase ) );
$total_term = asort( $terms );
$total_array = count($total_term);
for ($i=1; $i<=$total_array; $i++){
$SQL = mysql_query("SELECT webTitulo, webDescripcion, webkeywords, weburl FROM webs WHERE MATCH (webTitulo, webDescripcion, webkeywords, weburl) AGAINST ('$total_term[$i]')", $server_link) or die(mysql_error());
$frec_term = mysql_num_rows($SQL);
}
$sssql = mysql_query("SELECT uDR.webTitulo, uDR.webDescripcion, uDR.webkeywords, uDR.weburl, SUM(uDR.priority) as SPriority
FROM (
(SELECT s1.webTitulo, s1.webDescripcion, s1.weburl, s1.webkeywords, 3 as priority FROM webs s1 WHERE MATCH (webTitulo) AGAINST ('$frase'))
UNION
(SELECT s2.webTitulo, s2.webDescripcion, s2.weburl, s2.webkeywords, 1 as priority FROM webs s2 WHERE MATCH (webkeywords) AGAINST ('$frase'))
UNION
(SELECT s3.webTitulo, s3.webDescripcion, s3.weburl, s3.webkeywords, 2 as priority FROM webs s3 WHERE MATCH (webDescripcion) AGAINST ('$frase'))) uDR
GROUP BY uDR.webTitulo, uDR.weburl, uDR.webDescripcion, uDR.webkeywords
ORDER BY SPriority DESC ", $server_link)
or die(mysql_error());
$totalRows = mysql_num_rows($sssql);
$tf_idf = $frec_term * log10($totalRows/70);
echo $tf_idf;
70 は、存在しない変数を置き換える番号です。
ご挨拶