Class: StringMetric::Levenshtein::Experiment

Inherits:
Object
  • Object
show all
Defined in:
lib/string_metric/levenshtein/experiment.rb

Class Method Summary collapse

Class Method Details

.distance(from, to, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/string_metric/levenshtein/experiment.rb', line 6

def self.distance(from, to, options = {})
  m = from.length
  n = to.length

  [m, n].min.times do |i|
    if from[i] == to[i]
      from.slice!(i)
      to.slice!(i)
    end
  end

  options.delete(:strategy)

  # Call default distance implementation
  Levenshtein.distance(from, to, options)
end