Chatbot Report
Chatbot Report
UNIVERSITY CHATBOT
By
CERTIFICATE
This is to certify that the project report entitled
to APJ Abdul Kalam Technological University is a record of bona fide work done by
him/her under my supervision and guidance and this work has not been submitted
elsewhere for any degree or diploma.
Guided by
Dr. G. KIRUTHIGA
LAKSHMI RAJAGOPAL Head of department
Asst. Professor Department of Computer Science &
Department of Computer Science & Engineering
Engineering IES College of Engineering Chittilappilly,
IES College of Engineering Thrissur
Chittilappilly,
Thrissur
Department of Computer Science & Engineering Project Report 2019-20
ACKNOWLEDGMENT
Department of computer science and Engineering, for their immense support in the
successful completion of the project.
We would like to express my sincere thanks to my parents for the love, support
and encouragement they provided me throughout the project. We also extend my heartfelt
thanks to all my friends who helped me directly and indirectly through their valuable
support for our project.
Above all we would like to acknowledge the lord almighty, the foundation of all
wisdom who has been wonderfully guiding us step by step.
i
Department of Computer Science & Engineering Project Report 2019-20
ABSTRACT
Most of the time, Students have to visit universities or colleges to collect various
information like Tution fees, Term Schedule, etc. during their admission process or as per
their daily needs. This process is very tedious and time consuming, also it requires
manpower in providing required information to visitors. Hence, to overcome the problems
a chatbot can be developed. The project is about interaction between users an chatbot
which can be accessed from anywhere anytime. The chatbot can be easily attached with
any university or college website with few simple language conversions. Chatbot provides
various information related to university or college and also students-related information.
The chatbot can be used by anyone who can access the university’s website. The
project uses the concept of Artificial Intelligence and Machine Learning. User can ask
university-related questions, then the query is applied as an input to algorithm, which
processes the message and displays the corresponding response to the user. The Project
GUI is similar to a Messaging Application.
ii
Department of Computer Science & Engineering Project Report 2019-20
CONTENTS
ACKNOWLEGMENT i
ABSTRACT ii
CONTENTS iii
CHAPTER 1
INTRODUCTION 1
1.1 GENERAL 1
1.2 OBJECTIVES 1
CHAPTER 2
LITERATURE SURVEY 2
2.1 ARTIFICIALLY INTELLIGENT CHATBOT 2
2.2 A TOOL OF CONVERSATION: CHATBOT 2
2.3 AN INTELLIGENT BEHAVIOUR SHOWN BY 3
CHATBOT SYSTEM FOR BANKING IN VERNACULAR
LANGUAGES
2.4 COLLEGE ENQUIRY CHATBOT USING A.L.I.C.E 4
2.5 CHATBOT FOR UNIVERSITY RELATED FAQs 4
CHAPTER 3
EXISTING SYSTEM 6
3.1 DISADVANTAGES OF EXISTING SYSTEM 7
CHAPTER 4
PROPOSED SYSTEM 8
CHAPTER 5
SYSTEM REQUIREMENTS 9
5.1 HARDWARE REQUIREMENTS 9
5.2 SOFTWARE REQUIREMENTS 9
CHAPTER 6
SYSTEM DESIGN 10
6.1 ARCHITECTURAL DIAGRAM 10
6.2 MODULE DESCRIPTION 12
6.2.1 TRAINING MODULE 12
6.2.2 PREPROCESSING MODULE 13
6.2.3 TESTING MODULE 13
CHAPTER 7
SYSTEM IMPLEMENTATION 14
7.1 LANGUAGE DESCRIPTION 16
CHAPTER 8
RESULTS 18
8.1 SCREENSHOTS 19
CHAPTER 9
iii
Department of Computer Science & Engineering Project Report 2019-20
CONCLUSION 19
REFERENCES 20
ANNEXURES 21
ANNEXURE 1: DATAFLOW DIAGRAM 21
ANNEXURE 2: SAMPLE CODE 22
iv
Department of Computer Science & Engineering Project Report 2019-20
LIST OF FIGURES
v
Department of Computer Science & Engineering Project Report 2019-20
LIST OF ABBREVIATIONS
Acronyms Description
GUI Graphical user interface
AI Artificial intelligence
FAQ Frequently asked questions
AIML Artificial intelligence markup language
LSA Latent semantic analysis
IDE Integrated development environment
API Application programming interface
CI Continuous integration
JSON Javascript object notation
vi
Department of Computer Science & Engineering Report Project 2019-20
CHAPTER 1
INTRODUCTION
1.1 GENERAL
The project deals with user’s request in form of question based message and processes it to
deliver a desired response in form of message. It solves the process of visiting colleges and
gathering related information as per the needs, as it is time consuming. Also, the user can
communicate to admin office with telephone number provided but doesn’t receive a positive
feedback. The project is a web-based chatbot. Graphical User Interface (GUI) is much similar to
messaging application, which provides a friendly environment to the user as they are much
aware of operating messaging applications. The user types a question and on performing submit,
the message is preprocessed and the most relevant information from the database is provided as a
response in similar way of messaging. Developing a chatbot solves the problems that can arouse
in gathering required information. It can be accessed from anywhere at anytime. In various
websites, users are not able to find the required information on website which in turn end up
closing the websites, which can be fulfilled by using chatbot.
1.2 OBJECTIVES
• Guide the user through the conversation not to let him wonder what he should do or
say.
• Cover all possible answers and questions for core bot use cases.
CHAPTER 2
LITERATURE SURVEY
2
IES college of engineering,chittillapilly
Department of Computer Science & Engineering Report Project 2019-20
In today’s world computers play an important role in our society? Computers give us
information, they entertain us and help us in lots of manners. A chatbot is a program designed to
counterfeit a smart communication on a text or spoken ground. But this paper is based on the text
only chatbot. Chatbot recognize the user input as well as by using pattern matching, access
information to provide a predefined acknowledgment. For example, if the user is providing the
bot a sentence like “What is your name?” The chatbot is most likely to reply something like “My
name is Chatbot.” or the chatbot replies as “You can call me Chatbot.” based on the sentence
given by the user. When the input is bringing into being in the database, a response from a
predefined pattern is given to the user. A Chatbot is implemented using pattern comparing, in
which the order of the sentence is recognized and a saved response pattern is acclimatize to the
exclusive variables of the sentence. They cannot register and respond to complex questions, and
are unable to perform compound activities. Chatbot is relatively a new technology. The
application of a Chatbot can be seen in various fields in the future.
Chabot are extremely valuable for businesses and this value will only increase as time
goes by. On obvious area of Chabot implementation is customer service. Waiting on hold may
soon be a thing of the past as they become advanced enough to deal with basic level customer
services queries and this had made their technical support much more responsive and immediate.
This has resulted in significant cost reduction.
The ability to identify the user’s intent and extract the data and relevant entities contained
in the user’s request is the primary condition and the most relevant step at the core of a Chabot.
If Chabot are not able to correctly understanding the user request, it won’t be able to provide
correct answers. The Chabot must identify the user context to manage the conversation state,
3
IES college of engineering,chittillapilly
Department of Computer Science & Engineering Report Project 2019-20
flow and branching. The proposed Chabot identify the user context that helps to trigger the
particular intent alone for generating response to the user.
4
IES college of engineering,chittillapilly
Department of Computer Science & Engineering Report Project 2019-20
serve user satisfaction. This chatbot can be used by any University to answer FAQs to curious
students in an interactive fashion.
5
IES college of engineering,chittillapilly
Department of Computer Science & Engineering Report Project 2019-20
CHAPTER 3
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 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.
ALICE:
• ALICE is consists of two parts,Chatbot engine and Language Model. Language model is
stored in AIML (Artificial Intelligence Mark-up Language)files.
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.
6
IES college of engineering,chittillapilly
Department of Computer Science & Engineering Report Project 2019-20
3.1 DISADVANTAGES
• After the close observation of voice-to- text agents like SIRI ,it is clear that
1. At times SIRI can’t understand what we told her to do due to language
differences.
2. It cannot answer for complex queries.
7
IES college of engineering,chittillapilly
Department of Computer Science & Engineering Report Project 2019-20
CHAPTER 4
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.
8
IES college of engineering,chittillapilly
Department of Computer Science & Engineering Report Project 2019-20
CHAPTER 5
REQUIREMENT ANALYSIS
• JAVA
Used for backend app development.
• XML
Used for frontend app development.
9
IES college of engineering,chittillapilly
Department of Computer Science & Engineering Report Project 2019-20
CHAPTER 6
SYSTEM DESIGN
10
IES college of engineering,chittillapilly
Department of Computer Science & Engineering Report Project 2019-20
• The database is the most important part of any system. The table is created as below and
the data is entered in such a way that if a question has more than one answers, then they
are stored in Answer 2 and Answer 3 fields.
• Also, the Question only contains keywords rather than particular natural language
question as shown in Table I.
• Unibot provides details such as departmental syllabus, events, admission procedure and
fees, basic university details, class timetable, important circulars,etc
11
IES college of engineering,chittillapilly
Department of Computer Science & Engineering Report Project 2019-20
Bot includes tools that help simplify the process of training a chat bot instance. UniBot’s training
process involves loading example dialog into the chat bot’s database. This either creates or
builds upon the graph data structure that represents the sets of known statements and responses.
When a chat bot trainer is provided with a data set, it creates the necessary entries in the chat
bot’s knowledge graph so that the statement inputs and responses are correctly represented.
Several training classes come built-in with UniBot. These utilities range from allowing
you to update the chat bot’s database knowledge graph based on a list of statements representing
a conversation, to tools that allow you to train your bot based on a corpus of pre-loaded training
data.
12
IES college of engineering,chittillapilly
Department of Computer Science & Engineering Report Project 2019-20
Preprocessor functions
• unibot.preprocessors.clean_whitespace(statement)
Remove any consecutive whitespace characters from the statement text.
• unibot.preprocessors.unescape_html(statement)
Convert escaped html characters into unescaped html characters. For example:
“<b>” becomes “<b>”.
• unibot.preprocessors.convert_to_ascii(statement)
Converts unicode characters to ASCII character equivalents. For example: “på fédéral”
becomes “pa federal”.
13
IES college of engineering,chittillapilly
Department of Computer Science & Engineering Report Project 2019-20
CHAPTER 7
SYSTEM IMPLEMENTATION
The program selects the closest matching response by searching for the closest
matching known statement that matches the input, it then chooses a response from the
selection of known responses to that statement.
14
IES college of engineering,chittillapilly
Department of Computer Science & Engineering Report Project 2019-20
Logic Adapters
Logic adapters determine the logic for how UniBot selects a response to a given input
statement.
The logic adapter that your bot uses can be specified by setting the logic_adapters
parameter to the import path of the logic adapter you want to use.
It is possible to enter any number of logic adapters for your bot to use. If multiple
adapters are used, then the bot will return the response with the highest calculated
confidence value. If multiple adapters return the same confidence, then the adapter that is
entered into the list first will take priority.
A confidence value and the selected response statement should be returned. The confidence
value represents a rating of how accurate the logic adapter expects the selected response to be.
Confidence scores are used to select the best response from multiple logic adapters.
The confidence value should be a number between 0 and 1 where 0 is the lowest confidence
level and 1 is the highest.
A logic adapter that returns a response based on known responses to the closest matches to the
input statement.The best match adapter uses a function to compare the input statement to known
statements. Once it finds the closest match to the input statement, it uses another function to
select one of the known responses to that statement.
The MathematicalEvaluation logic adapter parses input to determine whether the user is asking a
question that requires math to be done. If so, the equation is extracted from the input and
returned with the evaluated result.
If the input that the chat bot receives, matches the input text specified for this adapter, the
specified response will be returned.
16
IES college of engineering,chittillapilly
Department of Computer Science & Engineering Report Project 2019-20
➢XML
Extensible Markup Language (XML) is a markup language that defines a set of rules for
encoding documents in a format that is both human-readable and machine-readable. Developers
uses the XML files for following purposes: Storing the data for some application such as menu
data or data for some comobox., to generate the dynamic content by applying different Style
sheets. XML is also used to develop the content management systems.
17
IES college of engineering,chittillapilly
Department of Computer Science & Engineering Report Project 2019-20
CHAPTER 8
RESULTS
8.1 SCREENSHOTS
18
IES college of engineering,chittillapilly
Department of Computer Science & Engineering Report Project 2019-20
CHAPTER 9
CONCLUSION
AI chatbot is the best tool which provides quick way to interact with the users. It is very
helpful to the users as it allows to enter questions in natural language and desired information
is obtained easily to the user. In this presentation, details about design, algorithm used and
implementation of the Unibot is presented. The user doesn’t need to gather information by
visiting websites or colleges.
19
IES college of engineering,chittillapilly
Department of Computer Science & Engineering Report Project 2019-20
REFERENCES
Drishti Malik, Vibhor Sharma, Monika Goyal, "An intelligent behaviour shown by chatbot
system", International Journal of New Technology and Research, 2017.
Balbir Singh Bani, Ajay Pratap Singh, "College Enquiry Chatbot Using A.L.I.C.E", International
Journal of New Technology and Research, 2017.
Nitesh Thakur, Akshay Hiwrale, Sourabh Selote, Abhijeet Shinde, Namrata Mahakalkar,
"Artificially Intelligent Chatbot" in , Nagpur:Department of Computer Science & Engineering,
Priyadarshini Institute of Engineering & Technology.
ANNEXURES
Figure indicates algorithm of proposed system. User can ask university-related questions,
then the query is applied as an input to algorithm, which processes the message and displays the
corresponding response to the user.
import android.widget.Toast;
import com.android.volley.DefaultRetryPolicy;
import com.android.volley.NetworkResponse;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.RetryPolicy;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonArrayRequest;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.Volley;
import com.example.upendra.myapplication.Model.Message;
import com.example.upendra.myapplication.R;
import com.example.upendra.myapplication.Util.Config;
import org.json.JSONArray;
import org.json.JSONObject;
import org.xml.sax.Parser;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import io.realm.Realm;
import io.realm.RealmResults;
import static android.R.id.message;
public class MainActivity extends AppCompatActivity {
private String name="";
SharedPreferences prefs;
Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btnSend = (Button) findViewById(R.id.btnSend);
inputMsg = (EditText) findViewById(R.id.inputMsg);
listViewMessages = (ListView) findViewById(R.id.list_view);
context = getApplicationContext();
queue = Volley.newRequestQueue(context);
inflater = getLayoutInflater();
messageList = new ArrayList<>();
prefs = getSharedPreferences("userId", 0);
if(prefs.getInt("userId", 0) != 0){
name = prefs.getString("firstname","");
}
realm = Realm.getInstance(context);
RealmResults<Message> results = realm.where(Message.class).findAll();
if(results.size()>0)
{
realm.beginTransaction();
Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btnSend = (Button) findViewById(R.id.btnSend);
inputMsg = (EditText) findViewById(R.id.inputMsg);
listViewMessages = (ListView) findViewById(R.id.list_view);
context = getApplicationContext();
queue = Volley.newRequestQueue(context);
inflater = getLayoutInflater();
messageList = new ArrayList<>();
prefs = getSharedPreferences("userId", 0);
if(prefs.getInt("userId", 0) != 0){
name = prefs.getString("firstname","");
}
realm = Realm.getInstance(context);
@Override
public void onResponse(JSONObject response) {
if (response != null && response.length() > 0) {
try {
if(response.getInt("success")==1)
{
realm.beginTransaction();
Message message = realm.createObject(Message.class);
JSONObject m = response.getJSONObject("message");
message.setChatBotName(m.optString("chatBotName", ""));
message.setChatBotID(m.optInt("chatBotID"));
message.setMessage(m.optString("message", ""));
message.setEmotion(m.optString("emotions",null));
message.setSelf(false);
realm.commitTransaction();
appendMessage(message);
}
else
{
String error=response.getString("errorMessage");
Toast.makeText(getApplicationContext(), "Error: "+error,
Toast.LENGTH_SHORT).show();
}
} catch (Exception e) {
Toast.makeText(getApplicationContext(), "json parse error: " +
e.getMessage(), Toast.LENGTH_SHORT).show();
}
} else {
// errors
Toast.makeText(getApplicationContext(), "Retry Later ",
Toast.LENGTH_SHORT).show();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
NetworkResponse networkResponse = error.networkResponse;
Log.e(TAG, "Volley error: " + error.getMessage() + ", code: " +
networkResponse);
Toast.makeText(getApplicationContext(), "Volley error: " +
error.getMessage(), Toast.LENGTH_SHORT).show();
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Message m = messagesItems.get(position);
LayoutInflater mInflater = (LayoutInflater) context
.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
if (messagesItems.get(position).isSelf()) {
convertView = mInflater.inflate(R.layout.list_item_message_right,
null);
} else {
convertView = mInflater.inflate(R.layout.list_item_message_left,
null);
}
TextView lblFrom = (TextView) convertView.findViewById(R.id.lblMsgFrom);
TextView txtMsg = (TextView) convertView.findViewById(R.id.txtMsg);
txtMsg.setText(m.getMessage());
lblFrom.setText(m.getChatBotName());
return convertView;
}
}
private void appendMessage(final Message m) {
runOnUiThread(new Runnable() {
@Override
public void run() {
messageList.add(m);
mAdapter.notifyDataSetChanged();
// Playing device's notification
playBeep();
}
});
}
private boolean networkIsAvailable(final Context context) {
final ConnectivityManager connectivityManager = ((ConnectivityManager)
context.getSystemService(Context.CONNECTIVITY_SERVICE));
return connectivityManager.getActiveNetworkInfo() != null &&
connectivityManager.getActiveNetworkInfo().isConnected();
}
@Override
protected void onResume() {
super.onResume();
}
@Override
public void onBackPressed() {
super.onBackPressed();
}
}