Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 76 lines (52 sloc) 2.329 kb
0b99d20 ugexe 1.1
authored
1 NAME
2 Text::Levenshtein::Damerau::XS - XS Damerau Levenshtein edit distance.
3
4 SYNOPSIS
5 use Text::Levenshtein::Damerau::XS qw/xs_edistance/;
6
7 print xs_edistance('Neil','Niel');
8 # prints 1
9
10 DESCRIPTION
11 Returns the true Damerau Levenshtein edit distance of strings with
12 adjacent transpositions. XS implementation (requires a C compiler).
13 Works correctly with utf8.
14
15 use utf8;
16 xs_edistance('ⓕⓞⓤⓡ','ⓕⓤⓞⓡ'),
17 # prints 1
18
19 Speed improvements over Text::Levenshtein::Damerau::PP:
20
d7064a2 ugexe NO_XSLOCKS to fix malloc calls
authored
21 # Text::Levenshtein::Damerau::PP::pp_edistance("four","fuor")
22 timethis 1000000: 381 wallclock secs (380.45 usr + 0.01 sys =
23 380.46 CPU) @ 2628.40/s (n=1000000)
0b99d20 ugexe 1.1
authored
24
d7064a2 ugexe NO_XSLOCKS to fix malloc calls
authored
25 # Text::Levenshtein::Damerau::XS::xs_edistance("four","fuor")
26 timethis 1000000: 19 wallclock secs (19.43 usr + 0.00 sys =
27 19.43 CPU) @ 51466.80/s (n=1000000)
0b99d20 ugexe 1.1
authored
28
29 METHODS
30 xs_edistance
31 Arguments: source string and target string.
32
33 * *OPTIONAL 3rd argument* int (max distance; only return results with
34 $int distance or less). 0 = unlimited. Default = 0.
35
36 Returns: int that represents the edit distance between the two argument.
37 Stops calculations and returns -1 if max distance is set and reached.
38
39 Wrapper function to take the edit distance between a source and target
40 string using XS algorithm implementation.
41
42 use Text::Levenshtein::Damerau::XS qw/xs_edistance/;
43 print xs_edistance('Neil','Niel');
44 # prints 1
45
d7064a2 ugexe NO_XSLOCKS to fix malloc calls
authored
46 # Max edit distance of 1
47 print xs_edistance('Neil','Niely',1); # distance is 2
0b99d20 ugexe 1.1
authored
48 # prints -1
49
d7064a2 ugexe NO_XSLOCKS to fix malloc calls
authored
50 TODO
51 * Handle very large strings of text. Can be accomplished by reworking
52 the scoring matrix or writing to disk.
53
54 * Add from_file methods.
55
56 * Add binary/byte string support.
57
0b99d20 ugexe 1.1
authored
58 SEE ALSO
59 * Text::Levenshtein::Damerau
60
61 * Text::Levenshtein::Damerau::PP
62
63 BUGS
64 Please report bugs to:
65
66 <https://rt.cpan.org/Public/Dist/Display.html?Name=Text-Levenshtein-Dame
67 rau-XS>
68
69 AUTHOR
70 Nick Logan <ug@skunkds.com>
71
72 LICENSE AND COPYRIGHT
73 This library is free software; you can redistribute it and/or modify it
74 under the same terms as Perl itself.
75
Something went wrong with that request. Please try again.