Skip to content
Damerau Levenshtein edit distance in Perl6
Perl 6
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples
lib/Text/Levenshtein
t
xt
.appveyor.yml
.travis.yml
LICENSE
META6.json
README.pod

README.pod

Text::Levenshtein::Damerau

Levenshtein and Damerau Levenshtein edit distances

Synopsis

use Text::Levenshtein::Damerau;

say dld('Neil','Niel'); # damerau levenstein distance
# prints 1

say ld('Neil','Niel'); # levenshtein distance
prints 2

Description

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

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 Int if max distance is set and reached if possible.

    use Text::Levenshtein::Damerau;
    say dld('AABBCC','AABCBCD');
    # prints 2
    
    # Max edit distance of 1
    say dld('AABBCC','AABCBCD',1); # distance is 2
    # prints Int
  • ld

    Levenshtein Distance (no transpositions)

    Arguments: $source, $target, $max?

    $max distance. 0 = unlimited. Default = 0

    Returns: Int that represents edit distance between the two argument. Stops calculations and returns Int if max distance is set and reached if possible.

    use Text::Levenshtein::Damerau;
    say ld('AABBCC','AABCBCD');
    # prints 3
    
    # Max edit distance of 1
    # Uses regular Levenshtein distance (no transpositions)
    say ld('AABBCC','AABCBCD',1); # distance is 3
    # prints Int

Bugs

Please report bugs to:

https://github.com/ugexe/Perl6-Text--Levenshtein--Damerau/issues

Author

Nick Logan nlogan@gmail.com

You can’t perform that action at this time.