Module: Raingrams::Helpers::Similarity

Included in:
Model
Defined in:
lib/raingrams/helpers/similarity.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



6
7
8
# File 'lib/raingrams/helpers/similarity.rb', line 6

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

Instance Method Details

#fragment_similarity(fragment, other_model) ⇒ Object

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



15
16
17
# File 'lib/raingrams/helpers/similarity.rb', line 15

def fragment_similarity(fragment,other_model)
  other_model.fragment_commonality(fragment) / fragment_commonality(fragment)
end

#sentence_similarity(sentence, other_model) ⇒ Object

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



24
25
26
# File 'lib/raingrams/helpers/similarity.rb', line 24

def sentence_similarity(sentence,other_model)
  other_model.sentence_commonality(sentence) / sentence_commonality(sentence)
end

#text_similarity(text, other_model) ⇒ Object

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



33
34
35
# File 'lib/raingrams/helpers/similarity.rb', line 33

def text_similarity(text,other_model)
  other_model.text_commonality(text) / text_commonality(text)
end