-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchatbot.py
30 lines (25 loc) · 918 Bytes
/
chatbot.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
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.Please ask specific question'
}
],
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