-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerator.js
42 lines (32 loc) · 1.07 KB
/
generator.js
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
/* globals
console, exports, require
*/
'use strict';
const intentUtteranceExpander = require('intent-utterance-expander');
const input = require('./input.json');
var fs = require('fs-extra');
const inputIntents = input.interactionModel.languageModel.intents;
var outputIntents = [];
var count = 0;
inputIntents.forEach(element => {
// console.log(element.name);
// console.log(element.samples);
if(element.samples.length > 0){
var expandedSamples = [];
element.samples.forEach(utterance => {
expandedSamples = expandedSamples.concat((intentUtteranceExpander(utterance)));
});
element.samples = expandedSamples;
count += expandedSamples.length;
}
outputIntents.push(element);
});
console.log(`Utterance count: ${count}`);
input.interactionModel.languageModel.intents = outputIntents;
const content = JSON.stringify(input, null, 4);
fs.outputFile("generated/interaction_model_generated.json", content, 'utf8', function (err) {
if (err) {
return console.log(err);
}
console.log("Model saved");
});