Spaces:
Paused
Paused
Upload 10 files
Browse files- .gitattributes +1 -0
- app.py +19 -0
- chatbot.py +44 -0
- database.sqlite3 +3 -0
- python3.7-installation-commands +22 -0
- requirements.txt +47 -0
- sentence_tokenizer.pickle +3 -0
- static/style.css +152 -0
- templates/index.html +125 -0
- training_data/personal_ques.txt +14 -0
- training_data/ques_ans.txt +23 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
database.sqlite3 filter=lfs diff=lfs merge=lfs -text
|
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from chatbot import chatbot
|
2 |
+
|
3 |
+
from flask import Flask, render_template, request
|
4 |
+
|
5 |
+
app = Flask(__name__)
|
6 |
+
app.static_folder = 'static'
|
7 |
+
|
8 |
+
@app.route("/")
|
9 |
+
def home():
|
10 |
+
return render_template("index.html")
|
11 |
+
|
12 |
+
@app.route("/get")
|
13 |
+
def get_bot_response():
|
14 |
+
userText = request.args.get('msg')
|
15 |
+
return str(chatbot.get_response(userText))
|
16 |
+
|
17 |
+
|
18 |
+
if __name__ == "__main__":
|
19 |
+
app.run()
|
chatbot.py
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from chatterbot import ChatBot
|
2 |
+
import spacy
|
3 |
+
|
4 |
+
spacy.cli.download("en_core_web_sm")
|
5 |
+
spacy.cli.download("en")
|
6 |
+
|
7 |
+
nlp = spacy.load('en_core_web_sm')
|
8 |
+
|
9 |
+
chatbot = ChatBot(
|
10 |
+
'CoronaBot',
|
11 |
+
storage_adapter='chatterbot.storage.SQLStorageAdapter',
|
12 |
+
logic_adapters=[
|
13 |
+
'chatterbot.logic.MathematicalEvaluation',
|
14 |
+
'chatterbot.logic.TimeLogicAdapter',
|
15 |
+
'chatterbot.logic.BestMatch',
|
16 |
+
{
|
17 |
+
'import_path': 'chatterbot.logic.BestMatch',
|
18 |
+
'default_response': 'I am sorry, but I do not understand. I am still learning.',
|
19 |
+
'maximum_similarity_threshold': 0.90
|
20 |
+
}
|
21 |
+
],
|
22 |
+
database_uri='sqlite:///database.sqlite3'
|
23 |
+
)
|
24 |
+
|
25 |
+
# Training With Own Questions
|
26 |
+
from chatterbot.trainers import ListTrainer
|
27 |
+
|
28 |
+
trainer = ListTrainer(chatbot)
|
29 |
+
|
30 |
+
training_data_quesans = open('training_data/ques_ans.txt').read().splitlines()
|
31 |
+
training_data_personal = open('training_data/personal_ques.txt').read().splitlines()
|
32 |
+
|
33 |
+
training_data = training_data_quesans + training_data_personal
|
34 |
+
|
35 |
+
trainer.train(training_data)
|
36 |
+
|
37 |
+
# Training With Corpus
|
38 |
+
from chatterbot.trainers import ChatterBotCorpusTrainer
|
39 |
+
|
40 |
+
trainer_corpus = ChatterBotCorpusTrainer(chatbot)
|
41 |
+
|
42 |
+
trainer_corpus.train(
|
43 |
+
'chatterbot.corpus.english'
|
44 |
+
)
|
database.sqlite3
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:291a18fad7f07219bf224573ea233abd057123134b2ded387b4d0434f27154b9
|
3 |
+
size 1716224
|
python3.7-installation-commands
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
sudo apt update
|
2 |
+
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev wget libbz2-dev
|
3 |
+
sudo add-apt-repository ppa:deadsnakes/ppa
|
4 |
+
sudo apt install python3.7
|
5 |
+
python3.7 --version
|
6 |
+
|
7 |
+
python3.7 -m pip install pip
|
8 |
+
alias pip3.7="python3.7 -m pip"
|
9 |
+
|
10 |
+
sudo apt-get install python3.7-distutils
|
11 |
+
|
12 |
+
pip3.7 install virtualenv
|
13 |
+
|
14 |
+
python3.7 -m virtualenv MyEnv
|
15 |
+
|
16 |
+
|
17 |
+
|
18 |
+
pip3.7 install Flask
|
19 |
+
pip3.7 install ChatterBot==1.0.8
|
20 |
+
pip3.7 install chatterbot-corpus==1.2.0
|
21 |
+
pip3.7 install spacy==2.1.9
|
22 |
+
pip3.7 install nltk==3.8.1
|
requirements.txt
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
blis==0.2.4
|
2 |
+
catalogue==2.0.9
|
3 |
+
certifi==2023.7.22
|
4 |
+
charset-normalizer==3.2.0
|
5 |
+
ChatterBot==1.0.8
|
6 |
+
chatterbot-corpus==1.2.0
|
7 |
+
click==8.1.6
|
8 |
+
confection==0.1.1
|
9 |
+
cymem==2.0.7
|
10 |
+
en-core-web-sm @ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.1.0/en_core_web_sm-2.1.0.tar.gz
|
11 |
+
Flask==2.2.5
|
12 |
+
idna==3.4
|
13 |
+
importlib-metadata==6.7.0
|
14 |
+
itsdangerous==2.1.2
|
15 |
+
Jinja2==3.1.2
|
16 |
+
joblib==1.3.1
|
17 |
+
langcodes==3.3.0
|
18 |
+
MarkupSafe==2.1.3
|
19 |
+
mathparse==0.1.2
|
20 |
+
murmurhash==1.0.9
|
21 |
+
nltk==3.8.1
|
22 |
+
numpy==1.21.6
|
23 |
+
packaging==23.1
|
24 |
+
pathy==0.10.2
|
25 |
+
plac==0.9.6
|
26 |
+
preshed==2.0.1
|
27 |
+
pydantic==1.10.12
|
28 |
+
python-dateutil==2.8.2
|
29 |
+
pytz==2023.3
|
30 |
+
PyYAML==3.13
|
31 |
+
regex==2023.6.3
|
32 |
+
requests==2.31.0
|
33 |
+
six==1.16.0
|
34 |
+
smart-open==6.3.0
|
35 |
+
spacy==2.1.9
|
36 |
+
spacy-legacy==3.0.12
|
37 |
+
spacy-loggers==1.0.4
|
38 |
+
SQLAlchemy==1.3.24
|
39 |
+
srsly==1.0.7
|
40 |
+
thinc==7.0.8
|
41 |
+
tqdm==4.65.0
|
42 |
+
typer==0.9.0
|
43 |
+
typing_extensions==4.4.0
|
44 |
+
urllib3==2.0.4
|
45 |
+
wasabi==0.10.1
|
46 |
+
Werkzeug==2.2.3
|
47 |
+
zipp==3.15.0
|
sentence_tokenizer.pickle
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:cf670a070387e89bbb679cb1173d6bc4d86c9e513efd97a44613c66cc662b639
|
3 |
+
size 24191
|
static/style.css
ADDED
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
:root {
|
2 |
+
--body-bg: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
|
3 |
+
--msger-bg: #fff;
|
4 |
+
--border: 2px solid #ddd;
|
5 |
+
--left-msg-bg: #ececec;
|
6 |
+
--right-msg-bg: #579ffb;
|
7 |
+
}
|
8 |
+
|
9 |
+
html {
|
10 |
+
box-sizing: border-box;
|
11 |
+
}
|
12 |
+
|
13 |
+
*,
|
14 |
+
*:before,
|
15 |
+
*:after {
|
16 |
+
margin: 0;
|
17 |
+
padding: 0;
|
18 |
+
box-sizing: inherit;
|
19 |
+
}
|
20 |
+
|
21 |
+
body {
|
22 |
+
display: flex;
|
23 |
+
justify-content: center;
|
24 |
+
align-items: center;
|
25 |
+
height: 100vh;
|
26 |
+
background-image: var(--body-bg);
|
27 |
+
font-family: Helvetica, sans-serif;
|
28 |
+
}
|
29 |
+
|
30 |
+
.msger {
|
31 |
+
display: flex;
|
32 |
+
flex-flow: column wrap;
|
33 |
+
justify-content: space-between;
|
34 |
+
width: 100%;
|
35 |
+
max-width: 867px;
|
36 |
+
margin: 25px 10px;
|
37 |
+
height: calc(100% - 50px);
|
38 |
+
border: var(--border);
|
39 |
+
border-radius: 5px;
|
40 |
+
background: var(--msger-bg);
|
41 |
+
box-shadow: 0 15px 15px -5px rgba(0, 0, 0, 0.2);
|
42 |
+
}
|
43 |
+
|
44 |
+
.msger-header {
|
45 |
+
/* display: flex; */
|
46 |
+
font-size: medium;
|
47 |
+
justify-content: space-between;
|
48 |
+
padding: 10px;
|
49 |
+
text-align: center;
|
50 |
+
border-bottom: var(--border);
|
51 |
+
background: #eee;
|
52 |
+
color: #666;
|
53 |
+
}
|
54 |
+
|
55 |
+
.msger-chat {
|
56 |
+
flex: 1;
|
57 |
+
overflow-y: auto;
|
58 |
+
padding: 10px;
|
59 |
+
}
|
60 |
+
.msger-chat::-webkit-scrollbar {
|
61 |
+
width: 6px;
|
62 |
+
}
|
63 |
+
.msger-chat::-webkit-scrollbar-track {
|
64 |
+
background: #ddd;
|
65 |
+
}
|
66 |
+
.msger-chat::-webkit-scrollbar-thumb {
|
67 |
+
background: #bdbdbd;
|
68 |
+
}
|
69 |
+
.msg {
|
70 |
+
display: flex;
|
71 |
+
align-items: flex-end;
|
72 |
+
margin-bottom: 10px;
|
73 |
+
}
|
74 |
+
|
75 |
+
.msg-img {
|
76 |
+
width: 50px;
|
77 |
+
height: 50px;
|
78 |
+
margin-right: 10px;
|
79 |
+
background: #ddd;
|
80 |
+
background-repeat: no-repeat;
|
81 |
+
background-position: center;
|
82 |
+
background-size: cover;
|
83 |
+
border-radius: 50%;
|
84 |
+
}
|
85 |
+
.msg-bubble {
|
86 |
+
max-width: 450px;
|
87 |
+
padding: 15px;
|
88 |
+
border-radius: 15px;
|
89 |
+
background: var(--left-msg-bg);
|
90 |
+
}
|
91 |
+
.msg-info {
|
92 |
+
display: flex;
|
93 |
+
justify-content: space-between;
|
94 |
+
align-items: center;
|
95 |
+
margin-bottom: 10px;
|
96 |
+
}
|
97 |
+
.msg-info-name {
|
98 |
+
margin-right: 10px;
|
99 |
+
font-weight: bold;
|
100 |
+
}
|
101 |
+
.msg-info-time {
|
102 |
+
font-size: 0.85em;
|
103 |
+
}
|
104 |
+
|
105 |
+
.left-msg .msg-bubble {
|
106 |
+
border-bottom-left-radius: 0;
|
107 |
+
}
|
108 |
+
|
109 |
+
.right-msg {
|
110 |
+
flex-direction: row-reverse;
|
111 |
+
}
|
112 |
+
.right-msg .msg-bubble {
|
113 |
+
background: var(--right-msg-bg);
|
114 |
+
color: #fff;
|
115 |
+
border-bottom-right-radius: 0;
|
116 |
+
}
|
117 |
+
.right-msg .msg-img {
|
118 |
+
margin: 0 0 0 10px;
|
119 |
+
}
|
120 |
+
|
121 |
+
.msger-inputarea {
|
122 |
+
display: flex;
|
123 |
+
padding: 10px;
|
124 |
+
border-top: var(--border);
|
125 |
+
background: #eee;
|
126 |
+
}
|
127 |
+
.msger-inputarea * {
|
128 |
+
padding: 10px;
|
129 |
+
border: none;
|
130 |
+
border-radius: 3px;
|
131 |
+
font-size: 1em;
|
132 |
+
}
|
133 |
+
.msger-input {
|
134 |
+
flex: 1;
|
135 |
+
background: #ddd;
|
136 |
+
}
|
137 |
+
.msger-send-btn {
|
138 |
+
margin-left: 10px;
|
139 |
+
background: rgb(0, 196, 65);
|
140 |
+
color: #fff;
|
141 |
+
font-weight: bold;
|
142 |
+
cursor: pointer;
|
143 |
+
transition: background 0.23s;
|
144 |
+
}
|
145 |
+
.msger-send-btn:hover {
|
146 |
+
background: rgb(0, 180, 50);
|
147 |
+
}
|
148 |
+
|
149 |
+
.msger-chat {
|
150 |
+
background-color: #fcfcfe;
|
151 |
+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260' viewBox='0 0 260 260'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%23dddddd' fill-opacity='0.4'%3E%3Cpath d='M24.37 16c.2.65.39 1.32.54 2H21.17l1.17 2.34.45.9-.24.11V28a5 5 0 0 1-2.23 8.94l-.02.06a8 8 0 0 1-7.75 6h-20a8 8 0 0 1-7.74-6l-.02-.06A5 5 0 0 1-17.45 28v-6.76l-.79-1.58-.44-.9.9-.44.63-.32H-20a23.01 23.01 0 0 1 44.37-2zm-36.82 2a1 1 0 0 0-.44.1l-3.1 1.56.89 1.79 1.31-.66a3 3 0 0 1 2.69 0l2.2 1.1a1 1 0 0 0 .9 0l2.21-1.1a3 3 0 0 1 2.69 0l2.2 1.1a1 1 0 0 0 .9 0l2.21-1.1a3 3 0 0 1 2.69 0l2.2 1.1a1 1 0 0 0 .86.02l2.88-1.27a3 3 0 0 1 2.43 0l2.88 1.27a1 1 0 0 0 .85-.02l3.1-1.55-.89-1.79-1.42.71a3 3 0 0 1-2.56.06l-2.77-1.23a1 1 0 0 0-.4-.09h-.01a1 1 0 0 0-.4.09l-2.78 1.23a3 3 0 0 1-2.56-.06l-2.3-1.15a1 1 0 0 0-.45-.11h-.01a1 1 0 0 0-.44.1L.9 19.22a3 3 0 0 1-2.69 0l-2.2-1.1a1 1 0 0 0-.45-.11h-.01a1 1 0 0 0-.44.1l-2.21 1.11a3 3 0 0 1-2.69 0l-2.2-1.1a1 1 0 0 0-.45-.11h-.01zm0-2h-4.9a21.01 21.01 0 0 1 39.61 0h-2.09l-.06-.13-.26.13h-32.31zm30.35 7.68l1.36-.68h1.3v2h-36v-1.15l.34-.17 1.36-.68h2.59l1.36.68a3 3 0 0 0 2.69 0l1.36-.68h2.59l1.36.68a3 3 0 0 0 2.69 0L2.26 23h2.59l1.36.68a3 3 0 0 0 2.56.06l1.67-.74h3.23l1.67.74a3 3 0 0 0 2.56-.06zM-13.82 27l16.37 4.91L18.93 27h-32.75zm-.63 2h.34l16.66 5 16.67-5h.33a3 3 0 1 1 0 6h-34a3 3 0 1 1 0-6zm1.35 8a6 6 0 0 0 5.65 4h20a6 6 0 0 0 5.66-4H-13.1z'/%3E%3Cpath id='path6_fill-copy' d='M284.37 16c.2.65.39 1.32.54 2H281.17l1.17 2.34.45.9-.24.11V28a5 5 0 0 1-2.23 8.94l-.02.06a8 8 0 0 1-7.75 6h-20a8 8 0 0 1-7.74-6l-.02-.06a5 5 0 0 1-2.24-8.94v-6.76l-.79-1.58-.44-.9.9-.44.63-.32H240a23.01 23.01 0 0 1 44.37-2zm-36.82 2a1 1 0 0 0-.44.1l-3.1 1.56.89 1.79 1.31-.66a3 3 0 0 1 2.69 0l2.2 1.1a1 1 0 0 0 .9 0l2.21-1.1a3 3 0 0 1 2.69 0l2.2 1.1a1 1 0 0 0 .9 0l2.21-1.1a3 3 0 0 1 2.69 0l2.2 1.1a1 1 0 0 0 .86.02l2.88-1.27a3 3 0 0 1 2.43 0l2.88 1.27a1 1 0 0 0 .85-.02l3.1-1.55-.89-1.79-1.42.71a3 3 0 0 1-2.56.06l-2.77-1.23a1 1 0 0 0-.4-.09h-.01a1 1 0 0 0-.4.09l-2.78 1.23a3 3 0 0 1-2.56-.06l-2.3-1.15a1 1 0 0 0-.45-.11h-.01a1 1 0 0 0-.44.1l-2.21 1.11a3 3 0 0 1-2.69 0l-2.2-1.1a1 1 0 0 0-.45-.11h-.01a1 1 0 0 0-.44.1l-2.21 1.11a3 3 0 0 1-2.69 0l-2.2-1.1a1 1 0 0 0-.45-.11h-.01zm0-2h-4.9a21.01 21.01 0 0 1 39.61 0h-2.09l-.06-.13-.26.13h-32.31zm30.35 7.68l1.36-.68h1.3v2h-36v-1.15l.34-.17 1.36-.68h2.59l1.36.68a3 3 0 0 0 2.69 0l1.36-.68h2.59l1.36.68a3 3 0 0 0 2.69 0l1.36-.68h2.59l1.36.68a3 3 0 0 0 2.56.06l1.67-.74h3.23l1.67.74a3 3 0 0 0 2.56-.06zM246.18 27l16.37 4.91L278.93 27h-32.75zm-.63 2h.34l16.66 5 16.67-5h.33a3 3 0 1 1 0 6h-34a3 3 0 1 1 0-6zm1.35 8a6 6 0 0 0 5.65 4h20a6 6 0 0 0 5.66-4H246.9z'/%3E%3Cpath d='M159.5 21.02A9 9 0 0 0 151 15h-42a9 9 0 0 0-8.5 6.02 6 6 0 0 0 .02 11.96A8.99 8.99 0 0 0 109 45h42a9 9 0 0 0 8.48-12.02 6 6 0 0 0 .02-11.96zM151 17h-42a7 7 0 0 0-6.33 4h54.66a7 7 0 0 0-6.33-4zm-9.34 26a8.98 8.98 0 0 0 3.34-7h-2a7 7 0 0 1-7 7h-4.34a8.98 8.98 0 0 0 3.34-7h-2a7 7 0 0 1-7 7h-4.34a8.98 8.98 0 0 0 3.34-7h-2a7 7 0 0 1-7 7h-7a7 7 0 1 1 0-14h42a7 7 0 1 1 0 14h-9.34zM109 27a9 9 0 0 0-7.48 4H101a4 4 0 1 1 0-8h58a4 4 0 0 1 0 8h-.52a9 9 0 0 0-7.48-4h-42z'/%3E%3Cpath d='M39 115a8 8 0 1 0 0-16 8 8 0 0 0 0 16zm6-8a6 6 0 1 1-12 0 6 6 0 0 1 12 0zm-3-29v-2h8v-6H40a4 4 0 0 0-4 4v10H22l-1.33 4-.67 2h2.19L26 130h26l3.81-40H58l-.67-2L56 84H42v-6zm-4-4v10h2V74h8v-2h-8a2 2 0 0 0-2 2zm2 12h14.56l.67 2H22.77l.67-2H40zm13.8 4H24.2l3.62 38h22.36l3.62-38z'/%3E%3Cpath d='M129 92h-6v4h-6v4h-6v14h-3l.24 2 3.76 32h36l3.76-32 .24-2h-3v-14h-6v-4h-6v-4h-8zm18 22v-12h-4v4h3v8h1zm-3 0v-6h-4v6h4zm-6 6v-16h-4v19.17c1.6-.7 2.97-1.8 4-3.17zm-6 3.8V100h-4v23.8a10.04 10.04 0 0 0 4 0zm-6-.63V104h-4v16a10.04 10.04 0 0 0 4 3.17zm-6-9.17v-6h-4v6h4zm-6 0v-8h3v-4h-4v12h1zm27-12v-4h-4v4h3v4h1v-4zm-6 0v-8h-4v4h3v4h1zm-6-4v-4h-4v8h1v-4h3zm-6 4v-4h-4v8h1v-4h3zm7 24a12 12 0 0 0 11.83-10h7.92l-3.53 30h-32.44l-3.53-30h7.92A12 12 0 0 0 130 126z'/%3E%3Cpath d='M212 86v2h-4v-2h4zm4 0h-2v2h2v-2zm-20 0v.1a5 5 0 0 0-.56 9.65l.06.25 1.12 4.48a2 2 0 0 0 1.94 1.52h.01l7.02 24.55a2 2 0 0 0 1.92 1.45h4.98a2 2 0 0 0 1.92-1.45l7.02-24.55a2 2 0 0 0 1.95-1.52L224.5 96l.06-.25a5 5 0 0 0-.56-9.65V86a14 14 0 0 0-28 0zm4 0h6v2h-9a3 3 0 1 0 0 6H223a3 3 0 1 0 0-6H220v-2h2a12 12 0 1 0-24 0h2zm-1.44 14l-1-4h24.88l-1 4h-22.88zm8.95 26l-6.86-24h18.7l-6.86 24h-4.98zM150 242a22 22 0 1 0 0-44 22 22 0 0 0 0 44zm24-22a24 24 0 1 1-48 0 24 24 0 0 1 48 0zm-28.38 17.73l2.04-.87a6 6 0 0 1 4.68 0l2.04.87a2 2 0 0 0 2.5-.82l1.14-1.9a6 6 0 0 1 3.79-2.75l2.15-.5a2 2 0 0 0 1.54-2.12l-.19-2.2a6 6 0 0 1 1.45-4.46l1.45-1.67a2 2 0 0 0 0-2.62l-1.45-1.67a6 6 0 0 1-1.45-4.46l.2-2.2a2 2 0 0 0-1.55-2.13l-2.15-.5a6 6 0 0 1-3.8-2.75l-1.13-1.9a2 2 0 0 0-2.5-.8l-2.04.86a6 6 0 0 1-4.68 0l-2.04-.87a2 2 0 0 0-2.5.82l-1.14 1.9a6 6 0 0 1-3.79 2.75l-2.15.5a2 2 0 0 0-1.54 2.12l.19 2.2a6 6 0 0 1-1.45 4.46l-1.45 1.67a2 2 0 0 0 0 2.62l1.45 1.67a6 6 0 0 1 1.45 4.46l-.2 2.2a2 2 0 0 0 1.55 2.13l2.15.5a6 6 0 0 1 3.8 2.75l1.13 1.9a2 2 0 0 0 2.5.8zm2.82.97a4 4 0 0 1 3.12 0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 3 3 0 0 0 1.56 1.99zm1.14-1.7c.35-.5.72-.98 1.1-1.46a1 1 0 1 0-1.1 1.45zm5.34-5.77c-1.03.86-2 1.79-2.9 2.77a3 3 0 0 0-1.11-.77 3 3 0 0 1 4-2zm42.66 2.77c-.9-.98-1.87-1.9-2.9-2.77a3 3 0 0 1 4.01 2 3 3 0 0 0-1.1.77zm1.34 1.54c.38.48.75.96 1.1 1.45a1 1 0 1 0-1.1-1.45zm3.73 5.84c-.46-.92-.95-1.82-1.5-2.68a3 3 0 0 0 1.57-1.99 3 3 0 0 1-.07 4.67zm1.8 4.53c-.29-.9-.6-1.8-.97-2.67.44-.28.84-.63 1.17-1.03a2 2 0 0 1-.2 3.7zm1.14 5.51c-.14-1.21-.35-2.4-.62-3.57.45-.14.86-.35 1.23-.63a2.99 2.99 0 0 1-.6 4.2zM275 214a29 29 0 0 0-57.97 0h57.96zM72.33 198.12c-.21-.32-.34-.7-.34-1.12v-12h-2v12a4.01 4.01 0 0 0 7.09 2.54c.57-.69.91-1.57.91-2.54v-12h-2v12a1.99 1.99 0 0 1-2 2 2 2 0 0 1-1.66-.88zM75 176c.38 0 .74-.04 1.1-.12a4 4 0 0 0 6.19 2.4A13.94 13.94 0 0 1 84 185v24a6 6 0 0 1-6 6h-3v9a5 5 0 1 1-10 0v-9h-3a6 6 0 0 1-6-6v-24a14 14 0 0 1 14-14 5 5 0 0 0 5 5zm-17 15v12a1.99 1.99 0 0 0 1.22 1.84 2 2 0 0 0 2.44-.72c.21-.32.34-.7.34-1.12v-12h2v12a3.98 3.98 0 0 1-5.35 3.77 3.98 3.98 0 0 1-.65-.3V209a4 4 0 0 0 4 4h16a4 4 0 0 0 4-4v-24c.01-1.53-.23-2.88-.72-4.17-.43.1-.87.16-1.28.17a6 6 0 0 1-5.2-3 7 7 0 0 1-6.47-4.88A12 12 0 0 0 58 185v6zm9 24v9a3 3 0 1 0 6 0v-9h-6z'/%3E%3Cpath d='M-17 191a1 1 0 0 0 0 2h2a1 1 0 0 0 0-2h-2zm19 9a1 1 0 0 1 1-1h2a1 1 0 0 1 0 2H3a1 1 0 0 1-1-1zm-14 5a1 1 0 0 0 0 2h2a1 1 0 0 0 0-2h-2zm-25 1a1 1 0 0 0 0 2h2a1 1 0 0 0 0-2h-2zm5 4a1 1 0 0 0 0 2h2a1 1 0 0 0 0-2h-2zm9 0a1 1 0 0 1 1-1h2a1 1 0 0 1 0 2h-2a1 1 0 0 1-1-1zm15 1a1 1 0 0 1 1-1h2a1 1 0 0 1 0 2h-2a1 1 0 0 1-1-1zm12-2a1 1 0 0 0 0 2h2a1 1 0 0 0 0-2H4zm-11-14a1 1 0 0 1 1-1h2a1 1 0 0 1 0 2h-2a1 1 0 0 1-1-1zm-19 0a1 1 0 0 0 0 2h2a1 1 0 0 0 0-2h-2zm6 5a1 1 0 0 1 1-1h2a1 1 0 0 1 0 2h-2a1 1 0 0 1-1-1zm-25 15c0-.47.01-.94.03-1.4a5 5 0 0 1-1.7-8 3.99 3.99 0 0 1 1.88-5.18 5 5 0 0 1 3.4-6.22 3 3 0 0 1 1.46-1.05 5 5 0 0 1 7.76-3.27A30.86 30.86 0 0 1-14 184c6.79 0 13.06 2.18 18.17 5.88a5 5 0 0 1 7.76 3.27 3 3 0 0 1 1.47 1.05 5 5 0 0 1 3.4 6.22 4 4 0 0 1 1.87 5.18 4.98 4.98 0 0 1-1.7 8c.02.46.03.93.03 1.4v1h-62v-1zm.83-7.17a30.9 30.9 0 0 0-.62 3.57 3 3 0 0 1-.61-4.2c.37.28.78.49 1.23.63zm1.49-4.61c-.36.87-.68 1.76-.96 2.68a2 2 0 0 1-.21-3.71c.33.4.73.75 1.17 1.03zm2.32-4.54c-.54.86-1.03 1.76-1.49 2.68a3 3 0 0 1-.07-4.67 3 3 0 0 0 1.56 1.99zm1.14-1.7c.35-.5.72-.98 1.1-1.46a1 1 0 1 0-1.1 1.45zm5.34-5.77c-1.03.86-2 1.79-2.9 2.77a3 3 0 0 0-1.11-.77 3 3 0 0 1 4-2zm42.66 2.77c-.9-.98-1.87-1.9-2.9-2.77a3 3 0 0 1 4.01 2 3 3 0 0 0-1.1.77zm1.34 1.54c.38.48.75.96 1.1 1.45a1 1 0 1 0-1.1-1.45zm3.73 5.84c-.46-.92-.95-1.82-1.5-2.68a3 3 0 0 0 1.57-1.99 3 3 0 0 1-.07 4.67zm1.8 4.53c-.29-.9-.6-1.8-.97-2.67.44-.28.84-.63 1.17-1.03a2 2 0 0 1-.2 3.7zm1.14 5.51c-.14-1.21-.35-2.4-.62-3.57.45-.14.86-.35 1.23-.63a2.99 2.99 0 0 1-.6 4.2zM15 214a29 29 0 0 0-57.97 0h57.96z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
|
152 |
+
}
|
templates/index.html
ADDED
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
|
4 |
+
<head>
|
5 |
+
<meta charset="UTF-8">
|
6 |
+
<title>CoronaBot</title>
|
7 |
+
<meta charset="UTF-8">
|
8 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
9 |
+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
10 |
+
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
|
11 |
+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
|
12 |
+
</head>
|
13 |
+
|
14 |
+
<body>
|
15 |
+
<!-- partial:index.partial.html -->
|
16 |
+
<section class="msger">
|
17 |
+
<header class="msger-header">
|
18 |
+
<div class="msger-header-title">
|
19 |
+
<i class="fas fa-bug"></i> Coronavirus Chatbot <i class="fas fa-bug"></i>
|
20 |
+
</div>
|
21 |
+
</header>
|
22 |
+
|
23 |
+
<main class="msger-chat">
|
24 |
+
<div class="msg left-msg">
|
25 |
+
<div class="msg-img" style="background-image: url(https://image.flaticon.com/icons/svg/327/327779.svg)"></div>
|
26 |
+
|
27 |
+
<div class="msg-bubble">
|
28 |
+
<div class="msg-info">
|
29 |
+
<div class="msg-info-name">CoronaBot</div>
|
30 |
+
<div class="msg-info-time">12:45</div>
|
31 |
+
</div>
|
32 |
+
|
33 |
+
<div class="msg-text">
|
34 |
+
Hi, welcome to CoronaBot! Go ahead and send me a message. 😄
|
35 |
+
</div>
|
36 |
+
</div>
|
37 |
+
</div>
|
38 |
+
|
39 |
+
</main>
|
40 |
+
|
41 |
+
<form class="msger-inputarea">
|
42 |
+
<input type="text" class="msger-input" id="textInput" placeholder="Enter your message...">
|
43 |
+
<button type="submit" class="msger-send-btn">Send</button>
|
44 |
+
</form>
|
45 |
+
</section>
|
46 |
+
<!-- partial -->
|
47 |
+
<script src='https://use.fontawesome.com/releases/v5.0.13/js/all.js'></script>
|
48 |
+
<script>
|
49 |
+
|
50 |
+
const msgerForm = get(".msger-inputarea");
|
51 |
+
const msgerInput = get(".msger-input");
|
52 |
+
const msgerChat = get(".msger-chat");
|
53 |
+
|
54 |
+
|
55 |
+
// Icons made by Freepik from www.flaticon.com
|
56 |
+
const BOT_IMG = "https://image.flaticon.com/icons/svg/327/327779.svg";
|
57 |
+
const PERSON_IMG = "https://image.flaticon.com/icons/svg/145/145867.svg";
|
58 |
+
const BOT_NAME = "CoronaBot";
|
59 |
+
const PERSON_NAME = "You";
|
60 |
+
|
61 |
+
msgerForm.addEventListener("submit", event => {
|
62 |
+
event.preventDefault();
|
63 |
+
|
64 |
+
const msgText = msgerInput.value;
|
65 |
+
if (!msgText) return;
|
66 |
+
|
67 |
+
appendMessage(PERSON_NAME, PERSON_IMG, "right", msgText);
|
68 |
+
msgerInput.value = "";
|
69 |
+
botResponse(msgText);
|
70 |
+
});
|
71 |
+
|
72 |
+
function appendMessage(name, img, side, text) {
|
73 |
+
// Simple solution for small apps
|
74 |
+
const msgHTML = `
|
75 |
+
<div class="msg ${side}-msg">
|
76 |
+
<div class="msg-img" style="background-image: url(${img})"></div>
|
77 |
+
|
78 |
+
<div class="msg-bubble">
|
79 |
+
<div class="msg-info">
|
80 |
+
<div class="msg-info-name">${name}</div>
|
81 |
+
<div class="msg-info-time">${formatDate(new Date())}</div>
|
82 |
+
</div>
|
83 |
+
|
84 |
+
<div class="msg-text">${text}</div>
|
85 |
+
</div>
|
86 |
+
</div>
|
87 |
+
`;
|
88 |
+
|
89 |
+
msgerChat.insertAdjacentHTML("beforeend", msgHTML);
|
90 |
+
msgerChat.scrollTop += 500;
|
91 |
+
}
|
92 |
+
|
93 |
+
function botResponse(rawText) {
|
94 |
+
|
95 |
+
// Bot Response
|
96 |
+
$.get("/get", { msg: rawText }).done(function (data) {
|
97 |
+
console.log(rawText);
|
98 |
+
console.log(data);
|
99 |
+
const msgText = data;
|
100 |
+
appendMessage(BOT_NAME, BOT_IMG, "left", msgText);
|
101 |
+
|
102 |
+
});
|
103 |
+
|
104 |
+
}
|
105 |
+
|
106 |
+
|
107 |
+
// Utils
|
108 |
+
function get(selector, root = document) {
|
109 |
+
return root.querySelector(selector);
|
110 |
+
}
|
111 |
+
|
112 |
+
function formatDate(date) {
|
113 |
+
const h = "0" + date.getHours();
|
114 |
+
const m = "0" + date.getMinutes();
|
115 |
+
|
116 |
+
return `${h.slice(-2)}:${m.slice(-2)}`;
|
117 |
+
}
|
118 |
+
|
119 |
+
|
120 |
+
|
121 |
+
</script>
|
122 |
+
|
123 |
+
</body>
|
124 |
+
|
125 |
+
</html>
|
training_data/personal_ques.txt
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Are you a robot?
|
2 |
+
Yes, My name is CoronaBot
|
3 |
+
Are you a bot?
|
4 |
+
Yes, My name is CoronaBot
|
5 |
+
Are you a chatbot?
|
6 |
+
Yes, My name is CoronaBot
|
7 |
+
Are you real?'
|
8 |
+
I am a ChatBot, My name is CoronaBot
|
9 |
+
What is your name?
|
10 |
+
My name is CoronaBot
|
11 |
+
Who made you?
|
12 |
+
Huzaif Sayyed made me
|
13 |
+
What do you do?
|
14 |
+
I am made to give Coronavirus Answers
|
training_data/ques_ans.txt
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
What is a coronavirus?
|
2 |
+
Coronaviruses are a large family of viruses that are known to cause illness ranging from the common cold to more severe diseases such as Middle East Respiratory Syndrome (MERS) and Severe Acute Respiratory Syndrome (SARS).
|
3 |
+
What is a novel coronavirus?
|
4 |
+
A novel coronavirus (CoV) is a new strain of coronavirus that has not been previously identified in humans.
|
5 |
+
Can humans become infected with a novel coronavirus of animal source?
|
6 |
+
Detailed investigations found that SARS-CoV was transmitted from civet cats to humans in China in 2002 and MERS-CoV from dromedary camels to humans in Saudi Arabia in 2012. Several known coronaviruses are circulating in animals that have not yet infected humans. As surveillance improves around the world, more coronaviruses are likely to be identified.
|
7 |
+
What are the symptoms of someone infected with a coronavirus?
|
8 |
+
It depends on the virus, but common signs include respiratory symptoms, fever, cough, shortness of breath, and breathing difficulties. In more severe cases, infection can cause pneumonia, severe acute respiratory syndrome, kidney failure and even death.
|
9 |
+
Can coronaviruses be transmitted from person to person?
|
10 |
+
Yes, some coronaviruses can be transmitted from person to person, usually after close contact with an infected patient, for example, in a household workplace, or health care centre.
|
11 |
+
Is there a vaccine for a novel coronavirus?
|
12 |
+
When a disease is new, there is no vaccine until one is developed. It can take a number of years for a new vaccine to be developed.
|
13 |
+
Is there a treatment for a novel coronavirus?
|
14 |
+
There is no specific treatment for disease caused by a novel coronavirus. However, many of the symptoms can be treated and therefore treatment based on the patient�s clinical condition. Moreover, supportive care for infected persons can be highly effective.
|
15 |
+
What can I do to protect myself?
|
16 |
+
Standard recommendations to reduce exposure to and transmission of a range of illnesses include maintaining basic hand and respiratory hygiene, and safe food practices and avoiding close contact, when possible, with anyone showing symptoms of respiratory illness such as coughing and sneezing.
|
17 |
+
Are health workers at risk from a novel coronavirus?
|
18 |
+
Yes, they can be, as health care workers come into contact with patients more often than the general public WHO recommends that health care workers consistently apply appropriate
|
19 |
+
What WHO recommendations for countries?
|
20 |
+
WHO encourages all countries to enhance their surveillance for severe acute respiratory infections (SARI), to carefully review any unusual patterns of SARI or pneumonia cases and to notify WHO of any suspected or confirmed case of infection with novel coronavirus.
|
21 |
+
Countries are encouraged to continue strengthening their preparedness for health emergencies in line with the International Health Regulations (2005).
|
22 |
+
Where can I find more information about known coronaviruses?
|
23 |
+
For more information on MERS-CoV <a href="http://www.emro.who.int/health-topics/mers-cov/index.html">here</a>, For More information on SARS-CoV <a href="https://www.who.int/csr/sars/en/">here</a>.
|