@@ -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+
208211const parseToLuPrebuiltEntities = function ( luisJson ) {
209212 let fileContent = ''
210213 if ( ! luisJson . prebuiltEntities ) {
@@ -367,7 +370,7 @@ const addAppMetaData = function(LUISJSON) {
367370const 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
0 commit comments