class BioDSL::Levenshtein

Class to calculate the Levenshtein distance between two given strings. en.wikipedia.org/wiki/Levenshtein_distance

Constants

BYTES_IN_INT

Public Class Methods

distance(s, t) click to toggle source
# File lib/BioDSL/seq/levenshtein.rb, line 37
def self.distance(s, t)
  return 0        if s == t
  return t.length if s.length == 0
  return s.length if t.length == 0

  v0 = "\0" * (t.length + 1) * BYTES_IN_INT
  v1 = "\0" * (t.length + 1) * BYTES_IN_INT

  new.levenshtein_distance_C(s, t, s.length, t.length, v0, v1)
end