forked from tejashah88/Alexa-Utterance-Generator
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
305 lines (253 loc) · 12.5 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="Cédric LACHAISE">
<!--<link rel="icon" href="../../favicon.ico">-->
<title>LUIS.AI Utterance Generator</title>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<link href="assets/css/ie10-viewport-bug-workaround.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="css/basic-format.css" rel="stylesheet">
<!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
<!--[if lt IE 9]><script src="assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
<script src="assets/js/ie-emulation-modes-warning.js"></script>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<!-- Add IntroJs styles -->
<link href="css/introjs.min.css" rel="stylesheet">
<!--'intent-utterance-generator' npm module-->
<script src="js/intent-utterance-generator-web.js"></script>
<script src="js/luis-json-generator.js"></script>
<!--clipboard.js-->
<script src="js/clipboard.min.js"></script>
</head>
<!--assets/img/github-banner.png-->
<body>
<a href="https://github.com/spikeyz/LUIS-Utterance-Generator"><img style="position: absolute; top: 0; left: 0; border: 0;" src="assets/img/github-banner.png" alt="Fork me on GitHub"></a>
<!-- Modal -->
<div class="modal fade" id="introModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title" id="myModalLabel">Welcome</h1>
</div>
<div class="modal-body">
<h4>Would you like to go through a short tutorial on using the website?</h4>
</div>
<div class="modal-footer">
<button id="startIntro" type="button" class="btn btn-success btn-lg" data-dismiss="modal">Yes</button>
<button type="button" class="btn btn-danger btn-lg" data-dismiss="modal">No</button>
</div>
</div>
</div>
</div>
<div class="jumbotron">
<div class="container">
<div class="big-title">
<h1>Microsoft LUIS.AI Utterance Generator</h1>
<h2>A website that allows you to generate numerous utterances with a simplistic GUI.</h2>
<p class="lead">Shoutout to <a href="https://github.com/tejashah88">tejashah88</a> for his <a href="https://github.com/tejashah88/Alexa-Utterance-Generator">Alexa-Utterance-Generator</a> Alexa version!</p>
</div>
<div class="instruction-box" data-position="auto" data-step="1" data-intro="You can check out the syntax for generating the utterances here.">
<h2 style="text-align: center;">Syntax for utterance generator<button class="btn btn-link btn-lg" type="button" data-toggle="collapse" data-target="#helpCollapse" aria-expanded="false" aria-controls="helpCollapse">Toggle</button></h2>
<div class="collapse" id="helpCollapse">
<div class="card card-block">
<p>Create first Entities with name surrounded by # like <b>#dogName#=JACK</b>. This value will be replaced during the generation</p>
<pre class="code-area">
Input: "(hello|hi) my dog #dogName#"
Output: "hello my dog JACK", "hi my dog JACK"</pre>
<p>The syntax is very similar to the original syntax for making the utterances. You can check it out <a href="https://dev.projectoxford.ai/docs/services/5890b47c39e2bb17b84a55ff/operations/5890b47c39e2bb052c5b9c09">here</a>. The only difference is that the new syntax makes it easier to create variations of utterances with parenthesis groups.</p>
<pre class="code-area">
Input: "(hello|hi) world"
Output: "hello world", "hi world"</pre>
<p>You also can specify the parenthesis group to be 'optional', with the '|' symbol</p>
<pre class="code-area">
Input: "I (love|hate) (|big) dogs"
Output: "I love big dogs", "I love dogs", "I hate big dogs", "I hate dogs"</pre>
<p>If you want more examples, the original author of the node module, <a href="https://github.com/miguelmota">miguelmota</a>, has some <a href="https://github.com/miguelmota/intent-utterance-expander#usage">here</a>!</p>
</div>
</div>
</div>
<div class="container" style="margin-top:20px">
<div class="row">
<div class="col-xs-4" id="apiVersion" data-step="2" data-intro="Select API version" style="margin-left:20px" >
<span class="lead" style="vertical-align:bottom">Microsoft LUIS API version :</span>
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-primary">
<input type="radio" name="options" value="1" autocomplete="off"> v1
</label>
<label class="btn btn-primary active">
<input type="radio" name="options" value="2" autocomplete="off" checked> v2
</label>
</div>
</div>
</div>
<!--ENTITIES-->
<div class="col-xs-4" data-position="auto" data-step="3" data-intro="This section allows you to create entities for all intents" >
<h3 class="list-group-item text-center">Entities</h3>
<br>
<div class="input-group">
<input id="entityName" type="text" class="form-control input-lg" placeholder="Add Entity..."></input>
<span class="input-group-btn">
<button id="addEntity" class="btn btn-primary btn-lg" type="button">+</button>
</span>
</div>
<ul id="entityList" class="list-group"></ul>
</div>
<!--INTENTS-->
<div class="col-xs-4" data-position="auto" data-step="4" data-intro="This section allows you to create intents in order to organize your utterances to each intent.">
<h3 class="list-group-item text-center">Intents</h3>
<br>
<div class="input-group">
<input id="intentName" type="text" class="form-control input-lg" placeholder="Add Intent..."></input>
<span class="input-group-btn">
<button id="addIntent" class="btn btn-primary btn-lg" type="button">+</button>
</span>
</div>
<ul id="intentList" class="list-group"></ul>
<!--<button id="compileUtterances" class="btn btn-success btn-lg btn-block" type="button" data-position="auto" data-step="4" data-intro="Once you are done, click this button to have your utterances generated. Good luck!">Create Utterances</button>-->
</div>
<!--UTTERANCES-->
<div class="col-xs-4" data-position="auto" data-step="5" data-intro="This section is where you enter the script to generate the utterances.">
<div class="input-group">
<h3 id="intentTitle" class="list-group-item text-center">Please add an intent</h3>
<span class="input-group-btn">
<h3 id="deleteIntent" class="btn btn-danger btn-lg" type="button">x</h3>
</span>
</div>
<br>
<textarea disabled id="codeArea" type="textarea" class="form-control" rows="5"></textarea><br/>
<button id="compileUtterances" class="btn btn-success btn-lg btn-block" type="button" data-position="auto" data-step="6" data-intro="Once you are done, click this button to have your utterances generated. Good luck!">Create Utterances</button>
</div>
</div>
<div id="finalResults" class="container" style="display:none">
<h2 class="list-group-item text-center">Final Results</h2>
<div class="container" style="padding:15px">
<pre id="resultUtterances" class="code-area"></pre>
</div>
<button id="copyUtterances" class="btn btn-info btn-lg btn-block" data-clipboard-target="#resultUtterances" type="button">Copy!</button>
</div>
</div>
</div>
<div class="container">
<footer>
<p>Fork by Cédric Lachaise (<a href="https://github.com/spikeyz">Spikeyz</a>)</p>
</footer>
</div>
<!-- /.container -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="../../assets/js/vendor/jquery.min.js"><\/script>')</script>
<script src="js/bootstrap.min.js"></script>
<!-- intro.js -->
<script src="js/intro.min.js"></script>
<script type="text/javascript">
var intents = new Map();
var entities = new Map();
var intentButtons;
var selectedIntent = "undefined";
var btnCopyUtterances = document.getElementById("copyUtterances");
var clipboard = new Clipboard(btnCopyUtterances);
clipboard.on('success', function(e) {
e.clearSelection();
});
$('#startIntro').on('click', (e) => {
introJs().start();
})
$('#codeArea').bind('input propertychange', () => {
intents.set(selectedIntent, $("#codeArea").val());
});
$('#copyUtterances').on('click', (e) => {
alert("Success! The generated utterances have been copied.");
})
$("#compileUtterances").on('click', (e) => {
if (intents.size === 0) {
document.getElementById("resultUtterances").innerText = "";
document.getElementById("finalResults").style.display = 'none';
return;
}
var inputData = {};
intents.forEach((value, key) => {
var lines = value.split("\n");
inputData[key] = lines;
});
//LUIS utterances
var version = $('#apiVersion input:radio:checked').val();
var outputData = luisJSONGenerator(inputData, entities, version);
document.getElementById("resultUtterances").innerText = JSON.stringify(outputData, undefined, 4);
if (intents.size > 0)
document.getElementById("finalResults").style.display = 'inline';
})
$("#deleteIntent").on('click', (e) => {
var targetIntentBtn = document.getElementById("intent" + selectedIntent);
intents.delete(selectedIntent);
if (targetIntentBtn !== null)
targetIntentBtn.remove();
$("#codeArea").val("");
var ul = document.getElementById("intentList");
if ($("ul button").length === 0) {
document.getElementById("codeArea").disabled = true;
document.getElementById("intentTitle").innerText = "Please add an intent";
} else {
document.getElementById("codeArea").disabled = false;
document.getElementById("intentTitle").innerText = "Select an intent";
}
})
$("#addIntent").on('click', (e) => {
var ul = document.getElementById("intentList");
var button = document.createElement("button");
selectedIntent = document.getElementById('intentName').value;
if (selectedIntent === "")
return;
if (intents.get(selectedIntent) === undefined)
intents.set(selectedIntent, "");
else
return;
document.getElementById('intentName').value = "";
document.getElementById("intentTitle").innerText = selectedIntent;
$("#codeArea").val("");
document.getElementById("codeArea").disabled = false;
button.appendChild(document.createTextNode(selectedIntent));
button.setAttribute("id", "intent" + selectedIntent);
button.setAttribute("class", "list-group-item");
button.addEventListener("click", function() {
selectedIntent = this.innerText;
document.getElementById("intentTitle").innerText = selectedIntent;
$("#codeArea").val(intents.get(selectedIntent));
});
ul.appendChild(button);
})
$("#addEntity").on('click', (e) => {
var ul = document.getElementById("entityList");
var button = document.createElement("button");
selectedEntity = document.getElementById('entityName').value;
let entity = selectedEntity.split('=');
entities.set(entity[0].trim(), entity[1].trim());
document.getElementById('entityName').value = "";
button.appendChild(document.createTextNode(selectedEntity));
button.setAttribute("id", "entity" + selectedEntity);
button.setAttribute("class", "list-group-item");
button.addEventListener("click", function() {
selectedEntity = this.innerText;
document.getElementById("entityTitle").innerText = selectedEntity;
});
ul.appendChild(button);
})
$('#introModal').modal('show');
</script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="assets/js/ie10-viewport-bug-workaround.js"></script>
</body>
</html>