You are on page 1of 22

A Project Report on

“Chatbot Using Natural Language Processing(NLP)”

Submitted in partial fulfillment as a requirement for the award of degree of

BACHELOR OF COMPUTER APPLICATION

Submitted by

Under the guidance of


Ms. Rashmi S
Assistant Professor, Department of Computer Science
S.B.R.R. Mahajana First Grade College
Mysore-12

Department of Computer Science and Applications


SBRR MAHAJANA FIRST GRADE COLLEGE
Jayalakshmipuram,
Mysore – 12
CHAPTER 1

INTRODUCTION
1.1 Topic introduction

Chat has become the center of focus in this current era, thus the bots are being utilized to
deliver information engagingly and conveniently. A chatbot is standout amongst the most
progressive and promising tools of communication among people and machines. Famous
chatbots like Google Assistant, Amazon Alexa, Siri, Facebook, Slack, and many more are in
trend. These are very much helpful, but in this era of enhancing technology, day by day
technology gets updated, and accordingly, user expectations also increase. A user wants more
automation in the chatbot. Although every system is not perfect there is always a flaw in the
system, so as in the chatbot there are some problems that the user has experienced while
using a chatbot. Chatbot can be described as an answering system where a system will be
able to answer questions or statements submitted by users and allow users to control over the
content to be displayed. A bot is trained on and according to the training, based on some rules
on which it is trained, it answers questions. It is called ruled based approach. Using these
ruled based approach, creation of these bots becomes relatively straight forward. But it is not
sufficient for the bot to answer questions whose pattern does not match with the rules on
which it is trained. The language by which these bots can be created are Artificial Intelligence
Markup Language(AIML). It is a language based on XML which allows the developer to
write the rules which bot will follow.

1.2 Objective of the project

A chatbot can communicate with a real person behaving like a human.


Let’s list down objectives and purpose of chatbots.
You can create chatbots for any business the same as you recruit a person for any department
of your company. Whether you are a:
➢ Wedding Planner
➢ Insurance Assistant
➢ Education Consultant
➢ Legal Assistant
➢ A real estate business
➢ Recruiter
➢ Travel Agency
➢ Hospital or a Beautician!

1.3 Motivation of project

Chatbots play a key role as human- computer interfaces. It’s a software that simulates typed
conversation, with the agenda of temporarily luring the human into thinking they were talking
to another human. Chatbot, basically acts as a conversational agent that can talk to any user in
given field using the Natural Language Processing. According to World Health Organization
(WHO), stress is the major cause of mental disorder throughout the world, posing threats to
over 300 million each year globally. With a rapid increase in the need for additional
assistance, the bot aims to create an environment that is less automated and more
conversational. Thus to overcome this stress, the chatbot provides insights and provides
positive responses through cognitive-behavioural therapy.

1.4 Project Overview

A chatbot can communicate with a real person behaving like a human. A chatbot is merely a
computer program that fundamentally simulates human conversations. It allows a form of
interaction between a human and a machine the communication, which happens via messages
or voice command.
A chatbot is programmed to work independently from a human operator. It can answer
questions formulated to it in natural language and respond like a real person. A chatbot is like
a normal application. There is an app layer, a database and APIs to call other external
administrations. Users can easily access chatbots, it adds intricacy for the application to
handle.
However, there is a common problem that must be tackled. It can’t comprehend the plan of
the customer. At the moment, bots are trained according to the past information available to
them. So, most organizations have a chatbot that maintains logs of discussions. Developers
utilize these logs to analyze what clients are trying to ask. With a blend of machine learning
tools and models, developers coordinate client inquiries and reply with the best appropriate
answer. For example, if any customer is asking about payments and receipts, such as, “where
is my product payment receipt?” and “I haven’t received a payment receipt?”, both sentences
are taken to have the same meaning.
If there is no comprehensive data available, then different APIs can be utilized to train the
chatbot.

Training a chatbot :

Training a chatbot occurs at a considerably faster and larger scale than human education.
While normal customer service representatives are given a manual instruction which they
must be thorough with, a customer support chatbot is nourished with a large number of
conversation logs, and from those logs, the chatbot can understand what type of question
needs, what kind of answers.

1.5 Literature survey


1.Endurance: A Companion for Dementia Patients: Many people suffering with dementia
retain much of their conversational abilities as their illness progresses. However, the shame
and frustration that many dementia sufferers experience often make routine, everyday talks
with even close family members challenging. That’s why Russian technology company
Endurance developed its companion chat bot. Many people with Alzheimer’s disease struggle
with short-term memory loss. As such, the chatbot aims to identify deviations in
conversational branches that may indicate a problem with immediate recollection – quite an
ambitious technical challenge for an NLP-based system. In addition, since the chatbot is a
cloud- based solution, physicians and family members can review communication logs taken
from the bot to identify potential degradation of memory function and communicative
obstacles that could signify deterioration of the patient’s condition. Interestingly, the as-yet
unnamed conversational agent is currently an open- source project, meaning that anyone can
contribute to the development of the bot’s codebase. The project is still in its earlier stages,
but has great potential to help scientists, researchers, and care teams better understand how
Alzheimer’s disease affects the brain. A Russian version of the bot is already available, and
an English version is expected at some point this year.

2. Casper: Helping Insomniacs Get through the Night: If you suffer from insomnia, you’ll
know that the feeling of almost suffocating loneliness – the idea that everyone else in the
world is resting peacefully while your own mind betrays you with worries and doubts – is
among the worst parts of not being able to sleep. Enter Casper’s amazingly named In
somnobot 3000 (which truly is one of the most tongue in cheek, retro-futuristic names for a
chatbot I’ve ever come across), a conversational agent that aims to give insomniacs someone
to talk to while the rest of the world rests easy. At this point, In somnobot 3000 is a little
rudimentary. The responses offered by the agent aren’t quite right. But I’m not sure whether
chatting with a bot would help me sleep, but at least it’d stop me from scrolling through the
never-ending horrors of my Twitter timeline at 4 a.m.

3. UNICEF: Helping Marginalized Communities Be Heard: So far, with the exception of


Endurance’s dementia companion bot, the chatbots we’ve looked at have mostly been little
more than cool novelties. International child advocacy nonprofit UNICEF, however, is using
chatbots to help people living in developing nations speak out about the most urgent needs in
their communities. The bot, called U-Report, focuses on largescale data gathering via polls –
this isn’t a bot for the talkative. U-Report regularly sends out prepared polls on a range of
urgent social issues, and users (known as “UReporters”) can respond with their input.
UNICEF then uses this feedback as the basis for potential policy recommendations. In one
particularly striking example of how this rather limited bot has made a major impact,
UReport sent a poll to users in Liberia about whether teachers were coercing students into sex
in exchange for better grades. Approximately 86% of the13,000 Liberian children U-Report
polled responded that their teachers were engaged in this despicable practice, which resulted
in a collaborative project between UNICEF and Liberia’s Minister of Education to put an end
to it.

4. Med What: Making Medical Diagnoses Faster :If you’re the kind of person who has
WebMD bookmarked, it might be worth checking out Med What. This chatbot aims to make
medical diagnoses faster, easier, and more transparent for both patients and physicians –
think of it like an intelligent version of WebMD that you can talk to. MedWhat is powered by
a sophisticated machine learning system that offers increasingly accurate responses to user
questions based on behaviours that it “learns” by interacting with human beings. In addition
to the evergrowing range of medical questions fielded by MedWhat, the bot also draws upon
vast volumes of medical research and peer-reviewed scientific papers to expand upon its
already considerable wealth of medical expertise. In many ways, MedWhat is much closer to
a virtual assistant (like Google Now) rather than a conversational agent. It also represents an
exciting field of chatbot development that pairs intelligent NLP systems with machine
learning technology to offer users an accurate and responsive experience.

5. ALICE: The Bot That Launched a Thousand. Other Bots : No list of innovative Chatbots
would be complete without mentioning ALICE, one of the very first bots to go online – and
one that’s held up incredibly well despite being developed and launched more than 20 years
ago. ALICE – which stands for Artificial Linguistic Internet Computer Entity, anacronym
that could have been lifted straight out of an episode of The XFiles – was developed and
launched by creator Dr. Richard Wallace way back in the dark days of the early Internet in
1995. (As you can see in the image above, the website’s aesthetic remains virtually
unchanged since that time, a powerful reminder of how far web design has come.), Despite
the fact that ALICE relies on such an old codebase, the bot offers users a remarkably accurate
conversational experience. Of course, no bot is perfect, especially one that’s old enough to
legally drink in the U.S. if only it had a physical form. ALICE, like many contemporary bots,
struggles with the nuances of some questions and returns a mixture of inadvertently
postmodern answers and statements that suggest ALICE has greater selfawareness for which
we might give the agent credit. For all its drawbacks, none of today’s chatbots would have
been possible without the ground breaking work of Dr.Wallace. Also, Wallace’s bot served as
the inspiration for the companion operating system in Spike Jonze’s 2013 science- fiction
romance movie, Her.
Chapter 2

System Analysis
2.1 Introduction

2.2 Scope of the project

Chatbots seem some humane now.

Intelligent enough to understand the patterns and put across answers that are appropriate
and relevant, chatbots have come a long way. With efficient chatbot development
practices, they can be made capable of literally engulfing and processing whatever
information comes their way. They learn and develop a predictive analytical capability
just like humans.

Eventually, all they need is a stimulus.


Simple chatbots were capable of matching a text string and offering an answer only
when the exact match is found. When we said chatbots have come a long way, we
actually meant it. The advanced chatbots today have a learning curve powered by
artificial intelligence and is leading them to be of great significance.

Here’s the secret:

Today 100,000 chatbots are available on facebook messengers.

2.3 Hardware / Software Requirements :

➢ Hardware Requirements :

✓ Processor : i3
✓ RAM : 4GB
✓ HDD : 250GB

➢ Software Requirements :

✓ IDE/Editor : VS code
✓ Programming language : Python
2.4 Functional requirements :

➢ Chating :

✓ The system should allow users to chat.


✓ The system shall inform the user if an answer is not available.
✓ The system shall inform the user about spelling mistakes.
✓ The system shall inform the user about the validity of the sentence.

➢ Searching :

✓ The system should allow users to search for information about admissions.
✓ The system should allow users to search for information about tuition fees.
✓ The system should allow users to search for information about
accommodation.

➢ Logs :

✓ The system should maintain a log of the current question and answer if the
user is not satisfied.
➢ Feedback :

✓ The user should be able to leave feedback, which is comprised of a text


message and a rating.

➢ Administrative System :

✓ Information management: The administrator should be able to add, update


and delete questions, answers and keywords.
✓ Log management: The administrator should be able to view and delete logs.
✓ Feedback management: The administrator should be able to view and delete
feedbacks.

2.5 Non Functional Requirements :


➢ User Interface :

✓ The system shall maintain an easy to use interface across all functionality and
for all users
✓ The clients’ user interface should be compatible with all commonly used
browsers, such as Internet explorer, Firefox, Google chrome and Safari.
➢ Scalability :

✓ The system shall be able to scale based on the number of users using the
system.

➢ Security :

✓ The administrative system should be protected from unauthorized access.


✓ The database should protected from attacks and unauthorized access.
✓ The interface should be protected from attacks.
✓ All passwords should be stored as a secure hash of the administrator password.

➢ Third party interaction :

✓ The system should be able to interact with the Google spelling server, which
handles the spelling.
✓ The system should be able to interact with the Google search server, which is
used for the customized search on the admissions website.

➢ Portability :

✓ The system should run on a variety of operating systems that support the Java
language.
✓ The system should run on a variety of hardware.

➢ Maintainability :

✓ The system should be easy to maintain.


✓ There should be a clear separation of HTML and Java interface code.
✓ There should be a clear separation between the interface and the business logic
code.
✓ There should be a clear separation between the data access objects that map
the database and the business logic code.

➢ Exception Handling :

✓ Exceptions should be reported effectively to the user if they occur.

➢ Ethics :

✓ The system shall not store or process any information about its users.
2.6 User requirements :

➢ Complex Dialogues :

✓ In addition to understanding and interacting within conversations, an


outstanding chatbot software has NLP functions (Natural Language
Processing) to analyze the context of a conversation.

✓ It can identify the intent of a question to provide an accurate answer and


suggest options to confirm or resolve the issue.

✓ The best chatbots have advanced conversation features and can proactively
search for information and ask clarifying questions even if the conversation
is not linear.

➢ Flexible data connections :

✓ By using Knowledge Graphs, data can be structured and modeled, which in


turn helps to generate new knowledge.
✓ The chatbot can capture, read and process large amounts of data to gain
insights from relevant data and to quickly solve customer problems.

2.7 Feasibility study :

➢ Economic Feasibility.
➢ Technical Feasibility.
➢ Operational Feasibility.
➢ Social Feasibility.
➢ Schedule Feasibility.
Chapter 3

System Design
3.1 Introduction

A chatbot is a human-computer dialog system via natural language. Hence a human having a

natural conversation with a computer or system.

The chatbot must be able to have a dialog and understand the user; you could describe this is a

function of comprehension.

This comprehension include intent and entity recognition. Intents can be seen as verbs and

entities as nouns.

Text based bots have in the very least a Natural Language Understanding (NLU) component.

Where as a voice bot demands an initial speech recognition layer (speech to text) and a final

speech generation layer (text to speech).

All intelligence is not vested within the NLU capabilities. Bots must have access to an external

base of knowledge and common sense via API’s; such that it can provide the function of

competence, answering user questions.

Lastly the embodied agent should provide a very functional presence. Ironically these digital

agent did not exist up until recently and once regarded as very optional. Now this function

proves to be crucial in the case of ordinary users.

3.2 Existing System


A few chatbots with useful applications in our system are presented. We begin by discussing
the ELIZA chatbot system architecture and the working. Then we continue discussing about
other systems like ALICE and Siri . ELIZA It was one of the first chatbots, designed in
1966. It acts like a therapist by rephrasing statements of the user and posing them back as
questions. ELIZA works by simple parsing and substitution of key words into reframed
phrases. People get emotionally caught up by ELIZA’s confident replies forgetting that it’s a
machine . ELIZA was written at MIT by Joseph Weizenbaum between 1964 and 1966. The
most famous application of ELIZA was DOCTOR, a simulation of a Rogerian
psychotherapist. It had almost no information about human thought or emotion and still
DOCTOR sometimes provided a startlingly human-like interaction. When the "patient"
exceeded the very small set of knowledge, DOCTOR might prompt a generic response, for
example, responding to "I am sad" with "Why are you sad?", a possible response to "My
sister hates me" would be "Who else in your family hates you?". ELIZA was taken seriously
by several of its users, even after Weizenbaum explained to them that it’s not a human

➢ ALICE

ALICE (Artificial Linguistic Internet Computer Entity) is inspired by ELIZA. It is a natural


language processing chatbot—a program that engages in a conversation with a human by
applying some pattern matching rules to the user's query and then generating an appropriate
response . It has won the Loebner Prize, three times. However, the program is unable to pass
the Turing test, as even the casual user will often expose its flaws in short conversations.
ALICE is consists of two parts, Chatbot engine and Language Model. Language model is
stored in AIML (Artificial Intelligence Mark-up Language) files. As discussed earlier, AIML
consists of pattern and templates. Pattern is used for matching of the user query whereas the
response will be provided in template. Following is an example: how are you I am fine. In
this example, user’s input is matched against the pattern and when a match is found, the
pattern matching process stops, and the template that belongs to that category is processed by
the interpreter to construct the output. AIML has wildcards – denoted by star – which are
used for matching a string of one or more words in the input. AIML also has srai (symbolic
reduction) tags, which can be used for reducing the amount of pattern and templates. Using
srai a number of questions can be grouped and a similar response can be provided in the
template

➢ Siri

Siri was developed by Apple. Siri is a computer program that works as a virtual personal
assistant and knowledge navigator. The feature uses a natural language user interface to
answer questions, give suggestions, and perform actions by using a set of Web services. The
software adapts to the user's individual language usage and individual searches with
continuous use, and returns results that are personalized. Siri was originally introduced as an
iOS application available in the App Store by Siri, Inc., which was acquired by Apple on
April 28, 2010. Siri has been an integral part of iOS since iOS 5 and was introduced as a
feature of the iPhone 4S on October 14, 2011 . Siri evaluates your speech locally on your
device. A recognizer installed on your phone communicates with a server in the cloud to
determine whether the query can be best handled with the information in its databases or if it
must connect to the network for an advanced search
3.3 Proposed System:
We propose a system which will work as an application and give users information about
different kinds of sports present in the world. This application will work using a pattern
matching algorithm using depth first search (DFS). It will also convert user’s queries from
speech to text using a speech-to-text converter and back to speech as an output to the user.
Firstly, the user will speak his/her query out loud; the application will convert this query from
speech into text. The system finds out what the user actually wants by retrieving the semantic
meaning of the query. Then the system will pass on this semantic text as input to the pattern
matching algorithm. The pattern matching system will make use of knowledge that is already
fed into the databases in order to generate a response. Once this response is generated we will
convert it back into speech and the application will read the content out.

3.4 Definition of the Application Modules :

3.5 System Architecture Diagram :

3.6 Data Flow Diagram :

3.7 Entity Relationship Diagram :

3.8 Use Case Diagram :

3.9 Sequence Diagram/ Activity Diagram :

3.10 Schema of Normalized Database :


4. System implementation :

4.1 Description of Application modules in details :


Chapter 4

Testing
4.1 Unit Testing :

4.2 Integration Testing :

4.3 Regression Testing :

4.4 System Testing :

4.5 Security Testing :

4.6 Functional Testing :

4.7 Performance Testing :

4.8 Test cases (table) :


Chapter 5

Conclusion & Future Enhancements


5.1 Conclusion
5.2 Future Enhancements

You might also like