Class: Simhilarity::Single

Inherits:
Matcher
  • Object
show all
Defined in:
lib/simhilarity/single.rb

Overview

Calculate the similarity score for pairs of items, one at a time.

Instance Attribute Summary

Attributes inherited from Matcher

#freq, #ngrammer, #normalizer, #options, #reader

Instance Method Summary collapse

Methods inherited from Matcher

#corpus, #corpus=, #inspect, #ngrams, #ngrams_sum, #normalize, #read, #simhash

Constructor Details

#initialize(options = {}) ⇒ Single

See Matcher#initialize.



7
8
9
# File 'lib/simhilarity/single.rb', line 7

def initialize(options = {})
  super(options)
end

Instance Method Details

#score(a, b) ⇒ Object

Calculate the similarity score for these two items. Scores range from 0 to 1, with 1 being a perfect match and 0 being a terrible match. For best results, call #corpus= first.



14
15
16
# File 'lib/simhilarity/single.rb', line 14

def score(a, b)
  Candidate.new(self, element_for(a), element_for(b)).score
end