Merge pull request #10 from v-geberr/171103-qs-utterance-map

added comments so mk can pull code sections
This commit is contained in:
Denise Mak 2017-11-03 13:30:55 -07:00 коммит произвёл GitHub
Родитель 80e186411a 4aaabeb699
Коммит 8dc612c3fe
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 10 добавлений и 7 удалений

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

@ -13,10 +13,12 @@
// add-utterance -status
// Checks the training status and writes status details to a file.
// <dependencies>
var rp = require('request-promise');
var fse = require('fs-extra');
var path = require('path');
// <constants>
// To run this sample, change these constants.
// Programmatic key, available in luis.ai under Account Settings
@ -30,10 +32,11 @@ const LUIS_versionId = "0.1";
// The contents of the file must be in this format described at: https://aka.ms/add-utterance-json-format
const uploadFile = "./utterances.json"
// <globals>
var trainAfterAdd = false;
var requestTrainingStatus = false;
// <cmdArgs>
// Command line arguments:
// -train to train based on the utterances in uploadFile
// -status to get training status
@ -45,7 +48,7 @@ if (process.argv.length >= 3) {
}
}
// <configAddUtterance>
/* upload configuration */
var configAddUtterance = {
LUIS_subscriptionKey: LUIS_programmaticKey,
@ -55,7 +58,7 @@ var configAddUtterance = {
uri: "https://westus.api.cognitive.microsoft.com/luis/api/v2.0/apps/{appId}/versions/{versionId}/examples".replace("{appId}", LUIS_appId).replace("{versionId}", LUIS_versionId)
};
// <addUtterance>
// Call add-utterance
var addUtterance = async (config) => {
@ -87,7 +90,7 @@ var addUtterance = async (config) => {
}
}
// <configTrain>
/* training configuration */
var configTrain = {
LUIS_subscriptionKey: LUIS_programmaticKey,
@ -96,7 +99,7 @@ var configTrain = {
uri: "https://westus.api.cognitive.microsoft.com/luis/api/v2.0/apps/{appId}/versions/{versionId}/train".replace("{appId}", LUIS_appId).replace("{versionId}", LUIS_versionId),
method: 'POST', // POST to request training, GET to get training status
};
// <train>
// Call train
var train = async (config) => {
@ -129,7 +132,7 @@ var train = async (config) => {
}
// <sendUtteranceToApi>
// Send JSON as the body of the POST request to the API
var sendUtteranceToApi = async (options) => {
try {
@ -148,7 +151,7 @@ var sendUtteranceToApi = async (options) => {
}
}
// <main>
if (trainAfterAdd) {
// Add the utterance to the LUIS app and train
addUtterance(configAddUtterance)