From d86288e36449bb29cc8db9fd954546b72a5d30ee Mon Sep 17 00:00:00 2001 From: ugexe Date: Sun, 13 Jan 2013 21:41:35 -0800 Subject: [PATCH] variable names clarified --- MANIFEST | 15 +++++++++++++++ damerau-int.c | 14 +++++++------- 2 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 MANIFEST diff --git a/MANIFEST b/MANIFEST new file mode 100644 index 0000000..884718e --- /dev/null +++ b/MANIFEST @@ -0,0 +1,15 @@ +Changes +damerau-int.c +examples/benchmark.pl +examples/fuzzy_name_search.pl +lib/Text/Levenshtein/Damerau/XS.pm +LICENSE +Makefile.PL +MANIFEST This list of files +README +t/00_compile.t +t/01_imports.t +t/02_xs_edistance.t +XS.xs +xt/cxs_edistance.t +xt/pod.t diff --git a/damerau-int.c b/damerau-int.c index 9ccf85f..77f1135 100644 --- a/damerau-int.c +++ b/damerau-int.c @@ -71,7 +71,7 @@ static void dict_free(item* head){ static int distance(unsigned int src[],unsigned int tgt[],unsigned int x,unsigned int y,unsigned int maxDistance){ item *head = NULL; unsigned int xy_max = MAX(x,y); - unsigned int db,i1,j1,i,j; + unsigned int swapCount,targetCharCount,prevSwapCount,i,j; unsigned int *scores = malloc( (x + 2) * (y + 2) * sizeof(unsigned int) ); unsigned int score_ceil = x + y; @@ -88,7 +88,7 @@ static int distance(unsigned int src[],unsigned int tgt[],unsigned int x,unsigne scores[(i+1) * (y + 2) + 1] = i; scores[(i+1) * (y + 2) + 0] = score_ceil; - db = 0; + swapCount = 0; for(j=1;j<=y;j++){ if(i == 1) { head = uniquePush(head,tgt[j]); @@ -96,17 +96,17 @@ static int distance(unsigned int src[],unsigned int tgt[],unsigned int x,unsigne scores[0 * (y + 2) + (j + 1)] = score_ceil; } - i1 = find(head,tgt[j-1])->value; - j1 = db; + targetCharCount = find(head,tgt[j-1])->value; + prevSwapCount = swapCount; if(src[i-1] == tgt[j-1]){ scores[(i+1) * (y + 2) + (j + 1)] = scores[i * (y + 2) + j]; - db = j; + swapCount = j; }else{ scores[(i+1) * (y + 2) + (j + 1)] = MIN(scores[i * (y + 2) + j], MIN(scores[(i+1) * (y + 2) + j], scores[i * (y + 2) + (j + 1)])) + 1; } - scores[(i+1) * (y + 2) + (j + 1)] = MIN(scores[(i+1) * (y + 2) + (j + 1)], (scores[i1 * (y + 2) + j1] + i - i1 - 1 + j - j1)); + scores[(i+1) * (y + 2) + (j + 1)] = MIN(scores[(i+1) * (y + 2) + (j + 1)], (scores[targetCharCount * (y + 2) + prevSwapCount] + i - targetCharCount - 1 + j - prevSwapCount)); } /* We will return -1 here if the */ @@ -127,4 +127,4 @@ static int distance(unsigned int src[],unsigned int tgt[],unsigned int x,unsigne free(scores); return score; } -} +} \ No newline at end of file