Skip Menu |

This queue is for tickets about the Text-Brew CPAN distribution.

Report information
The Basics
Id: 12044
Status: resolved
Priority: 0/
Queue: Text-Brew

People
Owner: keith [...] iveys.org
Requestors: kcivey [...] cpcug.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.01
Fixed in: 0.02



Subject: Erroneous results for initial INS or DEL
The distance and edits are wrong when a DEL or INS is required in the first position of the string. Try distance('ab', 'b') or distance('b', 'ab'). The problem seems to be the setting of $sofar to @{ $d[$i][0] } when what is intended is $d[$i][0][0]. Because of the scalar context, $sofar is currently always being set to 3, the number of elements in the array. I've attached a patch.
--- /usr/lib/perl5/site_perl/5.8.5/Text/Brew.pm 2003-01-12 14:18:16.000000000 -0500 +++ Text/Brew.pm 2005-03-28 21:12:26.422197011 -0500 @@ -69,7 +69,7 @@ foreach my $i (0 .. $m-1) { - my $sofar=@{ $d[$i][0] }; + my $sofar= $d[$i][0][0]; # cost move tb $d[$i+1][0]=[$sofar+$delCost, DEL , $d[$i][0]]; @@ -77,7 +77,7 @@ foreach my $j (0 .. $n-1) { - my $sofar=@{ $d[0][$j] }; + my $sofar= $d[0][$j][0]; # cost move tb $d[0][$j+1]=[$sofar+$insCost, INS , $d[0][$j]];