Text::L...rau::XS(3)

πŸ“¦
version 3.2 Β· 3 versions
, in epel 9

okay so bestie, welcome to the user-contributed Perl documentation for Text::L...rau::XS(3) β€” we're about to vibe through the whole thing. πŸ’–

✨ NAME ✨

Text::Levenshtein::Damerau::XS β€” XS Damerau Levenshtein edit distance. that's the whole name section, no cap.

🌸 SYNOPSIS 🌸

use Text::Levenshtein::Damerau::XS qw/xs_edistance/;

print xs_edistance('Neil','Niel');
# prints 1

πŸ¦‹ DESCRIPTION πŸ¦‹

so this module gives you the true Damerau Levenshtein edit distance of strings with adjacent transpositions. it's an XS implementation, which means yep, it requires a C compiler. also it works correctly with utf8, queen behavior.

use Text::Levenshtein::Damerau::XS qw/xs_edistance/;
use utf8;

xs_edistance('β“•β“žβ“€β“‘','β“•β“€β“žβ“‘'),
# prints 1

the speed improvements over Text::Levenshtein::Damerau::PP are giving main character energy:

# Text::Levenshtein::Damerau::PP::pp_edistance("four","fuor")
timethis 1000000: 381 wallclock secs (380.45 usr +  0.01 sys =
                        380.46 CPU) @ 2628.40/s (n=1000000)

# Text::Levenshtein::Damerau::XS::xs_edistance("four","fuor")
timethis 1000000: 19 wallclock secs (19.43 usr +  0.00 sys =
                        19.43 CPU) @ 51466.80/s (n=1000000)

πŸ’… METHODS πŸ’…

πŸŽ€ xs_edistance πŸŽ€

arguments: source string and target string. iconic.

  • optional 3rd argument int β€” this is the max distance; only return results with $int distance or less. 0 = unlimited. Default = 0.
  • returns an int that represents the edit distance between the two arguments. it stops calculating and returns -1 if max distance is set and reached. lowkey dramatic, but useful.

it's the wrapper function that takes the edit distance between a source and target string using the XS algorithm implementation.

use Text::Levenshtein::Damerau::XS qw/xs_edistance/;
print xs_edistance('Neil','Niel');
# prints 1
# Max edit distance of 1
print xs_edistance('Neil','Niely',1); # distance is 2
# prints -1

πŸ”₯ TODO πŸ”₯

  • handle very large strings of text. can be accomplished by reworking the scoring matrix or writing to disk.
  • add from_file methods.
  • add binary/byte string support.

πŸ‘‘ SEE ALSO πŸ‘‘

  • Text::Levenshtein::Damerau
  • Text::Levenshtein::Damerau::PP

πŸ’€ BUGS πŸ’€

please report bugs to:

<https://rt.cpan.org/Public/Dist/Display.html?Name=Text-Levenshtein-Damerau-XS>

πŸ™ˆ AUTHOR πŸ™ˆ

Nick Logan <ugexe@cpan.org>

this library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


that's the whole page, bestie β€” Text::L...rau::XS(3) from perl v5.32.1, dated 2022-01-21. mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from