test_utils.go 822 B

12345678910111213141516171819202122232425262728293031323334
  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("%s ", indexer.getDocId(indices, i))
  10. }
  11. }
  12. return
  13. }
  14. func indexedDocsToString(docs []types.IndexedDocument, numDocs int) (output string) {
  15. for _, doc := range docs {
  16. output += fmt.Sprintf("[%s %d %v] ", doc.DocId, doc.TokenProximity, doc.TokenSnippetLocations)
  17. }
  18. return
  19. }
  20. func scoredDocsToString(docs []types.ScoredDocument) (output string) {
  21. for _, doc := range docs {
  22. output += fmt.Sprintf("[%s [", doc.DocId)
  23. for _, score := range doc.Scores {
  24. output += fmt.Sprintf("%d ", int(score*1000))
  25. }
  26. output += "]] "
  27. }
  28. return
  29. }