@microsoft/bf-lu
Advanced tools
Comparing version 4.14.0-dev.20210602.be805a8 to 4.14.0-dev.20210604.3f9ee15
@@ -11,2 +11,4 @@ "use strict"; | ||
const crossTrainer = require('./crossTrainer'); | ||
const LuisBuilder = require('./../luis/luisCollate'); | ||
const { parseUtterancesToLu } = require('./../luis/luConverter'); | ||
module.exports = { | ||
@@ -37,7 +39,25 @@ /** | ||
const locale = /\w\.\w/.test(idWithoutExt) ? idWithoutExt.split('.').pop() : defaultLocale; | ||
for (let idx = 0; idx < idsToFind.length; idx++) { | ||
let file = idsToFind[idx]; | ||
const intentFilteringHandler = async (filePathOrFound, intent, isAbsolutePath) => { | ||
let content = filePathOrFound; | ||
if (isAbsolutePath) { | ||
importFile = (await filehelper.getFileContent(filePathOrFound, fileExtEnum.LUFile))[0]; | ||
content = importFile ? [importFile.content] : ''; | ||
} | ||
const luObj = await LuisBuilder.build(content, false, undefined, importResolver); | ||
const matchedUtterence = luObj.utterances.find(e => e.intent === intent); | ||
const fileContent = `# ${intent}\r\n${parseUtterancesToLu([matchedUtterence], luObj)}`; | ||
const foundItem = isAbsolutePath ? importFile : filePathOrFound[0]; | ||
const cloned = JSON.parse(JSON.stringify(foundItem)); | ||
cloned.content = fileContent; | ||
importedContents.push(cloned); | ||
}; | ||
for (const file of idsToFind) { | ||
if (path.isAbsolute(file.filePath)) { | ||
if (file.filePath.endsWith(fileExtEnum.LUFile)) { | ||
importedContents.push(...await filehelper.getFilesContent(file.filePath, fileExtEnum.LUFile)); | ||
if (!file.intent) { | ||
importedContents.push(...await filehelper.getFilesContent(file.filePath, fileExtEnum.LUFile)); | ||
} | ||
else { | ||
await intentFilteringHandler(file.filePath, file.intent, true); | ||
} | ||
} | ||
@@ -62,3 +82,8 @@ else if (file.filePath.endsWith(fileExtEnum.QnAFile)) { | ||
if (found.length > 0) { | ||
importedContents.push(...found); | ||
if (!file.intent) { | ||
importedContents.push(...found); | ||
} | ||
else { | ||
await intentFilteringHandler(found, file.intent, false); | ||
} | ||
} | ||
@@ -65,0 +90,0 @@ else { |
@@ -13,3 +13,6 @@ "use strict"; | ||
*/ | ||
constructor(filePath, includeInCollate) { | ||
/** | ||
* @property {string} intent | ||
*/ | ||
constructor(filePath, includeInCollate, intent = '') { | ||
this.filePath = filePath ? filePath : ''; | ||
@@ -20,2 +23,3 @@ if (includeInCollate === undefined) | ||
this.includeInCollate = includeInCollate; | ||
this.intent = intent; | ||
} | ||
@@ -22,0 +26,0 @@ } |
@@ -547,2 +547,3 @@ "use strict"; | ||
module.exports = luisToLuContent; | ||
module.exports.parseUtterancesToLu = parseUtterancesToLu; | ||
//# sourceMappingURL=luConverter.js.map |
{ | ||
"name": "@microsoft/bf-lu", | ||
"version": "4.14.0-dev.20210602.be805a8", | ||
"version": "4.14.0-dev.20210604.3f9ee15", | ||
"author": "Microsoft", | ||
@@ -5,0 +5,0 @@ "bugs": "https://github.com/microsoft/botframework-cli/issues", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1577318
19843