This repository was archived by the owner on Oct 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtest.js
207 lines (183 loc) · 6.09 KB
/
test.js
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
aimlHigh = require('./aiml-high');
var botAttributes = {name:'WireInterpreter', age:'42'};
var interpret = new aimlHigh(botAttributes);
interpret.loadFiles(['./test.aiml.xml']);
var callback = function(answer, wildCardArray, input){
var possibleValues = this;
// Loop through possible values, return if correct
for(var n in possibleValues) {
if (answer == possibleValues[n]) {
console.log('[✔︎] Correct: ', input, ' - Returned: ', answer);
return true;
}
}
// Was incorrect. Not good.
console.log('[X] Incorrect: ', input, '\n', ' - Returned: ', answer);
return false;
};
setTimeout(function() {
// Test bot attributes
interpret.findAnswer('What is your name?', callback.bind([
'My name is '+ botAttributes.name + '.'
]));
// Test setting and getting variable values
interpret.findAnswer('My name is Ben.', callback.bind([
'Hey Ben.!'
]));
interpret.findAnswer('What is my name?', callback.bind([
'Your name is Ben.'
]));
// Test srai tag
interpret.findAnswer('Who are you?', callback.bind([
'My name is '+ botAttributes.name + '.'
]));
// Test random tag
interpret.findAnswer('Give me a letter.', callback.bind([
'A', 'B', 'C'
]));
interpret.findAnswer('Test srai in random.', callback.bind([
'My name is '+ botAttributes.name + '.',
'Your name is Ben.'
]));
interpret.findAnswer('Test wildcard What is my name?', callback.bind([
'Thanks for testing!'
]));
// Test sr tag
interpret.findAnswer('Test sr tag', callback.bind([
'Your name is Ben.'
]));
interpret.findAnswer('Test sr in random', callback.bind([
'My name is '+ botAttributes.name + '.',
'Your name is Ben.'
]));
// Test star tag
interpret.findAnswer('Test the star tag', callback.bind([
'What is my name'
]));
// Test that tag
interpret.findAnswer('Test the that tag', callback.bind([
'I start testing that.'
]))
interpret.findAnswer('Test that-tag. match',callback.bind([
'That matched quite well!'
]));
interpret.findAnswer('Test that-tag. dont match', callback.bind([
undefined
]));
// Test condition tag
interpret.findAnswer('What is your feeling today?', callback.bind([
'I don\'t feel anything'
]));
interpret.findAnswer('How are you feeling today?', callback.bind([
undefined
]));
interpret.findAnswer('Tell me about your feelings', callback.bind([
'I kinda feel nothing My name is ' + botAttributes.name + '.'
]));
interpret.findAnswer("You feel crumpy", callback.bind([
'I feel crumpy!'
]));
interpret.findAnswer('What is your feeling today?', callback.bind([
'I don\'t feel anything'
]));
interpret.findAnswer("You feel happy", callback.bind([
'I feel happy!'
]));
interpret.findAnswer('How are you feeling today?', callback.bind([
'I am happy!'
]));
interpret.findAnswer('What is your feeling today?', callback.bind([
'Feeling happy!'
]));
interpret.findAnswer('Tell me about your feelings', callback.bind([
'I am happy!'
]));
interpret.findAnswer("You feel sad", callback.bind([
'I feel sad!'
]));
interpret.findAnswer('How are you feeling today?', callback.bind([
'I am sad!'
]));
interpret.findAnswer('What is your feeling today?', callback.bind([
'Feeling sad today'
]));
interpret.findAnswer('Tell me about your feelings', callback.bind([
'I am sad!'
]));
// Test wildcards
interpret.findAnswer('Explain HANA', callback.bind([
'Sorry, I do not have a clue'
]));
//Test Think tag
interpret.findAnswer('I am 123', callback.bind([
'Text before random Text after random'
]));
interpret.findAnswer('How old am I?', callback.bind([
'You are 22',
'You are 123'
]));
interpret.findAnswer('What do you know about me?', callback.bind([
'Your name is Ben. and you are 22',
'Your name is Ben. and you are 123',
]));
//Test condition and srai
interpret.findAnswer('Test condition and srai', callback.bind([
'Feeling sad today Your name is Ben.'
]));
interpret.findAnswer("You feel happy", callback.bind([
'I feel happy!'
]));
interpret.findAnswer('Test condition and srai', callback.bind([
'Feeling happy! My name is ' + botAttributes.name + '.'
]));
interpret.findAnswer("You feel crumpy", callback.bind([
'I feel crumpy!'
]));
interpret.findAnswer('Test condition and srai', callback.bind([
'I don\'t feel anything You are 22',
'I don\'t feel anything You are 123',
]));
// Test finding nothing
interpret.findAnswer('Test the wildcard pattern!', callback.bind([
'I found nothing.'
]));
// Case formatting
interpret.findAnswer('Do uppercase Greg Leuch', callback.bind([
'Hello GREG LEUCH'
]));
interpret.findAnswer('Do lowercase Greg Leuch', callback.bind([
'Hello greg leuch'
]));
interpret.findAnswer('Do formal case greg leuch', callback.bind([
'Hello Greg Leuch'
]));
interpret.findAnswer('Do sentence greg the botmaster', callback.bind([
'Greg the botmaster is the best.'
]));
// Allow non-formal tags
interpret.findAnswer("I like GIFs", callback.bind([
'GIF this: <img src="GIF"/>'
]));
// Allow non-formal tags
interpret.findAnswer("Support BR tags", callback.bind([
'This\nis\na\nbot.'
]));
// Case insensitive testing
interpret.findAnswer('You feel BAD', callback.bind([
'I feel BAD!'
]));
interpret.findAnswer('You feel good', callback.bind([
'I feel good!'
]));
interpret.findAnswer('You feel g332-sdfds__#ood', callback.bind([
undefined
]));
interpret.findAnswer('My name is nwbjks,-_??@$#mdnmdf', callback.bind([
undefined
]));
interpret.findAnswer('My name is nwbjks-mdnmdf', callback.bind([
'Hey nwbjks-mdnmdf!'
]));
// interpret.findAnswer('You feel hAPPy', callback.bind('I feel HAPPy!')); // INTENTIONAL ERROR CHECKING
// interpret.findAnswer('You feel FINEeeeee', callback.bind('I feel FINEEEEEE!')); // INTENTIONAL ERROR CHECKING
}, 1000);