Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.

Commit

Permalink
fix: idf
Browse files Browse the repository at this point in the history
  • Loading branch information
ZTL-UwU committed Mar 28, 2024
1 parent 102eabe commit a4092a2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion api/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub async fn get_tf_idf_array(paper: &[Value], db: &DbConn) -> Vec<f64> {
// tf-idf = tf * idf
// idf(smooth) = ln((1 + nd) / (1 + df)) + 1
let tf = word["t"].as_f64().unwrap() / paper.len() as f64;
let idf = 1.0 + f64::ln((1.0 + nd) / (1.0 + name.df as f64));
let idf = 1.0 + f64::log10(nd / (1.0 + name.df as f64));

res.push(tf * idf);
found = true;
Expand Down

0 comments on commit a4092a2

Please sign in to comment.