Help language development. Donate to The Perl Foundation

Acme::Polyglot::Levenshtein::Damerau cpan:UGEXE last updated on 2019-04-06

README.pod
=pod 

=encoding utf8

=head2 Acme::Polyglot::Levenshtein::Damerau

Levenshtein and Damerau Levenshtein edit distances

=for HTML <a href="https://travis-ci.org/ugexe/Acme--Polyglot--Levenshtein--Damerau"><img src="https://travis-ci.org/ugexe/Acme--Polyglot--Levenshtein--Damerau.svg?branch=master"></a>
          <a href="https://ci.appveyor.com/project/ugexe/Acme-Polyglot-Levenshtein-Damerau/branch/master"><img src="https://ci.appveyor.com/api/projects/status/github/ugexe/Acme--Polyglot--Levenshtein--Damerau?branch=master&passingText=Windows%20-%20OK&failingText=Windows%20-%20FAIL&pendingText=Windows%20-%20pending&svg=true"></a>

=head2 Synopsis

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

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

=head2 Description

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

=head2 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.

=head2 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

=head2 Routines

=over 8

=item * C<dld>

Damerau Levenshtein Distance (Levenshtein Distance including transpositions)

Arguments: $source, $target, $max?

I<$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

=back

=head3 Bugs

Please report bugs to:

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

=head3 Author

Nick Logan (ugexe) L<[email protected]>

=cut