-
Notifications
You must be signed in to change notification settings - Fork 33
/
types.go
39 lines (30 loc) · 984 Bytes
/
types.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
package shield
type Tokenizer interface {
Tokenize(text string) (words map[string]int64)
}
type Set struct {
Class string
Text string
}
type Shield interface {
// Learn learns a single document
Learn(class, text string) (err error)
// BulkLearn learns many documents at once
BulkLearn(sets []Set) (err error)
// Forget forgets the document in the specified class
Forget(class, text string) (err error)
// Score returns the scores for each class normalized from 0 to 1
Score(text string) (scores map[string]float64, err error)
// Classify returns the class with the highest score
Classify(text string) (c string, err error)
// Reset clears the storage
Reset() error
}
type Store interface {
Classes() ([]string, error)
AddClass(class string) error
ClassWordCounts(class string, words []string) (mc map[string]int64, err error)
IncrementClassWordCounts(m map[string]map[string]int64) error
TotalClassWordCounts() (map[string]int64, error)
Reset() error
}