Introduction:
* Here we are creating a simple chatbot using python.
* We won't require 1000 lines of code to create a chatbot but just a six-letter word 'Python' is enough to create it. Here we are using the Python's ChatterBot library to create our chatbot.
* ChatterBot is a Python library that makes it easy to generate automated responses to a user's input.
* ChatterBot uses a selection of machine learning algorithms to produce different types of responses.
* This makes it easy for developers to create chatbots and automate conversations with users.
Installation:
* You can install ChatterBot on your system using pip command.
pip install ChatterBot
Below is the implementaion for the chatbot:
# importing our chatterbot libraries
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
from chatterbot.trainers import ChatterBotCorpusTrainer
# creating instance(object) for our ChatBot and naming our ChatBot as 'Tom'.
my_chatbot = ChatBot('Tom')
# opening the traning data for our ChatBot from the file
# using open function and storing it in identifier named as 'training_data_for_mybot'.
training_data_for_mybot = open('training_data_for_mychatbot/Ques and Anes.txt') . read() . splitlines()
# training the ChatBot using our personal data from the file
trainer = ListTrainer(my_chatbot)
trainer . train(training_data_for_mybot)
# training the ChatBot with english corpus data
trainer = ChatterBotCorpusTrainer(my_chatbot)
trainer . train('chatterbot.corpus.english')
while True:
# input function is used to get the input from the user
user_request = input('you - ')
# get_response() returns the responses for the user_request
bot_response = my_chatbot . get_response(user_request)
print('Tom - ' , bot_response)
Output:
- The Full Source Code is available on our github site.
Click here -- github
***********************************************************************************
1 Comments
Great and really helpful article! Adding to the conversation, providing more information, or expressing a new point of view...Nice information and updates. Really i like it and everyday am visiting your site..
ReplyDeleteChatbot Companies
AI Chatbot Development
Chatbot Companies in Dubai
Chatbot Company
Chatbot Development Companies
Chatbot Dubai