module Edits::Levenshtein

Overview

Implementation of Levenshtein distance algorithm.

Determines distance between two string by counting edits, identifying:

Extended Modules

Defined in:

edits/levenshtein.cr

Class Method Summary

Class Method Detail

def self.distance(str1, str2, max : Int) #

Calculate the Levenshtein (edit) distance of two sequences, bounded by a maximum value. For low max values, this can have better performance.

Levenshtein.distance("cloud", "crayon")    # => 5
Levenshtein.distance("cloud", "crayon", 2) # => 2

[View source]
def self.distance(str1, str2) #

Calculate the Levenshtein (edit) distance of two sequences.

Note: a true distance metric, satisfies triangle inequality.

Levenshtein.distance("sand", "hands") # => 2

[View source]