Thu 1 Aug 15:42:49 CEST 2024
This commit is contained in:
parent
c21c237959
commit
3e6e578a54
13
data.go
13
data.go
|
@ -32,14 +32,19 @@ func computeScore(term string, s string) float64 {
|
||||||
term_splits := strings.Split(term, "/")
|
term_splits := strings.Split(term, "/")
|
||||||
|
|
||||||
score := 1.0 / float64(len(splits))
|
score := 1.0 / float64(len(splits))
|
||||||
for _, term := range term_splits {
|
used := make([]bool, len(term_splits))
|
||||||
for i, c := range splits {
|
for i, term := range term_splits {
|
||||||
|
if used[i] {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
for j, c := range splits {
|
||||||
if len(term) == 0 {
|
if len(term) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if strings.Contains(c, term) {
|
if strings.Contains(c, term) {
|
||||||
score += 1.0/float64(i)
|
used[i] = true
|
||||||
splits = splits[i:]
|
score += 1.0/float64(j)
|
||||||
|
splits = splits[j+1:]
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue