summaryrefslogtreecommitdiff
path: root/internal/levenshtein
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2024-05-27 15:02:59 +0200
committerJeroen Wijenbergh <46386452+jwijenbergh@users.noreply.github.com>2024-05-29 14:36:10 +0200
commitb69a84b33c88f716f15410681c9b483082404033 (patch)
tree0e6cc83e6a59029ae0afcc18ca92e9d7185759a2 /internal/levenshtein
parent115979c2280210fb118357dabe5d7a2f24edbc50 (diff)
levenshtein: Add some comments
Diffstat (limited to 'internal/levenshtein')
-rw-r--r--internal/levenshtein/levenshtein.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/internal/levenshtein/levenshtein.go b/internal/levenshtein/levenshtein.go
index 631161e..cf28607 100644
--- a/internal/levenshtein/levenshtein.go
+++ b/internal/levenshtein/levenshtein.go
@@ -34,12 +34,14 @@ func levenshtein(os, ot string) int {
v0[i] = i
}
+ // loop through every word in the first string
for i := 0; i < n; i++ {
v1[0] = i + 1
for j := 0; j < m; j++ {
// calculate deletion cost,
// insertion cost and
- // substitution cost
+ // substitution cost to get from the string
+ // to the target
dc := v0[j+1] + 1
ic := v1[j] + 1
var sc int
@@ -71,6 +73,7 @@ func adjusted(substr, full string) int {
}
// KeywordPenalty is the penalty for matching on keywords instead of display names
+// We have a penalty for matching on keywords because currently there are a lot of generic keywords
const KeywordPenalty = 2
// DiscoveryScore computes the score of a discovery entry with the given search query