Sha256: 50385ddc3ccb923cc249f6995369e2b98a314d31e80b7b91752de01ee27eb2a8

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

require 'raingrams/helpers/commonality'

module Raingrams
  module Helpers
    module Similarity
      def self.included(base)
        base.module_eval { include Raingrams::Helpers::Commonality }
      end

      #
      # Returns the conditional probability of the commonality of the
      # specified _fragment_ against the _other_model_, given the
      # commonality of the _fragment_ against the model.
      #
      def fragment_similarity(fragment,other_model)
        other_model.fragment_commonality(fragment) / fragment_commonality(fragment)
      end

      #
      # Returns the conditional probability of the commonality of the
      # specified _sentence_ against the _other_model_, given the
      # commonality of the _sentence_ against the model.
      #
      def sentence_similarity(sentence,other_model)
        other_model.sentence_commonality(sentence) / sentence_commonality(sentence)
      end

      #
      # Returns the conditional probability of the commonality of the
      # specified _text_ against the _other_model_, given the commonality
      # of the _text_ against the model.
      #
      def text_similarity(text,other_model)
        other_model.text_commonality(text) / text_commonality(text)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
raingrams-0.1.2 lib/raingrams/helpers/similarity.rb