Skip to content

Latest commit

 

History

History
69 lines (38 loc) · 1.97 KB

File metadata and controls

69 lines (38 loc) · 1.97 KB

Acme::Polyglot::Levenshtein::Damerau

Calculate damerau levenshtein edit distances

Synopsis

use Acme::Polyglot::Levenshtein::Damerau;

print Acme::Polyglot::Levenshtein::Damerau::dld('Neil','Niel');
# prints 1

Description

Returns the true Damerau Levenshtein edit distance of strings with adjacent transpositions.

WARNING

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.

Installation

# 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

Routines

  • 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

Bugs

Please report bugs to:

https://github.com/ugexe/Acme--Polyglot--Levenshtein--Damerau/issues

Author

Nick Logan (ugexe) nlogan@gmail.com