-
Notifications
You must be signed in to change notification settings - Fork 0
/
Basic Chatbot.py
63 lines (58 loc) · 1.84 KB
/
Basic 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#Import required libraries
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
# Create a new instance of a ChatBot, my chatbot name is 'Rush'
bot = ChatBot(
'Rush',
storage_adapter='chatterbot.storage.SQLStorageAdapter',
logic_adapters=[
{
'import_path': 'chatterbot.logic.BestMatch',
'default_response': 'I am sorry, but I do not understand.',
'maximum_similarity_threshold': 0.90
}
]
)
trainer = ListTrainer(bot)
# Train the chat bot with a few response
trainer.train(
[
' Hi ',
' Hello ',
' How are you ',
" I'm Good ",
' Is anyone there? ',
' Hi there, how can I help? ',
' What is your name? ',
" I'm Rush, Rushi's bot ",
' Who are you? ',
' My name is Rush ',
' Are you a robot? ',
" Yes I am a robot, but I'm a good one. ",
' Who made you? ',
' Rushi made me ',
' What is the purpose of creating you?',
' Rushi had the job of building a chatbot and he created me.I thank Rushi. ',
' What programming language was used to create you? ',
' Rushi created me using Python ',
' I want to learn how to create chatbots ',
' Great, this should help get you started : https://chatterbot.readthedocs.io/en/stable/ ',
' Thanks ',
' Happy to help! ',
' Thank you ',
' Any time! ',
" That's helpful ",
' My pleasure ',
' Bye ',
' See you later, thanks for visiting ',
' See you later ',
' Have a nice day ',
' Goodbye ',
' Bye! Come back again soon. '
]
)
# Get a response for some unexpected input
while True:
req = input('You :')
response = bot.get_response(req)
print('Bot :',response)