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 // add-utterance -status
// Checks the training status and writes status details to a file. // Checks the training status and writes status details to a file.
// <dependencies>
var rp = require('request-promise'); var rp = require('request-promise');
var fse = require('fs-extra'); var fse = require('fs-extra');
var path = require('path'); var path = require('path');
// <constants>
// To run this sample, change these constants. // To run this sample, change these constants.
// Programmatic key, available in luis.ai under Account Settings // 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 // The contents of the file must be in this format described at: https://aka.ms/add-utterance-json-format
const uploadFile = "./utterances.json" const uploadFile = "./utterances.json"
// <globals>
var trainAfterAdd = false; var trainAfterAdd = false;
var requestTrainingStatus = false; var requestTrainingStatus = false;
// <cmdArgs>
// Command line arguments: // Command line arguments:
// -train to train based on the utterances in uploadFile // -train to train based on the utterances in uploadFile
// -status to get training status // -status to get training status
@ -45,7 +48,7 @@ if (process.argv.length >= 3) {
} }
} }
// <configAddUtterance>
/* upload configuration */ /* upload configuration */
var configAddUtterance = { var configAddUtterance = {
LUIS_subscriptionKey: LUIS_programmaticKey, 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) 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 // Call add-utterance
var addUtterance = async (config) => { var addUtterance = async (config) => {
@ -87,7 +90,7 @@ var addUtterance = async (config) => {
} }
} }
// <configTrain>
/* training configuration */ /* training configuration */
var configTrain = { var configTrain = {
LUIS_subscriptionKey: LUIS_programmaticKey, 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), 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 method: 'POST', // POST to request training, GET to get training status
}; };
// <train>
// Call train // Call train
var train = async (config) => { 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 // Send JSON as the body of the POST request to the API
var sendUtteranceToApi = async (options) => { var sendUtteranceToApi = async (options) => {
try { try {
@ -148,7 +151,7 @@ var sendUtteranceToApi = async (options) => {
} }
} }
// <main>
if (trainAfterAdd) { if (trainAfterAdd) {
// Add the utterance to the LUIS app and train // Add the utterance to the LUIS app and train
addUtterance(configAddUtterance) addUtterance(configAddUtterance)