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, "/")
|
||||
|
||||
score := 1.0 / float64(len(splits))
|
||||
for _, term := range term_splits {
|
||||
for i, c := range splits {
|
||||
used := make([]bool, len(term_splits))
|
||||
for i, term := range term_splits {
|
||||
if used[i] {
|
||||
continue
|
||||
}
|
||||
for j, c := range splits {
|
||||
if len(term) == 0 {
|
||||
continue
|
||||
}
|
||||
if strings.Contains(c, term) {
|
||||
score += 1.0/float64(i)
|
||||
splits = splits[i:]
|
||||
used[i] = true
|
||||
score += 1.0/float64(j)
|
||||
splits = splits[j+1:]
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue