1Text::Levenshtein::DameUrsaeur::CXoSn(t3r)ibuted Perl DoTceuxmte:n:tLaetvieonnshtein::Damerau::XS(3)
2
3
4
6 Text::Levenshtein::Damerau::XS - XS Damerau Levenshtein edit distance.
7
9 use Text::Levenshtein::Damerau::XS qw/xs_edistance/;
10
11 print xs_edistance('Neil','Niel');
12 # prints 1
13
15 Returns the true Damerau Levenshtein edit distance of strings with
16 adjacent transpositions. XS implementation (requires a C compiler).
17 Works correctly with utf8.
18
19 use Text::Levenshtein::Damerau::XS qw/xs_edistance/;
20 use utf8;
21
22 xs_edistance('ⓕⓞⓤⓡ','ⓕⓤⓞⓡ'),
23 # prints 1
24
25 Speed improvements over Text::Levenshtein::Damerau::PP:
26
27 # Text::Levenshtein::Damerau::PP::pp_edistance("four","fuor")
28 timethis 1000000: 381 wallclock secs (380.45 usr + 0.01 sys =
29 380.46 CPU) @ 2628.40/s (n=1000000)
30
31 # Text::Levenshtein::Damerau::XS::xs_edistance("four","fuor")
32 timethis 1000000: 19 wallclock secs (19.43 usr + 0.00 sys =
33 19.43 CPU) @ 51466.80/s (n=1000000)
34
36 xs_edistance
37 Arguments: source string and target string.
38
39 • OPTIONAL 3rd argument int (max distance; only return results with
40 $int distance or less). 0 = unlimited. Default = 0.
41
42 Returns: int that represents the edit distance between the two
43 argument. Stops calculations and returns -1 if max distance is set and
44 reached.
45
46 Wrapper function to take the edit distance between a source and target
47 string using XS algorithm implementation.
48
49 use Text::Levenshtein::Damerau::XS qw/xs_edistance/;
50 print xs_edistance('Neil','Niel');
51 # prints 1
52
53 # Max edit distance of 1
54 print xs_edistance('Neil','Niely',1); # distance is 2
55 # prints -1
56
58 • Handle very large strings of text. Can be accomplished by reworking
59 the scoring matrix or writing to disk.
60
61 • Add from_file methods.
62
63 • Add binary/byte string support.
64
66 • Text::Levenshtein::Damerau
67
68 • Text::Levenshtein::Damerau::PP
69
71 Please report bugs to:
72
73 <https://rt.cpan.org/Public/Dist/Display.html?Name=Text-Levenshtein-Damerau-XS>
74
76 Nick Logan <ugexe@cpan.org>
77
79 This library is free software; you can redistribute it and/or modify it
80 under the same terms as Perl itself.
81
82
83
84perl v5.34.0 2021-07-23 Text::Levenshtein::Damerau::XS(3)