levenshteinDistanceAndPath

Returns the Levenshtein distance and the edit path between s and t.

  1. Tuple!(size_t, EditOp[]) levenshteinDistanceAndPath(Range1 s, Range2 t)
  2. Tuple!(size_t, EditOp[]) levenshteinDistanceAndPath(Range1 s, Range2 t)
    Tuple!(size_t, EditOp[])
    levenshteinDistanceAndPath
    (
    alias equals =
    (
    a
    ,
    b
    )
    => a == b
    Range1
    Range2
    )
    (
    auto ref Range1 s
    ,
    auto ref Range2 t
    )

Parameters

equals

The binary predicate to compare the elements of the two ranges.

s Range1

The original range.

t Range2

The transformation target

Return Value

Type: Tuple!(size_t, EditOp[])

Tuple with the first element being the minimal amount of edits to transform s into t and the second element being the sequence of edits to effect this transformation.

Allocates GC memory for the returned EditOp[] array.

Examples

string a = "Saturday", b = "Sundays";
auto p = levenshteinDistanceAndPath(a, b);
assert(p[0] == 4);
assert(equal(p[1], "nrrnsnnni"));

Meta