-
Notifications
You must be signed in to change notification settings - Fork 2
/
matcher_utils.go
119 lines (99 loc) · 2.53 KB
/
matcher_utils.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package neocortex
func (m *Matcher) And(and *Matcher) *Matcher {
m.AND = and
return m
}
func (m *Matcher) Or(or *Matcher) *Matcher {
m.OR = or
return m
}
func IntentIs(intent string, confidence ...float64) *Matcher {
conf := 0.0
if len(confidence) > 0 {
conf = confidence[0]
}
return &Matcher{
Intent: Match{
Is: intent,
Confidence: conf,
},
}
}
func (m *Matcher) AndIntentIs(intent string, confidence ...float64) *Matcher {
return m.And(IntentIs(intent, confidence...))
}
func (m *Matcher) OrIntentIs(intent string, confidence ...float64) *Matcher {
return m.Or(IntentIs(intent, confidence...))
}
func IfEntityIs(entity string, confidence ...float64) *Matcher {
conf := 0.0
if len(confidence) > 0 {
conf = confidence[0]
}
return &Matcher{
Entity: Match{
Is: entity,
Confidence: conf,
},
}
}
func (m *Matcher) AndEntityIs(entity string, confidence ...float64) *Matcher {
return m.And(IfEntityIs(entity, confidence...))
}
func (m *Matcher) OrEntityIs(entity string, confidence ...float64) *Matcher {
return m.Or(IfEntityIs(entity, confidence...))
}
func IfContextVariableIs(name string, value interface{}) *Matcher {
return &Matcher{
ContextVariable: CMatch{
Name: name,
Value: value,
},
}
}
func (m *Matcher) AndIfContextVariableIs(name string, value interface{}) *Matcher {
return m.And(IfContextVariableIs(name, value))
}
func (m *Matcher) OrIfContextVariableIs(name string, value interface{}) *Matcher {
return m.Or(IfContextVariableIs(name, value))
}
func IfDialogNodeTitleIs(title string) *Matcher {
return &Matcher{
DialogNode: DialogNodeMatch{
Title: title,
},
}
}
func (m *Matcher) AndIfDialogNodeTitleIs(title string) *Matcher {
return m.And(IfDialogNodeTitleIs(title))
}
func (m *Matcher) OrIfDialogNodeTitleIs(title string) *Matcher {
return m.Or(IfDialogNodeTitleIs(title))
}
func IfDialogNodeNameIs(name string) *Matcher {
return &Matcher{
DialogNode: DialogNodeMatch{
Name: name,
},
}
}
func (m *Matcher) AndIfDialogNodeNameIs(name string) *Matcher {
return m.And(IfDialogNodeNameIs(name))
}
func (m *Matcher) OrIfDialogNodeNameIs(name string) *Matcher {
return m.Or(IfDialogNodeNameIs(name))
}
func IfDialogNodeIs(title, name string) *Matcher {
return &Matcher{
DialogNode: DialogNodeMatch{
Title: title,
Name: name,
},
}
}
func (m *Matcher) AndIfDialogNodeIs(title, name string) *Matcher {
return m.And(IfDialogNodeIs(title, name))
}
func (m *Matcher) OrIfDialogNodeIs(title, name string) *Matcher {
return m.Or(IfDialogNodeIs(title, name))
}