You are on page 1of 5

An overview of NLP based Chatbot

Jayshree Ghorpade-Aher Riddhi Kontamwar Simran Kukreja


Dept. of Computer Engineering Dept. of Computer Engineering
Dept. of Computer Engineering
MITCOE MITCOE
MITCOE
Pune, India Pune, India
Pune, India
Email:ridkont@gmail.com Email:simrankukreja2911@gmail.com
Email: jayshree.aj@gmail.com

Tejal Karpe Saloni Kakkad


Dept. of Computer Engineering
Dept. of Computer Engineering
MITCOE MITCOE
Pune, India
Pune, India
Email:salonikakkad12345@gmail.com
Email:tejal1633@gmail.com

Abstract— A chatbot is a software that simulates a As chatbots have gained popularity over the last few
conversation with a human in a generalized form through years, most of them are rule-based in which output of the
various applications like messaging, websites, mobile linear conversations is predetermined. For most cases, this
applications, etc. Traditionally, a search engine was used to works fine. However, chatbots can do much more than this.
answer any type of questions, but with the advancement in
With the introduction of NLP, developers are now able to put
technology the use of chatbot has increased and it allows the
user to simply ask any question in a same manner they would the chat in chatbots .[1]
communicate with humans. The interesting features of this is that NLP is a technical process that allows machines to extract
they are self-learning and become intelligent over time using meaning from user text inputs. It aims to understand the intent
technologies like Machine Learning and Natural Language of the input instead of just obtaining information about the
Processing(NLP). This paper provides a brief overview of the use intent itself. With NLP, it is possible to train the chatbot on
of NLP in chatbot as well as the working of different algorithms. various conversations it will go through and help to give the
It studies various machine learning algorithms used for responses. The training part consists of providing the content
developing chatbots. examples it might come across. Providing more training set to
the chatbot gives it a wider knowledge base with which it can
Keywords— Chatbot, NLP (Natural Language Processing),
Supervised Machine Learning, Entity, Classification. interpret and answer the questions.[3]
In this paper, working of chatbot is described thoroughly.
The section II gives the use of NLP in chatbot and section III
I. INTRODUCTION
explains the steps in NLP. The section IV explains various
supervised algorithms. Lastly, the conclusion is given in
With advancement in World Wide Web, the human-
section V.
machine interaction plays vital role in the digital world. In
order to expand and elevate the simplicity of user
II. NLP IN CHATBOT
communication with any system, interaction between human
and machine is essential.
A chatbot is a service or a tool that the user can communicate
“Our Differentiation starts with the third dimension of with via text messages. The chatbot understands what the user
Chatbots. We call it the Human Dialogue Theory.” is trying to say and replies with a coherent, relevant message
– Riza Berkan. or directly completes the desired task by using NLP.

A chatbot is a software which has been designed to There are two components of NLP:
imitate an intelligent conversation with end user. In the past, 1. Natural Language Understanding
there has been a significant hike in interest in chatbots. Few of 2. Natural Language Generation
the current scenarios are as follows:
• DOM, The Pizza Bot, Dominos: It helps user to
1. Natural Language Understanding:
order dominos pizza of their choice via facebook
messenger account, and DOM allows the user to
customize their pizza hassle free. In NLU, the input gets transformed into the useful
• Allo, Google: It helps in various tasks like finding representations in order to analyze various aspects of the
scores, dinner reservations etc. language. NLU has two specific concepts:
• Tay, Microsoft: It is developed by Microsoft on Entities: Entities are basically nouns to represent an idea
Twitter. It was capable of interacting with twitter to chatbot.
users. Context: When a NLU algorithm considers a sentence, it
• KLM Royal Dutch Airlines: This bot helps the users doesn’t have the historical data of the user’s conversation.
to get the current updates of their flights, check-in This implies that, if a same question is asked again and
notifications of Dutch Airlines. chatbot has got the response, it won’t recall the previous
inquiry. So, the phases during the conversation of chat are
separately stored. It can either be banners like "Asking about
admission process". i. POS Tagging: The part of speech for each word
A chatbot must fulfill customer's needs which can be the is determined for each sentence.
same for different queries. For example, "I want to know
about the college reading hall" and "Do you have a reading ii. Text Lemmatization: It is a linguistic process
hall? I want to know about it", it is the same: details of reading that attempts to determine the root of each word.
hall. Hence, all user typing text show a single command which The lemma of word is its basic form along with
is identifying the tag: reading hall. its inflected forms.

Example: "A Computer is a programmable machine."


2. Natural Language Generation:
POS Tagging: A|Article, Computer|Noun, is|Verb,
In order to generate the output text, the intermediate programmable|Adjective, machine|Noun.
representation requires to be converted back to natural
language format. Hence, it is the process of producing Lemma(root): Compute, Program
meaningful phrases and sentences in the form of natural
language from some internal representation. Step 3: Semantic Analysis- It draws the exact meaning or the
It involves: dictionary meaning from the text. The text is checked for
• Text Planning: It includes extracting the relevant meaningfulness. It is checked by portraying syntactic
content from knowledge base. structures and objects in the task domain. The semantic
analyzer ignores sentence described as “The ice-cream is
• Sentence Planning: It includes selecting required hot”.
i. Identifying Stopwords: It is a list of empty
words, forming language grammar, setting tone of the
words in a terms list (prepositions, determiners,
sentence.
pronouns etc.) considered to have little semantic
value, and are eliminated when found in
• Text Realization: It is the process of mapping the
document.
planned sentence into sentence structure.
Example: "What is the capital of India?"
III. STEPS OF NLP Stopwords: is, the, of
Chatbots uses the NLP to convert the user’s text into Step 4: Discourse Integration- The meaning of any sentence
structured data which is then used for choosing the relevant depends upon the meaning of the sentence just before it. In
answer [8]. NLP includes the following steps: addition, it also finds the meaning of its successor sentences.
Step 1: Lexical Analysis- It identifies and analyzes the i. Dependency Parsing: It figures out how all the
structure of words. The collection of words and phrases in a words in the sentence are related to each other. It
language is called a Lexicon. Lexical analysis divides the searches for the subjects, verbs, objects,
whole text into paragraphs, sentences, and words. common phrases and nouns in the user’s text to
discover related phrases that what users want to
i. Sentence Segmentation: The first step is to split convey.
the text into separate sentences.
ii. Detecting N-Grams: It consists in identifying
ii. Word Tokenization: This step breaks a stream words that are usually together (compound
of text into words, phrases or other meaningful words) to be able to process them as a single
elements called tokens. It separates the words in conceptual unit.
order to extract knowledge.
iii. Co-reference Resolution: It is the task of
Example: "Education is the process of facilitating learning. A finding all expressions that refer to the same
right to education has been recognized by all Governments." entity in a given text.

Sentence Segmentation: Example: "I am a student of Computer Department. Who is


Sentence 1: Education is the process of facilitating learning. the HOD of this department?"
Sentence 2: A right to education has been recognized by all
Governments. N-Grams: Computer Department

Word Tokenization: Education, is, the, process, of, facilitating, Co-reference Resolution: In this example, “this” refers to
learning. “Computer Department”.

Step 2: Syntactic Analysis (Parsing)- It involves analysis of Step 5: Pragmatic Analysis- During this, what was said is re-
words in the sentence to check grammar and arrangement of interpreted on what it actually meant. It involves deriving
words in a manner that shows the relationship among the those aspects of language which require real world
words. The sentence such as “The food like the girl" is knowledge.
rejected by English syntactic analyzer.
i. Named Entity Recognition: It looks for Recursive Division stops only when the following conditions
different categories of words, similar to the name are true:
of the specific entity, the user’s address, 1. All sample data of a given node belongs to the same
whatever information is required. class, that is, value of all flag attribute are same.
2. No remaining backup attribute can be used to divide
Example: "Apple CEO Tim Cook introduced two new larger the sample further.
Iphones at Cupertino, Flint Center Event." 3. After split, certain branch does not have any sample
record.
NER: Apple, Flint Center: Name of Organization
Tim Cook: Name of Person In the decision tree, the first question is the root of the tree.
Cupertino: Name of Location From there, the chatbot might need additional information in
order to solve the problem, moving the conversation from up
to down. The more specific a query is, the more branches will
IV. ALGORITHMS AND TECHNIQUES be needed to solve it, and the more branches you create, the
more intelligent and helpful the chatbot will be.
A. Decision Tree:

Decision trees are how chatbots help customers find B. Naïve Bayes Algorithm:
exactly what they are looking for: they follow a step-by-step
process to discover the accurate answer to the customer’s It is a probabilistic classification technique which is based
question in a conversational way. The decision tree algorithm: on Bayes' theorem with an assumption of independence
ID3 (Iterative Dichotomiser 3) → uses Entropy function and assumptions among the features. Basically, a Naive Bayes
Information Gain as metrics.[11]
classifier assumes that the presence of a particular feature in a
class is unrelated to the presence of any other feature. For
The Information Gain can be calculated as:
example, if a human wants to know which engineering fields
are there in that particular college, the bot will first read the
data and further partition it into two parts like engineering and
non-engineering and accordingly split the data and answer the
...(1) human [14].
Naive Bayes model is easy to build. It is particularly
Entropy can be calculated as:
useful for very large data sets. This algorithm is capable of
self-categorizing the databases in an efficient way.

...(2)

Steps to build ID3 decision tree:

Step 1: Decision Tree begins with a single node which


represents all records (as roots) of the entire training set.

Step 2: If the sample records are in the same category,


then the nodes become leaf nodes, and are marked with
the classification the sample records belong to.

Step 3: Otherwise, the algorithm will use measure based


on entropy called as information gain, as the heuristic
information, and select the attribute which can achieve the
best classification from sample backup attribute set. This
attribute become to this node’s “test” or “judge” attribute.
In this version of this algorithm, all descriptive attributes
are classified, namely take discrete values, and continuous Figure 1: Naive Bayes workflow
numeric attributes must be discretizing.

Step 4: Create a branch for certain test attribute’s every Bayes theorem provides a way of calculating the
known value, and divided the sample data into every probability P(c|x) from P(c), P(x) and P(x|c). Refer the
branch according this. equation (3) below:[15]

Step 5: The algorithm does the same way through the


above procedure recursively, to form a sample decision ...(3)
tree for each division. Once an attribute has been selected
as the test attribute of a node, you do not have to consider
the likelihood that test this node’s any descendant nodes’
attribute.
V. PROPOSED STRUCTURE OF CHATBOT [2] Chen, H, Machine learning for information retrieval:
Neural networks, symbolic learning, and genetic algorithms. J.
Am. Soc. Inf. Sci., 46: 194-216

[3] B. Setiaji and F. W. Wibowo, "Chatbot Using a


Knowledge in Database: Human-to-Machine Conversation
Modeling," 2016, 7th International Conference on Intelligent
Systems, Modeling and Simulation (ISMS), Bangkok, pp. 72-
77.

[4] Y. Yang, X. Huang, X. Hao, Z. Liu and Z. Chen, "An


Industrial Study of Natural Language Processing Based Test
Case Prioritization," 2017 IEEE International Conference on
Software Testing, Verification and Validation (ICST), Tokyo,
pp. 548-549.
Figure 2: Workflow of chatbot
[5] Quote, Riza Berkan founder of exClone Inc.,
The above figure 2 shows the workflow of chatbot. It consists https://emerj.com/ai-podcast-interviews/when-will-chatbots-
of the following entities: reach-human-level-sophistication/
1. Input Query: It is the user input which is fed to the system [6] A. Gelbukh, "Natural language processing," Fifth
for further processing. International Conference on Hybrid Intelligent Systems
(HIS'05), Rio de Janeiro, Brazil,2005,pp.1pp.-.doi:
2. NLU Steps: These are the pre-processing steps used for 10.1109/ICHIS.2005.79
extracting information from input query.
[7] B. R. Ranoliya, N. Raghuwanshi and S. Singh, "Chatbot
3. Classification Algorithm: There are different machine for university related FAQs," 2017 International Conference
learning algorithms such as Decision Tree or Naive Bayes’ for on Advances in Computing, Communications and Informatics
text classification in order to extract the most relevant answer (ICACCI), Udupi,2017,pp.1525-1530.doi: 10.1109/ICACCI.
for the given input query. 2017.8126057

4. Retrieval from Database: Based on the query , the [8] A. Singh, N. Thakur and A. Sharma, "A review of
response is retrieved from the database and output is given to supervised machine learning algorithms," 2016 3rd
user. International Conference on Computing for Sustainable
Global Development (INDIACom), New Delhi, pp.1310-1315.
5. NLG: If the relevant answer is not present in the database
then the answer is generated. [9] S. Angra and S. Ahuja, "Machine learning and its
applications: A review," 2017 International Conference on
6.Output: Response is given to the user. Big Data Analytics and Computational Intelligence
(ICBDAC), Chirala, 2017, pp.57-60.

V. CONCLUSION [10] R.R.Halde, "Application of machine learning algorithms


for betterment in education system," 2016 International
With the rising trend of chatbot and along with the passage of Conference on Automatic Control and Dynamic Optimization
time, new features can be added in the existing platform. This Techniques(ICACDOT), Pune, 2016, pp. 1110-1114.
paper discusses the most commonly used supervised machine
learning algorithms for the implementation of chatbot. [11] Linna Li and Xuemin Zhang, "Study of data mining
Advancements in the machine learning techniques may be algorithm based on decision tree," 2010 International
able to handle complex conversation issues. Chatbots can Conference On Computer Design and Applications,
reach out to large audience through apps, websites and can be Qinhuangdao, 2010, pp. V1-155-V1-158.
more effective than humans. It may turn into an information
gathering tool in near future. [12] E. Haller and T. Rebedea, "Designing a Chatbot that
simulates a Historical Figure," 2013 19th International
Conference on Control Systems and Computer Science,
REFERENCES Bucharest, 2013, pp. 582-589

[1] A. M. Rahman, A. A. Mamun and A. Islam, [13] J.Song. et al. , TOLA : Topic-oriented learning
"Programming challenges of chatbot: Current and future assistance based on cyber-physical system and big data.
prospective," 2017 IEEE Region 10 Humanitarian Technology Future generation computer systems(2016), http
Conference (R10-HTC), Dhaka, 2017,pp.75-78. doi: ://dx,doi.org.10.1016/j.future.2016.05.040
10.1109/R10-HTC.2017.8288910
[14] F. Qin, X. Tang and Z. Cheng, "Application and research
of multi-label Naïve Bayes Classifier," Proceedings of the
10th World Congress on Intelligent Control and Automation,
Beijing, 2012, pp. 764-768.

[15] M. Niranjan, M. S. Saipreethy and T. G. Kumar, "An


intelligent question answering conversational agent using
Naïve Bayesian classifier," 2012 IEEE International
Conference on Technology Enhanced Education (ICTEE),
Kerala, 2012, pp. 1-5.

[16] Jingnian Chen, Houkuan Huang, Shengfeng Tian, Youli


Qu,Feature selection for text classification with Naïve
Bayes,Expert Systems with Applications, 2009, ISSN 0957-
4174.

[17] Y. Huang and L. Li, "Naive Bayes classification


algorithm based on small sample set," 2011 IEEE
International Conference on Cloud Computing and
Intelligence Systems, Beijing, pp. 34-39.

[18] Sang-Bum Kim, Kyoung-Soo Han, Hae-Chang Rim and


Sung Hyon Myaeng, "Some Effective Techniques for Naive
Bayes Text Classification," in IEEE Transactions on
Knowledge and Data Engineering, vol. 18, no. 11, pp. 1457-
1466, Nov. 2006.

[19] G. M. D'silva, S. Thakare, S. More and J. Kuriakose,


"Real world smart chatbot for customer care using a software
as a service (SaaS) architecture," 2017 International
Conference on I-SMAC (IoT in Social, Mobile, Analytics and
Cloud), Palladam, 2017, pp. 658-664.

[20] A. Augello, G. Pilato, A. Machi and S. Gaglio, "An


Approach to Enhance Chatbot Semantic Power and
Maintainability: Experiences within the FRASI Project," 2012
IEEE Sixth International Conference on Semantic Computing,
Palermo, pp. 186-193.

[21] M. C. Surabhi, "Natural language processing future,"


2013 International Conference on Optical Imaging Sensor and
Security (ICOSS), Coimbatore, 2013, pp. 1-3.

[22] H. N. Io and C. B. Lee, "Chatbots and conversational


agents: A bibliometric analysis," 2017 IEEE International
Conference on Industrial Engineering and Engineering
Management (IEEM), Singapore,2017,pp.215-219. doi:
10.1109/IEEM.2017.8289883

You might also like