SONOPANT DANDEKAR SHIKSHAN MANDALI’S
Project Report On
CHATBOT
SUBMITTED BY
Ms.VAISHNAVI HANUMANT THORAT.
66049
UNDER THE GUIDANCE OF
Prof.VAISHALI SHINDEKAR
THIRD YEAR BACHELOR OF SCIENCE
IN
COMPUTER SCIENCE
SEMESTER-VI
MUMBAI UNIVERSITY
2022-2023
SONOPANT DANDEKAR SHIKSHAN MANDALI’S
SONOPANT DANDEKAR ARTS, V.S. APTE
COMMERCE AND M.H. MEHTA SCIENCE COLLEGE,
PALGHAR-401404.
Department of Computer Science.
CERTIFICATE
This is to certify that VAISHNAVI HANUMANT THORAT is a student
studying in TY.BSC.CS SEM VI. She has completed project work entitled
CHATBOT under the guidance of Faculty Member Prof. VAISHALI
SHINDEKAR satisfactorily and has submitted to the University of Mumbai in
partial fulfillment of the requirement during the academic year 2022- 2023. The
matter presented in the project report has not been submitted earlier.
College Stamp
____________________________ ____________________________ ___________________________
H.O.D Project Guide External
INDEX
SR.NO CONTENTS PAGE.NO
1 Acknowledgment 1
2 Project Report 2
3 Introduction 3
4 Requirements 4
5 Installation of python idle 5-8
3.7
6 Objectives 9
7 layout 10-14
8 Coding 15-18
9 Result 19
10 Advantages 20
11 Conclusion 21
12 Future Updates 22
13 References 23
ACKNOWLEDGEMENT
The gratification and joy that accompanies the successful completion of
any task would be incomplete without the humble and deep-felt
expression of gratitude to everyone who has made it possible.
I would like to extend my heartfelt gratitude to RASHMI VARADE
who gave me an opportunity to work under her guidance in this
department.
Further would like to place on record my grateful thanks to friends and
family who spent their valuable time in guiding me in this project,
whose cooperation and encouragement, has immensely helped in the
completion of the project.
I also would like to convey my sincere thanks to Prof. VAISHALI
SHINDEKAR my internal project guide, who has been a constant
source of motivation and inspiration and has helped in bring out the best
in me. I am also thankful to all staff members of computer science
department who as a team have contributed in the successful completion
of this project.
Place: Palghar
Date:
VAISHNAVI HANUMANT THORAT.
Project report of ChatBot
INTRODUCTION
Welcome to our Python-based chatbot project! This chatbot has been designed
to provide you with a personalized and interactive experience. With our chatbot,
you can ask questions, receive helpful tips, and engage in fun conversations.
Our chatbot has been programmed using the Python programming language,
which is a widely-used and powerful language for building applications,
including chatbots. Python's simplicity and versatility make it an ideal choice for
this project.
We have implemented natural language processing (NLP) techniques to enable
the chatbot to understand your messages and respond appropriately. The chatbot
is capable of handling a range of queries and requests, and is constantly learning
and improving its responses based on user interactions.
We hope you find our chatbot to be a useful and enjoyable tool, and we look
forward to hearing your feedback as we continue to develop and improve it.
Let's get chatting!
Requirement:
Hardware Requirement:
PC(4GB RAM)
i3/i5 Processer
500 GB/1TB hard disk
Internet Connection (Wi-Fi).
Software Requirement:
Python IDLE 3.7.4 (64 Bits)
PYCharm IDLE 2022 VERSION
INSTALLATION OF THE PYTHON IDLE 3.7.4
Installation of python involves following steps:
1. Download binaries
2. Run the executable installer
3. Add path of python to environmental variable
Step 1: Download python installer binaries
1. Open official python website in web browser. Navigate the
downloads tab for windows.
2. Choose the latest version of python 3.7.4
3. Click on link to download windows x86-64 executable installer.
For 64-bit system.
Step 2: Run the Executable Installer
1. Once the installer is downloaded, run the python installer.
2. Check the install launcher for all users check box. Further check
the Add python 3.7.4 to path check box to include the interpreter in
the execution path.
3. Select customize installation.
Choose the optional features by checking the following check boxes:
4. Documentation
5. Pip
6. Tcl/tk and IDLE (to install tkinter and IDLE)
7. Python test suite (to install standard library suite of python)
8. Install the global launcher for “.py” files. This makes it easier to
start python.
9. Install for all users.
10. This takes you to Advanced options available while installing
python. Here, select the install for all users and Add python to
environment variables check boxes.
Optionally, we can select the Associate files with python, create
shortcuts for installed applications and other advanced options.
After selecting the advanced options, click on install to start
installation.
11. once the installation is over , we will see a python setup successful
window.
Step 3: Add python to environmental variables
The last step in installation process is to add python path to the system
environment variables. This step is done to access python through the
command line. In case we added python to environment variables while
setting the advance options during the installation procedure, you can
avoid this step. Else, this step is done manually as follows.
In start menu, search for “advance system setting”. Select “view advance
system settings”. In the “system properties” window, click on the
“advanced” tab and then click on the “Environment variables” button.
Locate the python installation directory on system. If we follow the
above steps, python will be installed in below locations:
>C:\Program Files (x86)\python 37-32: for 32-bit installation
>C:\Program Files\python 37-32: for 64-bit installation
The folder name may be different from “python37-32” if we installed a
different version. Look for a folder whose name starts with python.
Step 4: Verify the python Installation
You have successfully installed python 3.7.3 on windows 10. You can
verify if the python installation is successful either through the
command line or through the IDLE app that gets installed along with the
installation.
Search for the command prompt and type “python”. You can see that
python 3.7.3 is successfully installed.
An alternative way to search for “python” is the start menu and clicking
on IDLE (python 3.7 64-bit). You can start coding in python using the
integrated development environment (IDLE).
Now, we are ready to start developing python applications in your
windows 10 system.
OBJECTIVES
The objectives for our Python-based chatbot project are:
1. Provide personalized and interactive experiences for users: Our
chatbot should be able to understand users' messages and provide
responses that are tailored to their individual needs and
preferences.
2. Offer assistance and support: Our chatbot should be capable of
providing users with helpful tips and advice on a variety of topics,
such as troubleshooting common issues, providing product
recommendations, or answering frequently asked questions.
3. Engage users in fun and interesting conversations: Our chatbot
should be able to engage users in conversations that are enjoyable
and entertaining, such as telling jokes, sharing trivia, or playing
games.
4. Continuously learn and improve: Our chatbot should be designed to
learn from user interactions and use that information to improve its
responses over time. It should also be able to adapt to new
information and changing user needs.
5. Provide a seamless user experience: Our chatbot should be easy to
use and navigate, with a clear interface that is intuitive and user-
friendly.
Overall, our objective is to build a chatbot that is both useful and
enjoyable for users, while also leveraging the power and flexibility
of the Python programming language.
FLOWCHART
CODING
CHATBOT
import nltk
from nltk.stem import WordNetLemmatizer
lemmatizer = WordNetLemmatizer()
import pickle
import numpy as np
from keras.models import load_model
model = load_model('chatbot_model.h5')
import json
import random
intents = json.loads(open('intents.json').read())
words = pickle.load(open('words.pkl','rb'))
classes = pickle.load(open('classes.pkl','rb'))
def clean_up_sentence(sentence):
# tokenize the pattern - split words into array
sentence_words = nltk.word_tokenize(sentence)
# stem each word - create short form for word
sentence_words = [lemmatizer.lemmatize(word.lower())
for word in sentence_words]
return sentence_words
# return bag of words array: 0 or 1 for each word in the
bag that exists in the sentence
def bow(sentence, words, show_details=True):
# tokenize the pattern
sentence_words = clean_up_sentence(sentence)
# bag of words - matrix of N words, vocabulary matrix
bag = [0]*len(words)
for s in sentence_words:
for i,w in enumerate(words):
if w == s:
# assign 1 if current word is in the vocabulary
position
bag[i] = 1
if show_details:
print ("found in bag: %s" % w)
return(np.array(bag))
def predict_class(sentence, model):
# filter out predictions below a threshold
p = bow(sentence, words,show_details=False)
res = model.predict(np.array([p]))[0]
ERROR_THRESHOLD = 0.25
results = [[i,r] for i,r in enumerate(res) if
r>ERROR_THRESHOLD]
# sort by strength of probability
results.sort(key=lambda x: x[1], reverse=True)
return_list = []
for r in results:
return_list.append({"intent": classes[r[0]],
"probability": str(r[1])})
return return_list
def getResponse(ints, intents_json):
tag = ints[0]['intent']
list_of_intents = intents_json['intents']
for i in list_of_intents:
if(i['tag']== tag):
result = random.choice(i['responses'])
break
return result
def chatbo
base = Tk()
base.title("Hello")
base.geometry("400x500")
base.resizable(width=FALSE, height=FALSE)
#Create Chat window
ChatLog = Text(base, bd=0, bg="white", height="8",
width="50", font="Arial",)
ChatLog.config(state=DISABLED)
#Bind scrollbar to Chat window
scrollbar = Scrollbar(base, command=ChatLog.yview,
cursor="heart")
ChatLog['yscrollcommand'] = scrollbar.set
#Create Button to send message
SendButton = Button(base, font=("Verdana",12,'bold'),
text="Send", width="12", height=5,
bd=0, bg="#32de97",
activebackground="#3c9d9b",fg='#ffffff',
command= send )
#Create the box to enter message
EntryBox = Text(base, bd=0, bg="white",width="29",
height="5", font="Arial")
#EntryBox.bind("<Return>", send)
#Place all components on the screen
scrollbar.place(x=376,y=6, height=386)
ChatLog.place(x=6,y=6, height=386, width=370)
EntryBox.place(x=128, y=401, height=90, width=265)
SendButton.place(x=6, y=401, height=90)
base.mainloop()t_response(msg):
ints = predict_class(msg, model)
res = getResponse(ints, intents)
return res
#Creating GUI with tkinter
import tkinter
from tkinter import *
def send():
msg = EntryBox.get("1.0",'end-1c').strip()
EntryBox.delete("0.0",END)
if msg != '':
ChatLog.config(state=NORMAL)
ChatLog.insert(END, "You: " + msg + '\n\n')
ChatLog.config(foreground="#442265",
font=("Verdana", 12 ))
res = chatbot_response(msg)
ChatLog.insert(END, "Bot: " + res + '\n\n')
ChatLog.config(state=DISABLED)
ChatLog.yview(END)
base = Tk()
base.title("Hello")
base.geometry("400x500")
base.resizable(width=FALSE, height=FALSE)
#Create Chat window
ChatLog = Text(base, bd=0, bg="white", height="8",
width="50", font="Arial",)
ChatLog.config(state=DISABLED)
#Bind scrollbar to Chat window
scrollbar = Scrollbar(base, command=ChatLog.yview,
cursor="heart")
ChatLog['yscrollcommand'] = scrollbar.set
#Create Button to send message
SendButton = Button(base, font=("Verdana",12,'bold'),
text="Send", width="12", height=5,
bd=0, bg="#32de97",
activebackground="#3c9d9b",fg='#ffffff',
command= send )
#Create the box to enter message
EntryBox = Text(base, bd=0, bg="white",width="29",
height="5", font="Arial")
#EntryBox.bind("<Return>", send)
#Place all components on the screen
scrollbar.place(x=376,y=6, height=386)
ChatLog.place(x=6,y=6, height=386, width=370)
EntryBox.place(x=128, y=401, height=90, width=265)
SendButton.place(x=6, y=401, height=90)
base.mainloop()
RESULT
ADVANTAGES
There are several advantages to developing a chatbot using Python:
1. Ease of use: Python is a simple and intuitive language that is easy to learn, even for beginners. It is also
highly readable and easy to maintain, making it an ideal choice for building chatbots.
2. Versatility: Python is a versatile language that can be used to build a wide range of applications, including
chatbots. It has a large and active community of developers who have created many libraries and
frameworks that can be used to build chatbots quickly and easily.
3. Natural language processing (NLP) capabilities: Python has several powerful libraries for NLP, including
NLTK and SpaCy, which enable chatbots to understand and interpret user input more accurately.
4. Machine learning capabilities: Python has several popular machine learning libraries, such as TensorFlow
and Keras, that can be used to train chatbots to improve their responses over time.
5. Integration with other technologies: Python can be easily integrated with other technologies, such as web
frameworks like Flask and Django, which can be used to build chatbots that can be accessed via web
browsers or mobile devices.
6. Scalability: Python is highly scalable, making it possible to build chatbots that can handle a large volume of
user requests and interactions.
Overall, these advantages make Python an ideal choice for building chatbots that are highly capable, flexible, and
scalable, while also being easy to use and maintain
CONCLUSION
In conclusion, developing a chatbot using Python has many advantages, including ease
of use, versatility, natural language processing capabilities, machine learning
capabilities, integration with other technologies, and scalability. These advantages
enable developers to build chatbots that are highly capable, flexible, and scalable, while
also being easy to use and maintain. With the help of Python, we can create chatbots
that provide personalized and interactive experiences for users, offer assistance and
support, engage users in fun and interesting conversations, continuously learn and
improve, and provide a seamless user experience. Overall, Python-based chatbots have
the potential to revolutionize the way we interact with technology, making it easier and
more enjoyable to get the information and support we need.
Future Updates
There are several future updates that could be implemented to improve our Python-
based chatbot:
1. More advanced NLP capabilities: As NLP technology continues to evolve, we could integrate
more advanced NLP capabilities into our chatbot to improve its ability to understand and
interpret user input.
2. Improved machine learning algorithms: We could also explore new machine learning algorithms
and techniques to improve our chatbot's ability to learn and adapt to changing user needs over
time.
3. Multilingual support: We could add support for multiple languages to enable our chatbot to
communicate with users from different parts of the world.
4. Voice recognition: We could add support for voice recognition technology, which would enable
users to communicate with our chatbot using voice commands.
5. Integration with other platforms: We could integrate our chatbot with other platforms, such as
social media and messaging apps, to make it more accessible and convenient for users.
6. Emotion detection: We could integrate emotion detection capabilities into our chatbot, which
would enable it to detect and respond to users' emotional states.
Overall, these updates would make our chatbot even more capable, flexible, and useful
for users, and would enable us to stay at the forefront of chatbot technology
References:
https://www.google.com
https://www.google.com/search?
q=flowchart+for+chatbot+in+python&rlz=1C1RXQR_enIN1008IN1008&source=l
nms&tbm=isch&sa=X&ved=2ahUKEwjy-M3sw4X-
AhVLSWwGHdgmBh4Q_AUoAXoECAEQAw&biw=1360&bih=600&dpr=1#imgrc
=iHl4cLtBbzAleM