Sha256: 95890b72efdbdb7166d82eeee26643cffa04faf257f8dec9a5e5bd8628aaf5a4

Contents?: true

Size: 467 Bytes

Versions: 4

Compression:

Stored size: 467 Bytes

Contents

module Company
  module Mapping

# NormalizedTermFrequency inherits from TermFrequency class. It calculates Term Frequency as
# logarithmically scaled frequency: tf(t,d) = 1 + log(f(t,d)), or zero if
# f(t,d) is zero.

    class NormalizedTermFrequency < TermFrequency
      def calculate(text)
        rawFrequency(text).each_with_object({}) do |(key, value), logTF|
          logTF[key] = 1.0 + Math.log(value)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
company-mapping-0.2.3 lib/company/mapping/tfidf/tf/normalized_term_frequency.rb
company-mapping-0.2.2 lib/company/mapping/tfidf/tf/normalized_term_frequency.rb
company-mapping-0.2.1 lib/company/mapping/tfidf/tf/normalized_term_frequency.rb
company-mapping-0.2.0 lib/company/mapping/tfidf/tf/normalized_term_frequency.rb