Adding tests.
This commit is contained in:
Родитель
c28a45454d
Коммит
046162414b
|
@ -418,3 +418,20 @@ You can add comments to your .lu document by prefixing the comment with >. Here'
|
|||
- hi
|
||||
- hello
|
||||
```
|
||||
|
||||
## Application/ KB information
|
||||
You can include configuration information for your LUIS application or QnA Maker KB via comments.
|
||||
|
||||
**Note** Any information explicitly passed in via CLI arguments will override information in the .lu file.
|
||||
|
||||
```markdown
|
||||
> LUIS application description
|
||||
> !# @app.name = my luis application
|
||||
> !# @app.desc = description of my luis application
|
||||
> !# @app.versionId = 0.5
|
||||
> !# @app.culture = en-us
|
||||
> !# @app.luis_schema_version = 3.0.0
|
||||
|
||||
> QnA Maker KB description
|
||||
> !# @kb.name = my qna maker kb name
|
||||
```
|
|
@ -122,7 +122,13 @@ const helpers = {
|
|||
// Add support to parse application metadata if found
|
||||
let info = currentLine.split(/>[ ]*!#/g);
|
||||
if (info === undefined || info.length === 1) continue;
|
||||
currentSection += PARSERCONSTS.MODELINFO + info[1].trim() + NEWLINE;
|
||||
let previousSection = currentSection.substring(0, currentSection.lastIndexOf(NEWLINE));
|
||||
try {
|
||||
sectionsInFile = validateAndPushCurrentBuffer(previousSection, sectionsInFile, currentSectionType, lineIndex, log);
|
||||
} catch (err) {
|
||||
throw (err);
|
||||
}
|
||||
currentSection = PARSERCONSTS.MODELINFO + info[1].trim() + NEWLINE;
|
||||
currentSectionType = PARSERCONSTS.MODELINFO;
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -23,8 +23,8 @@ program
|
|||
.option('-s, --subfolder', '[Optional] Include sub-folders as well when looking for .lu files')
|
||||
.option('-n, --luis_name <luis_appName>', '[Optional] LUIS app name')
|
||||
.option('-d, --luis_desc <luis_appDesc>', '[Optional] LUIS app description')
|
||||
.option('-i, --luis_versionId <luis_versionId>', '[Optional] LUIS app version', '0.1')
|
||||
.option('-c, --luis_culture <luis_appCulture>', '[Optional] LUIS app culture', 'en-us')
|
||||
.option('-i, --luis_versionId <luis_versionId>', '[Optional] LUIS app version')
|
||||
.option('-c, --luis_culture <luis_appCulture>', '[Optional] LUIS app culture')
|
||||
.option('-t, --write_luis_batch_tests', '[Optional] Write out LUIS batch test json file')
|
||||
.option('--out <OutFileName>', '[Optional] Output file name for the LUIS model')
|
||||
.option('--verbose', '[Optional] Get verbose messages from parser')
|
||||
|
|
|
@ -78,23 +78,24 @@ const writeOutFiles = function(program,finalLUISJSON,finalQnAJSON, finalQnAAlter
|
|||
} catch (err) {
|
||||
throw (err);
|
||||
}
|
||||
if(!program.luis_versionId) program.luis_versionId = "0.1";
|
||||
if(!program.luis_schema_version) program.luis_schema_version = "3.0.0";
|
||||
if(!program.luis_name) program.luis_name = path.basename(rootFile, path.extname(rootFile));
|
||||
if(!program.luis_desc) program.luis_desc = "";
|
||||
if(!program.luis_culture) program.luis_culture = "en-us";
|
||||
if(!program.qna_name) program.qna_name = path.basename(rootFile, path.extname(rootFile));
|
||||
if(program.luis_culture) program.luis_culture = program.luis_culture.toLowerCase();
|
||||
// if(!program.luis_versionId) program.luis_versionId = "0.1";
|
||||
// if(!program.luis_schema_version) program.luis_schema_version = "3.0.0";
|
||||
// if(!program.luis_name) program.luis_name = path.basename(rootFile, path.extname(rootFile));
|
||||
// if(!program.luis_desc) program.luis_desc = "";
|
||||
// if(!program.luis_culture) program.luis_culture = "en-us";
|
||||
// if(!program.qna_name) program.qna_name = path.basename(rootFile, path.extname(rootFile));
|
||||
// if(program.luis_culture) program.luis_culture = program.luis_culture.toLowerCase();
|
||||
|
||||
if(finalLUISJSON) {
|
||||
finalLUISJSON.luis_schema_version = finalLUISJSON.luis_schema_version || program.luis_schema_version;
|
||||
finalLUISJSON.versionId = finalLUISJSON.versionId || program.luis_versionId;
|
||||
finalLUISJSON.name = finalLUISJSON.name || program.luis_name.split('.')[0],
|
||||
finalLUISJSON.desc = finalLUISJSON.desc || program.luis_desc;
|
||||
finalLUISJSON.culture = finalLUISJSON.culture || program.luis_culture;
|
||||
finalLUISJSON.luis_schema_version = program.luis_schema_version || finalLUISJSON.luis_schema_version || "3.0.0";
|
||||
finalLUISJSON.versionId = program.luis_versionId || finalLUISJSON.versionId || "0.1";
|
||||
finalLUISJSON.name = program.luis_name || finalLUISJSON.name || path.basename(rootFile, path.extname(rootFile)),
|
||||
finalLUISJSON.desc = program.luis_desc || finalLUISJSON.desc || "";
|
||||
finalLUISJSON.culture = program.luis_culture || finalLUISJSON.culture || "en-us";
|
||||
finalLUISJSON.culture = finalLUISJSON.culture.toLowerCase();
|
||||
}
|
||||
|
||||
if (finalQnAJSON) finalQnAJSON.name = finalQnAJSON.name || program.qna_name.split('.')[0];
|
||||
if (finalQnAJSON) finalQnAJSON.name = program.qna_name || finalQnAJSON.name || path.basename(rootFile, path.extname(rootFile));
|
||||
|
||||
var writeQnAFile = (finalQnAJSON.qnaList.length > 0) ||
|
||||
(finalQnAJSON.urls.length > 0) ||
|
||||
|
|
|
@ -935,5 +935,38 @@ describe('parseFile correctly parses utterances', function () {
|
|||
.catch(err => done(err))
|
||||
})
|
||||
|
||||
it ('LUIS and QnA meta data information in lu file is parsed correctly', function(done){
|
||||
let testLU = `> !# @kb.name = my test kb
|
||||
# ? hi
|
||||
\`\`\`markdown
|
||||
hello
|
||||
\`\`\`
|
||||
|
||||
> !# @app.versionId = 0.6
|
||||
> !# @app.name = orange tomato
|
||||
|
||||
# test
|
||||
- greeting`;
|
||||
|
||||
parseFile.parseFile(testLU)
|
||||
.then(res => {
|
||||
assert.equal(res.qnaJsonStructure.name, 'my test kb');
|
||||
assert.equal(res.LUISJsonStructure.name, 'orange tomato');
|
||||
assert.equal(res.LUISJsonStructure.versionId, '0.6');
|
||||
done();
|
||||
})
|
||||
.catch(err => done(err))
|
||||
})
|
||||
|
||||
it ('Multi line app meta data definition throws correctly', function(done){
|
||||
let testLU = `> !# @kb.name = foo bar
|
||||
test
|
||||
|
||||
# ? test q`;
|
||||
|
||||
parseFile.parseFile(testLU)
|
||||
.then(res => done(`Did not throw when expected`))
|
||||
.catch(err => done())
|
||||
})
|
||||
|
||||
})
|
||||
|
|
Загрузка…
Ссылка в новой задаче