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

Commit 432d1bd

Browse files
vishwacsenaVishwac Sena Kannan
andauthored
fix (#802)
Co-authored-by: Vishwac Sena Kannan <[email protected]>
1 parent ef2f009 commit 432d1bd

File tree

2 files changed

+37
-7
lines changed

2 files changed

+37
-7
lines changed

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -245,14 +245,17 @@ const buildPrebuiltEntities = function(blob, FinalLUISJSON){
245245
}
246246

247247
const buildModelFeatures = function(blob, FinalLUISJSON){
248-
// do we have model_features?
249-
if (blob.model_features === undefined || blob.model_features.length === 0) {
250-
return
251-
}
252-
blob.model_features.forEach(function (modelFeature) {
253-
let modelFeatureInMaster = helpers.filterMatch(FinalLUISJSON.model_features, 'name', modelFeature.name);
248+
// Find what scope to use in blob
249+
let blobScope = blob.model_features || blob.phraselists || [];
250+
if (blobScope.length === 0) return;
251+
252+
// Find the finalLuisJson scope to use
253+
let finalScope = FinalLUISJSON.model_features || FinalLUISJSON.phraselists;
254+
255+
blobScope.forEach(function (modelFeature) {
256+
let modelFeatureInMaster = helpers.filterMatch(finalScope, 'name', modelFeature.name);
254257
if (modelFeatureInMaster.length === 0) {
255-
FinalLUISJSON.model_features.push(modelFeature);
258+
finalScope.push(modelFeature);
256259
} else {
257260
if (modelFeatureInMaster[0].mode !== modelFeature.mode) {
258261
// error.

packages/lu/test/parser/lufile/luQnAFileReference.test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,39 @@ describe('Deep reference tests', function() {
167167
done()
168168
})
169169
})
170+
171+
it('Fix for BF-CLI #797 - deep references to phrase lists are handled correctly', function(done) {
172+
let luContent = `
173+
@ phraselist pl_1(interchangeable) =
174+
- pl 1
175+
- pl 1 1
176+
177+
## l_Test
178+
- [l_Test](./Test.lu#Test.Weather)
179+
`;
180+
181+
luMerger.Build([new luObj(luContent, new luOptions('main.lu', true))], false, undefined, findLuFiles)
182+
.then(res => done())
183+
.catch(err => done(err))
184+
})
170185
})
171186

172187
const findLuFiles = async function(srcId, idsToFind){
173188
let retPayload = [];
174189
idsToFind.forEach(ask => {
175190
switch(ask.filePath) {
191+
case './Test.lu':
192+
retPayload.push(new luObj(`
193+
[Phrase list definitions](./phrases.lumodule)
194+
195+
> # Intent definitions
196+
## Test.Weather
197+
- what is the weather`, new luOptions(ask.filePath, false)));
198+
retPayload.push(new luObj(`
199+
@ phraselist pl_2(interchangeable) =
200+
- pl 2
201+
- pl 2 2`, new luOptions(`phrases.lumodule`, true)))
202+
break;
176203
case 'qna1':
177204
retPayload.push(new luObj(`
178205
# ? q1

0 commit comments

Comments
 (0)