-
Notifications
You must be signed in to change notification settings - Fork 0
/
validate-model.js
48 lines (38 loc) · 1.59 KB
/
validate-model.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
43
44
45
46
47
48
var chai = require('chai');
var expect = chai.expect;
const differ = (set1, set2) => [...set1].filter(num => !set2.has(num));
module.exports = function (story, model) {
describe('Models', function () {
it('should not have undeclared intents', function () {
var storyIntents = new Set();
story.getAllStates().forEach(
state => {
for (var property in state.actions) {
storyIntents.add(property);
}
}
);
var registeredIntents = new Set(model.interactionModel.languageModel.intents.map(it => it.name));
expect(differ(storyIntents, registeredIntents)).to.be.empty;
});
// TODO this does not need to run for every story
it('model should not have duplicate utterance samples', function (done) {
const samples = new Set();
var obj = model;
var error = false;
obj.interactionModel.languageModel.intents.forEach(intent => {
if (intent.samples) {
intent.samples.forEach(sample => {
if (samples.has(sample)) {
error = true;
done("Duplicate sample " + sample + " on intent " + intent.name + ' on model ' + modelFile);
}
samples.add(sample);
});
}
});
if (!error) done();
}
);
});
};