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<Levenshtein distance> 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<edit distance>.


=head1 FUNCTIONS

=over 4

=item I<$d> = C<distance>(I<$string1>, I<$string2>)

Returns the Levenshtein distance between I<$string1> and I<$string2>.

Returns -1 on error.

=item I<$d> = C<prefix_distance>(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
    <empty>   <empty> 	   0  	       0
    abc       <empty> 	   3  	       0
    <empty>   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<distance> and C<prefix_distance> return -1 on error.
The only error is memory allocation failure.


=head1 SEE ALSO

=over 4

=item *

C<String::Approx>

=back


=head1 AUTHOR

Steven McDougall, E<lt>swmcd@world.std.comE<gt>


=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.
