-
Notifications
You must be signed in to change notification settings - Fork 5
/
similarity.go
36 lines (28 loc) · 930 Bytes
/
similarity.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
35
36
// Similarity definition
package txtai
// Similarity definition
type SimilarityAPI struct {
api API
}
// Creates a Similarity instance.
func Similarity(params ...string) SimilarityAPI {
return SimilarityAPI{NewAPI(params...)}
}
// Computes the similarity between query and list of text.
func (similarity *SimilarityAPI) Similarity(query string, texts []string) []IndexResult {
var results []IndexResult
similarity.api.Post("similarity", map[string]interface{}{
"query": query,
"texts": texts,
}, &results)
return results
}
// Computes the similarity between list of queries and list of text.
func (similarity *SimilarityAPI) BatchSimilarity(queries []string, texts []string) [][]IndexResult {
var results [][]IndexResult
similarity.api.Post("batchsimilarity", map[string]interface{}{
"queries": queries,
"texts": texts,
}, &results)
return results
}