-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgraph.html
354 lines (332 loc) · 13.9 KB
/
graph.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
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Rasa Core Visualisation</title>
<script src="https://dagrejs.github.io/project/dagre-d3/latest/dagre-d3.min.js"></script>
<script src="https://dagrejs.github.io/project/dagre/latest/dagre.min.js"></script>
<script src="https://d3js.org/d3.v4.js"></script>
<script src="https://dagrejs.github.io/project/graphlib-dot/v0.6.3/graphlib-dot.js"></script>
</head>
<body>
<div id="errormsg" style="color: #b00"></div>
<svg>
<style id="graph-style">
.node.invisible > rect {
display: none;
}
.node.start > rect {
fill: #7f7;
rx: 30;
ry: 18;
}
.node.end > rect {
fill: #f77;
rx: 30;
ry: 18;
}
.node:not(.active) > rect, .node:not(.active) > .label {
opacity: 0.4;
}
.edgePath:not(.active) path {
opacity: 0.4;
}
.node.ellipsis > rect {
fill: #CCC;
}
.node.intent > rect {
fill: #7ff;
}
.node.dashed > rect {
stroke-dasharray: 5;
}
text {
font-weight: 300;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serf, serif;
font-size: 14px;
color: #1f1d1d;
}
.node rect {
stroke: #444;
fill: #fff;
stroke-width: 1.5px;
}
.edgePath path {
stroke: #333;
stroke-width: 1.5px;
}
svg {
position: fixed;
top: 10px;
left: 0;
height: 100%;
width: 100%
}
</style>
<g></g>
</svg>
<script>
function serveGraph() {
let oldInputGraphValue;
const url = 'visualization.dot';
const refreshInterval = 500;
// trigger a refresh by fetching an updated graph
setInterval(function () {
fetch(url).then(r => r.text()).then(dot => {
document.getElementById('errormsg').innerHTML = '';
if (oldInputGraphValue === dot) return;
oldInputGraphValue = dot;
drawGraph(dot);
}).catch(err => {
document.getElementById('errormsg').innerHTML =
'Failed to update plot. (' + err.message + ')';
});
}, refreshInterval);
}
function drawGraph(graph) {
let g = graphlibDot.read(graph);
// Set margins, if not present
if (!g.graph().hasOwnProperty("marginx") &&
!g.graph().hasOwnProperty("marginy")) {
g.graph().marginx = 20;
g.graph().marginy = 20;
}
g.graph().transition = function (selection) {
return selection.transition().duration(300);
};
// Render the graph into svg g
d3.select("svg g").call(render, g);
}
// Set up zoom support
const svg = d3.select("svg"),
inner = d3.select("svg g"),
zoom = d3.zoom().on("zoom", function () {
inner.attr("transform", d3.event.transform);
});
svg.call(zoom);
// Create and configure the renderer
const render = dagreD3.render();
let isClient = false;
isClient = true;
if (isClient) {
// Mark all nodes and their edges as active
cssRules = document.getElementById('graph-style').sheet.cssRules;
cssRules[3].style.opacity = 1;
cssRules[4].style.opacity = 1;
let graph;
graph = `digraph {
0 [class="start active", fillcolor=green, fontsize=12, label=START, style=filled];
"-1" [class=end, fillcolor=red, fontsize=12, label=END, style=filled];
1 [class="", fontsize=12, label=action_tell_club_info];
2 [class="", fontsize=12, label=action_tell_event_choices];
3 [class="", fontsize=12, label=action_tell_event_info];
5 [class="", fontsize=12, label=utter_faq];
6 [class="", fontsize=12, label=utter_contact_email];
7 [class="", fontsize=12, label=utter_greet];
8 [class="", fontsize=12, label=utter_name];
9 [class="", fontsize=12, label=utter_greet_name];
10 [class="", fontsize=12, label=utter_options];
12 [class="", fontsize=12, label=utter_libraryfaq];
13 [class="", fontsize=12, label=utter_out_of_scope];
14 [class="", fontsize=12, label=utter_chitchat];
15 [class="", fontsize=12, label=utter_ask_stud_id];
16 [class="", fontsize=12, label=utter_ask_continue];
17 [class="", fontsize=12, label=utter_fine];
19 [class="", fontsize=12, label=utter_ask_stud_pwd];
20 [class="", fontsize=12, label=action_tell_stud_gpa];
25 [class="", fontsize=12, label=utter_ask_feedback_choice];
26 [class="", fontsize=12, label=utter_ask_feedback_message];
27 [class="", fontsize=12, label=action_get_feedback];
32 [class="", fontsize=12, label=utter_ask_academics];
33 [class="", fontsize=12, label=utter_ask_stud_id];
34 [class="", fontsize=12, label=utter_ask_stud_pwd];
47 [class="", fontsize=12, label=utter_ask_library];
54 [class="", fontsize=12, label=utter_ask_others];
59 [class="", fontsize=12, label=utter_ask_non_academics];
73 [class="", fontsize=12, label=action_tell_club_choices];
80 [class="", fontsize=12, label=utter_designations_reply];
81 [class="", fontsize=12, label=utter_button_for_club_info];
82 [class="", fontsize=12, label=utter_total_club_join];
87 [class="", fontsize=12, label=utter_how_to_create_clubs_reply];
91 [class="", fontsize=12, label="..."];
92 [class="", fontsize=12, label=action_two_stage_fallback];
94 [class="", fontsize=12, label=action_two_stage_fallback];
95 [class="", fontsize=12, label=action_restart_with_button];
97 [class="", fontsize=12, label=utter_goodbye];
99 [class="", fontsize=12, label=utter_start_reply];
105 [class="", fontsize=12, label=utter_options];
106 [class=intent, fillcolor=lightblue, label="How do I choose a club", shape=rect, style=filled];
107 [class=intent, fillcolor=lightblue, label="I want to know about BSF", shape=rect, style=filled];
108 [class=intent, fillcolor=lightblue, label="what is the full form of BPDC?", shape=rect, style=filled];
109 [class=intent, fillcolor=lightblue, label="Can i talk to a human instead", shape=rect, style=filled];
110 [class=intent, fillcolor=lightblue, label="Hi there", shape=rect, style=filled];
111 [class=intent, fillcolor=lightblue, label="Are all the textbooks allowed for issuing?", shape=rect, style=filled];
112 [class=intent, fillcolor=lightblue, label="can you help me with your docs", shape=rect, style=filled];
113 [class=intent, fillcolor=lightblue, label="what can you do", shape=rect, style=filled];
114 [class=intent, fillcolor=lightblue, label="what are my scores", shape=rect, style=filled];
115 [class=intent, fillcolor=lightblue, label="I have a complaint", shape=rect, style=filled];
116 [class=intent, fillcolor=lightblue, label="When can I apply for club President", shape=rect, style=filled];
117 [class=intent, fillcolor=lightblue, label="I want to join more than one clubs", shape=rect, style=filled];
118 [class=intent, fillcolor=lightblue, label="I want to create my own club", shape=rect, style=filled];
119 [class=intent, fillcolor=lightblue, label="events?", shape=rect, style=filled];
120 [class=intent, fillcolor=lightblue, label="no, my frst time", shape=rect, style=filled];
121 [class=intent, fillcolor=lightblue, label=yeah, shape=rect, style=filled];
122 [class=intent, fillcolor=lightblue, label="I want to join a club", shape=rect, style=filled];
123 [class=intent, fillcolor=lightblue, label="STEM@BITS", shape=rect, style=filled];
124 [class=intent, fillcolor=lightblue, label="My name is Richard smith", shape=rect, style=filled];
125 [class=intent, fillcolor=lightblue, label="How do I talk to a human", shape=rect, style=filled];
126 [class=intent, fillcolor=lightblue, label="What are the academic features of our college", shape=rect, style=filled];
127 [class=intent, fillcolor=lightblue, label="What are the extra curricular activities in our uni", shape=rect, style=filled];
128 [class=intent, fillcolor=lightblue, label="What's the current time?", shape=rect, style=filled];
129 [class=intent, fillcolor=lightblue, label="what languages you can be comfortable speaking?", shape=rect, style=filled];
130 [class=intent, fillcolor=lightblue, label="Sorry, I don't have it", shape=rect, style=filled];
131 [class=intent, fillcolor=lightblue, label="2015A2PS0100U", shape=rect, style=filled];
132 [class=intent, fillcolor=lightblue, label="Sorry, I don't have it", shape=rect, style=filled];
133 [class=intent, fillcolor=lightblue, label="dwjfni*&6a123", shape=rect, style=filled];
134 [class=intent, fillcolor=lightblue, label="I don't remember my password", shape=rect, style=filled];
135 [class=intent, fillcolor=lightblue, label=Chatbot, shape=rect, style=filled];
136 [class=intent, fillcolor=lightblue, label="are u, facebook?", shape=rect, style=filled];
137 [class=intent, fillcolor=lightblue, label="can you please tell me my gpa score", shape=rect, style=filled];
138 [class=intent, fillcolor=lightblue, label="Is there a library at BPDC", shape=rect, style=filled];
139 [class=intent, fillcolor=lightblue, label="Where are the other options?", shape=rect, style=filled];
140 [class=intent, fillcolor=lightblue, label="2018a1ps0058u", shape=rect, style=filled];
141 [class=intent, fillcolor=lightblue, label="dwjfni*&6a123", shape=rect, style=filled];
142 [class=intent, fillcolor=lightblue, label="How can I get old papers?", shape=rect, style=filled];
143 [class=intent, fillcolor=lightblue, label="Is that it?", shape=rect, style=filled];
144 [class=intent, fillcolor=lightblue, label="what are the events in our Uni?", shape=rect, style=filled];
145 [class=intent, fillcolor=lightblue, label="I want to be a part of MTC", shape=rect, style=filled];
146 [class=intent, fillcolor=lightblue, label=ACM, shape=rect, style=filled];
147 [class=intent, fillcolor=lightblue, label="/nlu_fallback", shape=rect, style=filled];
148 [class=intent, fillcolor=lightblue, label=byee, shape=rect, style=filled];
149 [class=intent, fillcolor=lightblue, label="/start", shape=rect, style=filled];
150 [class=intent, fillcolor=lightblue, label="what is the address of BPDC?", shape=rect, style=filled];
151 [class=intent, fillcolor=lightblue, label="what languages you prefer more speaking at?", shape=rect, style=filled];
152 [class=intent, fillcolor=lightblue, label="Can I go back to the options", shape=rect, style=filled];
0 -> 91 [class="", key=NONE, label=""];
0 -> 106 [class="", key=0];
0 -> 107 [class="", key=0];
0 -> 108 [class="", key=0];
0 -> 109 [class="", key=0];
0 -> 110 [class="", key=0];
0 -> 111 [class="", key=0];
0 -> 112 [class="", key=0];
0 -> 113 [class="", key=0];
0 -> 114 [class="", key=0];
0 -> 115 [class="", key=0];
0 -> 116 [class="", key=0];
0 -> 117 [class="", key=0];
0 -> 118 [class="", key=0];
0 -> 119 [class="", key=0];
0 -> 120 [class="", key=0];
0 -> 121 [class="", key=0];
0 -> 122 [class="", key=0];
1 -> "-1" [class="", key=NONE, label=""];
2 -> 123 [class="", key=0];
3 -> "-1" [class="", key=NONE, label=""];
5 -> "-1" [class="", key=NONE, label=""];
6 -> "-1" [class="", key=NONE, label=""];
7 -> 8 [class="", key=NONE, label=""];
8 -> 124 [class="", key=0];
9 -> 10 [class="", key=NONE, label=""];
10 -> 125 [class="", key=0];
10 -> 126 [class="", key=0];
10 -> 127 [class="", key=0];
10 -> 128 [class="", key=0];
12 -> "-1" [class="", key=NONE, label=""];
13 -> "-1" [class="", key=NONE, label=""];
14 -> "-1" [class="", key=NONE, label=""];
14 -> 129 [class="", key=0];
15 -> 130 [class="", key=0];
15 -> 131 [class="", key=0];
16 -> 132 [class="", key=0];
17 -> "-1" [class="", key=NONE, label=""];
19 -> 133 [class="", key=0];
19 -> 134 [class="", key=0];
20 -> "-1" [class="", key=NONE, label=""];
25 -> 135 [class="", key=0];
26 -> 136 [class="", key=0];
27 -> "-1" [class="", key=NONE, label=""];
32 -> 137 [class="", key=0];
32 -> 138 [class="", key=0];
32 -> 139 [class="", key=0];
33 -> 140 [class="", key=0];
34 -> 141 [class="", key=0];
47 -> 142 [class="", key=0];
54 -> "-1" [class="", key=NONE, label=""];
59 -> 143 [class="", key=0];
59 -> 144 [class="", key=0];
59 -> 145 [class="", key=0];
73 -> 146 [class="", key=0];
80 -> 81 [class="", key=NONE, label=""];
81 -> "-1" [class="", key=NONE, label=""];
82 -> 81 [class="", key=NONE, label=""];
87 -> 81 [class="", key=NONE, label=""];
91 -> 94 [class="", key=NONE, label=""];
91 -> 147 [class="", key=0];
91 -> 148 [class="", key=0];
91 -> 149 [class="", key=0];
91 -> 150 [class="", key=0];
91 -> 151 [class="", key=0];
91 -> 152 [class="", key=0];
92 -> "-1" [class="", key=NONE, label=""];
94 -> 95 [class="", key=NONE, label=""];
95 -> "-1" [class="", key=NONE, label=""];
97 -> "-1" [class="", key=NONE, label=""];
99 -> "-1" [class="", key=NONE, label=""];
105 -> "-1" [class="", key=NONE, label=""];
106 -> 1 [class="", key=0];
107 -> 2 [class="", key=0];
108 -> 5 [class="", key=0];
109 -> 6 [class="", key=0];
110 -> 7 [class="", key=0];
111 -> 12 [class="", key=0];
112 -> 13 [class="", key=0];
113 -> 14 [class="", key=0];
114 -> 15 [class="", key=0];
115 -> 25 [class="", key=0];
116 -> 80 [class="", key=0];
117 -> 82 [class="", key=0];
118 -> 87 [class="", key=0];
119 -> 3 [class="", key=0];
120 -> 17 [class="", key=0];
121 -> 73 [class="", key=0];
122 -> 73 [class="", key=0];
123 -> 3 [class="", key=0];
124 -> 9 [class="", key=0];
125 -> 6 [class="", key=0];
126 -> 32 [class="", key=0];
127 -> 59 [class="", key=0];
128 -> 14 [class="", key=0];
129 -> 14 [class="", key=0];
130 -> 16 [class="", key=0];
131 -> 19 [class="", key=0];
132 -> 17 [class="", key=0];
133 -> 20 [class="", key=0];
134 -> 16 [class="", key=0];
135 -> 26 [class="", key=0];
136 -> 27 [class="", key=0];
137 -> 33 [class="", key=0];
138 -> 47 [class="", key=0];
139 -> 54 [class="", key=0];
140 -> 34 [class="", key=0];
141 -> 20 [class="", key=0];
142 -> 12 [class="", key=0];
143 -> 54 [class="", key=0];
144 -> 2 [class="", key=0];
145 -> 73 [class="", key=0];
146 -> 1 [class="", key=0];
147 -> 92 [class="", key=0];
148 -> 97 [class="", key=0];
149 -> 99 [class="", key=0];
150 -> 5 [class="", key=0];
151 -> 14 [class="", key=0];
152 -> 105 [class="", key=0];
}
`;
drawGraph(graph);
} else {
serveGraph();
}
</script>
</body>
</html>