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

Commit 17c7565

Browse files
authored
fix luis objects merging over-filtering issue (#1108)
1 parent fe56306 commit 17c7565

File tree

2 files changed

+19
-22
lines changed

2 files changed

+19
-22
lines changed

packages/lu/src/parser/lu/luMerger.js

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -380,12 +380,7 @@ const buildLuJsonObject = async function(luObjArray, log, luis_culture, luSearch
380380
let parsedContent = await parseLuFile(luOb, log, luis_culture)
381381
parsedFiles.push(luOb.id)
382382

383-
// Fix for BF-CLI #620
384-
// We do not perform validation here. for parseFile V1 API route,
385-
// the recommendation is to call validate() after parse.
386-
if (haveLUISContent(parsedContent.LUISJsonStructure)) {
387-
allParsedLUISContent.push(parserObject.create(parsedContent.LUISJsonStructure, undefined, undefined, luOb.id, luOb.includeInCollate))
388-
}
383+
allParsedLUISContent.push(parserObject.create(parsedContent.LUISJsonStructure, undefined, undefined, luOb.id, luOb.includeInCollate))
389384

390385
allParsedQnAContent.push(parserObject.create(undefined, parsedContent.qnaJsonStructure, undefined, luOb.id, luOb.includeInCollate))
391386
allParsedAlterationsContent.push(parserObject.create(undefined, undefined, parsedContent.qnaAlterations, luOb.id, luOb.includeInCollate))
@@ -496,21 +491,6 @@ const updateParsedFiles = function(allParsedLUISContent, allParsedQnAContent, al
496491
}
497492
}
498493

499-
const haveLUISContent = function(blob) {
500-
if(!blob) return false;
501-
return ((blob[LUISObjNameEnum.INTENT].length > 0) ||
502-
(blob[LUISObjNameEnum.ENTITIES].length > 0) ||
503-
(blob[LUISObjNameEnum.CLOSEDLISTS].length > 0) ||
504-
(blob[LUISObjNameEnum.PATTERNANYENTITY].length > 0) ||
505-
(blob.patterns.length > 0) ||
506-
(blob[LUISObjNameEnum.UTTERANCE].length > 0) ||
507-
(blob.prebuiltEntities.length > 0) ||
508-
(blob[LUISObjNameEnum.REGEX].length > 0) ||
509-
(blob.model_features && blob.model_features.length > 0) ||
510-
(blob.phraselists && blob.phraselists.length > 0) ||
511-
(blob.composites.length > 0));
512-
}
513-
514494
const isNewEntity = function(luisModel, entityName){
515495
let simpleEntityInMaster = luisModel.entities.find(item => item.name == entityName);
516496
let compositeInMaster = luisModel.composites.find(item => item.name == entityName);

packages/lu/test/parser/luis/luisBuilder.test.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,22 @@ assert.isTrue(luisObject.validate())
7878
assert.equal(luisObject.content.includes(`@ intent "test intent" usesFeature bar`), true);
7979
})
8080

81-
81+
it('App settings can be merged correctly when importing lu files', async () => {
82+
let luFile = `
83+
> !# @app.culture = zh-cn
84+
> !# @app.settings.NormalizeWordForm = true
85+
> !# @app.settings.UseAllTrainingData = true
86+
87+
[import greeting](./test/fixtures/testcases/collate/1.lu)`;
88+
89+
const luisObject = await LUISBuilder.fromLUAsync(luFile)
90+
91+
assert.equal(luisObject.intents[0].name, 'Greeting');
92+
assert.equal(luisObject.culture, 'zh-cn');
93+
assert.equal(luisObject.settings.length, 2);
94+
assert.equal(luisObject.settings[0].name, 'NormalizeWordForm');
95+
assert.equal(luisObject.settings[0].value, true);
96+
assert.equal(luisObject.settings[1].name, 'UseAllTrainingData');
97+
assert.equal(luisObject.settings[1].value, true);
98+
});
8299
});

0 commit comments

Comments
 (0)