forked from KikeVen/simplebot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtwily_classifier.py
57 lines (52 loc) · 1.78 KB
/
twily_classifier.py
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
from textblob.classifiers import NaiveBayesClassifier
def trainer():
train = [
("i am good", "pos"),
("fine thanks", "pos"),
("doing ok", "pos"),
("thank you", "pos"),
("i am crappy", "neg"),
("omg", "neg"),
("wtf", "neg"),
("no thanks", "pos"),
("do you have information on the SDK", "pos"),
("not good", "neg"),
("you are awesome", "pos"),
("i don't know", "neg"),
("ass hole", "neg"),
("fucker", "neg"),
("it didn't answer my question", "neg"),
("screw you", "neg"),
("you rule", "pos"),
("fuck you", "neg"),
("i want to talk to a rep", "neg"),
("give me info on twilio whatsapp", "pos"),
("get me your boss", "neg"),
("help me with", "pos"),
("get me a rep", "neg"),
("you're kind", "pos"),
("what do you know", "neg"),
("i need assistance with", "pos"),
("this is crap", "neg"),
("contact us", "pos"),
("the python helper library", "pos"),
("live help", "neg"),
("tutorial", "pos"),
("no", "neg"),
("twilio api for whatsapp", "pos"),
("twilio autopilot", "pos"),
("what is twilio whatsapp api", "pos"),
("is that so", "neg"),
("you suck", "neg"),
("yes", "pos"),
("this is not working", "neg")
]
return NaiveBayesClassifier(train)
if __name__ == "__main__":
user_input = "Do you have information on the Twilio SDK"
classy = trainer().prob_classify(user_input)
print()
print(f'String: {user_input}')
print(f'---------{len(user_input) * "-"}+')
print(f'Negative probability: {classy.prob("neg")}')
print(f'Positive probability: {classy.prob("pos")}')