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

Commit 60e42cc

Browse files
vishwacsenaVishwac Sena Kannan
andauthored
fix (#792)
Co-authored-by: Vishwac Sena Kannan <[email protected]>
1 parent e7068d1 commit 60e42cc

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

packages/lu/src/parser/lufile/parseFileContents.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ const validateAndGetRoles = function(parsedContent, roles, line, entityName, ent
10151015
let roleFound = parsedContent.LUISJsonStructure.flatListOfEntityAndRoles.find(item => item.roles.includes(role) || item.name === role);
10161016
if (roleFound !== undefined) {
10171017
// PL entities use roles for things like interchangeable, disabled, enabled for all models. There are really not 'dupes'.
1018-
let hasBadNonPLRoles = (roleFound.roles || []).filter(item => item !== PLCONSTS.INTERCHANGEABLE && item !== PLCONSTS.ENABLEDFORALLMODELS && item !== PLCONSTS.DISABLED);
1018+
let hasBadNonPLRoles = (roleFound.roles || []).filter(item => item.toLowerCase() !== PLCONSTS.INTERCHANGEABLE && item.toLowerCase() !== PLCONSTS.ENABLEDFORALLMODELS && item.toLowerCase() !== PLCONSTS.DISABLED);
10191019
if (hasBadNonPLRoles.length !== 0) {
10201020
let errorMsg = `Roles must be unique across entity types. Invalid role definition found "${entityName}". Prior definition - '@ ${roleFound.type} ${roleFound.name}${roleFound.roles.length > 0 ? ` hasRoles ${roleFound.roles.join(',')}` : ``}'`;
10211021
let error = BuildDiagnostic({

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ const addRolesAndFeatures = function(entity) {
456456
const updateUtterancesList = function (srcCollection, tgtCollection, attribute) {
457457
(srcCollection || []).forEach(srcItem => {
458458
let matchInTarget = tgtCollection.find(item => item.intent.name == srcItem.intent);
459-
if(matchInTarget.utterances.length === 0) {
459+
if(!matchInTarget || matchInTarget.utterances.length === 0) {
460460
addUtteranceToCollection(attribute, srcItem, matchInTarget);
461461
return;
462462
}

packages/lu/test/parser/lufile/parseFileContents.NewEntityDefinition.test.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,5 +1175,27 @@ describe('V2 Entity definitions using @ notation', function () {
11751175
.catch(err => done(err))
11761176
})
11771177
})
1178+
1179+
describe('phrase lists with enabledForAllModels', function(){
1180+
it('BF-CLI #789 - phrase lists with enabledForAllModels parse correctly', function(done){
1181+
let luContent1 = new luObj(`@ phraselist Iam_gpl(interchangeable) enabledForAllModels =
1182+
- I
1183+
- I'm
1184+
- I am
1185+
- I be
1186+
1187+
@ phraselist my_gpl(interchangeable) enabledForAllModels =
1188+
- my
1189+
- mine
1190+
- me
1191+
`);
1192+
luBuilder.fromLUAsync([luContent1])
1193+
.then(res => {
1194+
assert.isTrue(res.model_features.length === 2);
1195+
done()
1196+
})
1197+
.catch(err => done(err))
1198+
})
1199+
})
11781200

11791201
});

0 commit comments

Comments
 (0)