Calculate damerau levenshtein edit distances
use Acme::Polyglot::Levenshtein::Damerau;
print Acme::Polyglot::Levenshtein::Damerau::dld('Neil','Niel');
# prints 1
Returns the true Damerau Levenshtein edit distance of strings with adjacent transpositions.
This is a polyglot module that works for both Perl 5 and Perl 6 -- don't use this code as inspiration for a non-polyglot codebase.
# Perl 5
$ cpanm https://github.com/ugexe/Acme--Polyglot--Levenshtein--Damerau.git
# Perl 6
$ zef install https://github.com/ugexe/Acme--Polyglot--Levenshtein--Damerau.git
dld
Damerau Levenshtein Distance (Levenshtein Distance including transpositions)
Arguments: $source, $target, $max?
$max distance. 0 = unlimited. Default = 0
Returns: int that represents the edit distance between the two argument. Stops calculations and returns -1 if max distance is set and reached if possible.
print Acme::Polyglot::Levenshtein::Damerau::dld('AABBCC','AABCBCD'); # prints 2 # Max edit distance of 1 print Acme::Polyglot::Levenshtein::Damerau::dld('AABBCC','AABCBCD',1); # distance is 2 # prints -1
Please report bugs to:
https://github.com/ugexe/Acme--Polyglot--Levenshtein--Damerau/issues
Nick Logan (ugexe) nlogan@gmail.com