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

Commit 7decc06

Browse files
authored
Fix entity type case sensitive issue and class definition typo issue (#1091)
* support output to file for kb:export command * fix entity type case sensitive issue and a typo
1 parent d2c102f commit 7decc06

File tree

7 files changed

+30
-8
lines changed

7 files changed

+30
-8
lines changed

packages/lu/src/parser/lu/luMerger.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ const resolveRefs = function(refTree, srcId) {
144144
if (result.utterances !== undefined) {
145145
result.utterances.forEach(utt => {
146146
if (luObj.uttHash[utt] === undefined) {
147-
luObj.utterances.push(new hClasses.uttereances(utt, ref.uttObj.intent));
147+
luObj.utterances.push(new hClasses.utterances(utt, ref.uttObj.intent));
148148
luObj.uttHash[utt] = '';
149149
}
150150
})

packages/lu/src/parser/lufile/classes/hclasses.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const readerObj = {
2323
this.utterances = utterances?utterances:[]
2424
}
2525
},
26-
uttereances: class {
26+
utterances: class {
2727
constructor(text, intent, entities) {
2828
this.text = text?text:'';
2929
this.intent = intent?intent:'';

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class NewEntitySection extends BaseSection {
5454

5555
ExtractType(parseTree) {
5656
if (parseTree.newEntityDefinition().newEntityLine().newEntityType()) {
57-
return parseTree.newEntityDefinition().newEntityLine().newEntityType().getText().trim();
57+
return parseTree.newEntityDefinition().newEntityLine().newEntityType().getText().trim().toLowerCase();
5858
}
5959
}
6060

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,7 @@ const parseAndHandleSimpleIntentSection = function (parsedContent, luResource, c
11521152
if (hashTable[uttHash]) {
11531153
utteranceObject = hashTable[uttHash];
11541154
} else {
1155-
utteranceObject = new helperClass.uttereances(utterance, intentName, []);
1155+
utteranceObject = new helperClass.utterances(utterance, intentName, []);
11561156
parsedContent.LUISJsonStructure.utterances.push(utteranceObject);
11571157
hashTable[uttHash] = utteranceObject;
11581158
}
@@ -1230,7 +1230,7 @@ const parseAndHandleSimpleIntentSection = function (parsedContent, luResource, c
12301230
}
12311231
} else {
12321232
if(!hashTable[uttHash]) {
1233-
let utteranceObject = new helperClass.uttereances(utterance, intentName, []);
1233+
let utteranceObject = new helperClass.utterances(utterance, intentName, []);
12341234
parsedContent.LUISJsonStructure.utterances.push(utteranceObject);
12351235
hashTable[uttHash] = utteranceObject;
12361236
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ const addUtteranceToCollection = function (attribute, srcItem, matchInTarget) {
498498
if(attribute === 'text') {
499499
matchInTarget.utterances.push(srcItem);
500500
} else {
501-
matchInTarget.utterances.push(new helperClasses.uttereances(srcItem.pattern.replace('{', '{@'),srcItem.intent,[]));
501+
matchInTarget.utterances.push(new helperClasses.utterances(srcItem.pattern.replace('{', '{@'),srcItem.intent,[]));
502502
}
503503
}
504504

packages/lu/test/parser/lufile/classes/classes.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ describe('Testing all classes', function() {
102102
});
103103
});
104104

105-
describe('uttereances class', function() {
105+
describe('utterances class', function() {
106106
it('can create a new instance with no values passed in', function() {
107-
assert.equal(new hClasses.uttereances().text, '');
107+
assert.equal(new hClasses.utterances().text, '');
108108
});
109109
});
110110

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,4 +1090,26 @@ describe('parseFile correctly parses utterances', function () {
10901090
})
10911091
.catch(err => done(err))
10921092
})
1093+
1094+
it ('Correctly parses entity type that is case insensitive', function(done){
1095+
let testLU = `
1096+
@ ML test
1097+
@ PREbuilt personName
1098+
@ phraseList abc(interchangeable) disabledforallmodels =
1099+
- a, b, c`;
1100+
parseFile.parseFile(testLU)
1101+
.then(res => {
1102+
assert.equal(res.LUISJsonStructure.entities.length, 1);
1103+
assert.equal(res.LUISJsonStructure.entities[0].name, "test");
1104+
assert.equal(res.LUISJsonStructure.prebuiltEntities.length, 1);
1105+
assert.equal(res.LUISJsonStructure.prebuiltEntities[0].name, "personName");
1106+
assert.equal(res.LUISJsonStructure.model_features[0].enabledForAllModels, false);
1107+
assert.equal(res.LUISJsonStructure.model_features.length, 1);
1108+
assert.equal(res.LUISJsonStructure.model_features[0].name, "abc");
1109+
assert.equal(res.LUISJsonStructure.model_features[0].words, "a,b,c");
1110+
assert.equal(res.LUISJsonStructure.model_features[0].enabledForAllModels, false);
1111+
done();
1112+
})
1113+
.catch(err => done(err))
1114+
})
10931115
})

0 commit comments

Comments
 (0)