Class: MiniSearch::Idf

Inherits:
Object
  • Object
show all
Defined in:
lib/mini_search/idf.rb

Class Method Summary collapse

Class Method Details

.calculate(number_of_documents_with_term, number_of_documents) ⇒ Object



5
6
7
8
9
10
# File 'lib/mini_search/idf.rb', line 5

def self.calculate(number_of_documents_with_term, number_of_documents)
  Math.log(
    (number_of_documents.to_f - number_of_documents_with_term.to_f + 0.5) /
    (number_of_documents_with_term.to_f + 0.5)
  )
end