test_utils.go 828 B

1234567891011121314151617181920212223242526272829303132333435
  1. package core
  2. import (
  3. "fmt"
  4. "github.com/huichen/wukong/types"
  5. )
  6. func indicesToString(indexer *Indexer, token string) (output string) {
  7. if indices, ok := indexer.tableLock.table[token]; ok {
  8. for i := 0; i < indexer.getIndexLength(indices); i++ {
  9. output += fmt.Sprintf("%d ",
  10. indexer.getDocId(indices, i))
  11. }
  12. }
  13. return
  14. }
  15. func indexedDocsToString(docs []types.IndexedDocument, numDocs int) (output string) {
  16. for _, doc := range docs {
  17. output += fmt.Sprintf("[%d %d %v] ",
  18. doc.DocId, doc.TokenProximity, doc.TokenSnippetLocations)
  19. }
  20. return
  21. }
  22. func scoredDocsToString(docs []types.ScoredDocument) (output string) {
  23. for _, doc := range docs {
  24. output += fmt.Sprintf("[%d [", doc.DocId)
  25. for _, score := range doc.Scores {
  26. output += fmt.Sprintf("%d ", int(score*1000))
  27. }
  28. output += "]] "
  29. }
  30. return
  31. }