File size: 1,229 Bytes
9ef3204
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
var tt = {}

tt.removePunc = function(text) {
	return text.replace(/[.,\/#!?$%\^&\*;:{}=\-_`~()]/g,"");
}

tt.hasWords = function(text, wordList) {
	var arr = text.split(" ");
	for (i in wordList) {
		var word = wordList[i];
		if (arr.indexOf(word) !== -1) {
			return true;
		}
	}
	return false;
}

tt.cleanText = function(text) {
	text = text.toLowerCase();
	text = tt.removePunc(text);
	return text;
}

tt.checkFave = function(text) {
	return tt.hasWords(text, ["you", "you're"]) && tt.hasWords(text, ["best", "fav", "fave", "favorite", "awesome", "smart", "great", "wonderful"]);
};

tt.checkThanks = function(text) {
	return tt.hasWords(text, ["thank", "thanks"]);
};

tt.checkParting = function(text) {
	return tt.hasWords(text, ["goodbye", "bye", "byebye"]);
};

tt.checkGreetings = function(text) {
	return tt.hasWords(text, ["hi", "hello", "hey"]);
};

tt.checkAgreement = function(text) {
	return tt.hasWords(text, ["yes", "yep", "okay"]);
};

tt.checkRandomQuestion = function(text) {
	return tt.hasWords(text, ["random", "rand"]) && tt.hasWords(text, ["question", "questions", "definition", "definitions"]);
};

tt.checkLocalResources = function(text) {
	return tt.hasWords(text, ["local"]);
};

module.exports = tt;