-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.html
executable file
·323 lines (271 loc) · 13.5 KB
/
main.html
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="semantic/dist/semantic.min.css">
<script src="./jquery-3.1.1.min.js"></script>
<script src="semantic/dist/semantic.min.js"></script>
<meta charset ="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>NLP Generic Tool</title>
</head>
<body>
<div class="ui two column relaxed very horizontally padded grid">
<!-- Title -->
<div class='sixteen wide column'>
<div class="ui fluid container">
<!-- <img src='./icons/htx.png' style="vertical-align:middle"> -->
<br>
<div class='ui huge header' style='font-size:40px'>NLP Generic Tool</div>
</div>
</div>
<!-- Input Area -->
<div class='column'>
<!-- Input Text -->
<div class="ui top attached tabular menu">
<a class="active item" data-tab="input" style="font-size:20px">Input Text</a>
<a class="item" data-tab="output" style="font-size:20px">Result</a>
</div>
<div class="ui bottom attached active tab segment" data-tab="input">
<!-- <div class="ui raised segment"> -->
<div class="ui form">
<div class="field">
<textarea placeholder="Write text here" id="text" style="font-size:15px"></textarea>
</div>
<button class="ui button" type="submit" id='button' style="font-size:15px">Submit</button>
</div>
<!-- </div> -->
</div>
<div class="ui bottom attached tab segment" data-tab="output">
<div id = 'output-content'>
<div class="ui negative message">
<div class="header" style="font-size:20px">
No input found!
</div>
<p style="font-size:20px">Please input text and click on Submit once done.</p>
</div>
</div>
</div>
<!-- QnA Bot -->
<div class='ui raised segment'>
<div class="ui form">
<h2 class="ui dividing header">Question and Answer Bot</h2>
<div class="field">
<input type='text' placeholder="Ask me a question!" id="qn-text" style="font-size:15px">
</div>
<div id="ans-content"></div>
<!-- <div class="ui teal inverted segment">
<p style='font-size:20px'>Here is a sample answer</p>
</div> -->
<button class="ui button" type="button" id='ask-button' style="font-size:15px">Ask Away!!</button>
</div>
</div>
</div>
<!-- Output Area -->
<div class='column'>
<div class="ui two column relaxed grid">
<!-- Summary -->
<div class='column'>
<div class="ui segment" style='height:100%'>
<h2 class="ui dividing header">Summary</h2>
<div class="ui justified container">
<div id="summary-content"></div>
</div>
</div>
</div>
<!-- Sentiment Analysis -->
<div class='column'>
<div class="ui segment" style='height:100%'>
<h2 class="ui dividing header">Sentiment</h2>
<div class='ui three column center aligned grid'>
<div class = 'column'>
<img class='negative' src='./icons/negative-off.svg'>
</div>
<div class = 'column'>
<img class='neutral' src='./icons/neutral-off.svg'>
</div>
<div class = 'column'>
<img class='positive' src='./icons/positive-off.svg'>
</div>
<div class = 'row'>
<div id="sen-content"></div>
</div>
</div>
</div>
</div>
</div>
<!-- Entities -->
<div class="ui segments">
<div class='ui segment'>
<h2 class="ui dividing header">Entities</h2>
</div>
<div class="ui teal segment">
<div class="ui two column stackable grid">
<div class='column'>
<p style="font-size:20px; text-align:center">Person</p>
</div>
<div class='column'>
<div id="person-content"></div>
</div>
</div>
</div>
<div class="ui brown segment">
<div class="ui two column stackable grid">
<div class='column'>
<p style="font-size:20px; text-align:center">Organisation</p>
</div>
<div class='column'>
<div id="org-content"></div>
</div>
</div>
</div>
<div class="ui purple segment">
<div class="ui two column stackable grid">
<div class='column'>
<p style="font-size:20px; text-align:center">Date</p>
</div>
<div class='column'>
<div id="date-content"></div>
</div>
</div>
</div>
<div class="ui violet segment">
<div class="ui two column stackable grid">
<div class='column'>
<p style="font-size:20px; text-align:center">Location</p>
</div>
<div class='column'>
<div id="loc-content"></div>
</div>
</div>
</div>
<div class="ui red segment">
<div class="ui two column stackable grid">
<div class='column'>
<p style="font-size:20px; text-align:center">Product</p>
</div>
<div class='column'>
<div id="product-content"></div>
</div>
</div>
</div>
<div class="ui yellow segment">
<div class="ui two column stackable grid">
<div class='column'>
<p style="font-size:20px; text-align:center">Event</p>
</div>
<div class='column'>
<div id="event-content"></div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
$('.menu .item').tab();
</script>
<!--Output Results-->
<script type="text/javascript">
function receiveData(response) {
var divContent = "<p style='font-size:20px'>" + response.text + "</p>";
$('#button').attr('class', 'ui button')
// summary
html_summary = "<p style='font-size:15px'>" + response.summary + "</p>";
$("#summary-content").html(html_summary);
// person
let html_person = "";
var person_color = 'teal';
for (let i = 0; i < response.person.length; i++) {
html_person += "<a class='ui " + person_color + " label' style='font-size:15px'>" + response.person[i] + "</a>";
var re = new RegExp(response.person[i], 'gi');
var divContent = divContent.replace(re, "<a class='ui " + person_color + " label' style='font-size:20px' data-tooltip='Person'>" + response.person[i] + "</a>");
// html += "<br />";
}
$("#person-content").html(html_person);
// organisation
let html_org = "";
var org_color = 'brown';
for (let i = 0; i < response.org.length; i++) {
html_org += "<a class='ui " + org_color + " label' style='font-size:15px'>" + response.org[i] + "</a>";
var re = new RegExp(response.org[i], 'gi');
var divContent = divContent.replace(re, "<a class='ui " + org_color + " label' style='font-size:20px' data-tooltip='Organisation'>" + response.org[i] + "</a>");
}
$("#org-content").html(html_org);
// date
let html_date = "";
var date_color = 'purple';
for (let i = 0; i < response.date.length; i++) {
html_date += "<a class='ui " + date_color + " label' style='font-size:15px'>" + response.date[i] + "</a>";
var re = new RegExp(response.date[i], 'g');
var divContent = divContent.replace(re, "<a class='ui " + date_color + " label' style='font-size:20px' data-tooltip='Date'>" + response.date[i] + "</a>");
}
$("#date-content").html(html_date);
// location
let html_loc = "";
var loc_color = 'violet';
for (let i = 0; i < response.loc.length; i++) {
html_loc += "<a class='ui " + loc_color + " label' style='font-size:15px'>" + response.loc[i] + "</a>";
var re = new RegExp(response.loc[i], 'gi');
var divContent = divContent.replace(re, "<a class='ui " + loc_color + " label' style='font-size:20px' data-tooltip='Location'>" + response.loc[i] + "</a>");
}
$("#loc-content").html(html_loc);
// product
let html_product = "";
var product_color = 'red';
for (let i = 0; i < response.pdt.length; i++) {
html_product += "<a class='ui " + product_color + " label' style='font-size:15px'>" + response.pdt[i] + "</a>";
var re = new RegExp(response.pdt[i], 'g');
var divContent = divContent.replace(re, "<a class='ui " + product_color + " label' style='font-size:20px' data-tooltip='Product'>" + response.pdt[i] + "</a>");
}
$("#product-content").html(html_product);
// event
let html_event = "";
var event_color = 'yellow';
for (let i = 0; i < response.event.length; i++) {
html_event += "<a class='ui " + event_color + " label' style='font-size:15px'>" + response.event[i] + "</a>";
var re = new RegExp(response.event[i], 'g');
var divContent = divContent.replace(re, "<a class='ui " + event_color + " label' style='font-size:20px' data-tooltip='Event'>" + response.event[i] + "</a>");
}
$("#event-content").html(html_event);
// sentiment
let html_sen = "";
$('.negative').attr('src', './icons/negative-off.svg');
$('.neutral').attr('src', './icons/neutral-off.svg');
$('.positive').attr('src', './icons/positive-off.svg');
if (response.sen < 0) {
html_sen = "<p style='font-size:20px'>Negative (" + response.sen.toFixed(2) + ")</p>";
$('.negative').attr('src', './icons/negative.svg');
}
else if (response.sen > 0) {
html_sen = "<p style='font-size:20px'>Positive (" + response.sen.toFixed(2) + ")</p>";
$('.positive').attr('src', './icons/positive.svg');
}
else {
html_sen = "<p style='font-size:20px'>Neutral (" + response.sen.toFixed(2) + ")</p>";
$('.neutral').attr('src', './icons/neutral.svg');
}
$("#sen-content").html(html_sen);
// html_output = "<h2 class='ui header'>Output Text</h2><p style='font-size:20px'>" + response.text + "</p>";
$("#output-content").html(divContent);
$.tab('change tab', 'output');
}
$("#button").click(function (e) {
console.log("Hello");
let text = $("#text").val();
$('#button').attr('class', 'ui loading button');
$.post("http://127.0.0.1:5000/run-main", {data1: text}, receiveData);
});
function askData(response) {
$('#ask-button').attr('class', 'ui button')
// qna
html_ans = "<div class='ui green inverted segment'><p style='font-size:15px'>" + response.ans + "</p></div><br>";
$("#ans-content").html(html_ans);
}
$("#ask-button").click(function (e) {
let text = $("#text").val();
let qn = $("#qn-text").val();
$('#ask-button').attr('class', 'ui loading button')
$.post("http://127.0.0.1:5000/qna-main", {text: text, qn:qn}, askData);
});
</script>
</body>