Skip to content

Commit

Permalink
Fix to clean up phraselists (#340)
Browse files Browse the repository at this point in the history
  • Loading branch information
vishwacsena authored Nov 12, 2019
1 parent 6a93b22 commit 48b85c6
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/lu/src/parser/lufile/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ const helpers = {
(finalLUISJSON.composites || []).find(i => i.features);
if (v5DefFound) {
finalLUISJSON.luis_schema_version = "6.0.0";
if (finalLUISJSON.model_features && finalLUISJSON.model_features.length !== 0) {
if (finalLUISJSON.model_features) {
finalLUISJSON.phraselists = [];
finalLUISJSON.model_features.forEach(item => finalLUISJSON.phraselists.push(Object.assign({}, item)));
delete finalLUISJSON.model_features;
Expand Down
7 changes: 7 additions & 0 deletions packages/lu/test/commands/luis/convert.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,13 @@ describe('luis:convert version 5 upgrade test', () => {
.it('luis:convert successfully converts LUIS JSON model with nDepth entity and features to LU', async () => {
expect(await compareLuFiles('./../../../results/root38.lu', './../../fixtures/verified/newEntityWithFeatures.lu')).to.be.true
})

test
.stdout()
.command(['luis:convert', '--in', `${path.join(__dirname, './../../fixtures/testcases/v6WithoutPhraseLists.lu')}`, '--out', './results/root38.json'])
.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 () => {
expect(await compareLuFiles('./../../../results/root38.json', './../../fixtures/verified/v6WithoutPhraseLists.json')).to.be.true
})
})

describe('luis:convert negative tests', () => {
Expand Down
18 changes: 18 additions & 0 deletions packages/lu/test/fixtures/testcases/v6WithoutPhraseLists.lu
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
> !# @app.name = test app
> !# @app.desc = test
> !# @app.versionId = 0.1
> !# @app.culture = en-us

# test
- one
- two

@ ml address =
- @ number doorNumber
- @ ml streetName
- @ geographyV2 city
- @ zipRegex zipcode

@ prebuilt number
@ prebuilt geographyV2
@ regex zipRegex = /[0-9]{5}/
75 changes: 75 additions & 0 deletions packages/lu/test/fixtures/verified/v6WithoutPhraseLists.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"intents": [
{
"name": "test"
}
],
"entities": [
{
"name": "address",
"roles": [],
"children": [
{
"name": "doorNumber",
"instanceOf": "number",
"children": []
},
{
"name": "streetName",
"instanceOf": null,
"children": []
},
{
"name": "city",
"instanceOf": "geographyV2",
"children": []
},
{
"name": "zipcode",
"instanceOf": "zipRegex",
"children": []
}
]
}
],
"composites": [],
"closedLists": [],
"regex_entities": [
{
"name": "zipRegex",
"regexPattern": "[0-9]{5}",
"roles": []
}
],
"regex_features": [],
"utterances": [
{
"text": "one",
"intent": "test",
"entities": []
},
{
"text": "two",
"intent": "test",
"entities": []
}
],
"patterns": [],
"patternAnyEntities": [],
"prebuiltEntities": [
{
"name": "number",
"roles": []
},
{
"name": "geographyV2",
"roles": []
}
],
"name": "test app",
"desc": "test",
"versionId": "0.1",
"culture": "en-us",
"luis_schema_version": "6.0.0",
"phraselists": []
}

0 comments on commit 48b85c6

Please sign in to comment.