File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change
1
+ from chatterbot import ChatBot
2
+
3
+ # naming the ChatBot calculator
4
+ # using mathematical evaluation logic
5
+ # the calculator AI will not learn with the user input
6
+ Bot = ChatBot (name = 'Calculator' ,
7
+ read_only = True ,
8
+ logic_adapters = ["chatterbot.logic.MathematicalEvaluation" ],
9
+ storage_adapter = "chatterbot.storage.SQLStorageAdapter" )
10
+
11
+
12
+ # clear the screen and start the calculator
13
+ print ('\033 c' )
14
+ print ("Hello, I am a calculator. How may I help you?" )
15
+ while (True ):
16
+ # take the input from the user
17
+ user_input = input ("me: " )
18
+
19
+ # check if the user has typed quit to exit the prgram
20
+ if user_input .lower () == 'quit' :
21
+ print ("Exiting" )
22
+ break
23
+
24
+ # otherwise, evaluate the user input
25
+ # print invalid input if the AI is unable to comprehend the input
26
+ try :
27
+ response = Bot .get_response (user_input )
28
+ print ("Calculator:" , response )
29
+ except :
30
+ print ("Calculator: Please enter valid input." )
You can’t perform that action at this time.
0 commit comments