#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