-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathtest.js
85 lines (68 loc) · 4.31 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
AIMLInterpreter = require('./AIMLInterpreter');
var aimlInterpreter = new AIMLInterpreter({name:'WireInterpreter', age:'42'});
aimlInterpreter.loadAIMLFilesIntoArray(['./test.aiml.xml']);
var callback = function(answer, wildCardArray, input){
console.log(answer + ' | ' + wildCardArray + ' | ' + input);
};
var caseCallback = function(answer, wildCardArray, input){
if (answer == this) {
console.log(answer + ' | ' + wildCardArray + ' | ' + input);
} else {
console.log('ERROR:', answer);
console.log(' Expected:', this.toString());
}
};
// Test bot attributes
aimlInterpreter.findAnswerInLoadedAIMLFiles('What is your name?', callback);
// Test setting and getting variable values
aimlInterpreter.findAnswerInLoadedAIMLFiles('My name is Ben.', callback);
aimlInterpreter.findAnswerInLoadedAIMLFiles('What is my name?', callback);
// Test srai tag
aimlInterpreter.findAnswerInLoadedAIMLFiles('Who are you?', callback);
// Test random tag
aimlInterpreter.findAnswerInLoadedAIMLFiles('Give me a letter.', callback);
aimlInterpreter.findAnswerInLoadedAIMLFiles('Test srai in random.', callback);
aimlInterpreter.findAnswerInLoadedAIMLFiles('Test wildcard What is my name?', callback);
aimlInterpreter.findAnswerInLoadedAIMLFiles('Test multiple beautiful wildcards you are', callback);
// Test sr tag
aimlInterpreter.findAnswerInLoadedAIMLFiles('Test sr tag What is my name?', callback);
aimlInterpreter.findAnswerInLoadedAIMLFiles('Test sr in random What is my name?', callback);
// Test star tag
aimlInterpreter.findAnswerInLoadedAIMLFiles('Test the star tag repeat what I said', callback);
// Test that tag
aimlInterpreter.findAnswerInLoadedAIMLFiles('Test the that tag', callback)
aimlInterpreter.findAnswerInLoadedAIMLFiles('Test that-tag. match',callback);
aimlInterpreter.findAnswerInLoadedAIMLFiles('Test that-tag. dont match', callback);
// Test condition tag
aimlInterpreter.findAnswerInLoadedAIMLFiles('What is your feeling today?', callback);
aimlInterpreter.findAnswerInLoadedAIMLFiles('How are you feeling today?', callback);
aimlInterpreter.findAnswerInLoadedAIMLFiles('Tell me about your feelings', callback);
aimlInterpreter.findAnswerInLoadedAIMLFiles("You feel crumpy", callback);
aimlInterpreter.findAnswerInLoadedAIMLFiles('What is your feeling today?', callback);
aimlInterpreter.findAnswerInLoadedAIMLFiles("You feel happy", callback);
aimlInterpreter.findAnswerInLoadedAIMLFiles('How are you feeling today?', callback);
aimlInterpreter.findAnswerInLoadedAIMLFiles('What is your feeling today?', callback);
aimlInterpreter.findAnswerInLoadedAIMLFiles('Tell me about your feelings', callback);
aimlInterpreter.findAnswerInLoadedAIMLFiles("You feel sad", callback);
aimlInterpreter.findAnswerInLoadedAIMLFiles('How are you feeling today?', callback);
aimlInterpreter.findAnswerInLoadedAIMLFiles('What is your feeling today?', callback);
aimlInterpreter.findAnswerInLoadedAIMLFiles('Tell me about your feelings', callback);
// Test wildcards
aimlInterpreter.findAnswerInLoadedAIMLFiles('Explain HANA', callback);
//Test Think tag
aimlInterpreter.findAnswerInLoadedAIMLFiles('I am 123', callback);
aimlInterpreter.findAnswerInLoadedAIMLFiles('How old am I?', callback);
aimlInterpreter.findAnswerInLoadedAIMLFiles('What do you know about me?', callback);
//Test condition and srai
aimlInterpreter.findAnswerInLoadedAIMLFiles('Test condition and srai', callback);
aimlInterpreter.findAnswerInLoadedAIMLFiles("You feel happy", callback);
aimlInterpreter.findAnswerInLoadedAIMLFiles('Test condition and srai', callback);
aimlInterpreter.findAnswerInLoadedAIMLFiles("You feel crumpy", callback);
aimlInterpreter.findAnswerInLoadedAIMLFiles('Test condition and srai', callback);
// Test finding nothing
aimlInterpreter.findAnswerInLoadedAIMLFiles('Test the wildcard pattern!', callback);
// Case insensitive testing
aimlInterpreter.findAnswerInLoadedAIMLFiles('You feel BAD', caseCallback.bind('I feel BAD!'));
aimlInterpreter.findAnswerInLoadedAIMLFiles('You feel good', caseCallback.bind('I feel good!'));
aimlInterpreter.findAnswerInLoadedAIMLFiles('You feel hAPPy', caseCallback.bind('I feel HAPPy!')); // INTENTIONAL ERROR CHECKING
aimlInterpreter.findAnswerInLoadedAIMLFiles('You feel FINEeeeee', caseCallback.bind('I feel FINEEEEEE!')); // INTENTIONAL ERROR CHECKING