Text::Levenshtein::Damerau::XS - XS Damerau Levenshtein edit distance.
use Text::Levenshtein::Damerau::XS qw/xs_edistance/; use warnings; use strict; print xs_edistance('Neil','Niel'); # prints 1
Returns the true Damerau Levenshtein edit distance of strings with adjacent transpositions. XS implementation (requires a C compiler). Works correctly with utf8.
use utf8; xs_edistance('ⓕⓞⓤⓡ','ⓕⓤⓞⓡ'), # prints 1
Speed improvements over Text::Levenshtein::Damerau::PP:
# Text::Levenshtein::Damerau::PP timethis 1000000: 699 wallclock secs (697.60 usr + 0.00 sys = 697.60 CPU) @ 1433.49/s (n=1000000) # Text::Levenshtein::Damerau::XS timethis 1000000: 21 wallclock secs (20.63 usr + 0.00 sys = 20.63 CPU) @ 48473.10/s (n=1000000)
Arguments: source string and target string.
OPTIONAL 3rd argument int (max distance; only return results with $int distance or less). 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.
Wrapper function to take the edit distance between a source and target string using XS algorithm implementation.
use Text::Levenshtein::Damerau::XS qw/xs_edistance/; print xs_edistance('Neil','Niel'); # prints 1 print xs_edistance('Neil','Nielx',1); # prints -1
Text::Levenshtein::Damerau
Text::Levenshtein::Damerau::PP
Please report bugs to:
https://rt.cpan.org/Public/Dist/Display.html?Name=Text-Levenshtein-Damerau-XS
Nick Logan <ug@skunkds.com>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Text::Levenshtein::Damerau::XS, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Text::Levenshtein::Damerau::XS
CPAN shell
perl -MCPAN -e shell install Text::Levenshtein::Damerau::XS
For more information on module installation, please visit the detailed CPAN module installation guide.