我有问题,我无法用我的实际代码计算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。
我如何提取它们?。
答案 0 :(得分:0)