0% found this document useful (0 votes)
310 views9 pages

Report For Chatbot Using NLTK Library Using Python Programming Python For Machine Learning (Int 522)

This document is a report submitted by Asha Lakkoju for an M-Tech course on building a chatbot using the NLTK library in Python. It introduces chatbots and their uses, describes the key NLTK libraries for natural language processing, and provides code to create a basic rule-based chatbot along with sample outputs. The report concludes that chatbots are transforming businesses by improving customer engagement and that their role will continue growing in importance through more advanced conversational abilities.

Uploaded by

Radhika Goyal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
310 views9 pages

Report For Chatbot Using NLTK Library Using Python Programming Python For Machine Learning (Int 522)

This document is a report submitted by Asha Lakkoju for an M-Tech course on building a chatbot using the NLTK library in Python. It introduces chatbots and their uses, describes the key NLTK libraries for natural language processing, and provides code to create a basic rule-based chatbot along with sample outputs. The report concludes that chatbots are transforming businesses by improving customer engagement and that their role will continue growing in importance through more advanced conversational abilities.

Uploaded by

Radhika Goyal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 9

REPORT FOR CHATBOT USING NLTK LIBRARY USING

PYTHON PROGRAMMING
AS A PROJECT WORK FOR COURSE

PYTHON FOR MACHINE LEARNING (INT 522)

NAM E : LAKKOJU ASHA


REGISTRATION NUMBER : 12100819
PROGRAM : M-TECH (MACHINE LEARNING & ARTIFICIAL
INTELLIGENCE)

SEMESTER : SEMESTER ONE


SCHOOL : SCHOOL OF COMPUTER SCIENCE AND
ENGINEERING
NAME OF UNIVERSITY : LOVELY PROFESSIONAL UNIVERSITY
DATE OF SUBMISSION : NOVEMBER 20, 2021

Lovely Professional University


Jalandhar, Punjab, India

1|Page
TABLE OF CONTENTS :
S.NO CONTENTS PAGE NO’S

1 Abstract 3

2 Introduction: 3-4
2.1 What is chatbot?
2.2 Why we use chatbot?
2.3 Types of chatbots
3 Libraries: 4-7
NLTK
3.1 Install library
3.2 Chat
3.3 Reflection
3.4 Creating set of rules
3.5 Defining Function
4 Code : Github link 7

5 Sample Output of the program 8

6 Conclusion 8-9

2|Page
BUILDING A CHATBOT USING NLTK LIBRARY IN PYTHON:

1. ABSTARCT :
What is a chatbot? How does it help to accelerate your business yield? How can
you build your own chatbot?
Chatbots are interactions between people and services, enhancing customer
experience. At the same time, they offer companies new opportunities to
improve the customers engagement process and operational efficiency by
reducing the typical cost of customer service.
To be successful, a chatbot solution should be able to effectively perform both
of these tasks. Human support plays a key role here: Regardless of the kind of
approach and the platform, human intervention is crucial in configuring,
training and optimizing the chatbot system.
It helps millions of people around the world get things done more easily every
day. Learn how Assistant works with content and services to help you find just
what you're looking for.

2. INTRODUCTION:

2.1 What is a Chatbot?


A chatbot can be defined as an AI based computer program that simulates
human conversations. They are also known as digital assistants that
understand human capabilities. Bots interpret the user intent, process their
requests, and give prompt relevant answers.
Bots can communicate through voice as well as text and can be deployed
across websites, applications, and messaging channels such as Facebook
Messenger, Twitter, or Whatsapp.
In its simplest form, chatbots can be programmed to answer specific,
frequently asked questions, offering an easy way to engage with visitors.
On the other hand, Artificial Intelligence (AI) - powered chatbots can
learn from user behavior and previous agent interactions to predict visitor

3|Page
behavior and offer relevant information. Using chatbots can help
automate interactions and offer instant accessibility across sales,
marketing, and customer service functions.
2.2 Why we use chatbots?
 Cost and Time Effective - Humans cannot be active on-site 24/7 but
chatbots can and the replying power of chatbots is much fast than
humans.
 Cheap Development cost - with the advancement in technology many
tools are developed that help easy development and integration of
chatbots with little investment.
 Human Resource - Today Chatbots can also talk with text o speech
technology so it gives the feel as a human is talking on another side.
 Business Branding - Businesses are changing with technology and
chatbot is one out of them. Chatbot also helps in advertising,
branding of organization product and services and give daily updates
to users.
2.3 Types of Chatbots?
There are mainly 2 types of chatbots.

 Rule-based Chatbots – As the Name suggests, there are certain


rules on which chatbot operates. Like a Machine learning model,
we train the chatbots on user intents and relevant responses, and
based on these intents chatbot identifies the new user’s intent and
response to him.
 Self-learning chatbots – Self-learning bots are highly efficient
because they are capable to grab and identify the user’s intent on
their own. they are build using advanced tools and techniques of
Machine Learning, Deep Learning, and NLP. Self-learning bots
are further divided into 2 subcategories.
Retrieval-based chatbots:- Retrieval-based it is somewhat the same as
Rule-based where predefined input patterns and responses are embedded.
Generative-Based chatbots:- It is based on the same phenomenon as
Machine Translation build using sequence 2 sequences neural network.

4|Page
Most of the organization uses self-learning chatbot along with embedding
some rules like Hybrid version of both methods which makes chatbot
powerful to handle each situation during a conversation with a customer.

3. LIBRARIES IMPORTED :

3.1 NLTK:
NLTK is a standard python library with prebuilt functions and utilities
for the ease of use and implementation. It is one of the most used
libraries for natural language processing and computational
linguistics.
It used to deal with NLP applications and chatbot is one among them.
Now we will advance our Rule-based chatbots using the NLTK
library. Please install the NLTK library first before working using the
pip command.
NLTK Installation process:
 Open a command prompt and type:
pip install nltk
First thing is to import the library and classes we need to use
 import nltk
from nltk.chat.util import Chat, reflections

3.2 CHAT :
Chat is a class that contains complete logic for processing the text
data which the chatbot receives and find useful information out of it.

3.3 REFLECTIONS :
Another import we have done is reflections which is a dictionary
containing basic input and corresponding outputs. You can also create

5|Page
your own dictionary with more responses you want. if you print
reflections it will be something like this.

 #importing nltk library.


import nltk
from nltk.chat.util import Chat, reflections

3.4 CREATING SET OF RULES:


After importing the libraries, First, we have to create rules. The lines
of code given below create a simple set of rules. the first line
describes the user input which we have taken as raw string input and
the next line is our chatbot response. You can modify these pairs as
per the questions and answers you want.

6|Page
3.5 DEFINING FUNCTION:
The function is very simple which first greet the user, and ask for any
help. And the conversation starts from here by calling a Chat class
and passing pairs and reflections to it.

def chat():
print("Hi! I am a chatbot created by Asha, How may I help you?")
chat = Chat(pairs, reflections)
chat.converse()
#initiate the conversation
if __name__ == "__main__":
chat()
I have created an amazing Rule-based chatbot just by using Python
and NLTK library. The nltk.chat works on various regex patterns
present in user Intent and corresponding to it, presents the output to a
user. Let’s run the application and chat with created chatbot.

4. GITHUB LINK :

https://github.com/AshaLakkoju/Chatbot.git

Here is the Link for the chatbot using nltk library using python

7|Page
5. SAMPLE OUTPUT OF THE PROGRAM:

Here in first step we greeted the chatbot, it responded in return


Second step we can ask some questions like:

 Planning our day


 Getting local information
 Ask : Updates, calculation, Translation, Finance, search. Etc,
 Play media : like music, podcasts, news
 Have fun : Get to know our assistance, Games, Entertainment.

Finally we can end conversation by telling – see you or bye to our Chatbot

6. CONCLUSION:

Chatbots are the top application of Natural Language processing and today it is simple
to create and integrate with various social medial handle and websites. Today most
Chatbots are created using tools like Dialogflow, RASA, etc. This is a quick
introduction to chatbots to present an understanding of how businesses are
transforming using Data science and artificial Intelligence.
Anyone can create their own Chatbot using simple Algorithms. They inhabit
platforms like – FB Messenger, Whatsapp, Skype, Slack, Line, Kik, Wechat and so
on.

8|Page
Today, the number of chatbots are keeps growing, and more and more brands are
starting to understand the main business benefits of chatbots.

The futuristic scope of chatbot technology: Now, as you are aware of what a chatbot
is and how important bot technology is for your business. You will certainly agree
that bots have drastically changed the way businesses interact with their customers.

Chatbot technologies will become a vital part of customer engagement strategy going
forward. Near to future bots will advance to enhance human capabilities and human
agents to be more innovative, in handling strategic activities.

In Future, we can see more number of chatbots using different libraries in certain
fields with respect to their usage.

9|Page

You might also like