Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rank_bm25.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def _calc_idf(self, nd):
# idf can be negative if word is contained in more than half of documents
negative_idfs = []
for word, freq in nd.items():
idf = math.log(self.corpus_size - freq + 0.5) - math.log(freq + 0.5)
idf = math.log(self.corpus_size + 1) - math.log(freq + 0.5)
self.idf[word] = idf
idf_sum += idf
if idf < 0:
Expand Down