-
Notifications
You must be signed in to change notification settings - Fork 3
/
controller.py
48 lines (46 loc) · 2.04 KB
/
controller.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
from calculator import calculator
from custom_solution import custom_solution
from google_solution import google_solution
#from nlc_module import nlc_module
from db_collection import db_collection
from chatbot_solutions import chatbot_solutions
class controller(object):
def __init__(self):
self.db_mode_flag = False
self.calculation = calculator()
self.custom_sol = custom_solution()
self.google_sol = google_solution()
#self.nlc_mod = nlc_module()
self.collection = db_collection()
self.chatterbot = chatbot_solutions()
def find_solution(self, command):
response = ""
print command
print self.db_mode_flag
if self.db_mode_flag is True:
self.collection.insertCollection(command)
response = "I'll remember that"
self.db_mode_flag = False
else:
if command == "no":
self.db_mode_flag = True
response = "Please enter what you consider a valid response"
else:
response = str(self.chatterbot.chatbot_response(command))
if response != "":
return response
if command.startswith("do"):
response = self.calculation.calculate(command)
else:
response = "CUSTOM SOLUTION :: " +self.custom_sol.doCustom(command) + "\n"
#nlc_response = self.nlc_mod.classify(command)
nlc_response = ""
if nlc_response != "":
response = response + "NLC SOLUTION :: \n" + nlc_response +"\n"
response = response + "Additionally, this might help:\n"
"""for hit in self.google_sol.google_search(command, num=1):
response = response + hit["formattedUrl"]+"\n"+hit["snippet"]+"\n"
"""
if self.db_mode_flag is False and response != "I'll remember that":
response = response + "Are you satisfied with that response?"
return response