forked from sitanshunanda/shield
-
Notifications
You must be signed in to change notification settings - Fork 1
/
types.go
47 lines (37 loc) · 1.07 KB
/
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
40
41
42
43
44
45
46
47
package shield
// Tokenizer interface
type Tokenizer interface {
Tokenize(text string) (words map[string]int64)
}
// Set struct
type Set struct {
Class string
Text string
}
// Shield interface
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
// Destroy
Destroy()
}
// Store interface
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
Close() error
}