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

Commit 908bda0

Browse files
munozemiliovishwacsenaVishwac Sena KannanVishwac Sena Kannan
authored
Fix to LU cherry pick (#777)
* Fix lu converter to handle cases with space in child entity names (#775) * changes to converter * fix. Co-authored-by: Vishwac Sena Kannan <vishwacsenakannan@ALLISONT6-PROBK.northamerica.corp.microsoft.com> Co-authored-by: Vishwac Sena Kannan <[email protected]> * Bump version to last RC Co-authored-by: Vishwac Sena Kannan <[email protected]> Co-authored-by: Vishwac Sena Kannan <vishwacsenakannan@ALLISONT6-PROBK.northamerica.corp.microsoft.com> Co-authored-by: Vishwac Sena Kannan <[email protected]>
1 parent bd26487 commit 908bda0

File tree

6 files changed

+7617
-14
lines changed

6 files changed

+7617
-14
lines changed

build/botframework-cli-mac.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pr:
2828
jobs:
2929
- job: CLI
3030
variables:
31-
buildVersion: '4.9.0-RC6'
31+
buildVersion: '4.9.0-RC42'
3232
_version: ${{coalesce(variables.version, variables.buildVersion)}}
3333

3434
steps:

build/botframework-cli.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pr:
2828
jobs:
2929
- job: CLI
3030
variables:
31-
buildVersion: '4.9.0-RC6'
31+
buildVersion: '4.9.0-RC42'
3232
_version: ${{coalesce(variables.version, variables.buildVersion)}}
3333

3434
steps:

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

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,7 @@ const parseEntitiesToLu = function(luisJson){
191191
}
192192
fileContent += NEWLINE + NEWLINE;
193193
}
194-
fileContent += `@ ml `;
195-
fileContent += entity.name.includes(' ') ? `"${entity.name}"` : `${entity.name}`;
194+
fileContent += `@ ${getEntityType(entity.features)} ${writeEntityName(entity.name)}`;
196195
fileContent += addRolesAndFeatures(entity);
197196
fileContent += NEWLINE + NEWLINE;
198197
} else {
@@ -205,6 +204,10 @@ const parseEntitiesToLu = function(luisJson){
205204
return fileContent
206205
}
207206

207+
const writeEntityName = function(entityName) {
208+
return entityName.includes(' ') ? `"${entityName}"` : `${entityName}`
209+
}
210+
208211
const parseToLuPrebuiltEntities = function(luisJson){
209212
let fileContent = ''
210213
if(!luisJson.prebuiltEntities){
@@ -367,7 +370,7 @@ const addAppMetaData = function(LUISJSON) {
367370
const handleNDepthEntity = function(entity) {
368371
let fileContent = '';
369372
const BASE_TAB_STOP = 1;
370-
fileContent += `@ ${EntityTypeEnum.ML} ${entity.name}`;
373+
fileContent += `@ ${getEntityType(entity.features)} ${writeEntityName(entity.name)}`;
371374
fileContent += addRolesAndFeatures(entity);
372375
fileContent += NEWLINE;
373376
fileContent += addNDepthChildDefinitions(entity.children, BASE_TAB_STOP, fileContent) + NEWLINE + NEWLINE
@@ -383,15 +386,7 @@ const addNDepthChildDefinitions = function(childCollection, tabStop, fileContent
383386
let myFileContent = '';
384387
(childCollection || []).forEach(child => {
385388
myFileContent += "".padStart(tabStop * 4, ' ');
386-
myFileContent += '- @ ';
387-
// find constraint
388-
let constraint = (child.features || []).find(feature => feature.isRequired == true);
389-
if (constraint !== undefined) {
390-
myFileContent += constraint.modelName;
391-
} else {
392-
myFileContent += EntityTypeEnum.ML;
393-
}
394-
myFileContent += ` ${child.name}`;
389+
myFileContent += `- @ ${getEntityType(child.features)} ${writeEntityName(child.name)}`;
395390
myFileContent += addRolesAndFeatures(child);
396391
myFileContent += NEWLINE;
397392
if (child.children && child.children.length !== 0) {
@@ -400,6 +395,15 @@ const addNDepthChildDefinitions = function(childCollection, tabStop, fileContent
400395
});
401396
return myFileContent;
402397
}
398+
const getEntityType = function(features) {
399+
// find constraint
400+
let constraint = (features || []).find(feature => feature.isRequired == true);
401+
if (constraint !== undefined) {
402+
return constraint.modelName;
403+
} else {
404+
return EntityTypeEnum.ML;
405+
}
406+
}
403407
/**
404408
* Helper to construt role and features list for an entity
405409
* @param {Object} entity

packages/lu/test/commands/luis/convert.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ describe('luis:convert version 7 upgrade test', () => {
175175
it('luis:convert successfully converts LUIS JSON model with no phrase lists (output must have phraselists if any v6 concepts are present in the .lu file)', async () => {
176176
await assertToJSON('./../../fixtures/testcases/plWithFlags.lu', './../../fixtures/verified/plWithFlags.json')
177177
})
178+
179+
it('Child entities names with spaces in them parse correctly to .lu format', async () => {
180+
await assertToLu('./../../fixtures/testcases/Child_Entity_With_Spaces.json', './../../fixtures/verified/Child_Entity_With_Spaces.lu')
181+
})
178182
})
179183

180184
describe('luis:convert negative tests', () => {

0 commit comments

Comments
 (0)