-
Notifications
You must be signed in to change notification settings - Fork 3
/
chatbot_solutions.py
44 lines (38 loc) · 1.25 KB
/
chatbot_solutions.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
from chatterbot import ChatBot
class chatbot_solutions(object):
# Create a new instance of a ChatBot
def __init__(self):
self.bot = ChatBot(
'Chatbot solutions',
storage_adapter='chatterbot.storage.JsonFileStorageAdapter',
logic_adapters=[
{
'import_path': 'chatterbot.logic.BestMatch'
},
{
'import_path': 'chatterbot.logic.LowConfidenceAdapter',
'threshold': 0.65,
'default_response': ''
}
],
trainer='chatterbot.trainers.ListTrainer'
)
# Train the chat bot with a few responses
self.bot.train([
'How are you?',
'I am good.Thankyou.',
'That is good to hear.',
'Thank you',
'You are welcome.',
'Whats your name?',
'I have no name.',
'Where are you?',
'I am in California.',
'Hi',
'Hello',
'Hello',
])
# Get a response for some unexpected input
def chatbot_response(self,sentence):
response = self.bot.get_response(sentence)
return response