package String::Levenshtein; use 5; use strict; use warnings; use vars qw(@ISA $VERSION @EXPORT_OK); require Exporter; require DynaLoader; @ISA = qw(Exporter DynaLoader); $VERSION = "1.02"; @EXPORT_OK = qw(distance prefix_distance); bootstrap String::Levenshtein $VERSION; 1 __END__ =head1 NAME String::Levenshtein - Compute the Levenshtein distance between two strings =head1 SYNOPSIS use String::Levenshtein qw(distance prefix_distance); $d = distance ("abcd", "abxc") $d = prefix_distance("Smith", "Smithson") =head1 DESCRIPTION String::Levenshtein computes the I between two strings. The Levenshtein distance is defined as the minimum number of characters that must be added, removed, or changed in order to transform one string into another. The Levenshtein distance is also called the I. =head1 FUNCTIONS =over 4 =item I<$d> = C(I<$string1>, I<$string2>) Returns the Levenshtein distance between I<$string1> and I<$string2>. Returns -1 on error. =item I<$d> = C(I<$string1>, I<$string2>) Returns the smallest number of characters that must be added, removed or changed in order to transform the shorter of I<$string1> and I<$string2> into a prefix of the longer. Returns -1 on error. =back =head1 EXAMPLES Levenshtein prefix String1 String2 distance distance 0 0 abc 3 0 xyz 3 0 abc abc 0 0 abc xyz 3 3 abc abd 1 1 gumbo gambol 2 1 aaaa bbbbbbb 7 4 McDougall MacDougal 2 2 Smith Smithson 3 0 Smithson Smith 3 0 =head1 EXPORTS =head2 C<@EXPORT> Nothing =head2 C<@EXPORT_OK> =over 4 =item * distance =item * prefix_distance =back =head1 DIAGNOSTICS C and C return -1 on error. The only error is memory allocation failure. =head1 SEE ALSO =over 4 =item * C =back =head1 AUTHOR Steven McDougall, Eswmcd@world.std.comE =head1 COPYRIGHT Copyright 2002 by Steven McDougall. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.