EditDistance

EditDistance[u,v]

gives the edit or Levenshtein distance between strings or vectors u and v.

Details and Options

  • EditDistance[u,v] gives the number of one-element deletions, insertions, and substitutions required to transform u to v.
  • For strings, setting the option IgnoreCase->True makes EditDistance treat lower and uppercase letters as equivalent.

Examples

open allclose all

Basic Examples  (2)

Edit distance between two strings:

Edit distance between two vectors:

Scope  (2)

Compute distance between strings of unequal length:

Compute distance between vectors of any length:

Options  (1)

IgnoreCase  (1)

Obtain edit distance ignoring case of letters:

Applications  (2)

Cluster string data using edit distance:

Cluster numeric data using edit distance:

Properties & Relations  (2)

EditDistance is less than or equal to HammingDistance for strings of equal length:

EditDistance is less than or equal to HammingDistance for vectors of equal length:

Introduced in 2007
 (6.0)