CHATBOT
CHATBOT
CHATBOT
CHATBOT:
A chatbot is a software program that is used to conduct an online chat conversation using text
or text-to-speech. Chatbots are designed to accurately mimic how a genuine conversation partner would
conduct themselves
Chatbots are used in dialogue systems for a variety of tasks, including information collecting, request
routing, and customer service. While some chatbot solutions employ advanced natural language
processing, word categorization, and AI, others only scan for broad keywords and construct answers
using standard expressions taken from a connected library or database.
https://drive.google.com/drive/folders/1YecYb-F0VBPqz_KhQxTz0r4KvlRewJtk?usp=share_link
1.iostream:
iostream is a popular header file used in c++ to get input from something and give output on the screen.
istream:
istream library is used to get input.
ostream:
ostream is the library used to display the output of a program.
2. string:
C++ Strings One of the most useful data types supplied in the C++ libraries is the string. A string is a
variable that stores a sequence of letters or other characters.
3.iomanip:
This is a C++ library that is used to set the width and fill all the words with desired characters. This library
was only used for the aesthetics of our output.
4.fstream:
This header file is used to get input from a file and write a output on a file.
If(condition){
Ahmad();
}else{
}
in this, we input the condition 500>str1.find(“Str2”)>0. If this condition is true then Ahmad() user-
defined function will be called else the statement in else bracket will be processed.
2. nested if-else:
A nested if statement is an if statement placed inside another if statement. Nested if
statements are often used when you must test a combination of conditions before deciding on
the proper action.
User-defined function:
In this tutorial, you will learn to create user-defined functions in C programming with the help of
an example.
C allows you to define functions according to your need. These functions are known as a user-
defined function
Logic of our chat bot:
first we made text files
then we call this file using a user-defined function as shown below.
int str(){
ifstream str("string.txt");
string ahm;
while(!str.eof()){
getline(str,ahm);
cout<<ahm<<endl;
}
}
Then we call the function into main function using the condition.
if(500>ahm.find("str")>0){
str();
}
ahm is the input string that we input in the program
if str is present in the program .find will find its position for example
the input string is => what is a string
in this str starts at position 9 then putting this in the condition the condition becomes true and
str() is called
we can make multiple user-defined functions for each word and then we can call them using
these conditions and our chatbot is ready.
There is no use of AI in our chatbot.
Conclusion:
This is a simple chatbot we made that can find answers to most of the questions of CPP. By using
these simple techniques we can make chatbots related to any subject in the world.