Skip to content

Commit 3d64a74

Browse files
committed
nit
1 parent e4d0dd0 commit 3d64a74

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
SIFT4[^1]Super Fast and Accurate string distance algorithm
1+
SIFT4 — fast approximate string distance algorithm[^1]
22

33
* zero memory copy
44
* 100% test coverage

sfit4_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ func TestDistance(t *testing.T) {
4242
{"abc", "def", 100, 5, 3},
4343
{"hello", "helo", 100, 5, 1},
4444
{"world", "word", 100, 5, 1},
45-
{"halooooxo", "hbloooogo", 100, 5, 6},
45+
{"halooooxo", "hbloooogo", 100, 5, 5},
4646

4747
// early exit not reached
48-
{"distance", "difference", 100, 5, 6},
49-
{"abcdef", "xyz", 100, 2, 3},
50-
{"abcdefabcdefabcdefabcdefabcdefabcdef", "xyz", 100, 2, 3},
48+
{"distance", "difference", 100, 5, 5},
49+
{"abcdef", "xyz", 100, 2, 2},
50+
{"abcdefabcdefabcdefabcdefabcdefabcdef", "xyz", 100, 2, 2},
5151

5252
// transposition
5353
{"abc", "acb", 100, 5, 1}, // Damerau–Levenshtein distance, transposition of adjacent characters is one operation

sift4.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type offset struct {
1414
trans bool
1515
}
1616

17-
// Distance is fast O(N) string distance algorithm.
17+
// Distance is fast approximate string distance O(N) algorithm.
1818
// If pointer to buffer is provided, then it will be reused for storing temporary structures.
1919
// - maxOffset is the number of characters to search for matching letters
2020
// - maxDistance is the distance at which the algorithm should stop computing the value and just exit (the strings are too different anyway)
@@ -102,7 +102,7 @@ func Distance(s1, s2 string, maxOffset, maxDistance int, buffer *Buffer) int {
102102
c2++
103103

104104
if maxDistance > 0 {
105-
if d := max(c1, c2) - lcss + trans; d > maxDistance {
105+
if d := max(c1, c2) - lcss + trans; d >= maxDistance {
106106
return d
107107
}
108108
}

0 commit comments

Comments
 (0)