Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Commit 48b85c6

Browse files
authored
Fix to clean up phraselists (#340)
1 parent 6a93b22 commit 48b85c6

File tree

4 files changed

+101
-1
lines changed

4 files changed

+101
-1
lines changed

packages/lu/src/parser/lufile/helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ const helpers = {
168168
(finalLUISJSON.composites || []).find(i => i.features);
169169
if (v5DefFound) {
170170
finalLUISJSON.luis_schema_version = "6.0.0";
171-
if (finalLUISJSON.model_features && finalLUISJSON.model_features.length !== 0) {
171+
if (finalLUISJSON.model_features) {
172172
finalLUISJSON.phraselists = [];
173173
finalLUISJSON.model_features.forEach(item => finalLUISJSON.phraselists.push(Object.assign({}, item)));
174174
delete finalLUISJSON.model_features;

packages/lu/test/commands/luis/convert.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,13 @@ describe('luis:convert version 5 upgrade test', () => {
408408
.it('luis:convert successfully converts LUIS JSON model with nDepth entity and features to LU', async () => {
409409
expect(await compareLuFiles('./../../../results/root38.lu', './../../fixtures/verified/newEntityWithFeatures.lu')).to.be.true
410410
})
411+
412+
test
413+
.stdout()
414+
.command(['luis:convert', '--in', `${path.join(__dirname, './../../fixtures/testcases/v6WithoutPhraseLists.lu')}`, '--out', './results/root38.json'])
415+
.it('luis:convert successfully converts LUIS JSON model with no phrase lists (output must have phraselists if any v6 concepts are present in the .lu file)', async () => {
416+
expect(await compareLuFiles('./../../../results/root38.json', './../../fixtures/verified/v6WithoutPhraseLists.json')).to.be.true
417+
})
411418
})
412419

413420
describe('luis:convert negative tests', () => {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
> !# @app.name = test app
2+
> !# @app.desc = test
3+
> !# @app.versionId = 0.1
4+
> !# @app.culture = en-us
5+
6+
# test
7+
- one
8+
- two
9+
10+
@ ml address =
11+
- @ number doorNumber
12+
- @ ml streetName
13+
- @ geographyV2 city
14+
- @ zipRegex zipcode
15+
16+
@ prebuilt number
17+
@ prebuilt geographyV2
18+
@ regex zipRegex = /[0-9]{5}/
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
"intents": [
3+
{
4+
"name": "test"
5+
}
6+
],
7+
"entities": [
8+
{
9+
"name": "address",
10+
"roles": [],
11+
"children": [
12+
{
13+
"name": "doorNumber",
14+
"instanceOf": "number",
15+
"children": []
16+
},
17+
{
18+
"name": "streetName",
19+
"instanceOf": null,
20+
"children": []
21+
},
22+
{
23+
"name": "city",
24+
"instanceOf": "geographyV2",
25+
"children": []
26+
},
27+
{
28+
"name": "zipcode",
29+
"instanceOf": "zipRegex",
30+
"children": []
31+
}
32+
]
33+
}
34+
],
35+
"composites": [],
36+
"closedLists": [],
37+
"regex_entities": [
38+
{
39+
"name": "zipRegex",
40+
"regexPattern": "[0-9]{5}",
41+
"roles": []
42+
}
43+
],
44+
"regex_features": [],
45+
"utterances": [
46+
{
47+
"text": "one",
48+
"intent": "test",
49+
"entities": []
50+
},
51+
{
52+
"text": "two",
53+
"intent": "test",
54+
"entities": []
55+
}
56+
],
57+
"patterns": [],
58+
"patternAnyEntities": [],
59+
"prebuiltEntities": [
60+
{
61+
"name": "number",
62+
"roles": []
63+
},
64+
{
65+
"name": "geographyV2",
66+
"roles": []
67+
}
68+
],
69+
"name": "test app",
70+
"desc": "test",
71+
"versionId": "0.1",
72+
"culture": "en-us",
73+
"luis_schema_version": "6.0.0",
74+
"phraselists": []
75+
}

0 commit comments

Comments
 (0)