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

[Lubuild] fix multiple bugs: case sensitive issue, default version issue and exception not throw out issue #576

Merged
merged 30 commits into from
Feb 27, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
9dae3eb
fix case issue of utterances and patterns
feich-ms Feb 17, 2020
934b64e
remove lower function for entities
feich-ms Feb 17, 2020
bba42be
adjust test cases
feich-ms Feb 17, 2020
b93333e
use a better solution to compare utterances
feich-ms Feb 17, 2020
2507698
add tests to verify the fixes
feich-ms Feb 18, 2020
a7c3ce0
Merge branch 'master' into feich/fixLubuildBug
feich-ms Feb 19, 2020
94ea201
move new added tests to luis package from lu package
feich-ms Feb 19, 2020
eef95fe
add test cases for luConfig parameter in lubuild CLI
feich-ms Feb 19, 2020
22de0ad
fix error not throw out bug
feich-ms Feb 19, 2020
e490c19
Merge branch 'master' into feich/fixLubuildBug
munozemilio Feb 19, 2020
071ecda
Merge branch 'master' into feich/fixLubuildBug
feich-ms Feb 20, 2020
bf47d8a
resolve comments of CLIError
feich-ms Feb 20, 2020
42e5e04
remove uncessary semicolon
feich-ms Feb 20, 2020
25a4b79
Updates and fixes
Feb 21, 2020
1e67d26
Updates
Feb 21, 2020
b9741e7
updating tests.
Feb 21, 2020
edc303b
Merge branch 'master' into feich/fixLubuildBug
Feb 21, 2020
da5b682
Updates for PR feedback, fix settings out path
Feb 21, 2020
a958d34
updates
Feb 21, 2020
4b9b708
Merge branch 'master' into feich/fixLubuildBug
feich-ms Feb 23, 2020
b508358
fix build errors
feich-ms Feb 23, 2020
4482ff0
fix command parameter issue in test cases
feich-ms Feb 23, 2020
e84c5e8
fix tslint errors
feich-ms Feb 23, 2020
63a460a
Merge branch 'master' into feich/fixLubuildBug
feich-ms Feb 25, 2020
6ffb49d
remove lubuild.js which is not necessary
feich-ms Feb 25, 2020
ea0d136
FI from master
Feb 27, 2020
5e29ccc
fixing bad merge
Feb 27, 2020
cfa2379
Merge branch 'master' into feich/fixLubuildBug
munozemilio Feb 27, 2020
4ae0375
fix tslint and expose more in index.js and composerindex.js
feich-ms Feb 27, 2020
ec07d18
remove lubuild module in index.js
feich-ms Feb 27, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions packages/lu/src/parser/lubuild/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,7 @@ export class LuBuildCore {
public compareApplications(currentApp: any, existingApp: any) {
currentApp.desc = currentApp.desc && currentApp.desc !== '' && currentApp.desc !== existingApp.desc ? currentApp.desc : existingApp.desc
currentApp.culture = currentApp.culture && currentApp.culture !== '' && currentApp.culture !== existingApp.culture ? currentApp.culture : existingApp.culture
currentApp.versionId = currentApp.versionId && currentApp.versionId !== '' && currentApp.versionId !== existingApp.versionId ? currentApp.versionId : existingApp.versionId;

// convert utterance text from lu file to lower case
// as utterances from luis api are all converted to lower case automatically
(currentApp.utterances || []).forEach((u: any) => {
u.text = u.text.toLowerCase()
});
currentApp.versionId = currentApp.versionId && currentApp.versionId !== '' && currentApp.versionId > existingApp.versionId ? currentApp.versionId : existingApp.versionId;

// convert list entities to remove synonyms word in list which is same with canonicalForm
(currentApp.closedLists || []).forEach((c: any) => {
Expand Down Expand Up @@ -84,7 +78,7 @@ export class LuBuildCore {

public updateVersion(currentApp: any, existingApp: any) {
let newVersionId: string
if (currentApp.versionId && currentApp.versionId !== existingApp.versionId) {
if (currentApp.versionId > existingApp.versionId) {
newVersionId = currentApp.versionId
} else {
newVersionId = this.updateVersionValue(existingApp.versionId)
Expand Down Expand Up @@ -177,12 +171,12 @@ export class LuBuildCore {
equal = equal && this.isArrayEqual(appA.closedLists, appB.closedLists)
equal = equal && this.isArrayEqual(appA.composites, appB.composites)
equal = equal && this.isArrayEqual(appA.entities, appB.entities)
equal = equal && this.isArrayEqual(appA.modelFeatures, appB.modelFeatures)
equal = equal && this.isArrayEqual(appA.model_features, appB.modelFeatures)
equal = equal && this.isArrayEqual(appA.patternAnyEntities, appB.patternAnyEntities)
equal = equal && this.isArrayEqual(appA.patterns, appB.patterns)
equal = equal && this.isArrayEqual(appA.prebuiltEntities, appB.prebuiltEntities)
equal = equal && this.isArrayEqual(appA.regexEntities, appB.regexEntities)
equal = equal && this.isArrayEqual(appA.regexFeatures, appB.regexFeatures)
equal = equal && this.isArrayEqual(appA.regex_entities, appB.regexEntities)
equal = equal && this.isArrayEqual(appA.regex_features, appB.regexFeatures)
equal = equal && this.isArrayEqual(appA.utterances, appB.utterances)

// handle exception for none intent which is default added in luis portal
Expand All @@ -204,15 +198,14 @@ export class LuBuildCore {
let yObj = []

if (x && x.length > 0) {
xObj = JSON.parse(JSON.stringify(x))
xObj = JSON.parse(JSON.stringify(x).toLowerCase())
}

if (y && y.length > 0) {
yObj = JSON.parse(JSON.stringify(y))
yObj = JSON.parse(JSON.stringify(y).toLowerCase())
}

if (xObj.length !== yObj.length) return false

if (differenceWith(xObj, yObj, isEqual).length > 0) return false

return true
Expand Down
32 changes: 32 additions & 0 deletions packages/lu/test/commands/luis/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,4 +555,36 @@ describe('luis:build update dialog assets successfully when dialog assets exist'
expect(await compareFiles('./../../../results/foo.fr-fr.lu.dialog', './../../fixtures/testcases/lubuild/foo2/dialogs/foo.fr-fr.lu.dialog')).to.be.true
expect(await compareFiles('./../../../results/foo.zh-cn.lu.dialog', './../../fixtures/testcases/lubuild/foo2/dialogs/foo.zh-cn.lu.dialog')).to.be.true
feich-ms marked this conversation as resolved.
Show resolved Hide resolved
})
})

describe('luis:build not update application if only cases of utterances or patterns are changed', () => {
const existingLuisApp = require('./../../fixtures/testcases/lubuild/case-insensitive/luis/test(development)-case-insensitive.en-us.lu.json')
before(function () {
nock('https://westus.api.cognitive.microsoft.com')
.get(uri => uri.includes('apps'))
.reply(200, [{
name: 'test(development)-case-insensitive.en-us.lu',
id: 'f8c64e2a-8635-3a09-8f78-39d7adc76ec5'
}])

nock('https://westus.api.cognitive.microsoft.com')
.get(uri => uri.includes('apps'))
.reply(200, {
name: 'test(development)-case-insensitive.en-us.lu',
id: 'f8c64e2a-8635-3a09-8f78-39d7adc76ec5',
activeVersion: '0.1'
})

nock('https://westus.api.cognitive.microsoft.com')
.get(uri => uri.includes('export'))
.reply(200, existingLuisApp)
})

test
.stdout()
.command(['luis:build', '--in', './test/fixtures/testcases/lubuild/case-insensitive/lufiles/case-insensitive.lu', '--authoringKey', uuidv1(), '--botName', 'test', '--log'])
.it('should not update a luis application when only cases of utterances or patterns are different for the coming lu file', ctx => {
expect(ctx.stdout).to.contain('Start to handle applications')
expect(ctx.stdout).to.contain('no changes')
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Greeting
- Hi Morning
- Hello Evening

# Help
- Help me with {Item}
- Please Help {Item}

# GetUserProfile
- I'm 36 years old
- My age is 36
- I am 36

> Prebuilt entities
@ prebuilt age
@ prebuilt personName

> Phrase list
@ phraselist profileDefinition(interchangeable) =
- I'm
- My
- I am

> Define a list entity for user city
@ list Cities =
- seattle :
- SEA
- Seatac
- redmond :
- microsoft
- REA

> Define a regex entity for user zip code
@ regex zipCode = /[0-9]{5}/
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
{
"luis_schema_version": "4.0.0",
"versionId": "0.2",
"name": "test(development)-case-insensitive.en-us.lu",
"desc": "Model for test app, targetting development",
"culture": "en-us",
"tokenizerVersion": "1.0.0",
"intents": [
{
"name": "GetUserProfile"
},
{
"name": "Greeting"
},
{
"name": "Help"
},
{
"name": "None"
}
],
"entities": [],
"composites": [],
"closedLists": [
{
"name": "Cities",
"subLists": [
{
"canonicalForm": "seattle",
"list": [
"SEA",
"Seatac"
]
},
{
"canonicalForm": "redmond",
"list": [
"microsoft",
"REA"
]
}
],
"roles": []
}
],
"patternAnyEntities": [
{
"name": "Item",
"roles": [],
"explicitList": []
}
],
"regex_entities": [
{
"name": "zipCode",
"regexPattern": "[0-9]{5}",
"roles": []
}
],
"prebuiltEntities": [
{
"name": "age",
"roles": []
},
{
"name": "personName",
"roles": []
}
],
"model_features": [
{
"name": "profileDefinition",
"mode": true,
"words": "I'm,My,I am",
"activated": true
}
],
"regex_features": [],
"patterns": [
{
"pattern": "please help {Item}",
"intent": "Help"
},
{
"pattern": "help me with {Item}",
"intent": "Help"
}
],
"utterances": [
{
"text": "hello evening",
"intent": "Greeting",
"entities": []
},
{
"text": "hi morning",
"intent": "Greeting",
"entities": []
},
{
"text": "i am 36",
"intent": "GetUserProfile",
"entities": []
},
{
"text": "i'm 36 years old",
"intent": "GetUserProfile",
"entities": []
},
{
"text": "my age is 36",
"intent": "GetUserProfile",
"entities": []
}
],
"settings": []
}