forked from huichen/wukong
-
Notifications
You must be signed in to change notification settings - Fork 10
/
test_utils.go
34 lines (30 loc) · 825 Bytes
/
test_utils.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package core
import (
"fmt"
"github.com/huichen/wukong/types"
)
func indicesToString(indexer *Indexer, token string) (output string) {
indices := indexer.InvertedIndexShard.InvertedIndex[token]
for i := 0; i < indexer.getIndexLength(indices); i++ {
output += fmt.Sprintf("%d ",
indexer.getDocId(indices, i))
}
return
}
func indexedDocsToString(docs []types.IndexedDocument, numDocs int) (output string) {
for _, doc := range docs {
output += fmt.Sprintf("[%d %d %v] ",
doc.DocId, doc.TokenProximity, doc.TokenSnippetLocations)
}
return
}
func scoredDocsToString(docs []types.ScoredDocument) (output string) {
for _, doc := range docs {
output += fmt.Sprintf("[%d [", doc.DocId)
for _, score := range doc.Scores {
output += fmt.Sprintf("%d ", int(score*1000))
}
output += "]] "
}
return
}