remove cross-train cli related changes and only keep the api

This commit is contained in:
Fei Chen 2019-11-26 19:12:28 +08:00
Родитель cd3bb6ea90
Коммит ab1fb84df2
65 изменённых файлов: 16 добавлений и 1072 удалений

Просмотреть файл

@ -1,95 +0,0 @@
/*!
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
import {CLIError, Command, flags} from '@microsoft/bf-cli-command'
const exception = require('./../../parser/utils/exception')
const fs = require('fs-extra')
const path = require('path')
const file = require('./../../utils/filehelper')
const fileExtEnum = require('./../../parser/utils/helpers').FileExtTypeEnum
const luCrossTrainer = require('./../../parser/lu/luCrossTrainer')
export default class LuisCrossTrian extends Command {
static description = 'Convert interuption intents among .lu file(s)'
static flags: flags.Input<any> = {
help: flags.help({char: 'h', description: 'luis:cross-train help'}),
in: flags.string({char: 'i', description: 'Source .lu file(s)'}),
out: flags.string({char: 'o', description: 'Output folder name. If not specified, source lu file(s) will be updated'}),
recurse: flags.boolean({char: 'r', description: 'Indicates if sub-folders need to be considered to file .lu file(s)', default: false}),
log: flags.boolean({description: 'Enables log messages', default: false}),
root: flags.string({description: 'Root lu files to do cross training. Separated by comma if multiple root files exist.'}),
intentname: flags.string({description: 'Interuption intent name', default: '_Interuption'})
}
async run() {
try {
const {flags} = this.parse(LuisCrossTrian)
//Check if file or folder
//if folder, only lu to luis is supported
const isLu = await file.detectLuContent(undefined, flags.in)
// Parse the object depending on the input
let result: any
if (isLu && flags.root) {
const luFiles = await file.getLuObjects(undefined, flags.in, flags.recurse, fileExtEnum.LUFile)
const rootFiles = await file.getLuObjects(undefined, flags.root, flags.recurse, fileExtEnum.LUFile)
const luConfigObject = await file.getConfigObject(flags.in, flags.recurse)
let crossTrainConfig = {
rootIds: rootFiles.map((r: any) => r.id),
triggerRules: luConfigObject,
intentName: flags.intentname,
verbose: flags.log
}
result = await luCrossTrainer.luCrossTrain(luFiles, JSON.stringify(crossTrainConfig))
}
// If result is null or undefined return
if (!result) {
throw new CLIError('No LU content parsed!')
}
await this.writeLuFiles(result, flags)
} catch (err) {
if (err instanceof exception) {
throw new CLIError(err.text)
}
throw err
}
}
private async writeLuFiles(fileIdToLuResourceMap: Map<string, any>, flags?: any) {
let newFolder
if (flags && flags.out) {
newFolder = flags.out
if (!path.isAbsolute(flags.out)) {
newFolder = path.resolve(flags.out)
}
if (!fs.existsSync(newFolder)) {
fs.mkdirSync(newFolder)
}
}
for (const fileId of fileIdToLuResourceMap.keys()) {
try {
if (newFolder) {
const fileName = path.basename(fileId)
const newFileId = path.join(newFolder, fileName)
await fs.writeFile(newFileId, fileIdToLuResourceMap.get(fileId).Content, 'utf-8')
this.log('Successfully wrote LUIS model to ' + newFileId)
} else {
await fs.writeFile(fileId, fileIdToLuResourceMap.get(fileId).Content, 'utf-8')
this.log('Successfully wrote LUIS model to ' + fileId)
}
} catch (err) {
throw new CLIError('Unable to write file - ' + fileId + ' Error: ' + err.message)
}
}
}
}

Просмотреть файл

@ -11,7 +11,7 @@ const luObject = require('./../parser/lu/lu')
/* tslint:disable:prefer-for-of no-unused*/
export async function getLuObjects(stdin: string, input: string, recurse = false, extType: string | undefined) {
export async function getLuObjects(stdin: string, input: string | undefined, recurse = false, extType: string | undefined) {
let luObjects: any = []
if (stdin) {
luObjects.push(new luObject(stdin, 'stdin'))
@ -26,29 +26,23 @@ export async function getLuObjects(stdin: string, input: string, recurse = false
return luObjects
}
async function getLuFiles(inputPath: string, recurse = false, extType: string | undefined): Promise<Array<any>> {
let filesToParse: string[] = []
const inputs = inputPath.split(',')
if (inputs) {
for (const input of inputs) {
let fileStat = await fs.stat(input)
if (fileStat.isFile()) {
filesToParse.push(input)
continue
}
if (!fileStat.isDirectory()) {
throw new CLIError('Sorry, ' + input + ' is not a folder or does not exist')
}
filesToParse = helpers.findLUFiles(input, recurse, extType)
if (filesToParse.length === 0) {
throw new CLIError(`Sorry, no ${extType} files found in the specified folder.`)
}
}
async function getLuFiles(input: string | undefined, recurse = false, extType: string | undefined): Promise<Array<any>> {
let filesToParse: any[] = []
let fileStat = await fs.stat(input)
if (fileStat.isFile()) {
filesToParse.push(input)
return filesToParse
}
if (!fileStat.isDirectory()) {
throw new CLIError('Sorry, ' + input + ' is not a folder or does not exist')
}
filesToParse = helpers.findLUFiles(input, recurse, extType)
if (filesToParse.length === 0) {
throw new CLIError(`Sorry, no ${extType} files found in the specified folder.`)
}
return filesToParse
}
@ -169,68 +163,6 @@ export async function detectLuContent(stdin: string, input: string) {
return false
}
async function getConfigFiles(input: string, recurse = false): Promise<Array<any>> {
let filesToParse: string[] = []
let fileStat = await fs.stat(input)
if (fileStat.isFile()) {
filesToParse.push(input)
return filesToParse
}
if (!fileStat.isDirectory()) {
throw new CLIError('Sorry, ' + input + ' is not a folder or does not exist')
}
filesToParse = helpers.findConfigFiles(input, recurse)
if (filesToParse.length === 0) {
throw new CLIError('Sorry, no .lu files found in the specified folder.')
}
return filesToParse
}
export async function getConfigObject(input: string, recurse = false) {
const luConfigFiles = await getConfigFiles(input, recurse)
if (luConfigFiles.length === 0) {
throw new CLIError(`Sorry, no .json file found in the folder '${input}' and its sub folders`)
}
let finalLuConfigObj = Object.create(null)
for (const luConfigFile of luConfigFiles) {
const configFileDir = path.dirname(luConfigFile)
const luConfigContent = await getContentFromFile(luConfigFile)
if (luConfigContent && luConfigContent !== '') {
try {
const luConfigObj = JSON.parse(luConfigContent)
for (const rootluFilePath of Object.keys(luConfigObj)) {
const rootLuFileFullPath = path.resolve(configFileDir, rootluFilePath)
const destLuFileToIntent = luConfigObj[rootluFilePath]
for (const destLuFilePath of Object.keys(destLuFileToIntent)) {
const triggerIntent = destLuFileToIntent[destLuFilePath]
const destLuFileFullPath = path.resolve(configFileDir, destLuFilePath)
if (rootLuFileFullPath in finalLuConfigObj) {
const finalDestLuFileToIntent = finalLuConfigObj[rootLuFileFullPath]
finalDestLuFileToIntent[destLuFileFullPath] = triggerIntent
} else {
let finalDestLuFileToIntent = Object.create(null)
finalDestLuFileToIntent[destLuFileFullPath] = triggerIntent
finalLuConfigObj[rootLuFileFullPath] = finalDestLuFileToIntent
}
}
}
} catch (err) {
if (err instanceof CLIError) {
throw err
} else {
throw new CLIError(`Sorry, invalid cross training config:\r\n${luConfigContent}`)
}
}
}
}
return finalLuConfigObj
}
export function parseJSON(input: string, appType: string) {
try {
return JSON.parse(input)

Просмотреть файл

@ -1,80 +0,0 @@
import { expect, test } from '@oclif/test'
const fs = require('fs-extra')
const path = require('path')
const compareLuFiles = async function (file1: string, file2: string) {
let result = await fs.readFile(path.join(__dirname, file1))
let fixtureFile = await fs.readFile(path.join(__dirname, file2))
result = result.toString().replace(/\r\n/g, "\n")
fixtureFile = fixtureFile.toString().replace(/\r\n/g, "\n")
return result === fixtureFile
}
describe('luis:convert interuption intent among lu files', () => {
after(async function () {
await fs.remove(path.join(__dirname, './../../../interuptionGen'))
})
test
.stdout()
.command(['luis:cross-train', '--in', `${path.join(__dirname, './../../fixtures/testcases/interuption')}`, '--root', `${path.join(__dirname, './../../fixtures/testcases/interuption/main/main.lu')},${path.join(__dirname, './../../fixtures/testcases/interuption/main/main.fr-fr.lu')}`, '--out', 'interuptionGen', '--intentname', '_Interuption', '--recurse'])
.it('luis:convert interuption intents when interuption intents are set', async () => {
expect(await compareLuFiles('./../../../interuptionGen/main.lu', './../../fixtures/verified/interuption/main.lu')).to.be.true
expect(await compareLuFiles('./../../../interuptionGen/dia1.lu', './../../fixtures/verified/interuption/dia1.lu')).to.be.true
expect(await compareLuFiles('./../../../interuptionGen/dia2.lu', './../../fixtures/verified/interuption/dia2.lu')).to.be.true
expect(await compareLuFiles('./../../../interuptionGen/dia3.lu', './../../fixtures/verified/interuption/dia3.lu')).to.be.true
expect(await compareLuFiles('./../../../interuptionGen/dia4.lu', './../../fixtures/verified/interuption/dia4.lu')).to.be.true
expect(await compareLuFiles('./../../../interuptionGen/main.fr-fr.lu', './../../fixtures/verified/interuption/main.fr-fr.lu')).to.be.true
expect(await compareLuFiles('./../../../interuptionGen/dia1.fr-fr.lu', './../../fixtures/verified/interuption/dia1.fr-fr.lu')).to.be.true
expect(await compareLuFiles('./../../../interuptionGen/dia2.fr-fr.lu', './../../fixtures/verified/interuption/dia2.fr-fr.lu')).to.be.true
})
test
.stdout()
.command(['luis:cross-train', '--in', `${path.join(__dirname, './../../fixtures/testcases/interuption2')}`, '--root', `${path.join(__dirname, './../../fixtures/testcases/interuption2/main/main.lu')}`, '--out', 'interuptionGen', '--intentname', '_Interuption', '--recurse'])
.it('luis:convert interuption intents when empty lu file occurs', async () => {
expect(await compareLuFiles('./../../../interuptionGen/main.lu', './../../fixtures/verified/interuption2/main.lu')).to.be.true
expect(await compareLuFiles('./../../../interuptionGen/dia1.lu', './../../fixtures/verified/interuption2/dia1.lu')).to.be.true
expect(await compareLuFiles('./../../../interuptionGen/dia3.lu', './../../fixtures/verified/interuption2/dia3.lu')).to.be.true
})
test
.stdout()
.command(['luis:cross-train', '--in', `${path.join(__dirname, './../../fixtures/testcases/interuption3')}`, '--root', `${path.join(__dirname, './../../fixtures/testcases/interuption3/main/main.lu')}`, '--out', 'interuptionGen', '--intentname', '_Interuption', '--recurse'])
.it('luis:convert interuption intents when nestedIntentSection is enabled', async () => {
expect(await compareLuFiles('./../../../interuptionGen/main.lu', './../../fixtures/verified/interuption3/main.lu')).to.be.true
expect(await compareLuFiles('./../../../interuptionGen/dia1.lu', './../../fixtures/verified/interuption3/dia1.lu')).to.be.true
expect(await compareLuFiles('./../../../interuptionGen/dia2.lu', './../../fixtures/verified/interuption3/dia2.lu')).to.be.true
expect(await compareLuFiles('./../../../interuptionGen/dia3.lu', './../../fixtures/verified/interuption3/dia3.lu')).to.be.true
expect(await compareLuFiles('./../../../interuptionGen/dia4.lu', './../../fixtures/verified/interuption3/dia4.lu')).to.be.true
})
test
.stdout()
.command(['luis:cross-train', '--in', `${path.join(__dirname, './../../fixtures/testcases/interuption4')}`, '--root', `${path.join(__dirname, './../../fixtures/testcases/interuption4/main/main.lu')}`, '--out', 'interuptionGen', '--intentname', '_Interuption', '--recurse'])
.it('luis:convert interuption intents when local intents occur', async () => {
expect(await compareLuFiles('./../../../interuptionGen/main.lu', './../../fixtures/verified/interuption4/main.lu')).to.be.true
expect(await compareLuFiles('./../../../interuptionGen/dia1.lu', './../../fixtures/verified/interuption4/dia1.lu')).to.be.true
expect(await compareLuFiles('./../../../interuptionGen/dia2.lu', './../../fixtures/verified/interuption4/dia2.lu')).to.be.true
expect(await compareLuFiles('./../../../interuptionGen/dia3.lu', './../../fixtures/verified/interuption4/dia3.lu')).to.be.true
})
test
.stdout()
.command(['luis:cross-train', '--in', `${path.join(__dirname, './../../fixtures/testcases/interuption5')}`, '--root', `${path.join(__dirname, './../../fixtures/testcases/interuption5/main/main.lu')}`, '--out', 'interuptionGen', '--intentname', '_Interuption', '--recurse'])
.it('luis:convert interuption intents when multiple dialog invocations occur in same trigger', async () => {
expect(await compareLuFiles('./../../../interuptionGen/main.lu', './../../fixtures/verified/interuption5/main.lu')).to.be.true
expect(await compareLuFiles('./../../../interuptionGen/dia1.lu', './../../fixtures/verified/interuption5/dia1.lu')).to.be.true
expect(await compareLuFiles('./../../../interuptionGen/dia2.lu', './../../fixtures/verified/interuption5/dia2.lu')).to.be.true
expect(await compareLuFiles('./../../../interuptionGen/dia3.lu', './../../fixtures/verified/interuption5/dia3.lu')).to.be.true
expect(await compareLuFiles('./../../../interuptionGen/dia4.lu', './../../fixtures/verified/interuption5/dia4.lu')).to.be.true
})
test
.stdout()
.stderr()
.command(['luis:cross-train', '--in', `${path.join(__dirname, './../../fixtures/testcases/interuption6')}`, '--root', `${path.join(__dirname, './../../fixtures/testcases/interuption6/main/main.lu')}`, '--out', 'interuptionGen', '--intentname', '_Interuption', '--recurse'])
.it('luis:convert should throw exception when dialog call loop is detected in config', async (ctx) => {
expect(ctx.stderr).to.contain('Sorry, dialog call loop detected for lu file')
})
})

Просмотреть файл

@ -1,5 +0,0 @@
# bookHotel
- réserver un hôtel à Seattle
# hotelType
- Quel type d'hôtel préférez-vous

Просмотреть файл

@ -1,5 +0,0 @@
# bookHotel
- book a hotel in Seattle
# hotelType
- Which type of hotel do you prefer

Просмотреть файл

@ -1,14 +0,0 @@
# dia3_trigger
- réserver un vol de {fromLocation = Seattle} à {toLocation = Beijing}
- quel temps de vol préférez-vous
@simple fromLocation
@ simple toLocation
@ phraselist flightTimeline =
- morning,afternoon,evening
# dia4_trigger
- Réservez un billet de train de Seattle à Portland
- Quand voulez-vous partir de la gare de Seattle

Просмотреть файл

@ -1,14 +0,0 @@
# dia3_trigger
- book a flight from {fromLocation = Seattle} to {toLocation = Beijing}
- which {flightTime} do you prefer
@simple fromLocation
@ simple toLocation
@ phraselist flightTimeline =
- morning,afternoon,evening
# dia4_trigger
- book a train ticket from Seattle to Portland
- When do you want to leave from Seattle train station

Просмотреть файл

@ -1,12 +0,0 @@
# bookFlight
- book a flight from {fromLocation = Seattle} to {toLocation = Beijing}
@simple fromLocation
@ simple toLocation
# flightTime
- which {flightTime} do you prefer
@ phraselist flightTimeline =
- morning,afternoon,evening

Просмотреть файл

@ -1,5 +0,0 @@
# bookRailway
- book a train ticket from Seattle to Portland
# railwayTime
- When do you want to leave from Seattle train station

Просмотреть файл

@ -1,14 +0,0 @@
{
"./main/main.lu": {
"./dia1/dia1.lu": "dia1_trigger",
"./dia2/dia2.lu": "dia2_trigger"
},
"./dia2/dia2.lu": {
"./dia3/dia3.lu": "dia3_trigger",
"./dia4/dia4.lu": "dia4_trigger"
},
"./main/main.fr-fr.lu": {
"./dia1/dia1.fr-fr.lu": "dia1_trigger",
"./dia2/dia2.fr-fr.lu": "dia2_trigger"
}
}

Просмотреть файл

@ -1,16 +0,0 @@
# dia1_trigger
- réserver un hôtel à Seattle
- Quel type d'hôtel préférez-vous
# dia2_trigger
- réserver un vol de {fromLocation = Seattle} à {toLocation = Beijing}
- quel temps de vol préférez-vous
- Réservez un billet de train de Seattle à Portland
- Quand voulez-vous partir de la gare de Seattle
@simple fromLocation
@ simple toLocation
@ phraselist flightTimeline =
- morning,afternoon,evening

Просмотреть файл

@ -1,16 +0,0 @@
# dia1_trigger
- book a hotel in Seattle
- Which type of hotel do you prefer
# dia2_trigger
- book a flight from {fromLocation = Seattle} to {toLocation = Beijing}
- which {flightTime} do you prefer
- book a train ticket from Seattle to Portland
- When do you want to leave from Seattle train station
@simple fromLocation
@ simple toLocation
@ phraselist flightTimeline =
- morning,afternoon,evening

Просмотреть файл

@ -1,14 +0,0 @@
# dia2_trigger
- book a hotel in Seattle
- Which type of hotel do you prefer
# dia3_trigger
- book a flight from {fromLocation = Seattle} to {toLocation = Beijing}
- which flight time do you prefer
@simple fromLocation
@ simple toLocation
@ phraselist flightTimeline =
- morning,afternoon,evening

Просмотреть файл

Просмотреть файл

@ -1,12 +0,0 @@
# bookFlight
- book a flight from {fromLocation = Seattle} to {toLocation = Beijing}
@simple fromLocation
@ simple toLocation
# flightTime
- which flight time do you prefer
@ phraselist flightTimeline =
- morning,afternoon,evening

Просмотреть файл

@ -1,9 +0,0 @@
{
"./main/main.lu": {
"./dia1/dia1.lu": "dia1_trigger"
},
"./dia1/dia1.lu": {
"./dia2/dia2.lu": "dia2_trigger",
"./dia3/dia3.lu": "dia3_trigger"
}
}

Просмотреть файл

@ -1,12 +0,0 @@
# dia1_trigger
- book a hotel in Seattle
- Which type of hotel do you prefer
- book a flight from {fromLocation = Seattle} to {toLocation = Beijing}
- which flight time do you prefer
@simple fromLocation
@ simple toLocation
@ phraselist flightTimeline =
- morning,afternoon,evening

Просмотреть файл

@ -1,5 +0,0 @@
# bookHotel
- book a hotel in Seattle
# hotelType
- Which type of hotel do you prefer

Просмотреть файл

@ -1,24 +0,0 @@
> !# @enableSections = true
> !# @enableMergeIntents = true
# dia3_trigger
## bookFlight
- book a flight from {fromLocation = Seattle} to {toLocation = Beijing}
@simple fromLocation
@ simple toLocation
## flightTime
- which flight time do you prefer
@ phraselist flightTimeline =
- morning,afternoon,evening
# dia4_trigger
- book a train ticket from Seattle to Portland
- When do you want to leave from Seattle train station
# local_intent
- Hello
- Hi

Просмотреть файл

@ -1,16 +0,0 @@
> !# @enableSections = true
> !# @enableMergeIntents = true
# flight
## bookFlight
- book a flight from {fromLocation = Seattle} to {toLocation = Beijing}
@simple fromLocation
@ simple toLocation
## flightTime
- which flight time do you prefer
@ phraselist flightTimeline =
- morning,afternoon,evening

Просмотреть файл

@ -1,9 +0,0 @@
> !# @enableSections = true
> !# @enableMergeIntents = true
# railway
## bookRailway
- book a train ticket from Seattle to Portland
## railwayTime
- When do you want to leave from Seattle train station

Просмотреть файл

@ -1,10 +0,0 @@
{
"./main/main.lu": {
"./dia1/dia1.lu": "dia1_trigger",
"./dia2/dia2.lu": "dia2_trigger"
},
"./dia2/dia2.lu": {
"./dia3/dia3.lu": "dia3_trigger",
"./dia4/dia4.lu": "dia4_trigger"
}
}

Просмотреть файл

@ -1,18 +0,0 @@
# dia1_trigger
- book a hotel in Seattle
- Which type of hotel do you prefer
# dia2_trigger
- book a flight from {fromLocation = Seattle} to {toLocation = Beijing}
- which flight time do you prefer
- book a train ticket from Seattle to Portland
- When do you want to leave from Seattle train station
- Hello
- Hi
@simple fromLocation
@ simple toLocation
@ phraselist flightTimeline =
- morning,afternoon,evening

Просмотреть файл

@ -1,18 +0,0 @@
# dia2_trigger
- book a hotel in Seattle
- Which type of hotel do you prefer
# dia3_trigger
- book a flight from {fromLocation = Seattle} to {toLocation = Beijing}
- which flight time do you prefer
@simple fromLocation
@ simple toLocation
@ phraselist flightTimeline =
- morning,afternoon,evening
# local_trigger1
- Hello
- Hi

Просмотреть файл

@ -1,5 +0,0 @@
# bookHotel
- book a hotel in Seattle
# hotelType
- Which type of hotel do you prefer

Просмотреть файл

@ -1,12 +0,0 @@
# bookFlight
- book a flight from {fromLocation = Seattle} to {toLocation = Beijing}
@simple fromLocation
@ simple toLocation
# flightTime
- which flight time do you prefer
@ phraselist flightTimeline =
- morning,afternoon,evening

Просмотреть файл

@ -1,9 +0,0 @@
{
"./main/main.lu": {
"./dia1/dia1.lu": "dia1_trigger"
},
"./dia1/dia1.lu": {
"./dia2/dia2.lu": "dia2_trigger",
"./dia3/dia3.lu": "dia3_trigger"
}
}

Просмотреть файл

@ -1,14 +0,0 @@
# dia1_trigger
- book a hotel in Seattle
- Which type of hotel do you prefer
- book a flight from {fromLocation = Seattle} to {toLocation = Beijing}
- which flight time do you prefer
- Hello
- Hi
@simple fromLocation
@ simple toLocation
@ phraselist flightTimeline =
- morning,afternoon,evening

Просмотреть файл

@ -1,16 +0,0 @@
# dia2_trigger
- book a hotel in Seattle
- Which type of hotel do you prefer
- book a flight from {fromLocation = Seattle} to {toLocation = Beijing}
- which flight time do you prefer
@simple fromLocation
@ simple toLocation
@ phraselist flightTimeline =
- morning,afternoon,evening
# dia3_trigger
- Hello
- Hi

Просмотреть файл

@ -1,5 +0,0 @@
# bookHotel
- book a hotel in Seattle
# hotelType
- Which type of hotel do you prefer

Просмотреть файл

@ -1,12 +0,0 @@
# bookFlight
- book a flight from {fromLocation = Seattle} to {toLocation = Beijing}
@simple fromLocation
@ simple toLocation
# flightTime
- which flight time do you prefer
@ phraselist flightTimeline =
- morning,afternoon,evening

Просмотреть файл

@ -1,3 +0,0 @@
# Greeting
- Hello
- Hi

Просмотреть файл

@ -1,10 +0,0 @@
{
"./main/main.lu": {
"./dia1/dia1.lu": "dia1_trigger"
},
"./dia1/dia1.lu": {
"./dia2/dia2.lu": "dia2_trigger",
"./dia3/dia3.lu": "dia2_trigger",
"./dia4/dia4.lu": "dia3_trigger"
}
}

Просмотреть файл

@ -1,14 +0,0 @@
# dia1_trigger
- book a hotel in Seattle
- Which type of hotel do you prefer
- book a flight from {fromLocation = Seattle} to {toLocation = Beijing}
- which flight time do you prefer
- Hello
- Hi
@simple fromLocation
@ simple toLocation
@ phraselist flightTimeline =
- morning,afternoon,evening

Просмотреть файл

@ -1,14 +0,0 @@
# dia2_trigger
- book a hotel in Seattle
- Which type of hotel do you prefer
# dia3_trigger
- book a flight from {fromLocation = Seattle} to {toLocation = Beijing}
- which flight time do you prefer
@simple fromLocation
@ simple toLocation
@ phraselist flightTimeline =
- morning,afternoon,evening

Просмотреть файл

@ -1,5 +0,0 @@
# bookHotel
- book a hotel in Seattle
# hotelType
- Which type of hotel do you prefer

Просмотреть файл

@ -1,16 +0,0 @@
# dia4_trigger
- book a hotel in Seattle
- Which type of hotel do you prefer
# bookFlight
- book a flight from {fromLocation = Seattle} to {toLocation = Beijing}
@simple fromLocation
@ simple toLocation
# flightTime
- which flight time do you prefer
@ phraselist flightTimeline =
- morning,afternoon,evening

Просмотреть файл

@ -1,12 +0,0 @@
{
"./main/main.lu": {
"./dia1/dia1.lu": "dia1_trigger"
},
"./dia1/dia1.lu": {
"./dia2/dia2.lu": "dia2_trigger",
"./dia3/dia3.lu": "dia3_trigger"
},
"./dia3/dia3.lu": {
"./dia1/dia1.lu": "dia4_trigger"
}
}

Просмотреть файл

@ -1,12 +0,0 @@
# dia1_trigger
- book a hotel in Seattle
- Which type of hotel do you prefer
- book a flight from {fromLocation = Seattle} to {toLocation = Beijing}
- which flight time do you prefer
@simple fromLocation
@ simple toLocation
@ phraselist flightTimeline =
- morning,afternoon,evening

Просмотреть файл

@ -1,11 +0,0 @@
# bookHotel
- réserver un hôtel à Seattle
# hotelType
- Quel type d'hôtel préférez-vous
# _Interuption
- réserver un vol de Seattle à Beijing
- quel temps de vol préférez-vous
- Réservez un billet de train de Seattle à Portland
- Quand voulez-vous partir de la gare de Seattle

Просмотреть файл

@ -1,11 +0,0 @@
# bookHotel
- book a hotel in Seattle
# hotelType
- Which type of hotel do you prefer
# _Interuption
- book a flight from Seattle to Beijing
- which {flightTime} do you prefer
- book a train ticket from Seattle to Portland
- When do you want to leave from Seattle train station

Просмотреть файл

@ -1,18 +0,0 @@
# dia3_trigger
- réserver un vol de {fromLocation = Seattle} à {toLocation = Beijing}
- quel temps de vol préférez-vous
@simple fromLocation
@ simple toLocation
@ phraselist flightTimeline =
- morning,afternoon,evening
# dia4_trigger
- Réservez un billet de train de Seattle à Portland
- Quand voulez-vous partir de la gare de Seattle
# _Interuption
- réserver un hôtel à Seattle
- Quel type d'hôtel préférez-vous

Просмотреть файл

@ -1,18 +0,0 @@
# dia3_trigger
- book a flight from {fromLocation = Seattle} to {toLocation = Beijing}
- which {flightTime} do you prefer
@simple fromLocation
@ simple toLocation
@ phraselist flightTimeline =
- morning,afternoon,evening
# dia4_trigger
- book a train ticket from Seattle to Portland
- When do you want to leave from Seattle train station
# _Interuption
- book a hotel in Seattle
- Which type of hotel do you prefer

Просмотреть файл

@ -1,18 +0,0 @@
# bookFlight
- book a flight from {fromLocation = Seattle} to {toLocation = Beijing}
@simple fromLocation
@ simple toLocation
# flightTime
- which {flightTime} do you prefer
@ phraselist flightTimeline =
- morning,afternoon,evening
# _Interuption
- book a train ticket from Seattle to Portland
- When do you want to leave from Seattle train station
- book a hotel in Seattle
- Which type of hotel do you prefer

Просмотреть файл

@ -1,11 +0,0 @@
# bookRailway
- book a train ticket from Seattle to Portland
# railwayTime
- When do you want to leave from Seattle train station
# _Interuption
- book a flight from Seattle to Beijing
- which {flightTime} do you prefer
- book a hotel in Seattle
- Which type of hotel do you prefer

Просмотреть файл

@ -1,16 +0,0 @@
# dia1_trigger
- réserver un hôtel à Seattle
- Quel type d'hôtel préférez-vous
# dia2_trigger
- réserver un vol de {fromLocation = Seattle} à {toLocation = Beijing}
- quel temps de vol préférez-vous
- Réservez un billet de train de Seattle à Portland
- Quand voulez-vous partir de la gare de Seattle
@simple fromLocation
@ simple toLocation
@ phraselist flightTimeline =
- morning,afternoon,evening

Просмотреть файл

@ -1,16 +0,0 @@
# dia1_trigger
- book a hotel in Seattle
- Which type of hotel do you prefer
# dia2_trigger
- book a flight from {fromLocation = Seattle} to {toLocation = Beijing}
- which {flightTime} do you prefer
- book a train ticket from Seattle to Portland
- When do you want to leave from Seattle train station
@simple fromLocation
@ simple toLocation
@ phraselist flightTimeline =
- morning,afternoon,evening

Просмотреть файл

@ -1,14 +0,0 @@
# dia2_trigger
- book a hotel in Seattle
- Which type of hotel do you prefer
# dia3_trigger
- book a flight from {fromLocation = Seattle} to {toLocation = Beijing}
- which flight time do you prefer
@simple fromLocation
@ simple toLocation
@ phraselist flightTimeline =
- morning,afternoon,evening

Просмотреть файл

@ -1,16 +0,0 @@
# bookFlight
- book a flight from {fromLocation = Seattle} to {toLocation = Beijing}
@simple fromLocation
@ simple toLocation
# flightTime
- which flight time do you prefer
@ phraselist flightTimeline =
- morning,afternoon,evening
# _Interuption
- book a hotel in Seattle
- Which type of hotel do you prefer

Просмотреть файл

@ -1,12 +0,0 @@
# dia1_trigger
- book a hotel in Seattle
- Which type of hotel do you prefer
- book a flight from {fromLocation = Seattle} to {toLocation = Beijing}
- which flight time do you prefer
@simple fromLocation
@ simple toLocation
@ phraselist flightTimeline =
- morning,afternoon,evening

Просмотреть файл

@ -1,13 +0,0 @@
# bookHotel
- book a hotel in Seattle
# hotelType
- Which type of hotel do you prefer
# _Interuption
- book a flight from Seattle to Beijing
- which flight time do you prefer
- book a train ticket from Seattle to Portland
- When do you want to leave from Seattle train station
- Hello
- Hi

Просмотреть файл

@ -1,28 +0,0 @@
> !# @enableSections = true
> !# @enableMergeIntents = true
# dia3_trigger
## bookFlight
- book a flight from {fromLocation = Seattle} to {toLocation = Beijing}
@simple fromLocation
@ simple toLocation
## flightTime
- which flight time do you prefer
@ phraselist flightTimeline =
- morning,afternoon,evening
# dia4_trigger
- book a train ticket from Seattle to Portland
- When do you want to leave from Seattle train station
# local_intent
- Hello
- Hi
# _Interuption
- book a hotel in Seattle
- Which type of hotel do you prefer

Просмотреть файл

@ -1,24 +0,0 @@
> !# @enableSections = true
> !# @enableMergeIntents = true
# flight
## bookFlight
- book a flight from {fromLocation = Seattle} to {toLocation = Beijing}
@simple fromLocation
@ simple toLocation
## flightTime
- which flight time do you prefer
@ phraselist flightTimeline =
- morning,afternoon,evening
# _Interuption
- book a train ticket from Seattle to Portland
- When do you want to leave from Seattle train station
- Hello
- Hi
- book a hotel in Seattle
- Which type of hotel do you prefer

Просмотреть файл

@ -1,17 +0,0 @@
> !# @enableSections = true
> !# @enableMergeIntents = true
# railway
## bookRailway
- book a train ticket from Seattle to Portland
## railwayTime
- When do you want to leave from Seattle train station
# _Interuption
- book a flight from Seattle to Beijing
- which flight time do you prefer
- Hello
- Hi
- book a hotel in Seattle
- Which type of hotel do you prefer

Просмотреть файл

@ -1,18 +0,0 @@
# dia1_trigger
- book a hotel in Seattle
- Which type of hotel do you prefer
# dia2_trigger
- book a flight from {fromLocation = Seattle} to {toLocation = Beijing}
- which flight time do you prefer
- book a train ticket from Seattle to Portland
- When do you want to leave from Seattle train station
- Hello
- Hi
@simple fromLocation
@ simple toLocation
@ phraselist flightTimeline =
- morning,afternoon,evening

Просмотреть файл

@ -1,18 +0,0 @@
# dia2_trigger
- book a hotel in Seattle
- Which type of hotel do you prefer
# dia3_trigger
- book a flight from {fromLocation = Seattle} to {toLocation = Beijing}
- which flight time do you prefer
@simple fromLocation
@ simple toLocation
@ phraselist flightTimeline =
- morning,afternoon,evening
# local_trigger1
- Hello
- Hi

Просмотреть файл

@ -1,11 +0,0 @@
# bookHotel
- book a hotel in Seattle
# hotelType
- Which type of hotel do you prefer
# _Interuption
- book a flight from Seattle to Beijing
- which flight time do you prefer
- Hello
- Hi

Просмотреть файл

@ -1,18 +0,0 @@
# bookFlight
- book a flight from {fromLocation = Seattle} to {toLocation = Beijing}
@simple fromLocation
@ simple toLocation
# flightTime
- which flight time do you prefer
@ phraselist flightTimeline =
- morning,afternoon,evening
# _Interuption
- book a hotel in Seattle
- Which type of hotel do you prefer
- Hello
- Hi

Просмотреть файл

@ -1,14 +0,0 @@
# dia1_trigger
- book a hotel in Seattle
- Which type of hotel do you prefer
- book a flight from {fromLocation = Seattle} to {toLocation = Beijing}
- which flight time do you prefer
- Hello
- Hi
@simple fromLocation
@ simple toLocation
@ phraselist flightTimeline =
- morning,afternoon,evening

Просмотреть файл

@ -1,16 +0,0 @@
# dia2_trigger
- book a hotel in Seattle
- Which type of hotel do you prefer
- book a flight from {fromLocation = Seattle} to {toLocation = Beijing}
- which flight time do you prefer
@simple fromLocation
@ simple toLocation
@ phraselist flightTimeline =
- morning,afternoon,evening
# dia3_trigger
- Hello
- Hi

Просмотреть файл

@ -1,9 +0,0 @@
# bookHotel
- book a hotel in Seattle
# hotelType
- Which type of hotel do you prefer
# _Interuption
- Hello
- Hi

Просмотреть файл

@ -1,16 +0,0 @@
# bookFlight
- book a flight from {fromLocation = Seattle} to {toLocation = Beijing}
@simple fromLocation
@ simple toLocation
# flightTime
- which flight time do you prefer
@ phraselist flightTimeline =
- morning,afternoon,evening
# _Interuption
- Hello
- Hi

Просмотреть файл

@ -1,9 +0,0 @@
# Greeting
- Hello
- Hi
# _Interuption
- book a hotel in Seattle
- Which type of hotel do you prefer
- book a flight from Seattle to Beijing
- which flight time do you prefer

Просмотреть файл

@ -1,14 +0,0 @@
# dia1_trigger
- book a hotel in Seattle
- Which type of hotel do you prefer
- book a flight from {fromLocation = Seattle} to {toLocation = Beijing}
- which flight time do you prefer
- Hello
- Hi
@simple fromLocation
@ simple toLocation
@ phraselist flightTimeline =
- morning,afternoon,evening

Просмотреть файл

@ -35,24 +35,4 @@ describe('utils/filehelper test', () => {
console.log(err)
}
})
it('File helper correctly build a triggerIntent to dialog mapping dict', async function(){
try{
let pathToFile = path.resolve(__dirname, './../fixtures/testcases/interuption/intent_to_lu.json')
let configObject = await fileHelper.getConfigObject(pathToFile)
let configObjKeys = Object.keys(configObject)
expect(configObjKeys.length).to.deep.equals(3)
expect(configObject[configObjKeys[1]][path.resolve(path.dirname(pathToFile), './dia4/dia4.lu')]).to.deep.equals('dia4_trigger')
expect(configObject[configObjKeys[2]][path.resolve(path.dirname(pathToFile), './dia2/dia2.fr-fr.lu')]).to.deep.equals('dia2_trigger')
pathToFile = path.resolve(__dirname, './../fixtures/testcases/interuption2')
configObject = await fileHelper.getConfigObject(pathToFile)
configObjKeys = Object.keys(configObject)
expect(configObjKeys.length).to.deep.equals(2)
expect(configObject[configObjKeys[0]][path.resolve(pathToFile, './dia1/dia1.lu')]).to.deep.equals('dia1_trigger')
expect(configObject[configObjKeys[1]][path.resolve(pathToFile, './dia3/dia3.lu')]).to.deep.equals('dia3_trigger')
}catch(err){
console.log(err)
}
})
})