Help language development. Donate to The Perl Foundation

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


=encoding utf8

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

Levenshtein and Damerau Levenshtein edit distances

=for HTML <a href=""><img src=""></a>
          <a href=""><img src=""></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

    # Perl 6
    $ zef install

=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


=head3 Bugs

Please report bugs to:


=head3 Author

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