Course Project Report For: Artificial Intelligence EL-3011
Course Project Report For: Artificial Intelligence EL-3011
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
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.
PYTHON Program:
import nltk
from nltk.stem.lancaster import LancasterStemmer
stemmer = LancasterStemmer()
import numpy
import tflearn
import tensorflow
import random
import json
import pickle
try:
with open("data.pickle", "rb") as f:
words, labels, training, output = pickle.load(f)
except:
words = []
labels = []
docs_x = []
docs_y = []
labels = sorted(labels)
training = []
output = []
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)
tensorflow.reset_default_graph()
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")
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
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
$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.