Skip to content

Commit 899e5a0

Browse files
authored
Merge pull request #80 from comroid-git/master
Fix PartialRatio issue
2 parents 4783229 + ce6a497 commit 899e5a0

2 files changed

Lines changed: 22 additions & 12 deletions

File tree

diffutils/src/me/xdrop/diffutils/DiffUtils.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,18 @@ private static EditOp[] editOpsFromCostMatrix(int len1, char[] c1, int p1, int o
127127

128128
while (i > 0 || j > 0) {
129129

130+
if (i != 0 && j != 0 && matrix[ptr] == matrix[ptr - len2 - 1]
131+
&& c1[p1 + i - 1] == c2[p2 + j - 1]) {
132+
133+
i--;
134+
j--;
135+
ptr -= len2 + 1;
136+
dir = 0;
137+
138+
continue;
139+
140+
}
141+
130142
if (dir < 0 && j != 0 && matrix[ptr] == matrix[ptr - 1] + 1) {
131143

132144
EditOp eop = new EditOp();
@@ -156,18 +168,6 @@ private static EditOp[] editOpsFromCostMatrix(int len1, char[] c1, int p1, int o
156168

157169
}
158170

159-
if (i != 0 && j != 0 && matrix[ptr] == matrix[ptr - len2 - 1]
160-
&& c1[p1 + i - 1] == c2[p2 + j - 1]) {
161-
162-
i--;
163-
j--;
164-
ptr -= len2 + 1;
165-
dir = 0;
166-
167-
continue;
168-
169-
}
170-
171171
if (i != 0 && j != 0 && matrix[ptr] == matrix[ptr - len2 - 1] + 1) {
172172

173173
pos--;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package me.xdrop.fuzzywuzzy
2+
3+
class BugfixTest extends GroovyTestCase {
4+
void testIssue39() {
5+
int score = FuzzySearch.partialRatio("kaution",
6+
"kdeffxxxiban:de1110010060046666666datum:16.11.17zeit:01:12uft0000899999tan076601testd.-20-maisonette-z4-jobas-hagkautionauszug")
7+
8+
assert score == 100
9+
}
10+
}

0 commit comments

Comments
 (0)