Sha256: 9c3a4fca5e287e8fe1f76fbb1e8c0a1cd8ed50329aaee8ca7703aadc5c28106a

Contents?: true

Size: 413 Bytes

Versions: 5

Compression:

Stored size: 413 Bytes

Contents

module TfIdfSimilarity
  class Document
    # @return [Float] the maximum term count of any term in the document
    def maximum_term_count
      @maximum_term_count ||= term_counts.values.max.to_f
    end

    # @return [Float] the average term count of all terms in the document
    def average_term_count
      @average_term_count ||= term_counts.values.reduce(0, :+) / term_counts.size.to_f
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
tf-idf-similarity-0.3.0 lib/tf-idf-similarity/extras/document.rb
tf-idf-similarity-0.2.0 lib/tf-idf-similarity/extras/document.rb
tf-idf-similarity-0.1.6 lib/tf-idf-similarity/extras/document.rb
tf-idf-similarity-0.1.5 lib/tf-idf-similarity/extras/document.rb
tf-idf-similarity-0.1.4 lib/tf-idf-similarity/extras/document.rb