diff --git a/packages/lu/src/parser/luis/luisCollate.js b/packages/lu/src/parser/luis/luisCollate.js index 27a38d75a..d8b566f55 100644 --- a/packages/lu/src/parser/luis/luisCollate.js +++ b/packages/lu/src/parser/luis/luisCollate.js @@ -245,14 +245,17 @@ const buildPrebuiltEntities = function(blob, FinalLUISJSON){ } const buildModelFeatures = function(blob, FinalLUISJSON){ - // do we have model_features? - if (blob.model_features === undefined || blob.model_features.length === 0) { - return - } - blob.model_features.forEach(function (modelFeature) { - let modelFeatureInMaster = helpers.filterMatch(FinalLUISJSON.model_features, 'name', modelFeature.name); + // Find what scope to use in blob + let blobScope = blob.model_features || blob.phraselists || []; + if (blobScope.length === 0) return; + + // Find the finalLuisJson scope to use + let finalScope = FinalLUISJSON.model_features || FinalLUISJSON.phraselists; + + blobScope.forEach(function (modelFeature) { + let modelFeatureInMaster = helpers.filterMatch(finalScope, 'name', modelFeature.name); if (modelFeatureInMaster.length === 0) { - FinalLUISJSON.model_features.push(modelFeature); + finalScope.push(modelFeature); } else { if (modelFeatureInMaster[0].mode !== modelFeature.mode) { // error. diff --git a/packages/lu/test/parser/lufile/luQnAFileReference.test.js b/packages/lu/test/parser/lufile/luQnAFileReference.test.js index d62c55d23..91af9cee3 100644 --- a/packages/lu/test/parser/lufile/luQnAFileReference.test.js +++ b/packages/lu/test/parser/lufile/luQnAFileReference.test.js @@ -167,12 +167,39 @@ describe('Deep reference tests', function() { done() }) }) + + it('Fix for BF-CLI #797 - deep references to phrase lists are handled correctly', function(done) { + let luContent = ` +@ phraselist pl_1(interchangeable) = + - pl 1 + - pl 1 1 + +## l_Test +- [l_Test](./Test.lu#Test.Weather) +`; + + luMerger.Build([new luObj(luContent, new luOptions('main.lu', true))], false, undefined, findLuFiles) + .then(res => done()) + .catch(err => done(err)) + }) }) const findLuFiles = async function(srcId, idsToFind){ let retPayload = []; idsToFind.forEach(ask => { switch(ask.filePath) { + case './Test.lu': + retPayload.push(new luObj(` +[Phrase list definitions](./phrases.lumodule) + +> # Intent definitions +## Test.Weather +- what is the weather`, new luOptions(ask.filePath, false))); + retPayload.push(new luObj(` +@ phraselist pl_2(interchangeable) = +- pl 2 +- pl 2 2`, new luOptions(`phrases.lumodule`, true))) + break; case 'qna1': retPayload.push(new luObj(` # ? q1