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

Commit d669410

Browse files
authored
Fix to BF-LU to exclude empty descriptors on intents (from JSON -> LU) (#383)
* fix. * fix * Fixing broken test * fixing pr comment.
1 parent 649396d commit d669410

File tree

4 files changed

+147
-5
lines changed

4 files changed

+147
-5
lines changed

packages/lu/src/parser/luis/luConverter.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,12 @@ const parseIntentsToLu = function(luisObj, luisJSON){
5858
fileContent += parseUtterancesToLu(intent.utterances, luisJSON)
5959
fileContent += NEWLINE + NEWLINE;
6060
if (intent.intent.features) {
61-
fileContent += `@ intent ${intent.intent.name}`;
62-
fileContent += addRolesAndFeatures(intent.intent);
63-
fileContent += NEWLINE + NEWLINE;
61+
let rolesAndFeatures = addRolesAndFeatures(intent.intent);
62+
if (rolesAndFeatures !== '') {
63+
fileContent += `@ intent ${intent.intent.name}`;
64+
fileContent += rolesAndFeatures;
65+
fileContent += NEWLINE + NEWLINE;
66+
}
6467
}
6568
});
6669
return fileContent

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,9 +467,16 @@ describe('luis:convert version 5 upgrade test', () => {
467467

468468
test
469469
.stdout()
470-
.command(['luis:convert', '--in', `${path.join(__dirname, './../../fixtures/testcases/v6WithoutPhraseLists.lu')}`, '--out', './results/root45.json'])
470+
.command(['luis:convert', '--in', `${path.join(__dirname, './../../fixtures/testcases/emptyIntentDescriptors.json')}`, '--out', './results/root40.lu'])
471+
.it('luis:convert successfully converts LUIS JSON model with empty intent feature descriptors', async () => {
472+
expect(await compareLuFiles('./../../../results/root40.lu', './../../fixtures/verified/emptyIntentDescriptors.lu')).to.be.true
473+
})
474+
475+
test
476+
.stdout()
477+
.command(['luis:convert', '--in', `${path.join(__dirname, './../../fixtures/testcases/v6WithoutPhraseLists.lu')}`, '--out', './results/root38.json'])
471478
.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 () => {
472-
expect(await compareLuFiles('./../../../results/root45.json', './../../fixtures/verified/v6WithoutPhraseLists.json')).to.be.true
479+
expect(await compareLuFiles('./../../../results/root38.json', './../../fixtures/verified/v6WithoutPhraseLists.json')).to.be.true
473480
})
474481

475482
test
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
{
2+
"luis_schema_version": "6.0.0",
3+
"intents": [
4+
{
5+
"name": "None",
6+
"features": []
7+
},
8+
{
9+
"name": "test",
10+
"features": []
11+
}
12+
],
13+
"entities": [
14+
{
15+
"name": "address",
16+
"children": [
17+
{
18+
"name": "doorNumber",
19+
"instanceOf": "number",
20+
"children": [],
21+
"features": []
22+
},
23+
{
24+
"name": "streetName",
25+
"children": [],
26+
"features": []
27+
},
28+
{
29+
"name": "city",
30+
"instanceOf": "geographyV2",
31+
"children": [],
32+
"features": []
33+
},
34+
{
35+
"name": "zipcode",
36+
"instanceOf": "zipRegex",
37+
"children": [],
38+
"features": []
39+
}
40+
],
41+
"roles": [],
42+
"features": []
43+
}
44+
],
45+
"hierarchicals": [],
46+
"composites": [],
47+
"closedLists": [],
48+
"prebuiltEntities": [
49+
{
50+
"name": "geographyV2",
51+
"roles": []
52+
},
53+
{
54+
"name": "number",
55+
"roles": []
56+
}
57+
],
58+
"utterances": [
59+
{
60+
"text": "one",
61+
"intent": "test",
62+
"entities": []
63+
},
64+
{
65+
"text": "two",
66+
"intent": "test",
67+
"entities": []
68+
}
69+
],
70+
"versionId": "0.1",
71+
"name": "Json 6.0.0 Full Appaaaaaaaaaa",
72+
"desc": "test",
73+
"culture": "en-us",
74+
"tokenizerVersion": "1.0.0",
75+
"patternAnyEntities": [],
76+
"regex_entities": [
77+
{
78+
"name": "zipRegex",
79+
"regexPattern": "[0-9]{5}",
80+
"roles": []
81+
}
82+
],
83+
"phraselists": [],
84+
"regex_features": [],
85+
"patterns": [],
86+
"settings": []
87+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
2+
> LUIS application information
3+
> !# @app.name = Json 6.0.0 Full Appaaaaaaaaaa
4+
> !# @app.desc = test
5+
> !# @app.versionId = 0.1
6+
> !# @app.culture = en-us
7+
> !# @app.luis_schema_version = 6.0.0
8+
9+
10+
> # Intent definitions
11+
12+
## None
13+
14+
15+
## test
16+
- one
17+
- two
18+
19+
20+
> # Entity definitions
21+
22+
@ ml address
23+
- @ number doorNumber
24+
- @ ml streetName
25+
- @ geographyV2 city
26+
- @ zipRegex zipcode
27+
28+
29+
30+
> # PREBUILT Entity definitions
31+
32+
@ prebuilt geographyV2
33+
34+
@ prebuilt number
35+
36+
37+
> # Phrase list definitions
38+
39+
40+
> # List entities
41+
42+
> # RegEx entities
43+
44+
@ regex zipRegex = /[0-9]{5}/
45+

0 commit comments

Comments
 (0)