Text-LevenshteinXS-0.03/0040755000076500007650000000000010070361207013617 5ustar joshjoshText-LevenshteinXS-0.03/Changes0100644000076500007650000000055510070361114015111 0ustar joshjoshRevision history for Perl extension Text::LevenshteinXS. 0.03 Tue Jun 29 14:42:00 2004 - move variable declaration to fix SGI compile error. 0.02 Sat Mar 06 10:54:00 2004 - short circuits added for special cases to increase speed. 0.01 Wed Mar 26 10:23:49 2003 - original version; created by h2xs 1.21 with options -n Text::LevenshteinXS Text-LevenshteinXS-0.03/LevenshteinXS.pm0100644000076500007650000000323210070361044016710 0ustar joshjoshpackage Text::LevenshteinXS; use strict; use warnings; use Carp; require Exporter; require DynaLoader; use AutoLoader; our @ISA = qw(Exporter DynaLoader); our %EXPORT_TAGS = ( 'all' => [ qw( ) ] ); our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); our @EXPORT = qw( distance ); our $VERSION = '0.03'; bootstrap Text::LevenshteinXS $VERSION; 1; __END__ =head1 NAME Text::LevenshteinXS - An XS implementation of the Levenshtein edit distance =head1 SYNOPSIS use Text::LevenshteinXS qw(distance); print distance("foo","four"); # prints "2" print distance("foo","bar"); # prints "3" =head1 DESCRIPTION This module implements the Levenshtein edit distance in a XS way. The Levenshtein edit distance is a measure of the degree of proximity between two strings. This distance is the number of substitutions, deletions or insertions ("edits") needed to transform one string into the other one (and vice versa). When two strings have distance 0, they are the same. A good point to start is: =head1 CREDITS All the credits go to Vladimir Levenshtein the author of the algorithm and to Lorenzo Seidenari who made the C implementation =head1 SEE ALSO Text::Levenshtein , Text::WagnerFischer , Text::Brew , String::Approx =head1 AUTHOR Copyright 2003 Dree Mistrut > Modifications Copyright 2004 Josh Goldberg > This package is free software and is provided "as is" without express or implied warranty. You can redistribute it and/or modify it under the same terms as Perl itself. =cut Text-LevenshteinXS-0.03/LevenshteinXS.xs0100644000076500007650000000276410070360737016747 0ustar joshjosh#include "EXTERN.h" #include "perl.h" #include "XSUB.h" /****************************************************/ /* Levenshtein Distance Algorithm */ /* C Implementation by Lorenzo Seidenari */ /* http://www.merriampark.com/ldc.htm */ /* modified by dree */ /****************************************************/ #include #include int levenshtein_distance(char *s,char*t); int minimum(int a,int b,int c); int levenshtein_distance(char *s,char*t) /*Compute levenshtein distance between s and t*/ { //Step 1 int k,i,j,n,m,cost,*d,distance; if (strcmp(s,t) == 0) {return 0;} n=strlen(s); m=strlen(t); if(n==0) {return m;} if(m==0) {return n;} d=malloc((sizeof(int))*(m+1)*(n+1)); m++; n++; //Step 2 for(k=0;k 'Text::LevenshteinXS', 'VERSION_FROM' => 'LevenshteinXS.pm', 'PREREQ_PM' => { Test }, ($] >= 5.005 ? () : ( ABSTRACT_FROM => 'LevenshteinXS.pm', AUTHOR => 'Dree Mistrut and Josh Goldberg ' )), ); Text-LevenshteinXS-0.03/MANIFEST0100644000076500007650000000024410022431745014747 0ustar joshjoshChanges LevenshteinXS.pm LevenshteinXS.xs Makefile.PL MANIFEST README test.pl META.yml Module meta-data (added by MakeMaker) Text-LevenshteinXS-0.03/META.yml0100644000076500007650000000053310070361207015066 0ustar joshjosh# http://module-build.sourceforge.net/META-spec.html #XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# name: Text-LevenshteinXS version: 0.03 version_from: LevenshteinXS.pm installdirs: site requires: Test: distribution_type: module generated_by: ExtUtils::MakeMaker version 6.17 Text-LevenshteinXS-0.03/README0100644000076500007650000000262110021760757014506 0ustar joshjosh Text::LevenshteinXS is an XS implementation of the Levenshtein edit distance in Perl. A good point to start is: See also Text::Levenshtein on CPAN for a pure Perl version of this module. PREREQUISITES This suite requires Perl 5; I tested it only under Perl 5.6. Text::LevenshteinXS requires the Test module. A C compiler. INSTALLATION You install Text::LevenshteinXS by running these commands in the *nix environment: perl Makefile.PL make make test (optional) make install To install Text::LevenshteinXS in the Win32 environment, use nmake instead of make. nmake is available for free (in a self extracting executable): After download and inflate, put nmake.exe and nmake.err in c:\windows\command . You need also a C compiler (e.g. Visual C++). DOCUMENTATION POD format documentation is included in LevenshteinXS.pm. POD is readable with the command: perldoc Text::LevenshteinXS AVAILABILITY The latest version of Text::LevenshteinXS is available from the CPAN COPYRIGHT Copyright 2003 Dree Mistrut This package is free software and is provided "as is" without express or implied warranty. You can redistribute it and/or modify it under the same terms as Perl itself. Text-LevenshteinXS-0.03/test.pl0100644000076500007650000000056410021760757015146 0ustar joshjoshuse Test; BEGIN { plan tests => 6 }; use Text::LevenshteinXS qw(distance); ok(1); if (distance("foo","four") == 2) {ok(1)} else {ok(0)} if (distance("foo","foo") == 0) {ok(1)} else {ok(0)} if (distance("foo","") == 3) {ok(1)} else {ok(0)} if (distance("four","foo") == 2) {ok(1)} else {ok(0)} if (distance("foo","bar") == 3) {ok(1)} else {ok(0)}