-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathchatbot.py
More file actions
27 lines (25 loc) · 998 Bytes
/
chatbot.py
File metadata and controls
27 lines (25 loc) · 998 Bytes
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
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
def get_response(usrText):
bot = ChatBot('Bot',
storage_adapter='chatterbot.storage.SQLStorageAdapter',
logic_adapters=[
{
'import_path': 'chatterbot.logic.BestMatch'
},
{
'import_path': 'chatterbot.logic.LowConfidenceAdapter',
'threshold': 0.70,
'default_response': 'I am sorry, but I do not understand.'
}
],
trainer='chatterbot.trainers.ListTrainer')
bot.set_trainer(ListTrainer)
while True:
if usrText.strip() != 'Bye':
result = bot.get_response(usrText)
reply = str(result)
return(reply)
if usrText.strip() == 'Bye':
return('Bye')
break