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

Commit 4a034fe

Browse files
vishwacsenaVishwac Sena KannanVishwac Sena Kannan
authored
Fix lu parser to handle phrase lists with enabledForAllModels = false (#882)
* fix * Fixing tests. Co-authored-by: Vishwac Sena Kannan <[email protected]> Co-authored-by: Vishwac Sena Kannan <[email protected]>
1 parent afd83f6 commit 4a034fe

File tree

10 files changed

+3255
-16
lines changed

10 files changed

+3255
-16
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const INTENTTYPE = 'intent';
4848
const PLCONSTS = {
4949
DISABLED : 'disabled',
5050
ENABLEDFORALLMODELS: 'enabledforallmodels',
51+
DISABLEDFORALLMODELS: 'disabledforallmodels',
5152
INTERCHANGEABLE: '(interchangeable)'
5253
};
5354
const parseFileContentsModule = {
@@ -1042,7 +1043,7 @@ const validateAndGetRoles = function(parsedContent, roles, line, entityName, ent
10421043
let roleFound = parsedContent.LUISJsonStructure.flatListOfEntityAndRoles.find(item => item.roles.includes(role) || item.name === role);
10431044
if (roleFound !== undefined) {
10441045
// PL entities use roles for things like interchangeable, disabled, enabled for all models. There are really not 'dupes'.
1045-
let hasBadNonPLRoles = (roleFound.roles || []).filter(item => item.toLowerCase() !== PLCONSTS.INTERCHANGEABLE && item.toLowerCase() !== PLCONSTS.ENABLEDFORALLMODELS && item.toLowerCase() !== PLCONSTS.DISABLED);
1046+
let hasBadNonPLRoles = (roleFound.roles || []).filter(item => item.toLowerCase() !== PLCONSTS.INTERCHANGEABLE && item.toLowerCase() !== PLCONSTS.ENABLEDFORALLMODELS && item.toLowerCase() !== PLCONSTS.DISABLED && item.toLowerCase() !== PLCONSTS.DISABLEDFORALLMODELS);
10461047
if (hasBadNonPLRoles.length !== 0) {
10471048
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(',')}` : ``}'`;
10481049
let error = BuildDiagnostic({
@@ -1377,6 +1378,8 @@ const handlePhraseList = function(parsedContent, entityName, entityType, entityR
13771378
isPLEnabled = false;
13781379
} else if (item.toLowerCase() === PLCONSTS.ENABLEDFORALLMODELS) {
13791380
isPLEnabledForAllModels = true;
1381+
} else if (item.toLowerCase() === PLCONSTS.DISABLEDFORALLMODELS) {
1382+
isPLEnabledForAllModels = false;
13801383
} else if (item.toLowerCase() === PLCONSTS.INTERCHANGEABLE) {
13811384
entityName += item;
13821385
} else {

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,13 @@ const handlePhraseLists = function(collection) {
335335
fileContent += entity.name.includes(' ') ? `"${entity.name}"` : `${entity.name}`;
336336
fileContent += `${(entity.mode ? `(interchangeable)` : ``)}`;
337337
if (entity.activated !== undefined && !entity.activated) flags += `disabled`;
338-
if (entity.enabledForAllModels !== undefined && entity.enabledForAllModels) {
339-
flags += (flags !== '') ? `, enabledForAllModels` : `enabledForAllModels`;
340-
}
338+
if (entity.enabledForAllModels !== undefined) {
339+
if (entity.enabledForAllModels === true) {
340+
flags += (flags !== '') ? `, enabledForAllModels` : `enabledForAllModels`;
341+
} else {
342+
flags += (flags !== '') ? `, disabledForAllModels` : `disabledForAllModels`;
343+
}
344+
}
341345
if (flags !== '') fileContent += ` ${flags}`;
342346
if (entity.words && entity.words !== '') {
343347
fileContent += ` = ${NEWLINE}\t- ${entity.words}`;

0 commit comments

Comments
 (0)