0% found this document useful (0 votes)
5 views

Chat-Bot-Final-2

The document outlines the development of a chatbot application designed to assist students and parents with queries related to Machine Learning. It details the system specifications, including hardware and software configurations, and compares the existing manual system with the proposed chatbot system, highlighting its advantages such as time-saving and 24/7 availability. The document also discusses the feasibility studies conducted to ensure the project's technical, operational, and economic viability.

Uploaded by

seevagandaass
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Chat-Bot-Final-2

The document outlines the development of a chatbot application designed to assist students and parents with queries related to Machine Learning. It details the system specifications, including hardware and software configurations, and compares the existing manual system with the proposed chatbot system, highlighting its advantages such as time-saving and 24/7 availability. The document also discusses the feasibility studies conducted to ensure the project's technical, operational, and economic viability.

Uploaded by

seevagandaass
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 44

CHAPTER PAGE

NO. TITLE NO
SYNOPSIS 4
INTRODUCTION 4
1.1 ORGANIZATION PROFILE 5
1 1.2 SYSTEM SPECIFICATION 7
1.2.1 HARDWARE CONFIGURATION 8
1.2.2 SOFTWARE SPECIFICATION 8
SYSTEM STUDY 10
2 2.1 EXISTING SYSTEM 10
2.1.1 DRAWBACKS 10
2.2 PROPOSED SYSTEM 11
2.2.1 ADVANTAGES 11
SYSTEM DESIGN AND DEVELOPMENT 12
3.1 FILE DESIGN 13
3.2 INPUT DESIGN 14
3 3.3 OUTPUT DESIGN 14
3.4 DATABASE DESIGN 14
3.5 SYSTEM DEVELOPMENT 15
3.5.1 DESCRIPTION OF MODULES 21
4 TESTING AND IMPLEMENTATION 21
5 CONCLUSION 22
6 REFERENCES
APPENDIES
A. DATA FLOW DIAGRAM
7 B. TABLE STRUCTURE
C. SAMPLE CODING
D. SAMPLE SCREENS

1
SYNOPSIS

An application “CHATBOT FOR TEACHING MACHINE LEARNING” is designed by


using JSON Database structure to retrieve the data. The project is implemented mainly to solve
the
doubts and queries of both students and parents and teaching for Machine Learning (ML).
A chatbot suits the user needs and requirements. Chatbots are usually a stateful services
remembering previous commands (and perhaps even conversation) in order to provide
functionality.
When chat bot technology is integrated with popular web services or technologies it can be
utilized securely by an large audience. The project provides user by human text recognition
feature
and have basic interaction with them just like a human. And it provides text-based user interface,
allowing user to type commands as well as receive the texts. It can answer the questions asked by
the user.
Chatbot system is in trend, thus it is being used on many websites. With the chatbot, one
doesn‘t have to wait for asking information about the machine learning, they don‘t have to search
for throw websites In this project the design of a chatbot, which provides a genuine and accurate
answer for any query using NLTK library, Machine Learning(ML).

2
1. INTRODUCTION
1.1 ORGANIZATION PROFILE
A chatbot is a computer software program that conducts a conversation via auditory or
textual methods. Chatbots are programs that work on Artificial Intelligence (AI) & Machine
Learning Platform. A person can ask any questions and chatbot will answer accordingly.
Nowadays a chatbot is highly popular and takes speed as a computer communication application.

Many chatbots have been developed that provide a multitude of services through a wide
range of methods. A chatbot is a brand-new conversational agent in the highspeed changing
technology world. With the advance of Artificial Intelligence and machine learning, chatbots are
becoming more and more popular.

One of the potential paths to retrieve the info automatically and quickly is through a
chatbot. The interaction in the format of speech or text between humans and computers is gaining
more and more in popularity nowadays. People expect to have similar experiences when they talk
to machines as when they talk to human beings.

In order to provide suitable responses based on phrases or keywords taken from questions,
a dialogue system or program is needed, which is often called a chatbot. The chatbot is a
computer program that has an ability to communicate with people by providing answers to
questions. A chatbot is used in many areas like order food, product suggestions, customer support,
weather, personal finance assistance, scheduled a meeting, search and track flights, send money,
and many more. Chatbot has become more popular in business groups right now as it can reduce

3
customer service costs and handles multiple users at a time. But yet to accomplish many tasks
there is a need to make chatbots as efficient as possible.

People input the natural language speech or text, while the program provides the most
feasible intelligent response in the form of text or speech. Worldwide various chat systems are
available that enable communication using natural languages.

These chat systems are broadly categorized into two main types namely,

 Human-Human Dialog System - There is not any involvement of machine learning in


Human-Human Dialog System and this work as a negotiator between two humans.
The Human-Human Dialog System doesn‘t require natural processing abilities
through machines. Globally, WhatsApp and skype are the most popular Human-
Human Dialog chat system.

 Human-Computer Dialog System - The other available chat system other than
Human-human dialog system is the Human-Computer Dialog System is termed as
chatbot . Basically, chatbot is a computer program that pretends chat with humans
through natural language. On any platform like mobile, website and desktop
application, this system can interact with the humans, chatbot simulates as a human
being.

 Human being only interacts with one human at a time, the chatbot interacts and
communicates with hundreds and thousands of persons simultaneously. It works and
responds without considering how many persons are interacting and what time of the
day and night it is.

4
 However, for natural language processing ability, the development of chatbot is an
arduous task. Chatbots are applicable in many fields such as in education, travelling,
real estate, internet, gaming, education, ecommerce, hospitality and health, call
center, media, financial bot insurance banks, business, travelling customer service
and in shopping .

1.2 SYSTEM SPECIFICATION

1.2.1 HARDWARE CONFIGURATION


Processor : AMD Pro A4-3350B 2.00GHZ
Mother Board : HP
RAM : 2GB
Hard Disk : 320 GB
Mouse : Logitech Optical Mouse
Keyboard : Logitech Multimedia

1.2.2 SOFTWARE SPECIFICATION


Operating System : Windows 10
Front – End : JavaScript

5
Back – End : JavaScript runtime

6
2. SYSTEM STUDY

2.1 EXISTING SYSTEM

The existing system is a manual system. Each and every action is done manually by in
person. It takes more time to finish and also having chances of committing some delay and
some cases we may not see their requirements. The maintenance is also difficult for the
existing system. Students manually visit to the college to get answers for their queries by the
college help desk.

This process consumes lot of time as well as money as the customer needed to visit
college if it‘s miles away from home.

Also, the manual process performs the above requirements it takes more time. And
there is no possible for a system to interact with the humans.

2.1.1 DRAWBACKS
• Human being only interacts with one human at a time. If there is a long queue of
queries, human can‘t offer the requirement solution at the same time.

• Ideally, a message in live chat is answered quickly only when the client side chat
person is also in online or otherwise they need to wait until the client side person is to
response. It may lead to lose interest of a customer.

• It is not cost-effective and it may loss making. Also this process may lead to
communication gap between student and college.

7
2.2 PROPOSED SYSTEM

A chatbot system is a software program that interacts with users using its own
language called the natural language. The purpose of a chatbot system is to simulate a
conversation with a human which is so human-like that the person gets fooled into believing
that he's talking with a human.

Chatbots seem to hold tremendous promise for providing users with quick and
convenient support responding specifically to their questions. The most frequent motivation
for chatbot users is considered to be productivity, while other motives are entertainment,
social factors, and contact with novelty. However, to balance the motivations mentioned
above, a chatbot should be built in a way that acts as a tool, a toy, and a friend at the same
time.

By using chatbot students just have to query through the bot which is used for
chatting.

Students can chat using any format there is no specific format the user has to follow. The
system

uses built in Natural language processing to answer they query.

2.2.1 ADVANTAGES
• User does not have to go personally to college office for the enquiry.
• This application enables the students to be updated with college cultural activities.
• It saves time for the students as well as teaching and non-teaching staffs.
• Chatbot can run on local computers.
• Having a full-time service is convenient and can answer urgent questions of students
who need answers after hours.

8
• Chatbot interfaces is user friendly to all students.Save Time and Money.Chatbots,
there is no such constraint and they can handle as many queries as required at once.

3. SYSTEM ANALYSIS

3.1 FEASIBILITY STUDY

An important outcome of the preliminary investigation is the determination that the


system requested is feasible. A feasibility study is carried out to select the best system that
meets the performance requirements. A feasibility study is both necessary and prudent to

evaluate the feasibility of the project at the earliest possible time.

Three key consideration involved in the feasibility analysis are,


• Technical feasibility
• Operational feasibility
• Economic feasibility

3.1.1 TECHNICAL FEASIBILITY

Technical feasibility is one of the first studies that must be conducted after project has
been identified. Any system developed on the available technical resources. This lead to high
demands being placed on the client. This application has been developed with python, where
it provides more general approach to data science.

It is a general purpose language with a readable syntax. A JSON is a Java script


notation that mainly used for storing and transferring data between browser and server.

JavaScript supports JSON with built-in package called json.

9
3.1.2 OPERATIONAL FEASIBILITY

Accessing operational feasibility is to gain an understanding of whether the proposed


system is to solve the user problems or take advantage of the opportunities or not is important
to understand how the new system will fetch into the current day-to-day operation of the
organization.

Operational feasibility studies are generally utilized to process evaluation,


organization and resistance. Python also enables developers to roll out programs and get
prototypes running, making the development process much faster. Once a project is on its
way to becoming an analytical tool or application, it can be more sophisticated languages
such as java and c if necessary.

3.1.3 ECONOMIC FEASIBILITY

Economic feasibility is the cost and logistical outlook for this project. Thus the
developed system as well within the budget and this was achieved because most of the
technologies used are freely available. The economical feasibility study analyses data to
determine whether the cost ultimately to the user. This project requires the historical data. So
it is not a difficult task to any user to analyze the patterns or predicting the sales. Due to this,
it is economically feasible.

10
3.2.3 SOFTWARE DESCRIPTION
JAVASCRIPT

JavaScript is a high-level, dynamic programming language that has become an


essential part of web development, allowing developers to create interactive and
dynamic websites. First introduced in 1995 by Brendan Eich of Netscape
Communications, JavaScript is now supported by all major web browsers and is
crucial for creating engaging web applications. It is primarily used for client-side
scripting, meaning that JavaScript code runs directly in the user's browser, enabling
immediate updates and interactions on the web page without needing to refresh. Over
time, JavaScript's role has expanded beyond the front-end to include server-side
programming through Node.js, allowing developers to write full-stack applications
using a single language. This versatility has led JavaScript to become one of the most
popular and widely used programming languages in the world.

JavaScript allows developers to build complex web applications by manipulating


HTML and CSS through the Document Object Model (DOM), which represents the
structure of a web page.

11
 JavaScript providing a dynamic and interactive user experience.

 JavaScript is also asynchronous, allowing for non-blocking operations like


fetching data from APIs or interacting with databases, which is vital for real-
time web applications.

 JavaScript frameworks like React, Angular, and Vue.js, as well as libraries


like jQuery.

 JavaScript has become even more powerful, enabling developers to build


complex, large-scale applications with ease.

 Furthermore, the constant evolution of JavaScript through updates like


ECMAScript ensures that it remains relevant and efficient for modern
development.

JAVASCRIPT: Advantages

 Client-Side Scripting: JavaScript runs in the browser, enabling real-time


interactivity and dynamic content updates without refreshing the page,
improving user experience.
 Versatile Programming: JavaScript supports various programming paradigms,
including object-oriented, functional, and imperative programming, making it
highly flexible.
 Cross-Platform Compatibility: JavaScript code can run on different operating
systems and browsers, ensuring that web applications are accessible to users
across various devices and platforms.
 Event-Driven Programming: JavaScript responds to user events (e.g., clicks,
mouse movement, key presses) and system events (e.g., page loading) to
trigger actions, making it ideal for building interactive websites.
 Asynchronous and Non-blocking: JavaScript uses techniques like callbacks,
Promises, and async/await to handle asynchronous operations, improving
application performance and responsiveness.
 DOM Manipulation: JavaScript can interact with and modify the HTML and
CSS of a webpage in real-time, allowing developers to dynamically update
content and create interactive elements.

12
 Rich Ecosystem: JavaScript has a large ecosystem of libraries and frameworks
(e.g., React, Vue.js, Node.js, Express.js) that speed up development and
improve the functionality of applications.
 Integration with APIs: JavaScript integrates seamlessly with various APIs
(like REST or GraphQL) to fetch and display data, as well as connect to
external services, enabling richer user experiences.
 Cross-functional Usage: With technologies like Node.js, JavaScript can be
used both on the client side (browser) and server side, allowing for full-stack
development using one language.
 Continuous Improvement: JavaScript is regularly updated through
ECMAScript specifications, adding new features (e.g., ES6/ES2015),
ensuring better performance, cleaner syntax, and improved developer
experience.

Library used:
NLP

NLP stands for Natural Language Processing, which is a field of artificial intelligence (AI)
focused on the interaction between computers and humans using natural language (i.e., the
way humans speak or write). NLP enables machines to understand, interpret, and generate
human language in a way that is valuable and meaningful.

Machine Learning

Machine Learning is a broad field, and libraries like used to implement machine learning
algorithms and models.These libraries make it easier to develop, train, and deploy ML models
by providing tools for everything from data preprocessing to model evaluation and
deployment.

NLP (Natural Language Processing), a subfield of AI, also heavily relies on ML libraries like
spaCy and NLTK for processing text and building models that understand language.

13
For dataflow programming and differentiable programming in JavaScript, the open-source
libraries that support these tasks typically focus on building computational graphs, enabling
differentiation for machine learning, optimization, and similar tasks.

Running on top of the machine learning platform TensorFlow. It was developed with a focus
on enabling fast experimentation. Being able to go from idea to result as fast as possible is
key to doing good research.

BACK END: JavaScript Runtime

The JavaScript runtime (like Node.js for server-side or browser for client-side) plays a
crucial role in managing the flow of execution, handling user interactions, and managing
various tasks such as processing user input, generating responses, and interacting with
external APIs or databases.

The JavaScript runtime is an environment that enables the execution of JavaScript code. In
the browser, this would be the browser's JavaScript engine (e.g., V8 in Chrome), while on the
server-side, this would be a runtime like Node.js. The runtime provides an execution context
where the JavaScript code can run, manage memory, handle asynchronous operations, and
execute tasks.

Handling Requests: On the backend, Node.js is commonly used for chatbot server-side logic.
Here, JavaScript runtime handles the lifecycle of HTTP requests.

14
For example, when the frontend sends a message to the backend via a POST request (via an
API endpoint), Node.js processes the request, runs any necessary logic (like querying a
database or calling an NLP service), and sends back a response.

API Integration (Server-Side):

If the chatbot uses an external API for NLP or any other service, Node.js sends a request to
the appropriate service.

The runtime handles the asynchronous nature of these calls. The server does not wait idly
for the response; instead, it continues handling other incoming requests while waiting for the
NLP API to respond.

Once the NLP API responds (e.g., the intent and entities from the message are identified),
Node.js processes the response and formulates a reply.

If necessary, the server can perform additional operations (like querying a database or
generating dynamic content).

3. SYSTEM DESIGN
3.1 INPUT DESIGN

Input design is the process of converting user-oriented inputs to a computer-based


format. The quality of the system input determines the quality of system output. Input design
is a part of the overall system design, which requires very careful attention. If the data going
into the system is incorrect then the processing and output will magnify these errors.

Designs are used to enter message to the chatbot. The concept of a loop within a
conversation is intangible. We can speak to it, but it‘s not always so easy to define what‘s
actually happening, and it‘s even harder to visualize. Designing a conversation has many
similarities to designing an interface, it‘s just a matter of finding where they overlap and
extending the concept.

15
At the most basic level, a loop could consist of a user bouncing from one card to the
next, and back again. If we were to visualize this with each circle representing a card, a single
piece of content, within the bot.

Input Design is the process of converting a user-oriented description of the input into a
computer-based system. This design is important to avoid errors in the data input process and
show the correct direction to the management for getting correct information from the
computerized system. It is achieved by creating user-friendly screens for the data entry to
handle large volume of data. The goal of designing input is to make data entry easier and to
be free from errors.

Input design must capture all the data that the system needs, without introducing any
errors. Input error can be greatly reduced when inputting directly by,

Entry box - The Entry box used to enter queries or messages by the user. User can insert
multiline text as a input.

Send button - Send button in this chatbot accustomed-to send the messages and queries to
the chatbot. In this stage the messages send by the user are browsed in json.

Scrollbar - If there is long chat is exists, we need to go top first to the end of chat . For this
case we need scrollbar. By using scrollbar user can easily move the chat up and down

4.2 OUTPUT DESIGN


Output design is very important concept in the computerized system, without reliable
output the user may feel the entire system is unnecessary and avoids using it. The proper
output design is important in any system and facilitates effective decision-making.

A quality output is one, which meets the requirements of the end user and presents the
information clearly. In any system results of processing are communicated to the users and to
other system through outputs. In output design it is determined how the information is to be
displaced for immediate need and also the hard copy output. It is the most important and
direct source information to the user. Efficient and intelligent output design improves the
system‘s relationship to help user decision-making.

16
Designing computer output should proceed in an organized, well thought out manner;
the right output must be developed while ensuring that each output element is designed so
that people will find the system can use easily and effectively.

When analysis design computer output, they should Identify the specific output that is
needed to meet the requirements. Select methods for presenting information. Create
document, report, or other formats that contain information produced by the system.

The output design is an ongoing activity almost from the beginning of the project, and
follows the principles of form design. Effects and well define an output design improves the
relationship of system and the user, thus facilitating decision-making.

A quality output is one, which meets the requirements of the end user and presents the
information clearly. In any system results of processing are communicated to the users and to
other system through outputs. It is the most important and direct source information to the
user. Efficient and intelligent output design improves the system‘s relationship to help user
decision-making.

Chatlog
Chatlog is the area that shows output of the queries asked by user. Chatbot read data sets in
the json file and transfer the data which is needed for the user‘s question.

4.3 DATABASE DESIGN


The database design is the process of producing a detailed information of a database.
Database is the place where the actual data sets are stored .We can retrieve it whenever we
need and store more data. Update, delete, adding are possible in dataset.

HDF5 - The h5py package is a Pythonic interface to the HDF5 binary data format.
HDF5 lets you store huge amounts of numerical dat a, and easily manipulate that data from
NumPy. For example, you can slice into multi-terabyte datasets stored on disk, as if they were
real NumPy arrays.

17
JSON - JSON JavaScript Object Notation is a format for structuring data. It is mainly
used for storing and transferring data between the browser and the server. Python too supports
JSON with a built-in package called json. This package provides all the necessary tools for
working with JSON Objects including parsing, serializing, deserializing, and many more.

Pickle in Python is primarily used in serializing and deserializing a Python object


structure. In other words, it's the process of converting a Python object into a byte stream to
store it in a file/database, maintain program state across sessions, or transport data over the
network. Data integration

In a database, information from several file are coordinated, accessed and operated upon as
through it is in a single file. Logically, the information are centralized, physically, the data
may be located on different devices, connected through data communication facilities.

Data integrity
Data integrity means storing all data in one place only and how each application to access it.
This approach results in more consistent information, one update being sufficient to achieve a
new record status for all applications which use it.

Conceptual design
The next step is to form a concise description of the data requirements using a high level data
model. This description would be independent of storage requirements. This step involves
identifying entities involves in the system, and the relationship between the different entities.
Entities and relationships are depicted in the form of a diagram called the Entity relationship
Diagram.

4.4 MODULE DESCRIPTION

The project consists of the following modules display as follows.


A) User
B) Chatbot
C) Information
A) USER

Text to machine: User will ask the computer to run command by giving input as text.

18
Command execution: Based on command received from the user, system will execute
the command(if available). Eg. Greetings

Machine to text: Once a command is received ,application speaks the command which
make user experience more interactive with the system.

B) CHATBOT

To make conversation between human and machine.


The machine has been embedded knowledge to identify the sentences and making a
decision itself as response to answer a question.

User can chat with the bot it implies as if enquiring to the college details.

C) INFORMATION
It can answer the questions asked by the user whatever question that is related to
college.

It search and gives that particular college information.

4.5 DATA FLOW DIAGRAM

19
F.1: DATA FLOW DIAGRAM

5. TESTING AND IMPLEMENTATION


5.1 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

20
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.

UNIT TESTING
Unit testing involves the design of test cases that validate that the internal program
logic is functioning properly, and that program input produces valid outputs. All decision
branches and internal code flow should be validated. The testing of an individual software
unit of the application. This is a structural testing, that relies on knowledge of a construction
and it‘s invasive. Unit tests perform basic tests at component level and test a specific business
process, application, and/or system configuration. Unit tests ensure that each unique path of a
business process perform accurately to the documented specifications and contains clearly
defined inputs and expected results.

INTEGRATION TESTING

Integration testing is specifically aimed at exposing the problems that arise from the
combination of components. The purpose of integration testing is to verify functional,
performance, and reliability requirements placed on major design items.

Integration tests are designed to test software components to determine if the user
actually run as one program. Testing is event driven and is more concerned with the basic
outcome of screens or fields. Integration tests demonstrate that although the components were
individually satisfaction, as shown 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.

VALIDATION TESTING

At the culmination of integration testing, software completely assembled as a package,


interfacing errors have been uncovered and corrected, and a final series of software tests.
Validation testing may begin. Validation can be defined in many ways, but a simple definition

21
is that validation succeeds when software functions in a manner that can be reasonably
expected by the customer.

Validation Testing is the testing used for data validation. The data type and value of
the data is tested in the validation testing process. In the proposed system, the password is the
only data for testing. There is no need to check the data type of any data in the proposed
system.

5.2 IMPLEMENTATION

Implementation is the stage of the project when the theoretical design is turned out
into a working system. Thus it can be considered to be the most critical stage in achieving a

22
successful new system and in giving the user, confidence that the new system will work and
be effective. The implementation stage involves careful planning, investigation of the existing
system and it‘s constraints on implementation, designing of methods to achieve changeover
and evaluation of changeover methods.

The major tasks involved in the implementation are:


Computer based/system testing.
Training the user personnel
Full system testing and making the necessary changes as desired by the user.
Change over.
Maintenance.
The implementation strategy used is the parallel changeover. The automated system has
been put to use gradually so that its usage can prove better for the concern. After the system
has been tested, the implementation type or the change over technique from the existing
system to the new system is a step-by-step process. When the end-user related to the
particular module is satisfied with the performance, the next step of implementation is
preceded.

Implementation Procedures
Implementation means converting older system to a new design in operation. This involves
creating computer capable files and basic software needed to run this system. The basic
concept for implementation needed is software installation and system requirements. So in
order to implement them, suitable hardware and software must be available. Now the
computer is ready for implementing the proposed system.

23
6. CONCLUSION AND FUTURE ENHANCEMENT
6.1 CONCLUSION

The main objectives of the project were to develop an algorithm that will be used to
identify answers related to user submitted questions. To develop a database were all the
related data will be stored and to develop a web interface. The web interface developed had
two parts, one for simple users and one for the administrator. A background research took
place, which included an overview of the conversation procedure and any relevant chatbots
available. A database was developed, which stores information about questions, answers,
keywords, logs and feedback messages.

An evaluation took place from data collected by potential data‘s of the college. Also
after received feedback from the first deployment, extra requirements were introduced and
implemented. The more a person interacts with chatbots, the more trends, and patterns the
system identifies based on the information it receives. Then, this data can be utilized to
determine user preferences and tastes, which is a long-term selling point for making a home
smarter.

6.2 FUTURE ENHANCEMENT

Set up voice terminals for chatbot. While voice interface may be optional, chatbots have
been in the enterprise long enough for developers and experts to begin identifying what
elements of chatbots are mainstay requirements.

NLP development, human-like conversational flexibility and 24/7 service are crucial to
maintaining chatbots' longevity in enterprise settings. Chatbots are AI devices and, looking
ahead, they need to keep up with AI trends, such as automated machine learning, easy system
integration and developing intelligence.

Adding face detection and face recognition in chatbot. The R&D centers of various
organizations are teaching chatbots to behave as humans do.

Chatbots are getting the skills of humans, and it will increase the rate of satisfaction. So
chatbots are becoming more human for outstanding results while benefiting the customers.

24
REFERENCES
BOOK REFERENCES:
1. Emanuela Haller and Traian Rebedea, ―Designing a Chat-bot that Simulates an
Historical figure‖, IEEE Conference Publications, July 2013.
2. Young Steve, A review of Large-vocabulary continuous-speech recognition, IEEE SP
Magazine, 13:45- 57,1996, ISSN 1053-5888.

3. Maja Pantic, Reinier Zwitserloot, and Robbert Jan Grootjans, ―Teaching


Introductory
Artificial Intelligence Using A simple Agent Framework‖, IEEE Transactions on
education, Vol. 48. No. 3. August 2005.

WEBSITE REFERENCES:
1. https://docs.python.org/3/
2. https://github.com/parulnith/Building-a-Simple-Chatbot-in-Python-using-NLTK
3. https://www.edureka.co/blog/how-to-make-a-chatbot-in-python/
4. https://keras.io/
5. https://www.nltk.org/
6. https://www.tensorflow.org/tutorials
7. https://numpy.org/
8. https://chatterbot.readthedocs.io/en/stable/
9. https://stackoverflow.com/
10. https://www.pythonanywhere.com/

25
APPENDICES
A. SAMPLE CODING

Chat_GUI.py
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 - splitting words into array
sentence_words = nltk.word_tokenize(sentence) #
stemming every word - reducing to base form

sentence_words = [lemmatizer.lemmatize(word.lower()) for word in sentence_words]


return sentence_words

# return bag of words array: 0 or 1 for words that exist in sentence def
bag_of_words(sentence, words, show_details=True):

# tokenizing patterns sentence_words =


clean_up_sentence(sentence)

# bag of words - vocabulary matrix


bag = [0]*len(words) for s in
sentence_words:

26
for i,word in enumerate(words):
if word == s:

# assign 1 if current word is in the vocabulary position


bag[i] = 1 if show_details: print ("found in
bag: %s" % word) return(np.array(bag))

def predict_class(sentence): # filter below threshold


predictions p = bag_of_words(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]
# sorting strength 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

#Creating tkinter GUI


import tkinter from
tkinter import * def
send():

msg = EntryBox.get("1.0",'end-1c').strip()

27
EntryBox.delete("0.0",END)

if msg != '':
ChatBox.config(state=NORMAL)
ChatBox.insert(END, "You: " + msg + '\n\n')
ChatBox.config(foreground="#446665", font=("Verdana", 12 ))

ints = predict_class(msg)
res = getResponse(ints, intents)

ChatBox.insert(END, "Bot: " + res + '\n\n')

ChatBox.config(state=DISABLED)
ChatBox.yview(END)

root = Tk() root.title("Chatbot")


root.geometry("400x500")
root.resizable(width=FALSE, height=FALSE)

#Create Chat window


ChatBox = Text(root, bd=0, bg="white", height="8", width="50", font="Arial",)

ChatBox.config(state=DISABLED)

#Bind scrollbar to Chat window


scrollbar = Scrollbar(root, command=ChatBox.yview, cursor="heart")
ChatBox['yscrollcommand'] = scrollbar.set

#Create Button to send message

28
SendButton = Button(root, font=("Verdana",12,'bold'), text="Send", width="12", height=5,
bd=0, bg="#f9a602", activebackground="#3c9d9b",fg='#000000', command= send )

#Create the box to enter message


EntryBox = Text(root, 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)
ChatBox.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)

root.mainloop()

Train_chat.py import numpy as np from


keras.models import Sequential from keras.layers
import Dense, Activation, Dropout from
keras.optimizers import SGD import random

import nltk from nltk.stem import


WordNetLemmatizer lemmatizer =
WordNetLemmatizer() import json import
pickle

words=[] classes
= [] documents
= []

ignore_letters = ['!', '?', ',', '.']

29
intents_file = open('intents.json').read() intents
= json.loads(intents_file)

for intent in intents['intents']: for pattern in


intent['patterns']: #tokenize each word
word = nltk.word_tokenize(pattern)
words.extend(word) #add documents in
the corpus documents.append((word,
intent['tag']))

# add to our classes list if


intent['tag'] not in classes:
classes.append(intent['tag'])
print(documents)

# lemmaztize and lower each word and remove duplicates words =


[lemmatizer.lemmatize(w.lower()) for w in words if w not in ignore_letters] words =
sorted(list(set(words)))

# sort classes classes =


sorted(list(set(classes)))

# documents = combination between patterns and intents print


(len(documents), "documents")

# classes = intents print (len(classes),


"classes", classes) # words = all
words, vocabulary

print (len(words), "unique lemmatized words", words)

pickle.dump(words,open('words.pkl','wb')) pickle.dump(classes,open('classes.pkl','wb'))

# create our training data training


= []

# create an empty array for our output output_empty


= [0] * len(classes)

# training set, bag of words for each sentence

30
for doc in documents: #
initialize our bag of words
bag = []

# list of tokenized words for the pattern


pattern_words = doc[0]

# lemmatize each word - create base word, in attempt to represent related words
pattern_words = [lemmatizer.lemmatize(word.lower()) for word in pattern_words]
# create our bag of words array with 1, if word match found in current pattern for
word in words:

bag.append(1) if word in pattern_words else bag.append(0)

# output is a '0' for each tag and '1' for current tag (for each pattern)
output_row = list(output_empty) output_row[classes.index(doc[1])]
=1

training.append([bag, output_row]) #
shuffle our features and turn into np.array
random.shuffle(training) training =
np.array(training)

# create train and test lists. X - patterns, Y - intents


train_x = list(training[:,0]) train_y =
list(training[:,1]) print("Training data created")

# Create model - 3 layers. First layer 128 neurons, second layer 64 neurons and 3rd output
layer contains number of neurons

# equal to number of intents to predict output intent with softmax model


= Sequential() model.add(Dense(128, input_shape=(len(train_x[0]),),
activation='relu')) model.add(Dropout(0.5)) model.add(Dense(64,
activation='relu')) model.add(Dropout(0.5))

model.add(Dense(len(train_y[0]), activation='softmax'))

31
# Compile model. Stochastic gradient descent with Nesterov accelerated gradient gives good
results for this model sgd = SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True)
model.compile(loss='categorical_crossentropy', optimizer=sgd, metrics=['accuracy'])

#fitting and saving the model hist = model.fit(np.array(train_x), np.array(train_y),


epochs=200, batch_size=5, verbose=1) model.save('chatbot_model.h5', hist)

print("model created")

intents.json
{"intents": [
{"tag": "greetings",
"patterns": ["hello","hey","hi","good day","Greetings","what's up?","how is it going?"],
"responses": ["Hello!","Hey!","What can I do for you?"]

},
{"tag": "name",
"patterns": ["what is your name","name","what's your name","who are you","what should I
call you"],

"responses": ["You can call me Snitch","I'm Snitch","I'm Snitch your virtual assistant"]
},

{"tag": "patterns",
"patterns": ["How you could help me?", "What you can do?", "What help you provide?",
"How you can be helpful?", "What support is offered"],
"responses": ["I can guide you through \n1. Courses\n2. Course duration\n3. Fees\n4.
Location\n5. Semester\n6. Sem Duration\n7. Admission Requirement\n8. Classes\n9. Exams\
n10. Hours\n11. Facilities\n12. Fun Activities"]

},
{"tag": "courses",

32
"patterns": ["what courses are available", "how many courses are there in this
college","courses"],

"responses": ["Erode Sengunthar Engineering College is an Autonomous college in Erode.It


is affiliated with Anna University. Course's Offered, \n\n1. B.E\n\n2. M.E\n\n3. B.Tech\n\n4.
M.Tech\n\n5. MBA\n\n6. MCA"]

},
{"tag": "courseDuration",
"patterns": ["how long will it take to complete course","course duration"],
"responses": ["For B.E, B.Tech it will take 4years,\n\n For M.E, M.Tech, MBA, MCA it will
take 2years"]

},
{"tag": "Location",
"patterns": ["location","where is it located","what is the location of the college"],
"responses": ["Erode Sengunthar Engineering College is Located in Thudupathi, 5km from
Perundurai, Erode, Tamilnadu, India."]
},

{"tag": "semesters",
"patterns": ["how many semesters are there in a year","how many semesters one should study
in a year","how many semesters per year","semesters"],

"responses": ["There are two semesters in a year."]


},
{"tag": "semDuration",
"patterns": ["how many months are there in a semester","how long will be a single
semester","sem duration"],

"responses": ["The single semester will be around 4 months."]


},
{"tag": "studentRequirements",
"patterns": ["what are the student requirements for admission","entry
requirements","admission requirements"],

"responses": ["Eligibility \n1. B.E - 10+2 with 50%+TNEA\\n\\n2. M.E - Graduation with

33
50% + GATE\\n\\n3. B.Tech - 10+2 with 50% + TNEA\\n\\n4. M.Tech - Graduation with
50% + GATE\\n\\n5. MBA - Graduation with 50% + TANCET\\n\\n6. MCA - Graduation
with 50% + TANCET"]

},
{"tag": "classes",
"patterns": ["how many classes will be there in a day","how long are the classes?","classes"],
"responses": ["There may be four or five classes per day. Each class will be of 1 hour and 30
minutes."]

},

{"tag": "exams",
"patterns": ["what are the exams like?","What is the exam pattern","exams"],
"responses": ["There are assignments which carry more weight than your written exams. The
assignments have deadlines which you should not exceed if you want to get better marks."]

},
{"tag": "hours",
"patterns": ["what are your hours","when are you guys open","what your hours of operation"],

"responses": ["You can message us here at any hours. But our college premises will be open
from 7:00 am to 5:00 pm only."]

},
{"tag": "funActivities",
"patterns": ["will there be any extra curriculum activities?","does the college conducts any
fun program"],

"responses": ["Yes, Of course. Our college not only provides excellent education but also
encourage students to take part in different curriculum activities. The college conducts yearly
programs like Sports meet, Carnival, Holi festival, and Etc. \n Also our college has basketball
court, badminton court, table tennis, chess, carrom board and many more refreshment zones.\
n There are many intra college meet and inter college meets."] },

34
{"tag": "facilities",

"patterns": ["what facilities are provided by the college?","what are the facilities of college
for students", "what are the college infrastructures "],

"responses": ["With excellent education facilities, Our College provides various other
facilities like 24 hours internet, library, classes with AC, discusson room, canteen, parking
space, and student service for any students queries."]

},
{"tag": "fee",
"patterns": ["how much is the college fee","what is the fee structure"],
"responses": ["Fees Structure per year, \n\n1. B.E - 60000\n\n2. M.E - 50000\n\n3. B.Tech -
60000\n\n4. M.Tech - 35000\n\n5. MBA - 50000\n\n6. MCA - 41000"]

},
{"tag": "goodbye",
"patterns": ["cya","See you later","Goodbye","I am leaving","Have a Good Day","bye","see
ya"],

"responses": ["Sad to see you go :(","Talk you later","Goodbye"]


},
{"tag": "invalid",
"patterns": ["","gvsd","asbhk"],
"responses": ["Sorry, can't understand you", "Please give me more info", "Not sure I
understand"]

},

{"tag": "thanks",
"patterns": ["Thanks", "Thank you", "That's helpful", "Awesome, thanks", "Thanks for
helping me"],

"responses": ["Happy to help!", "Any time!", "My pleasure"]


}

35
]}

B. SAMPLE INPUT

F.2: CHATBOT INTERFACE

36
C. SAMPLE OUTPUT

F.3: TRAINING DATA CREATED

37
F.4: CHATBOT RESPONCE - 1

38
F.5: CHATBOT RESPONCE - 2

39
F.6: CHATBOT RESPONCE - 3

40
F.7: CHATBOT RESPONCE - 4

41
F.8: CHATBOT RESPONCE - 5

42
F.9: CHATBOT RESPONCE - 6

43
44

You might also like