Smart College Enquiry Chatbot Using Deep Learning Algorithm
Smart College Enquiry Chatbot Using Deep Learning Algorithm
Submitted by
SANTHIPRIYA D 420620104013
SINDHUJA P 420620104014
SARANYA P 420620104324
BACHELOR OF ENGINEERING
In
BONAFIDE CERTIFICATE
supervision.
SIGNATURE SIGNATURE
BONAFIDE CERTIFICATE
supervision.
SIGNATURE SIGNATURE
BONAFIDE CERTIFICATE
supervision.
SIGNATURE SIGNATURE
BONAFIDE CERTIFICATE
supervision.
SIGNATURE SIGNATURE
i
TABLE OF CONTENTS
ii
4.2 Software Requirements 14
5 SYSTEM DESIGN
5.1 System Architecture 16
5.2 Data Flow Diagram 17
5.3 Uml Diagrams 19
5.4 Goals 19
5.5 Use Case Diagram 20
5.6 Class Diagram 21
5.7 Sequence Diagram 22
5.8 Activity Diagram 23
6 MODULE DESCRIPTION
6.1 List of Modules 25
6.2 Modules Description 25
6.2.1 Admin Login 25
6.2.2 Add Query And Dataset 25
6.2.3 User Login 25
6.2.4 Asking Querie 26
6.2.5 Providing Feedback 36
7 SYSTEM TESTING
7.1 Types Of Tests 28
7.1.1 Unit Testing 28
7.1.2 Integration Testing 28
7.1.3 Functional Test 29
7.1.4 System Test 29
iii
7.1.5 White Box Testing 30
7.1.6 Black Box Testing 30
7.1.7 Unit Testing 30
7.1.8 Test Strategy And Approach 30
7.1.9 Test Objectives 31
7.1.10 Features To Be Tested 31
7.2 Integration Testing 31
7.3 Acceptance Testing 32
8 APPLICATION AREAS
8.Application Areas 33
9 SYSTEM STUDY
9.1 Feasibility Study 35
9.1.1 Economical Feasibility 35
9.1.2 Technical Feasibility 35
9.1.3 Social Feasibility 36
10 CONCLUSION & FUTURE
ENCHANCEMENT
10.1 Conclusion 38
10.2 Future Enhancements 38
APPENDIX
A1. Software Environment 40
A2. Sample Code 54
A3.Screen Shots 69
REFERENCES 74
iv
LIST OF FIGURES
v
LIST OF ABBREVATIONS
vi
CHAPTER – 1
INTRODUCTION
1
1. INTRODUCTION
1.1. GENERAL
2
non-linearly. This conclusion was reached after a thorough investigation into the
various navigational strategies used by pupils to function in a virtual environment.
To improve conversation comprehension, a multi-resolution RNN is used to
represent high-level course and natural language tokens .Contrary to the traditional
conversation systems like ELIZA,which are largely built with hand-crafted rules,
researchers have recently started to develop principled and data-driven approaches
to build open domain conversational systems due to the advantages of the large
scale social conversation data that is publicly available and the rapid advancement
of deep learning approaches.Non-task centred chatbots are gaining popularity
recently,and the secret to creating a chatbot is learning how to respond to messages
in an appropriate (human-like and natural) manner.The approaches currently in use
are either retrieval based or generation based. Nevertheless,because there is still a
problem with the language's library, the server's development is not complete. If
text recognition is possible for chatbots to learn from, an AI will be able to respond
to messages more accurately.Tensorflow training enhances the accuracy of these
chatbots using the convolution neural network technique.
3
Chatbot was a computer application which may speak to human beings naturally,
the way they interact with one another. It can replace a person's for several tasks of
answering queries. A chatbot is an agent that interacts with users using simple
language. It had been built as an effort to fool humans. Several applications of
chatbots like Customer Service, call centers etc. uses AI terminology to talk with
user. One among the prime goals of chatbots is to resemble an intelligent human
and make it difficult for the receiver of the conversation to know the important
working alongside various architecture and capabilities for his or her usage has
widely broadened. These chatbots can prove sufficient to fool the user into
believing they're “talking” to a person's being, but are very limited in improving
their knowledge domain at runtime, and usually have a very little to no means of
keeping track of all the conversational data. Chatbots makes use of machine
learning to succeed in AI helping them to know the user query and supply an
appropriate response. The chatbots are developed using the synthetic Intelligence
terminology for communicating or interacting with the user.
4
CHAPTER – 2
2. LITERATURE SURVEY
5
2. LITERATURE SURVEY
2.1 Chatbot System for Collage FAQ’s Using Artificial Intelligence
Author: Mr.Ashish Saxena1 , Santosh S.Chinchalli
A chat larva (also called a talk Bot, chatterbox, Artificial informal Entity) may
be a worm that conducts oral communication via sensory system or matter ways.
Such programs are usually designed to convincingly simulate however an
individual's would have as a conversational partner, there by passing the Turing
test. Chat bots are typically employed in dialog systems for numerous sensible
functions as well as client service or information acquisition. This system will be a
web application which can give answers to the queries of the scholars. Students
simply ought to choose the class for the department queries then raise the question
to the larva which will be used for chatting. The answers will be provide
mistreatment the inbuilt computer science algorithms. Students won have to travel
to the college to make the enquiry. The system replies to the user with the help of
effective graphical user interface. The user can query about the college related
activities. Through on-line with the assistance of this internet application.
2.2 College Enquiry Chat-Bot System
Author: Harshala Gawade, Prachi Vishe
Nowadays, many people are using smartphone with many new applications i.e.
technology is growing day by day. Today Artificial Intelligence is playing a major
role in a variety of fields ranging from industries in product manufacturing, to
customer care in public relations. As there are many online Artificial Intelligence
(AI) systems or chat bots which are in existence that help people solve their
problems. So, we are going to implement a virtual assistant based on AI that can
solve any college related query. A chat bot has information stored in its database to
identify the sentences and making a decision itself as response to answer a given
6
question. Designed to convincingly simulate the way a human would behave as a
conversational partner. Bots can be created by using language like Artificial
Intelligence Mark-up Language(AIML), a language based on XML that allow
developer’s write rules for the bot to follow. Another drawback is writing rules for
different scenarios is very time consuming and it is impossible to write rules for
every possible scenario. So these bots can handle simple queries but fail to manage
complex queries.
2.3 Artificially Intelligent Chatbot Universal Research Reports
Author: Nitesh Thakur, Akshay Hiwrale
As Nowadays Technology is getting smarter day by day and helping Humans to
solve their queries. Today Artificial Intelligence is playing a major role in a variety
of fields ranging from industries in product manufacturing, to customer care in
public relations. As there are many online Artificial Intelligence (AI) system or
chat bots are in existence that help people solve their problems. So, our team is
going to implement a system (a virtual assistant) based on AI that can solve any
college related query. As this will help students in fetching the information without
visiting the college or to stand in queue. Students can use this chat bot to get the
answers to their queries in a very easy and fast way. This type of android
applications like Chat Bot project will be built using artificial intelligence
algorithms that will analyze user’s queries and understand user’s message. This
android application will provide answers to the queries of the students. Students
will just have to select the category for the department queries and then ask the
query to the bot that will be used for chatting.
2.4 Chat-Bot For College Management System
Author: Srushti Barve, Supriya Gaikwad
7
Chat-bot also known as a talkbot, chatterbox, Bot is a computer program that
mimics human conversation. A bot is a software which performs tasks
automatically. Basically a bot is a computer program designed for communication
and to get answers through that communication. Most of the Chat-bots are
developed using Artificial Intelligence algorithms. The user have to register and
then login to the bot. After login user can see the page on which queries can be
submitted to get answers so, users don’t need to go personally to the college for
inquiry. Chat-bots are created by the programmer and designed to have
communication and to get answers for queries. In this paper, a proposal is explain
to design a chat bot as a Web application which will be helpful for students to
solve all the problems they face and the questions which arises in their mind during
and after the admission. This proposal explains the implementation of chat bot
system as an application named as, college enquiry chat bot.
2.5 Online Chatting System for College Enquiry using Knowledgeable
Database
Author:Prof.S.A.Bhuskute
A chatterbox or Chatbot aims to make a conversation between both human and
machine. The machine has been embedded knowledge to identify the sentences
and making a decision itself as response to answer a question. The response
principle is matching the input sentence from user .The present technical project
consist of developing an expert System for college enquiry desk using an android
based Chabot, through Artificial Intelligence technology and virtual assistance
(Human-machine conversation),transmitting natural language to a server. Artificial
Intelligent is the fastest growing technology every were in the world. With the help
of Artificial Intelligent and Knowledgeable database. We can make the
transformation in the pattern matching and virtual assistance. A chatbot is a
8
technology that allows users to have natural conversations to access content and
services. Chatbots typically take the form of a chat client, leveraging natural
language processing to conduct a conversation with the user. Chatbots control
conversation flow based on the context of the user’s requests and respond with
natural language phrases to provide direct answers, request additional information
or recommend actions that can be taken.
9
CHAPTER – 3
SYSTEM ANALYSIS
10
3. SYSTEM ANALYSIS
3.1 EXISTING SYSTEM
Now a days there are many changes occurred in the Education system with help
of advanced technology. Everything is happening over the internet without any
trouble. In those days for enquiring about courses we have to visit the college, but as
the days are passing away it’s completing changing. Collecting the course details, fee
structure manually will be hectic procedure and it also needs a manpower. For
reducing that manpower and avoid such difficulties and time consuming many
devices or systems were emerged day by day
Machine Learning Models: Chatbots often use machine learning models like
support vector machines (SVM), decision trees, or deep learning models such as
recurrent neural networks (RNNs) or transformer models like BERT for intent
recognition and response generation
The existing system is not only tedious but also makes a gap between
administration and students. Surfing the website for small information can be
suffering sometimes.
It is rather better to just enter your query and get information on your fingertip.
In previous days for submitting a small application we had to visit that place,
but as the days are passing away it’s completely changing.
11
The existing system is not only tedious but also makes a gap between
administration and students.
Surfing the website for small information can be suffering sometimes.
3.2 PROPOSED SYSTEM
Chat-bots are motivated by the need of traditional websites to provide a
chat facility where a bot is required to be able to chat with user and solve queries.
Lastly, the most important advantage of having a chat-bot is that it is available
24/7. No matter what time it is, a user can get a query solved.
All these advantages of a chat-bot constitute the motivation to implement a College
Enquiry Chat-bot
Natural Language Understanding (NLU): Deep learning models, such as
recurrent neural networks (RNNs) or transformer models like BERT, would be
used for NLU tasks like intent recognition, entity recognition, and sentiment
analysis. These models would help the chatbot better understand the nuances of
natural language.
For the User, there is no need to visit the college personally to enquiry about
thecollege related information.
This system aids the students to be updated with college related activities.
This system is developed aiming at reducing the time for the student, parents
aswell as the faculty at the institution.
12
CHAPTER – 4
SYSTEM SPECIFICATION
13
4. SYSTEM SPECIFICATION
14
CHAPTER – 5
SYSTEM DESIGN
15
5. SYSTEM DESIGN
16
5.2 DATA FLOW DIAGRAM
17
Figure:5.2 Data Flow Diagram
18
5.3 UML DIAGRAMS
5.4 GOALS
The Primary goals in the design of the UML are as follows:
1. Provide users a ready-to-use, expressive visual modeling Language so that
they can develop and exchange meaningful models.
2. Provide extendibility and specialization mechanisms to extend the core
concepts.
3. Be independent of particular programming languages and development
process.
19
5.5 USE CASE DIAGRAM
20
5.6 CLASS DIAGRAM
Input Output
Query processing
Solution provided
21
5.7 SEQUENCE DIAGRAM
22
5.8 ACTIVITY DIAGRAM
23
CHAPTER – 6
MODULE DESCRIPTION
24
6. MODULE DESCRIPTION
6.1 MODULES
Our project modules are as follows.
Admin Login
Add Query And Dataset
User Login
Asking Querie
Providing Feedback
6.2 MODULES DESCSRIPTION
6.2.1 Admin Login
System has one administrator (there is no registration for admin). The
administrator must log in using their username and password. The admin who is in
charge of keeping the college chatbot system up to date has a number of tasks to
complete, such as adding the query to the database, altering the data, deleting the
data, viewing user feedback, and so on.
6.2.2 Add Query And Dataset
If the administrator adds the dataset, the chatbot offers three ways to add the
query:by adding a question, by adding a response, or by choosing the category that
the dataset belongs to. If the administrator views the dataset, the chatbot enables
seeing the dataset by category. The chatbot also offers the two extra alternatives of
deleting and editing the dataset.
6.2.3 User Login
The user is welcomed by the chatbot system, which then asks them for their
login information. Then, the user and the chatbot begin a conversation.After
clicking on the chatbot provided in the college website. The chatbot system greets
25
the user and requests the user to provide the login id. After which the chatbot starts
chatting with the user. When the user proceeds to choose chatbot to get an answer to
his/her query, the chatbot displays a page to select few options regarding college and
identifies his/her category of query. If the user gets his query cleared then the task of
chatbot is completed.
6.2.4 Asking Queries
The chatbot system will ask the user to enter their question in words if they are
not pleased with the rule-based response, and the chatbot will then provide the
appropriate response. The database is first verified for the user's query. The user
receives an acceptable response if the query is genuine. If the question is
unfounded, the chatbot invites the user to ask questions about the college.
6.2.5 Providing Feedback
After the chat, the chatbot takes feedback from the user. Feedback is
taken in order to know the users experience with the chatbot. If the user gives
feedback positively then the bot thanks the user and provides a box to enter any
further queries. If the user gives feedback negatively then bot asks the user to
elaborate his/her query in order to respond. Username of the user is also stored and
phone number provided to helps users to track user actions.
26
CHAPTER – 7
SYSTEM TESTING
27
7. SYSTEM TESTING
The purpose of testing is to discover errors. Testing is the process of trying to
discover every conceivable fault or weakness in a work product. It provides a way
to check the functionality of components, sub assemblies, assemblies and/or a
finished product It is the process of exercising software with the intent of ensuring
that the Software system meets its requirements and user expectations and does not
fail in an unacceptable manner. There are various types of test. Each test type
addresses a specific testing requirement.
28
by successfully unit testing, the combination of components is correct and
consistent. Integration testing is specifically aimed at exposing the problems that
arise from the combination of components.
29
System testing is based on process descriptions and flows, emphasizing pre-driven
process links and integration points.
Unit testing is usually conducted as part of a combined code and unit test phase
of the software lifecycle, although it is not uncommon for coding and unit testing
to be conducted as two distinct phases.
30
7.1.9 TEST OBJECTIVES
Test Results: All the test cases mentioned above passed successfully. No defects
encountered.
31
CHAPTER – 8
APPLICATION AREAS
32
8. APPLICATION AREAS
A smart college enquiry chatbot using deep learning algorithms can find
application in streamlining various aspects of student services and administrative
tasks within a college or university. It can be used to provide quick and accurate
responses to inquiries related to admissions, course information, enrollment
procedures, campus facilities and services, as well as general questions about
college events and activities. By leveraging deep learning algorithms, the chatbot
can continuously improve its responses based on user interactions, offering a more
personalized and efficient way to engage with students, faculty, and staff.
Additionally, such a chatbot can help reduce the workload on administrative staff,
allowing them to focus on more complex tasks while enhancing the overall student
experience.
33
CHAPTER – 9
SYSTEM STUDY
34
9. SYSTEM STUDY
The feasibility of the project is analyzed in this phase and business proposal is
put forth with a very general plan for the project and some cost estimates. During
system analysis the feasibility study of the proposed system is to be carried out.
This is to ensure that the proposed system is not a burden to the company. For
feasibility analysis, some understanding of the major requirements for the system
is essential.
Three key considerations involved in the feasibility analysis are
Economical Feasibility
Technical Feasibility
Social Feasibility
9.1.1 ECONOMICAL FEASIBILITY
This study is carried out to check the economic impact that the system will
have on the organization. The amount of fund that the company can pour into the
research and development of the system is limited. The expenditures must be
justified. Thus the developed system as well within the budget and this was
achieved because most of the technologies used are freely available. Only the
customized products had to be purchased.
This study is carried out to check the technical feasibility, that is, the technical
requirements of the system. Any system developed must not have a high demand
on the available technical resources. This will lead to high demands on the
available technical resources. This will lead to high demands being placed on the
35
client. The developed system must have a modest requirement, as only minimal or
null changes are required for implementing this system.
The aspect of study is to check the level of acceptance of the system by the
user. This includes the process of training the user to use the system efficiently.
The user must not feel threatened by the system, instead must accept it as a
necessity. The level of acceptance by the users solely depends on the methods that
are employed to educate the user about the system and to make him familiar with
it. His level of confidence must be raised so that he is also able to make some
constructive criticism, which is welcomed, as he is the final user of the system.
36
CHAPTER – 10
37
10. CONCLUSION & FUTURE ENCHANCEMENT
10.1 CONCLUSION
38
APPENDIX 1
SOFTWARE ENVIRONMENT
39
A1. SOFTWARE ENVIRONMENT
A1.2.1.1 Python
Python is Interactive − You can actually sit at a Python prompt and interact
with the interpreter directly to write your programs.
Python was developed by Guido van Rossum in the late eighties and early
nineties at the National Research Institute for Mathematics and Computer Science
in the Netherlands.
Python is derived from many other languages, including ABC, Modula-3, C, C++,
Algol-68, SmallTalk, and Unix shell and other scripting languages.
40
Python is copyrighted. Like Perl, Python source code is now available under the
GNU General Public License (GPL).
Easy-to-learn − Python has few keywords, simple structure, and a clearly defined
syntax. This allows the student to pick up the language quickly.
easy-to-maintain.
A broad standard library − Python's bulk of the library is very portable and
cross-platform compatible on UNIX, Windows, and Macintosh.
Interactive Mode − Python has support for an interactive mode which allows
interactive testing and debugging of snippets of code.
Portable − Python can run on a wide variety of hardware platforms and has the
same interface on all platforms.
Extendable − You can add low-level modules to the Python interpreter. These
modules enable programmers to add to or customize their tools to be more
efficient.
41
GUI Programming − Python supports GUI applications that can be created and
ported to many system calls, libraries and windows systems, such as Windows MFC,
Macintosh, and the X Window system of Unix.
Scalable − Python provides a better structure and support for large programs
than shell scripting.
Apart from the above-mentioned features, Python has a big list of good features,
few are listed below −
It can be easily integrated with C, C++, COM, ActiveX, CORBA, and Java.
The most up-to-date and current source code, binaries, documentation, news, etc.,
is available on the official website of Python https://www.python.org.
Windows Installation
Follow the link for the Windows installer python-XYZ.msifile where XYZ
42
is the version you need to install.
To use this installer python-XYZ.msi, the Windows system must support
Microsoft Installer 2.0. Save the installer file to your local machine and then
run it to find out if your machine supports MSI.
Run the downloaded file. This brings up the Python install wizard, which is
really easy to use. Just accept the default settings, wait until the install is
finished, and you are done.
The Python language has many similarities to Perl, C, and Java. However, there
are some definite differences between the languages.
$ python
Python2.4.3(#1,Nov112010,13:34:43)
Type the following text at the Python prompt and press the Enter –
print"Hello, Python!"
If you are running new version of Python, then you would need to use print
statement with parenthesis as in print ("Hello, Python!");. However in Python
43
version 2.4.3, this produces the following result −
Script Mode Programming
Hello, Python!
Invoking the interpreter with a script parameter begins execution of the script and
continues until the script is finished. When the script is finished, the interpreter is
no longer active.
Let us write a simple Python program in a script. Python files have extension .py.
Type the following source code in a test.py file –
print"Hello, Python!"
We assume that you have Python interpreter set in PATH variable. Now, try to
run this program as follows –
$ python test.py
Hello, Python!
Flask Framework
44
Sr.No Methods & Description
GET
HEAD
POST
Used to send HTML form data to server. Data received by POST method is not
cached by server.
PUT
Replaces all current representations of the target resource with the uploaded
content.
DELETE
By default, the Flask route responds to the GET requests. However, this
preference can be altered by providing methods argument to route() decorator.
In order to demonstrate the use of POST method in URL routing, first let us
create an HTML form and use the POST method to send form data to a URL.
<html>
<body>
<formaction="http://localhost:5000/login"method="post">
45
<p>Enter Name:</p>
<p><inputtype="text"name="nm"/></p>
<p><inputtype="submit"value="submit"/></p>
</form>
</body>
</html>
app=Flask( name )
@app.route('/success/<name>')
def success(name):
@app.route('/login',methods=['POST','GET'])
def login():
ifrequest.method=='POST':
user=request.form['nm']
else:
user=request.args.get('nm')
46
if name ==' main ':
app.run(debug =True)
After the development server starts running, open login.html in the browser, enter
name in the text field and click Submit.
user = request.form['nm']
Change the method parameter to ‘GET’ in login.html and open it again in the
browser. The data received on server is by the GET method. The value of ‘nm’
parameter is now obtained by –
User = request.args.get(‘nm’)
Here, args is dictionary object containing a list of pairs of form parameter and its
corresponding value. The value corresponding to ‘nm’ parameter is passed on to
‘/success’ URL as before.
47
software development,
mathematics,
system scripting.
A1.2.1.4 What can Python do
Python can be used on a server to create web applications.
Python can be used alongside software to create workflows.
Python can connect to database systems. It can also read and modify files.
Python can be used to handle big data and perform complex mathematics.
Python can be used for rapid prototyping, or for production-ready software
development.
A1.2.1.4.1Why Python
Python works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc).
Python has a simple syntax similar to the English language.
Python has syntax that allows developers to write programs with fewer lines
than some other programming languages.
Python runs on an interpreter system, meaning that code can be executed as
soon as it is written. This means that prototyping can be very quick.
Python can be treated in a procedural way, an object-orientated way or a
functional way.
Good to know
The most recent major version of Python is Python 3, which we shall be using
in this tutorial. However, Python 2, although not being updated with anything
other than security updates, is still quite popular.
In this tutorial Python will be written in a text editor. It is possible to write
Python in an Integrated Development Environment, such as Thonny, Pycharm,
48
Netbeans or Eclipse which are particularly useful when managing larger
collections of Python files.
Python Syntax compared to other programming languages
Python was designed to for readability, and has some similarities to the English
language with influence from mathematics.
Python uses new lines to complete a command, as opposed to other
programming languages which often use semicolons or parentheses.
Python relies on indentation, using whitespace, to define scope; such as the
scope of loops, functions and classes. Other programming languages often use
curly-brackets for this purpose.
To check if you have python installed on a Windows PC, search in the start bar for
Python or run the following on the Command Line (cmd.exe):
To check if you have python installed on a Linux or Mac, then on linux open the
command line or on Mac open the Terminal and type:
python --version
If you find that you do not have python installed on your computer, then you can
download it for free from the following website: https://www.python.org/
The way to run a python file is like this on the command line:
49
C:\Users\Your Name>python helloworld.py
Let's write our first Python file, called helloworld.py, which can be done in any
text editor.
helloworld.py
print("Hello, World!")
Simple as that. Save your file. Open your command line, navigate to the directory
where you saved your file, and run:
Hello, World!
Congratulations, you have written and executed your first Python program.
A1.2.7 The Python Command Line
To test a short amount of code in python sometimes it is quickest and easiest not to
write the code in a file. This is made possible because Python can be run as a
command line itself.
C:\Users\Your Name>python
From there you can write any python, including our hello world example from
earlier in the tutorial:
C:\Users\Your Name>python
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)]
on win32
50
>>> print("Hello, World!")
C:\Users\Your Name>python
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)]
on win32
Whenever you are done in the python command line, you can simply type the
following to quit the python command line interface:
exit()
Execute Python Syntax
As we learned in the previous page, Python syntax can be executed by writing
directly in the Command Line:
>>> print("Hello, World!")Hello, World!
Or by creating a python file on the server, using the .py file extension, and running
it in the Command Line:
C:\Users\Your Name>python myfile.py
Python Indentations
Where in other programming languages the indentation in code is for readability
only, in Python the indentation is very important.
Python uses indentation to indicate a block of code.
Example
if 5 > 2:
print("Five is greater than two!")
Python will give you an error if you skip the indentation:
51
Example
if 5 > 2:
print("Five is greater than two!")
Comments
Python has commenting capability for the purpose of in-code documentation.
Comments start with a #, and Python will render the rest of the line as a comment:
Example
Comments in Python:
#This is a comment.print("Hello, World!")
Docstrings
Python also has extended documentation capability, called docstrings.
Docstrings can be one line, or multiline.
Python uses triple quotes at the beginning and end of the docstring:
Example
Docstrings are also comments:
"""Thisis a multiline docstring."""print("Hello, World!")
52
APPENDIX 2
SOURCE CODE
53
A2. SOURCE CODE
54
network =
tflearn.fully_connected(network,len(output[0]),activation="softmax"
) network = tflearn.regression(network)
model = tflearn.DNN(network)
model.load("assets/model.chatbot.tflearn"
) chats=[]
@app.route("/")
#home def hello():
return
render_template("home.html")
@app.route('/logon')
def logon():
return
render_template('signup.html')
@app.route('/login')
def login():
return
render_template('signin.html')
@app.route("/signup")
def signup():
username =
request.args.get('user','') name
= request.args.get('name','')
email =
request.args.get('email','')
number =
request.args.get('mobile','')
55
password =
request.args.get('password','') con =
sqlite3.connect('signup.db')
cur = con.cursor()
cur.execute("insert into `info` (`user`,`email`, `password`,`mobile`,`name`)
VALUES (?, ?, ?,
?,
?)",(username,email,password,number,
name)) con.commit()
con.close()
return
render_template("signin.html")
@app.route("/signin")
def signin():
mail1 = request.args.get('user','')
password1 =
request.args.get('password','') con =
sqlite3.connect('signup.db')
cur = con.cursor()
cur.execute("select `user`, `password` from info where `user` = ? AND `password`
=
?",(mail1,password
1,)) data =
cur.fetchone() if
data == None:
return render_template("signin.html")
elif mail1 == 'admin' and password1 == 'admin':
56
return render_template("form.html")
elif mail1 == str(data[0]) and password1 ==
str(data[1]): return
render_template("form.html")
else:
return
render_template("signup.html")
@app.route('/form')
def form():
return render_template('form.html')
@app.route("/start",methods=['POST','
GET']) def start():
inp = [str(x) for x in
request.form.values()] print(inp[0])
#return
render_template('chat_bot.html',result=inp[0])
results =
model.predict([bag_of_words(inp[0],words)])[0]
print(results)
results_index =
np.argmax(results) tag =
labels[results_index]
print(tag)
if results[results_index] < 0.8 or
len(inp[0])<2:
email="[email protected]"
57
Msg="Chat bot not able to answer for this
question"+inp ms.process(email,Msg)
result ="Sorry, I didn't get you. Please try again. Kindly make live chat to
6382621629" else:
for tg in data['intents']:
if tg['tag'] == tag:
responses =
tg['responses']
result=""+random.choice(response
s)
es= ["Sad to see you go :(", "Talk to you later", "Goodbye!", "See you
later","bye-bye"] if result in es:
email="[email protected]"
58
s_words = [stemmer.stem(word.lower()) for word in
s_words] for se in s_words:
for i,w in
enumerate(words)
: if w == se:
bag[i] =
1 return np.array(bag)
# start()
if name ==" main__":
app.run(debug=True)
import json
import numpy as
np import
random import
pickle import
tflearn
import tensorflow
as tf import os
import nltk
data =
json.load(myfile)
59
try:
a
with open("assets/input_data.pickle",
"rb") as f: words, labels, training, output
= pickle.load(f) except:
words =
[] labels
= []
docs_x =
[] docs_y
= []
for intent in data["intents"]:
docs_y.append(intent["tag"])
if intent["tag"] not in
labels:
labels.append(intent["ta
g"])
60
w != "?"] words = sorted(list(set(words)))
labels = sorted(labels)
#one hot encoding --- bag of words
training = []
output = []
out_empty = [0 for _ in
range(len(labels))] for x,doc in
enumerate(docs_x):
bag = []
wrds = [stemmer.stem(w) for w
in doc] for w in words:#all
if w in
wrds:#current
bag.append(1)
else:
bag.append(0)
output_row = out_empty[:] #copy
output_row[labels.index(docs_y[x
])] = 1 #print("\n bag: "+str(bag))
#print("\n row: "+str(output_row))
training.append(bag)
output.append(output_r
ow) training =
np.array(training)
output =
61
np.array(output)
with open("assets/input_data.pickle",
"wb") as f: pickle.dump((words, labels,
training, output),f)
tf.compat.v1.reset_default_graph()
network = tflearn.input_data(shape=[None,
len(training[0])]) network =
tflearn.fully_connected(network,8)
network = tflearn.fully_connected(network,8)
network =
tflearn.fully_connected(network,len(output[0]),activation="softmax"
) network = tflearn.regression(network)
model = tflearn.DNN(network)
if
os.path.exists("model.chatbot.tflearn.
meta"):
model.load("model.chatbot.tflearn")
else:
model.fit(training, output, n_epoch=1000, batch_size=8,
show_metric=True) model.save("model.chatbot.tflearn")
def bag_of_words(s,words):
bag = [0 for _ in
range(len(words))] s_words =
nltk.word_tokenize(s)
s_words = [stemmer.stem(word.lower()) for word in
s_words] for se in s_words:
62
for i,w in enumerate(words):
if w == se:
bag[i] = 1
return
np.array(bag) def
start_chat():
print("\n\nBot is ready to talk to you. (type 'quit'
to stop) ") while True:
inp = input("You: ")
if inp.lower() in ["quit","exit"]:
break
results =
model.predict([bag_of_words(inp,words)])[0]
#print(results)
results_index =
np.argmax(results) tag =
labels[results_index]
#print(tag)
if results[results_index] < 0.8 or len(inp)<2:
print("Bot: Sorry, I didn't get you. Please try again.\n Kindly make live chat to
6382621629") email="[email protected]"
63
Msg="Chat bot not able to anser for this question"+inp
ms.process(email,Msg
) else:
for tg in data['intents']:
if tg['tag'] == tag:
responses = tg['responses']
print("Bot:
"+random.choice(responses)+"\n")
start_chat()
import json
import numpy as
np import
random import
pickle import
tflearn
import tensorflow
as tf import os
import nltk
from nltk.stem.lancaster import
LancasterStemmer import ms as ms
stemmer = LancasterStemmer()
with open("assets/intents.json") as myfile:
data =
json.load(myfile)
try:
64
a
with open("assets/input_data.pickle",
"rb") as f: words, labels, training, output
= pickle.load(f) except:
words =
[] labels
= []
docs_x =
[] docs_y
= []
for intent in data["intents"]:
for pattern in intent["patterns"]:
wrds = nltk.word_tokenize(pattern) #break the sentences
into words words.extend(wrds)
docs_x.append(wrds)
docs_y.append(intent["ta
g"]) if intent["tag"] not in
labels:
labels.append(intent["tag
"])
65
out_empty = [0 for _ in
range(len(labels))] for x,doc in
enumerate(docs_x):
bag = []
wrds = [stemmer.stem(w) for w
in doc] for w in words:#all
if w in
wrds:#current
bag.append(1)
else:
bag.append(0)
output_row = out_empty[:]
#copy
output_row[labels.index(docs_y[x
])] = 1 #print("\n bag: "+str(bag))
#print("\n row:
"+str(output_row))
training.append(bag)
output.append(output_row)
training = np.array(training)
output = np.array(output)
with open("assets/input_data.pickle",
"wb") as f: pickle.dump((words, labels,
training, output),f)
tf.compat.v1.reset_default_graph()
network = tflearn.input_data(shape=[None,
66
len(training[0])]) network =
tflearn.fully_connected(network,8)
network = tflearn.fully_connected(network,8)
network =
tflearn.fully_connected(network,len(output[0]),activation="softmax"
) network = tflearn.regression(network)
model = tflearn.DNN(network)
if
os.path.exists("model.chatbot.tflearn.m
eta"):
model.load("model.chatbot.tflearn")
else:
bag[i] = 1
return
np.array(bag) def
67
start_chat():
print("\n\nBot is ready to talk to you. (type 'quit'
to stop) ") while True:
inp = input("You: ")
if inp.lower() in ["quit","exit"]:
break
results =
model.predict([bag_of_words(inp,words)])[0]
#print(results)
results_index =
np.argmax(results) tag =
labels[results_index]
#print(tag)
if results[results_index] < 0.8 or len(inp)<2:
print("Bot: Sorry, I didn't get you. Please try again.\n Kindly make live chat
to 63826229") email="[email protected]"
Msg="Chat bot not able to anser for this
question"+inp ms.process(email,Msg)
else:
for tg in data['intents']
if tg['tag'] == tag:
responses = tg['responses']
print("Bot:
"+random.choice(responses)+"\n")
start_chat()
68
APPENDIX 3
SCREEN SHOTS
69
A3.SCREEN SHOTS
70
Fig A3:2.Login from
71
Fig A3:3. User Register page
72
Fig A3:5. This is Ask Question reply data
73
FigA3:6. This is gmail page to send user Feedback Manager
74
REFERENCES
75
Computing and Big Data Analysis (ICCCBDA), pp. 517-522. IEEE, 2019
7. susanna, Ms Ch Lavanya, R. Pratyusha, P. Swathi, P. Rishi Krishna, and V. Sai
Pradeep. "College enquiry chatbot." International Research Journal of Engineering
and Technology (IRJET) 7, no. 3 (2020): 784-788.
8. Wu, Yu, Zhoujun Li, Wei Wu, and Ming Zhou. "Response selection with topic
clues for retrieval-based chatbots." Neurocomputing 316 (2018): 251-261. 10.
Windiatmoko, Yurio, Ridho Rahmadi, and Ahmad Fathan Hidayatullah.
"Developing facebook chatbot based on deep learning using rasa framework for
university enquiries." In IOP conference series: materials science and engineering,
v.ol. 1077, no. 1, p. 012060. IOP Publishing, 2021.
9. Yan, R., 2018, July. ” chitty-chitty-chat bot”: deep learning for convensational AI.
In IJCAI (vol. 18, pp. 5520-5526).
76