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

Commit 7ccb128

Browse files
authored
Refactor luis build interface to decouple dialog gen from build (#990)
* refactor luis build interface to decouple dialog gen with build * refactor qnamaker to decouple dialig gen from build * adjust qna build code * fix typo * fix a test case * adjust cli interface * refactor crosstrainer interface * fix log * fix tslint
1 parent a3fd50a commit 7ccb128

File tree

35 files changed

+765
-1087
lines changed

35 files changed

+765
-1087
lines changed

packages/cli/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ OPTIONS
751751
752752
--deleteOldVersion Deletes old version of LUIS application after building new one.
753753
754-
--dialog=dialog [default: multiLanguage] Dialog recognizer type [multiLanguage|crosstrained]
754+
--dialog=dialog Dialog recognizer type [multiLanguage|crosstrained]. No dialog recognizers will be generated if not specified. Only valid if --out is set
755755
756756
--fallbackLocale=fallbackLocale Locale to be used at the fallback if no locale specific recognizer is found. Only
757757
valid if --out is set
@@ -1353,7 +1353,7 @@ OPTIONS
13531353
--defaultCulture=defaultCulture Culture code for the content. Infer from .qna if available. Defaults to en-us
13541354
if not set
13551355
1356-
--dialog=dialog [default: multiLanguage] Dialog recognizer type [multiLanguage|crosstrained]
1356+
--dialog=dialog Dialog recognizer type [multiLanguage|crosstrained]. No dialog recognizers will be generated if not specified. Only valid if --out is set
13571357
13581358
--fallbackLocale=fallbackLocale Locale to be used at the fallback if no locale specific recognizer is found.
13591359
Only valid if --out is set
@@ -1371,7 +1371,7 @@ OPTIONS
13711371
--endpoint=endpoint Qnamaker authoring endpoint for publishing
13721372
13731373
--schema=schema Defines $schema for generated .dialog files
1374-
1374+
13751375
EXAMPLE
13761376
13771377
$ bf qnamaker:build --in {INPUT_FILE_OR_FOLDER} --subscriptionKey {SUBSCRIPTION_KEY} --botName {BOT_NAME}

packages/lu/src/parser/cross-train/cross-train.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ module.exports = {
2727
* Cross train lu and qna files.
2828
* @param {string} input full path of input lu and qna files folder.
2929
* @param {string} intentName interruption intent name. Default value is _Interruption.
30-
* @param {string} config path to config of mapping rules or mapping rules json content itself. If undefined, it will read config.json from input folder.
30+
* @param {string} config path to config of mapping rules or mapping rules json content itself.
3131
* @param {boolean} verbose verbose to indicate whether log warnings and errors or not when parsing cross-train files.
3232
* @returns {luResult: any, qnaResult: any} trainedResult of luResult and qnaResult or undefined if no results.
3333
*/
@@ -37,10 +37,15 @@ module.exports = {
3737
const qnaContents = await file.getFilesContent(input, fileExtEnum.QnAFile)
3838
const configContent = config && !fs.existsSync(config) ? {id: path.join(input, 'config.json'), content: config} : await file.getConfigContent(config)
3939

40-
const configObject = file.getConfigObject(configContent, intentName, verbose)
40+
const trainedResult = await crossTrainer.crossTrain(
41+
luContents,
42+
qnaContents,
43+
JSON.parse(configContent.content), {
44+
configId: configContent.id,
45+
intentName,
46+
verbose
47+
})
4148

42-
const trainedResult = await crossTrainer.crossTrain(luContents, qnaContents, configObject)
43-
4449
return trainedResult
4550
}
4651
}

packages/lu/src/parser/cross-train/crossTrainer.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,21 @@ module.exports = {
2727
* Do cross training among lu files
2828
* @param {any[]} luContents the lu content array whose element includes path and content
2929
* @param {any[]} qnaContents the qna content array whose element includes path and content
30-
* @param {any} crossTrainConfig cross train json config
31-
* @param {any} importResolver import Resolver when resolving import files
30+
* @param {any} configObject cross train config json object
31+
* @param {any} options some optional parameters including configId, intentName, verbose, importResolver
3232
* @returns {Map<string, LUResource>} map of file id and luResource
3333
* @throws {exception} throws errors
3434
*/
35-
crossTrain: async function (luContents, qnaContents, crossTrainConfig, importResolver) {
35+
crossTrain: async function (luContents, qnaContents, configObject, options = {}) {
3636
try {
37+
const importResolver = options.importResolver
38+
39+
const crossTrainConfig = fileHelper.getConfigObject(
40+
configObject,
41+
options.configId,
42+
options.intentName || '_Interruption',
43+
options.verbose || true)
44+
3745
let {luObjectArray, qnaObjectArray} = pretreatment(luContents, qnaContents)
3846
const {rootIds, triggerRules, intentName, verbose} = crossTrainConfig
3947

0 commit comments

Comments
 (0)