module Levenshtein
Overview
Levenshtein distance methods.
Defined in:
levenshtein.crClass Method Summary
-  .distance(string1 : String, string2 : String) : Int32 
Computes the levenshtein distance of two strings.
 -  .find(name, tolerance = nil, &) 
Finds the best match for name among strings added within the given block.
 -  .find(name, all_names, tolerance = nil) 
Finds the best match for name among strings provided in all_names.
 
Class Method Detail
def self.distance(string1 : String, string2 : String) : Int32Source
Computes the levenshtein distance of two strings.
require "levenshtein"
Levenshtein.distance("algorithm", "altruistic") # => 6
Levenshtein.distance("hello", "hallo")          # => 1
Levenshtein.distance("こんにちは", "こんちは")           # => 1
Levenshtein.distance("hey", "hey")              # => 0 def self.find(name, tolerance = nil, &)Source
Finds the best match for name among strings added within the given block. tolerance can be used to set maximum Levenshtein distance allowed.
require "levenshtein"
best_match = Levenshtein.find("hello") do |l|
  l.test "hulk"
  l.test "holk"
  l.test "halka"
  l.test "ello"
end
best_match # => "ello" def self.find(name, all_names, tolerance = nil)Source
Finds the best match for name among strings provided in all_names. tolerance can be used to set maximum Levenshtein distance allowed.
require "levenshtein"
Levenshtein.find("hello", ["hullo", "hel", "hall", "hell"], 2) # => "hullo"
Levenshtein.find("hello", ["hurlo", "hel", "hall"], 1)         # => nil 
    © 2012–2021 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.
    https://crystal-lang.org/api/1.2.1/Levenshtein.html