Module Raingrams::Helpers::Similarity
In: lib/raingrams/helpers/similarity.rb
Model TrigramModel BigramModel QuadgramModel PentagramModel HexagramModel Model TrigramModel BigramModel QuadgramModel PentagramModel HexagramModel RuntimeError PrefixFrequencyMissing Set NgramSet Array Ngram Token StopSentence StartSentence Unknown ProbabilityTable Tokens Commonality Random Similarity Frequency Probability Helpers OpenModel OpenVocabulary Raingrams dot/f_1.png

Methods

Included Modules

Raingrams::Helpers::Commonality

Public Class methods

[Source]

# File lib/raingrams/helpers/similarity.rb, line 6
      def self.included(base)
        base.module_eval { include Raingrams::Helpers::Commonality }
      end

Public Instance methods

Returns the conditional probability of the commonality of the specified fragment against the other_model, given the commonality of the fragment against the model.

[Source]

# File lib/raingrams/helpers/similarity.rb, line 15
      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.

[Source]

# File lib/raingrams/helpers/similarity.rb, line 24
      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.

[Source]

# File lib/raingrams/helpers/similarity.rb, line 33
      def text_similarity(text,other_model)
        other_model.text_commonality(text) / text_commonality(text)
      end

[Validate]