edit_distance

Values

pub fn levenshtein(one: String, other: String) -> Int

Compute the edit distance between two strings using the Levenshtein distance. The Levenshtein distance between two strings is the number of edits that will get you from one string to the other; the allowed edits are:

  • insertion: adding a new character to one of the two strings
  • deletion: removing a character from one of the two strings
  • replacemente: replace a character with a new one in one of the two strings

Examples

assert 2 == levenshtein("gleam", "beam")
assert 1 == levenshtein("cat", "cap")
Search Document