-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
68 lines (57 loc) · 1.39 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright (c) 2023 Usitha Indeewara. All Rights Reserved.
#include "main.h"
data_t data = {
{
{"hello", "hi", "hey"},
{"Hi! Nice to meet you!", "Hello!"}
},
{
{"bye", "see ya"},
{"See you later!", "Good Bye"}
},
{
{"how are you"},
{"I'm doing great! How about you?", "I fine. How are you?"}
},
{
{"fine", "doing great"},
{"Nice", "Great"}
},
{
{"what can you do"},
{"nothing"}
}
};
str chatbot(str inp) {
str result = rdm(std::vector<str>{"Sorry I didn't understand!", "Hmm", "Nice", ":)"});
for(const auto &dataset: data) {
for(const auto &checker : dataset.i) {
if(is_include(inp, checker)) {
result = rdm(dataset.o);
}
}
}
return result;
}
template<typename T>
void print(T item) {
std::cout << item;
}
template<typename T>
str input(T prompt) {
print(prompt);
std::string inpu {};
std::getline(std::cin >> std::ws, inpu);
return inpu;
}
int main() {
print("Welcome! This is a simple chatbot by Usitha Indeewara. \nCopyright (c) 2023 Usitha Indeewara. All Rights Reserved.\n\n\n");
while(true) {
str userinput = input("You: ");
if(is_include(userinput, "exit")) {
break;
}
print("Bot: " + chatbot(userinput) + "\n");
}
return 0;
}