module Vladlev

Constants

C_EXT_NATIVE
JRUBY_NATIVE
VERSION

Public Class Methods

_internal_distance(str1, str2, max) click to toggle source

Calculate the levenshtein distance between two strings

@param [String] first string to compare @param [String] second string to compare @return [Integer] the levenshtein distance between the strings

# File lib/vladlev.rb, line 18
def self._internal_distance(str1, str2, max)
  Java::LevenshteinDistance.distance(str1, str2, max)
end
_normalized_distance(str1, str2, max) click to toggle source
# File lib/vladlev.rb, line 22
def self._normalized_distance(str1, str2, max)
  Java::LevenshteinDistance.normalized_distance(str1, str2, max)
end
distance(str1, str2, max = 9999) click to toggle source
# File lib/vladlev.rb, line 63
def self.distance(str1, str2, max = 9999)
  return 0 if str1.nil? && str2.nil?
  return str2.size if str1.nil?
  return str1.size if str2.nil?

  self._internal_distance(str1, str2, max)
end
file_fallback_path(*files) click to toggle source
# File lib/vladlev.rb, line 2
def self.file_fallback_path(*files)
  files.map { |file| File.join(File.dirname(__FILE__), file) }.detect { |file| File.exists?(file) }
end
get_normalized_distance(str1, str2, max = 9999) click to toggle source
# File lib/vladlev.rb, line 71
def self.get_normalized_distance(str1, str2, max = 9999)
  return 0 if str1.nil? && str2.nil?
  return 1.0 if str1.nil?
  return 1.0 if str2.nil?

  self._normalized_distance(str1, str2, max)
end