0

我有一个问题,我无法用我的实际代码计算 tf-idf。

这是 tf-idf 的示例:

$tfidf = $term_frequency *  // tf
        log( $total_document_count / $documents_with_term, 2); // idf

我有全部文件,但我需要 $documents_with_term 和 $term_frequency。

这是我的实际代码:

$frase = htmlspecialchars($_GET['frase'], ENT_NOQUOTES);

$sssql = $server_link->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, $a as priority FROM webs s1 WHERE MATCH (webTitulo) AGAINST ('$frase'))

UNION

(SELECT s2.webTitulo, s2.webDescripcion, s2.weburl, s2.webkeywords, $b as priority FROM webs s2 WHERE MATCH (webkeywords) AGAINST ('$frase*' IN BOOLEAN MODE))

UNION

(SELECT s3.webTitulo, s3.webDescripcion, s3.weburl, s3.webkeywords, $c 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 ");

$totalRows = $sssql->num_rows; //This is the $total_document_count

我有 $total_document_count,但我不知道如何提取 TF 和 $documents_with_term。

我怎样才能提取它们?

4

1 回答 1

0
于 2013-09-27T13:40:57.123 回答