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