Source – zipwip
Now I will show you how you can build your own AI Chatbot using python. Now I will import the necessary libraries we need for this purpose:
#Importing modules
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
from chatterbot.trainers import ChatterBotCorpusTrainer
This chatbot will be based on some bank queries, to move further let’s make instances:
BankBot = ChatBot(name = 'BankBot',
read_only = False,
logic_adapters = ["chatterbot.logic.BestMatch"],
storage_adapter = "chatterbot.storage.SQLStorageAdapter")
Training your chatbot using data is quite simple. To do that you need to instantiate a ChatterBotCorpusTrainer object. It will take the name of your objective as a parameter.
corpus_trainer = ChatterBotCorpusTrainer(BankBot)
corpus_trainer.train("chatterbot.corpus.english")
You can also train a chatterbot on your custom instances. You can see how to do this below:
greet_conversation = [
"Hello",
"Hi there!",
"How are you doing?",
"I'm doing great.",
"That is good to hear",
"Thank you.",
"You're welcome."
]
open_timings_conversation = [
"What time does the Bank open?",
"The Bank opens at 9AM",
]
close_timings_conversation = [
"What time does the Bank close?",
"The Bank closes at 5PM",
]
#chatbot #machine learning #python