0% found this document useful (0 votes)
61 views8 pages

Course Project Report For: Artificial Intelligence EL-3011

1. Five students created a library assistance chatbot using TensorFlow in Python to help readers get information about book availability without visiting the library. 2. The chatbot was also created using Facebook Messenger to allow users to interact with the bot through messages and get responses regarding their queries. 3. The goal of the project was to replace human-human interaction at the library with a human-bot interaction to save users' time and provide easy access to library resources and information.

Uploaded by

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

Course Project Report For: Artificial Intelligence EL-3011

1. Five students created a library assistance chatbot using TensorFlow in Python to help readers get information about book availability without visiting the library. 2. The chatbot was also created using Facebook Messenger to allow users to interact with the bot through messages and get responses regarding their queries. 3. The goal of the project was to replace human-human interaction at the library with a human-bot interaction to save users' time and provide easy access to library resources and information.

Uploaded by

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

BRACT’s

Vishwakarma Institute of Technology, Pune-37


Department of Electronics Engineering

Course Project Report for Artificial Intelligence EL-3011

Class: TY-Elex Division: I

Semester I Academic Year: 2019-20

Student Details:
Sr. Name Class & Roll No. Gr.No.
No.
1 Darshan Nilesh Dodal I-37 182082
2 Rutik Sanjay Katkamwar I-66 182185
3 Lokesh Manojkumar Jangid I-56 182206
4 Atharva Kishore Lahurikar I-81 1710199
5 Krishna Kumar I-72 1710113

Course Project Name: Library assistance chatbot.

Aim: To create a chatbot that can help readers to get information regarding the availability of
books in library without the need of personally visiting the library.

Theory: A chatbot is an artificial intelligence-powered piece of software in a device (Siri, Alexa,


Google Assistant etc), application, website or other networks that try to gauge consumer’s needs
and then assist them to perform a particular task like a commercial transaction, hotel booking, form
submission etc. Today almost every company has a chatbot deployed to engage with the users. A
Library maneuvers with a social thought of providing valuable information resources to people
who can’t afford an extensive collection of books for professional assistance. It is one of the major
assets in a college. Thus a college focuses on maintaining and managing the details of the library
data with at most efficacy. The value of any information resource can be judged based on its
knowledge and utility and not on monetary. Hence it is necessary for an institution to take care of
providing the required support to teachers and students to effectively use the resources in a library.
The Library Chatbot is built using intelligence that analyses user requests and respond accordingly.
It is used to ensure the availability of books to the students and faculties of various academic years
and departments without visiting the library. The system replies using an effective chat interface
which implies that as if a real person is talking to the user. The user can request for information
about the library related activities through online with the help of this bot. It supports the user by
saving their time and provides data related to library resources and answers to simple queries. User
does not have to go personally to library to ensure the availability of books.
Approach 1: [Using NLTK (Natural Language Toolkit) ]
NLTK (Natural Language Toolkit) is a leading platform for building Python programs to work
with human language data. It provides easy-to-use interfaces to over 50 corpora and lexical
resources such as WordNet, along with a suite of text processing libraries for classification,
tokenization, stemming, tagging, parsing, and semantic reasoning, wrappers for industrial-strength
NLP libraries.
NLTK has been called “a wonderful tool for teaching and working in, computational linguistics
using Python,” and “an amazing library to play with natural language.”
Natural Language Processing with Python provides a practical introduction to programming for
language processing.

PYTHON Program:

import nltk
from nltk.stem.lancaster import LancasterStemmer
stemmer = LancasterStemmer()

import numpy
import tflearn
import tensorflow
import random
import json
import pickle

with open("intents.json") as file:


data = json.load(file)

try:
with open("data.pickle", "rb") as f:
words, labels, training, output = pickle.load(f)
except:
words = []
labels = []
docs_x = []
docs_y = []

for intent in data["intents"]:


for pattern in intent["patterns"]:
wrds = nltk.word_tokenize(pattern)
words.extend(wrds)
docs_x.append(wrds)
docs_y.append(intent["tag"])

if intent["tag"] not in labels:


labels.append(intent["tag"])
words = [stemmer.stem(w.lower()) for w in words if w != "?"]
words = sorted(list(set(words)))

labels = sorted(labels)

training = []
output = []

out_empty = [0 for _ in range(len(labels))]

for x, doc in enumerate(docs_x):


bag = []

wrds = [stemmer.stem(w.lower()) for w in doc]

for w in words:
if w in wrds:
bag.append(1)
else:
bag.append(0)

output_row = out_empty[:]
output_row[labels.index(docs_y[x])] = 1

training.append(bag)
output.append(output_row)

training = numpy.array(training)
output = numpy.array(output)

with open("data.pickle", "wb") as f:


pickle.dump((words, labels, training, output), f)

tensorflow.reset_default_graph()

net = tflearn.input_data(shape=[None, len(training[0])])


net = tflearn.fully_connected(net, 8)
net = tflearn.fully_connected(net, 8)
net = tflearn.fully_connected(net, len(output[0]), activation="softmax")
net = tflearn.regression(net)

model = tflearn.DNN(net)

try:
model.load("model.tflearn")
except:
model.fit(training, output, n_epoch=1000, batch_size=8, show_metric=True)
model.save("model.tflearn")

def bag_of_words(s, words):


bag = [0 for _ in range(len(words))]

s_words = nltk.word_tokenize(s)
s_words = [stemmer.stem(word.lower()) for word in s_words]
for se in s_words:
for i, w in enumerate(words):
if w == se:
bag[i] = 1

return numpy.array(bag)

def chat():
print("Start talking with the bot (type quit to stop)!")
while True:
inp = input("You: ")
if inp.lower() == "quit":
break

results = model.predict([bag_of_words(inp, words)])


results_index = numpy.argmax(results)
tag = labels[results_index]

for tg in data["intents"]:
if tg['tag'] == tag:
responses = tg['responses']

print(random.choice(responses))

chat()

Result:
Approach 2: Using Facebook Messenger
1. Create a Facebook App and Facebook Page.
2. Setup Web Hook
3. Get Page Access Token
4. Subscribe the App to the Page
5. Test your bot

PHP Program:

<?php

/* validate verify token needed for setting up web hook */


if (isset($_GET['hub_verify_token'])) {
if ($_GET['hub_verify_token'] === 'https://www.messenger.com/t/101993817961317') {
echo $_GET['hub_challenge'];
return;
} else {
echo 'Invalid Verify Token';
return;
}
}

/* receive and send messages */


$input = json_decode(file_get_contents('php://input'), true);
if (isset($input['entry'][0]['messaging'][0]['sender']['id'])) {

$sender = $input['entry'][0]['messaging'][0]['sender']['id']; //sender facebook id


$message = $input['entry'][0]['messaging'][0]['message']['text']; //text that user sent

$url = 'https://graph.facebook.com/v2.6/me/messages?access_token=PAGE_ACCESS_TOKEN';

/*initialize curl*/
$ch = curl_init($url);
/*prepare response*/
$jsonData = '{
"recipient":{
"id":"' . $sender . '"
},
"message":{
"text":"You said, ' . $message . '"
}
}';
/* curl setting to send a json post data */
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
if (!empty($message)) {
$result = curl_exec($ch); // user will get the message
}
}

?>

Results:
Conclusion:
• We have created a Library Chatbot using TensorFlow in python for the Students, Faculties,
Staffs and others.
• The Library can be accessed by using the chatbot to know their requirements of books
without visiting the Library physically.
• The Library bot saves time and replaces the human-human interaction into human-bot
interaction.
• The chatbot is still in its early days, but growing very fast.
• The main goal of creation of our library Chatbot is to allow the end user to have a
conversation with a bot, without considering a task oriented scenario and that we’ve
succeeded in our project.

References:

1) Prof.K.Bala, Mukesh Kumar, Sayali Hulawale, Sahil Pandita, “Chatbot for college management
system using A.I”, International Research Journal of Engineering and Technology, Volume: 04,
Issue: 11, Nov -2017
2) Sorna Shanthi.D, Keerthana.S, Nandha Kumar.PK, Nithya.D, “Hexabot: A Text-Based Assistive
Chatbot To Explore Library Resources”, International Journal of Engineering and Advanced
Technology (IJEAT), Volume-8, Issue-3S, February 2019
3) M. Dahiya, “A Tool of Conversation: Chatbot”, International Journal of Computer Sciences and
Engineering, Volume-5, Issue-5, May-2017.
4) Naveen Joshi, “Yesterday, today, and tomorrow of chatbots” Sunday 11, November 2018.

You might also like