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

Commit 760713e

Browse files
Vishwac Sena KannanVishwac Sena Kannan
authored andcommitted
Finalizing
1 parent dc620e8 commit 760713e

19 files changed

+172
-139
lines changed

packages/luis/src/parser/converters/luistoluconverter.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ module.exports = {
103103
}
104104
fileContent += NEWLINE + NEWLINE;
105105
}
106-
fileContent += `@ simple ${entity.name}`;
106+
fileContent += `@ ml ${entity.name}`;
107107
fileContent += addRolesAndFeatures(entity);
108108
fileContent += NEWLINE + NEWLINE;
109109
} else {
@@ -187,6 +187,10 @@ module.exports = {
187187
return fileContent;
188188
}
189189
}
190+
/**
191+
* Helper function to handle nDepth entity definition
192+
* @param {Object} entity
193+
*/
190194
const handleNDepthEntity = function(entity) {
191195
let fileContent = '';
192196
const BASE_TAB_STOP = 1;
@@ -196,6 +200,12 @@ const handleNDepthEntity = function(entity) {
196200
fileContent += addNDepthChildDefinitions(entity.children, BASE_TAB_STOP, fileContent) + NEWLINE + NEWLINE
197201
return fileContent;
198202
}
203+
/**
204+
* Recursive helper function to add child definitions.
205+
* @param {Object[]} childCollection
206+
* @param {number} tabStop
207+
* @param {string} fileContent
208+
*/
199209
const addNDepthChildDefinitions = function(childCollection, tabStop, fileContent) {
200210
let myFileContent = '';
201211
(childCollection || []).forEach(child => {
@@ -206,7 +216,7 @@ const addNDepthChildDefinitions = function(childCollection, tabStop, fileContent
206216
} else if (child.children && child.children.length !== 0){
207217
myFileContent += EntityTypeEnum.ML;
208218
} else {
209-
myFileContent += EntityTypeEnum.SIMPLE;
219+
myFileContent += EntityTypeEnum.ML;
210220
}
211221
myFileContent += ` ${child.name}`;
212222
myFileContent += addRolesAndFeatures(child);

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@ const handleNDepthEntity = function(parsedContent, entityName, entityRoles, enti
977977
let entityIsUnique = verifyUniqueEntityName(parsedContent, childEntityName, childEntityType, line, true);
978978

979979
// Get current tab level
980-
let tabLevel = Math.ceil(groupsFound.groups.leadingSpaces ? groupsFound.groups.leadingSpaces.length / SPACEASTABS : undefined) || (groupsFound.groups.leadingTabs ? groupsFound.groups.leadingTabs.length : undefined);
980+
let tabLevel = Math.ceil(groupsFound.groups.leadingSpaces !== undefined ? groupsFound.groups.leadingSpaces.length / SPACEASTABS : 0) || (groupsFound.groups.leadingTabs !== undefined ? groupsFound.groups.leadingTabs.length : 0);
981981
if (defLine === line.start.line + 1) {
982982
// remember the tab level at the first line of child definition
983983
baseTabLevel = tabLevel;
@@ -986,6 +986,7 @@ const handleNDepthEntity = function(parsedContent, entityName, entityRoles, enti
986986
}
987987

988988
currentParentEntity = entityIdxByLevel.reverse().find(item => item.level == tabLevel - baseTabLevel);
989+
entityIdxByLevel.reverse();
989990
if (!currentParentEntity) {
990991
let errorMsg = `[ERROR] line ${defLine}: Invalid definition found for child "${child.trim()}". Parent of each child entity must be of type "${EntityTypeEnum.ML}".`;
991992
throw (new exception(retCode.errorCode.INVALID_INPUT, errorMsg));

packages/luis/test/fixtures/verified/allGen.lu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353

5454
> # Entity definitions
5555

56-
@ simple userName
56+
@ ml userName
5757

5858

5959
> # PREBUILT Entity definitions

packages/luis/test/fixtures/verified/luis_sorted.lu

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@
6262

6363
> # Entity definitions
6464

65-
@ simple customDevice
65+
@ ml customDevice
6666

67-
@ simple userName
67+
@ ml userName
6868

6969

7070
> # PREBUILT Entity definitions

packages/luis/test/fixtures/verified/modelAsFeatureGen.lu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
> # Entity definitions
2323

24-
@ simple simple1 usesFeatures phraselist1,age
24+
@ ml simple1 usesFeatures phraselist1,age
2525

2626

2727
> # PREBUILT Entity definitions

packages/luis/test/fixtures/verified/modelAsFeatures.lu

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
@ intent test1 usesFeature test3
1313
@ intent test2 usesFeature simple1
1414
@ intent test3 usesFeature age
15-
@ simple simple1 usesFeature phraselist1
16-
@ simple1 usesFeature age
15+
@ ml simple1 usesFeature phraselist1
16+
@ ml usesFeature age
1717

1818
@ list list1
1919
> pl as a feature to model

packages/luis/test/fixtures/verified/nDepthEntity.lu

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
@ ml nDepth usesFeatures intent1,phraselist1
1515
- @ age nDepth_child1
1616
- @ ml nDepth_child2 usesFeatures intent1,phraselist1
17-
- @ simple nDepth_child2.1
17+
- @ ml nDepth_child2.1
1818

1919

20-
@ simple simple1
20+
@ ml simple1
2121

2222

2323
> # PREBUILT Entity definitions

packages/luis/test/fixtures/verified/nDepthEntityInUtterance.lu

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
@ ml nDepth
1717
- @ age nDepth_child1
1818
- @ ml nDepth_child2
19-
- @ simple nDepth_child2.1
19+
- @ ml nDepth_child2.1
2020

2121

22-
@ simple simple1
22+
@ ml simple1
2323

24-
@ simple nDepth_child1
24+
@ ml nDepth_child1
2525

2626

2727
> # PREBUILT Entity definitions

packages/luis/test/fixtures/verified/newEntity1.lu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
> # Entity definitions
55

6-
@ simple s1 hasRoles sr1,sr2
6+
@ ml s1 hasRoles sr1,sr2
77

88

99
> # PREBUILT Entity definitions

packages/luis/test/fixtures/verified/newEntity2.lu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
> # Entity definitions
55

6-
@ simple s1 hasRole sr1
6+
@ ml s1 hasRole sr1
77

88

99
> # PREBUILT Entity definitions

0 commit comments

Comments
 (0)