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

Commit 8c430fd

Browse files
authored
use addbatch when there's no existing blu file (#1263) (#1264)
* use addbatch when there's no existing blu file * Update build.ts fixed eslint error
1 parent c42dcdc commit 8c430fd

File tree

3 files changed

+102
-8
lines changed

3 files changed

+102
-8
lines changed

packages/orchestratorlib/src/build.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ export class OrchestratorBuild {
157157
Utility.debuggingLog(`OrchestratorBuild.syncLabelResolverEx(), subject.utteranceEntityLabelsMap.size=${subject.utteranceEntityLabelsMap.size}`);
158158
Utility.debuggingLog(`OrchestratorBuild.syncLabelResolverEx(), target.utteranceLabelsMap.size=${target.utteranceLabelsMap.size}`);
159159
Utility.debuggingLog(`OrchestratorBuild.syncLabelResolverEx(), target.utteranceEntityLabelsMap.size=${target.utteranceEntityLabelsMap.size}`);
160+
if (subject.utteranceLabelsMap.size === 0) {
161+
Utility.debuggingLog('OrchestratorBuild.syncLabelResolverEx(), ready to call LabelResolver.addBatch()');
162+
LabelResolver.addBatch(target);
163+
Utility.debuggingLog('OrchestratorBuild.syncLabelResolverEx(), after calling LabelResolver.addBatch()');
164+
}
160165
// ---- NOTE ---- delete example intent label if it is not in target.
161166
subject.utteranceLabelsMap.forEach((labels: Set<string>, utterance: string) => {
162167
if (target.utteranceLabelsMap.has(utterance)) {

packages/orchestratorlib/test/create.test.ts

Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,37 @@ import {UnitTestHelper} from './utility.test';
1919

2020
describe('OrchestratorCreateTests', () => {
2121
const baseModelPath: string = path.resolve('./resources/model/model_dte_bert_3l');
22+
const inputPath: string = './test/fixtures/dispatch';
23+
const inputPath2: string = path.resolve('./test/fixtures/newDispatch');
24+
const snapshotPath: string = path.join(inputPath, OrchestratorHelper.SnapshotFileName);
2225

2326
beforeEach(async () => {
2427
Utility.debuggingLog('OrchestratorCreateTests - downloading a base nerual network language model for unit test');
2528
await UnitTestHelper.downloadModelFileForTest(
2629
baseModelPath,
2730
OrchestratorBaseModel.defaultHandler,
2831
OrchestratorBaseModel.defaultHandler);
32+
33+
if (Utility.exists(snapshotPath)) {
34+
Utility.deleteFile(snapshotPath);
35+
}
36+
});
37+
38+
afterEach(async () => {
39+
if (Utility.exists(inputPath2)) {
40+
Utility.deleteFolderRecursive(inputPath2);
41+
}
2942
});
3043

31-
it('Create Dispatch Snapshot', async function (): Promise<void> {
44+
it('Create Dispatch Snapshot - no existing snapshot', async function (): Promise<void> {
3245
Utility.resetFlagToPrintDebuggingLogToConsole(UnitTestHelper.getDefaultUnitTestDebuggingLogFlag());
3346
this.timeout(UnitTestHelper.getDefaultFunctionalTestTimeout());
34-
const outputPath: string = './test/fixtures/dispatch';
3547

36-
const snapshotPath: string = path.join(outputPath, OrchestratorHelper.SnapshotFileName);
37-
if (Utility.exists(snapshotPath)) {
38-
Utility.deleteFile(snapshotPath);
39-
}
4048
await OrchestratorCreate.runAsync(
4149
baseModelPath,
4250
'',
43-
outputPath,
44-
outputPath,
51+
inputPath,
52+
inputPath,
4553
true);
4654

4755
assert.ok(Utility.exists(snapshotPath));
@@ -50,6 +58,41 @@ describe('OrchestratorCreateTests', () => {
5058
assert.ok(snapshotContent.indexOf('Weather') > 0);
5159
});
5260

61+
it('Create Dispatch Snapshot - incremental', async function (): Promise<void> {
62+
Utility.resetFlagToPrintDebuggingLogToConsole(UnitTestHelper.getDefaultUnitTestDebuggingLogFlag());
63+
this.timeout(UnitTestHelper.getDefaultFunctionalTestTimeout());
64+
65+
await OrchestratorCreate.runAsync(
66+
baseModelPath,
67+
'',
68+
inputPath,
69+
inputPath,
70+
true);
71+
72+
assert.ok(Utility.exists(snapshotPath));
73+
const snapshotContent: string = OrchestratorHelper.readFile(snapshotPath);
74+
assert.ok(snapshotContent.indexOf('HomeAutomation') > 0);
75+
assert.ok(snapshotContent.indexOf('Weather') > 0);
76+
77+
fs.ensureDirSync(inputPath2);
78+
fs.copySync(path.resolve(inputPath), inputPath2);
79+
fs.copySync(path.resolve('./test/fixtures/Gaming.lu'), path.join(inputPath2, 'Gaming.lu'));
80+
81+
await OrchestratorCreate.runAsync(
82+
baseModelPath,
83+
'',
84+
inputPath2,
85+
inputPath,
86+
true);
87+
88+
assert.ok(Utility.exists(snapshotPath));
89+
const snapshotContent2: string = OrchestratorHelper.readFile(snapshotPath);
90+
assert.ok(snapshotContent2.length > snapshotContent.length);
91+
assert.ok(snapshotContent2.indexOf('HomeAutomation') > 0);
92+
assert.ok(snapshotContent2.indexOf('Weather') > 0);
93+
assert.ok(snapshotContent2.indexOf('Gaming') > 0);
94+
});
95+
5396
it('Create Snapshot - LU file with reference to other LU file', async function (): Promise<void> {
5497
Utility.resetFlagToPrintDebuggingLogToConsole(UnitTestHelper.getDefaultUnitTestDebuggingLogFlag());
5598
this.timeout(UnitTestHelper.getDefaultFunctionalTestTimeout());
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
## gaming.invite_player
2+
- Invite {@gaming.contact_name=Cody} to party
3+
- {@gaming.contact_name=Bata Bing}
4+
- Invite {@gaming.contact_name=Carlos} to party
5+
- Invite {@gaming.contact_name=James pendergast} to the party
6+
- Invite {@gaming.contact_name=Zach} to party.
7+
- Invite {@gaming.contact_name=Devin} to the party
8+
- I'm in there
9+
- Invite {@gaming.contact_name=master chief} the game
10+
- Invite {@gaming.contact_name=Gavin robber 922} 2 a party
11+
- Invite {@gaming.contact_name=Dylan} to the party
12+
- Invite {@gaming.contact_name=crazy ex Tucker} to {@gaming.game_title=the part}
13+
- Just asking to join a party
14+
15+
@ intent gaming.invite_player
16+
17+
## gaming.invite_party
18+
- The first one
19+
- Invite party.
20+
21+
@ intent gaming.invite_party
22+
23+
## gaming.leave_party
24+
- Leave party
25+
26+
@ intent gaming.leave_party
27+
28+
## gaming.find_players
29+
- What is {@gaming.contact_name=blade runner 223} in my friends list?
30+
31+
@ intent gaming.find_players
32+
33+
## gaming.show_friends
34+
- Who are my Xbox my best friends ?
35+
- Go to friends list
36+
37+
@ intent gaming.show_friends
38+
39+
## gaming.start_party
40+
- Join party
41+
42+
@ intent gaming.start_party
43+
44+
@ ml gaming.contact_name
45+
46+
@ ml gaming.game_title

0 commit comments

Comments
 (0)