-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathentities.go
47 lines (39 loc) · 1.19 KB
/
entities.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 gowit
// Entity represents an entity of Wit.AI
type Entity struct {
ID string `json:"id"` // ID or name of the requested entity
Name string `json:"name,omitempty"`
Doc string `json:"doc"` // Short sentence describing this entity
Lang string `json:"lang,omitempty"`
BuiltIn bool `json:"builtin,omitempty"`
Values []Value `json:"values,omitempty"` // Possible values for this entity
Lookups []string `json:"-"`
}
func (e *Entity) AddValue(v Value) {
e.Values = append(e.Values, v)
}
func (e *Entity) AddValues(vs []Value) {
e.Values = append(e.Values, vs...)
}
func (e *Entity) DeleteValue(v Value) error {
return deleteValue(e, &v)
}
func (e *Entity) DeleteAllValues() error {
for _, v := range e.Values {
if err := e.DeleteValue(v); err != nil {
return err
}
}
return nil
}
// Value represents a value within an entity
type Value struct {
Name string `json:"value"`
Expressions []string `json:"expressions"`
}
func (v *Value) AddExpression(expression string) {
v.Expressions = append(v.Expressions, expression)
}
func (v *Value) AddExpressions(expressions []string) {
v.Expressions = append(v.Expressions, expressions...)
}