We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e4d0dd0 commit 3d64a74Copy full SHA for 3d64a74
README.md
@@ -1,4 +1,4 @@
1
-SIFT4[^1] — Super Fast and Accurate string distance algorithm
+SIFT4 — fast approximate string distance algorithm[^1]
2
3
* zero memory copy
4
* 100% test coverage
sfit4_test.go
@@ -42,12 +42,12 @@ func TestDistance(t *testing.T) {
42
{"abc", "def", 100, 5, 3},
43
{"hello", "helo", 100, 5, 1},
44
{"world", "word", 100, 5, 1},
45
- {"halooooxo", "hbloooogo", 100, 5, 6},
+ {"halooooxo", "hbloooogo", 100, 5, 5},
46
47
// early exit not reached
48
- {"distance", "difference", 100, 5, 6},
49
- {"abcdef", "xyz", 100, 2, 3},
50
- {"abcdefabcdefabcdefabcdefabcdefabcdef", "xyz", 100, 2, 3},
+ {"distance", "difference", 100, 5, 5},
+ {"abcdef", "xyz", 100, 2, 2},
+ {"abcdefabcdefabcdefabcdefabcdefabcdef", "xyz", 100, 2, 2},
51
52
// transposition
53
{"abc", "acb", 100, 5, 1}, // Damerau–Levenshtein distance, transposition of adjacent characters is one operation
sift4.go
@@ -14,7 +14,7 @@ type offset struct {
14
trans bool
15
}
16
17
-// Distance is fast O(N) string distance algorithm.
+// Distance is fast approximate string distance O(N) algorithm.
18
// If pointer to buffer is provided, then it will be reused for storing temporary structures.
19
// - maxOffset is the number of characters to search for matching letters
20
// - 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 {
102
c2++
103
104
if maxDistance > 0 {
105
- if d := max(c1, c2) - lcss + trans; d > maxDistance {
+ if d := max(c1, c2) - lcss + trans; d >= maxDistance {
106
return d
107
108
0 commit comments