Skip to content
Snippets Groups Projects
Commit 3e7de1f0 authored by Tinsaye Abye's avatar Tinsaye Abye
Browse files

[fix] division by zero in idf

parent efb4db64
No related branches found
No related tags found
2 merge requests!12Release/1.0.0,!1Resolve "implement draft from Exposé"
......@@ -50,7 +50,7 @@ public class TFIDF implements SimilarityComputation<String> {
}
/**
* Calculate the inverse document frequency after log(|D| / |{d:ti ∈ d}|)
* Calculate the inverse document frequency after log(|D| / 1 + |{d:ti ∈ d}|)
*
* @param term the term
* @param doc1 the first document
......@@ -69,7 +69,7 @@ public class TFIDF implements SimilarityComputation<String> {
if (df == 0) {
return 0D;
}
return Math.log(2 / (float) df);
return Math.log(2 / (float) 1 + df);
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment