levenshtein

levenshtein, function

def pure levenshtein(a: text, b: text): number

Returns the case-sensitive Levenshtein distance between a and b.

Examples

table T = with
  [| as From, as To |]
  [| "kitten", "sitting" |]
  [| "Saturday", "Sunday" |]

T.Distance = levenshtein(T.From, T.To)

show table "Distance" with
  T.From
  T.To
  T.Distance

This produces the following table:

From To Distance
kitten sitting 3
Saturday Sunday 3

Remarks

The distance counts insertions, deletions, and substitutions.

User Contributed Notes
0 notes + add a note