-
Notifications
You must be signed in to change notification settings - Fork 5
/
summary.go
56 lines (43 loc) · 1.16 KB
/
summary.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Summary definition
package txtai
import (
"strconv"
)
// Summary definition
type SummaryAPI struct {
api API
}
// Creates a Summary instance.
func Summary(params ...string) SummaryAPI {
return SummaryAPI{NewAPI(params...)}
}
// Runs a summarization model against a block of text.
func (summary *SummaryAPI) Summary(text string, minlength int, maxlength int) string {
var results string
params := map[string]string {
"text": text,
}
if minlength != -1 {
params["minlength"] = strconv.Itoa(minlength)
}
if maxlength != -1 {
params["maxlength"] = strconv.Itoa(maxlength)
}
summary.api.Get("summary", params, &results)
return results
}
// Runs a summarization model against a block of text.
func (summary *SummaryAPI) BatchSummary(texts []string, minlength int, maxlength int) []string {
var results []string
params := map[string]interface{} {
"texts": texts,
}
if minlength != -1 {
params["minlength"] = minlength
}
if maxlength != -1 {
params["maxlength"] = maxlength
}
summary.api.Post("batchsummary", params, &results)
return results
}