clean up and archive files used in docs

This commit is contained in:
Dina Berry 2018-08-31 07:25:55 -07:00
Родитель 0d9c471d9f
Коммит 0c0a5f4030
93 изменённых файлов: 896 добавлений и 1900 удалений

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

@ -1,180 +1,180 @@
using System;
using System.IO;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace AddUtterances
{
class Program
{
// NOTE: Replace this example LUIS application ID with the ID of your LUIS application.
static string appID = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
// NOTE: Replace this example LUIS application version number with the version number of your LUIS application.
static string appVersion = "0.1";
// NOTE: Replace this example LUIS programmatic key with a valid key.
static string key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
static string host = "https://westus.api.cognitive.microsoft.com";
static string path = "/luis/api/v2.0/apps/" + appID + "/versions/" + appVersion + "/";
static string usage = @"Usage:
add-utterances <input file>
add-utterances -train <input file>
add-utterances -status
The contents of <input file> must be in the format described at: https://aka.ms/add-utterance-json-format
";
static string JsonPrettyPrint(string json)
{
if (string.IsNullOrEmpty(json))
return string.Empty;
json = json.Replace(Environment.NewLine, "").Replace("\t", "");
StringBuilder sb = new StringBuilder();
bool quote = false;
bool ignore = false;
int offset = 0;
int indentLength = 3;
foreach (char ch in json)
{
switch (ch)
{
case '"':
if (!ignore) quote = !quote;
break;
case '\'':
if (quote) ignore = !ignore;
break;
}
if (quote)
sb.Append(ch);
else
{
switch (ch)
{
case '{':
case '[':
sb.Append(ch);
sb.Append(Environment.NewLine);
sb.Append(new string(' ', ++offset * indentLength));
break;
case '}':
case ']':
sb.Append(Environment.NewLine);
sb.Append(new string(' ', --offset * indentLength));
sb.Append(ch);
break;
case ',':
sb.Append(ch);
sb.Append(Environment.NewLine);
sb.Append(new string(' ', offset * indentLength));
break;
case ':':
sb.Append(ch);
sb.Append(' ');
break;
default:
if (ch != ' ') sb.Append(ch);
break;
}
}
}
return sb.ToString().Trim();
}
async static Task<HttpResponseMessage> SendGet(string uri)
{
using (var client = new HttpClient())
using (var request = new HttpRequestMessage())
{
request.Method = HttpMethod.Get;
request.RequestUri = new Uri(uri);
request.Headers.Add("Ocp-Apim-Subscription-Key", key);
return await client.SendAsync(request);
}
}
async static Task<HttpResponseMessage> SendPost(string uri, string requestBody)
{
using (var client = new HttpClient())
using (var request = new HttpRequestMessage())
{
request.Method = HttpMethod.Post;
request.RequestUri = new Uri(uri);
request.Content = new StringContent(requestBody, Encoding.UTF8, "text/json");
request.Headers.Add("Ocp-Apim-Subscription-Key", key);
return await client.SendAsync(request);
}
}
async static Task AddUtterances(string input_file)
{
string uri = host + path + "examples";
string requestBody = File.ReadAllText(input_file);
var response = await SendPost(uri, requestBody);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine("Added utterances.");
Console.WriteLine(JsonPrettyPrint(result));
}
async static Task Train(string input_file)
{
string uri = host + path + "train";
string requestBody = File.ReadAllText(input_file);
var response = await SendPost(uri, requestBody);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine("Sent training request.");
Console.WriteLine(JsonPrettyPrint(result));
await Status();
}
async static Task Status()
{
var response = await SendGet(host + path + "train");
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine("Requested training status.");
Console.WriteLine(JsonPrettyPrint(result));
}
static void Main(string[] args)
{
if (args.Length < 1)
{
Console.WriteLine(usage);
}
else
{
if (true == String.Equals(args[0], "-train", StringComparison.OrdinalIgnoreCase))
{
if (args.Length > 1)
{
Train(args[1]).Wait();
}
else
{
Console.WriteLine(usage);
}
}
else if (true == String.Equals(args[0], "-status", StringComparison.OrdinalIgnoreCase))
{
Status().Wait();
}
else
{
AddUtterances(args[0]).Wait();
}
}
}
}
}
using System;
using System.IO;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace AddUtterances
{
class Program
{
// NOTE: Replace this example LUIS application ID with the ID of your LUIS application.
static string appID = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
// NOTE: Replace this example LUIS application version number with the version number of your LUIS application.
static string appVersion = "0.1";
// NOTE: Replace this example LUIS programmatic key with a valid key.
static string key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
static string host = "https://westus.api.cognitive.microsoft.com";
static string path = "/luis/api/v2.0/apps/" + appID + "/versions/" + appVersion + "/";
static string usage = @"Usage:
add-utterances <input file>
add-utterances -train <input file>
add-utterances -status
The contents of <input file> must be in the format described at: https://aka.ms/add-utterance-json-format
";
static string JsonPrettyPrint(string json)
{
if (string.IsNullOrEmpty(json))
return string.Empty;
json = json.Replace(Environment.NewLine, "").Replace("\t", "");
StringBuilder sb = new StringBuilder();
bool quote = false;
bool ignore = false;
int offset = 0;
int indentLength = 3;
foreach (char ch in json)
{
switch (ch)
{
case '"':
if (!ignore) quote = !quote;
break;
case '\'':
if (quote) ignore = !ignore;
break;
}
if (quote)
sb.Append(ch);
else
{
switch (ch)
{
case '{':
case '[':
sb.Append(ch);
sb.Append(Environment.NewLine);
sb.Append(new string(' ', ++offset * indentLength));
break;
case '}':
case ']':
sb.Append(Environment.NewLine);
sb.Append(new string(' ', --offset * indentLength));
sb.Append(ch);
break;
case ',':
sb.Append(ch);
sb.Append(Environment.NewLine);
sb.Append(new string(' ', offset * indentLength));
break;
case ':':
sb.Append(ch);
sb.Append(' ');
break;
default:
if (ch != ' ') sb.Append(ch);
break;
}
}
}
return sb.ToString().Trim();
}
async static Task<HttpResponseMessage> SendGet(string uri)
{
using (var client = new HttpClient())
using (var request = new HttpRequestMessage())
{
request.Method = HttpMethod.Get;
request.RequestUri = new Uri(uri);
request.Headers.Add("Ocp-Apim-Subscription-Key", key);
return await client.SendAsync(request);
}
}
async static Task<HttpResponseMessage> SendPost(string uri, string requestBody)
{
using (var client = new HttpClient())
using (var request = new HttpRequestMessage())
{
request.Method = HttpMethod.Post;
request.RequestUri = new Uri(uri);
request.Content = new StringContent(requestBody, Encoding.UTF8, "text/json");
request.Headers.Add("Ocp-Apim-Subscription-Key", key);
return await client.SendAsync(request);
}
}
async static Task AddUtterances(string input_file)
{
string uri = host + path + "examples";
string requestBody = File.ReadAllText(input_file);
var response = await SendPost(uri, requestBody);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine("Added utterances.");
Console.WriteLine(JsonPrettyPrint(result));
}
async static Task Train(string input_file)
{
string uri = host + path + "train";
string requestBody = File.ReadAllText(input_file);
var response = await SendPost(uri, requestBody);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine("Sent training request.");
Console.WriteLine(JsonPrettyPrint(result));
await Status();
}
async static Task Status()
{
var response = await SendGet(host + path + "train");
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine("Requested training status.");
Console.WriteLine(JsonPrettyPrint(result));
}
static void Main(string[] args)
{
if (args.Length < 1)
{
Console.WriteLine(usage);
}
else
{
if (true == String.Equals(args[0], "-train", StringComparison.OrdinalIgnoreCase))
{
if (args.Length > 1)
{
Train(args[1]).Wait();
}
else
{
Console.WriteLine(usage);
}
}
else if (true == String.Equals(args[0], "-status", StringComparison.OrdinalIgnoreCase))
{
Status().Wait();
}
else
{
AddUtterances(args[0]).Wait();
}
}
}
}
}

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

@ -1,345 +1,345 @@
// Add Utterances to LUIS Application - AddUtterances.java
// Language Understanding Intelligent Service
// Microsoft Cognitive Services, a part of Microsoft Azure
//
// Requires JDK 1.7 or later
//
// Package required: Google's GSON JSON library
// Download latest JAR from GitHub: https://github.com/google/gson/releases
// and place it in the same directory as AddUtterances.java
//
// Paste your LUIS application ID, version, and subscription key in the
// variables LUIS_APP_ID, LUIS_APP_VERSION, and LUIS_AUTHORING_ID below.
//
// To compile from command line:
// javac -classpath .;gson-2.8.2.jar AddUtterances.java
//
// To run from command line:
// java -classpath .;gson-2.8.2.jar AddUtterances
// java -classpath .;gson-2.8.2.jar AddUtterances -train
// java -classpath .;gson-2.8.2.jar AddUtterances -status
//
// (substitute the correct name of the GSON JAR file in tho commands above)
//
// The utterances in the file ./utterances.json are added to your LUIS app.
// The JSON response from the action is in the file utterances.results.json.
//
// You may add the following flags to the end of the run command:
// -train Adds the utterances, starts training, gets the training status
// -status Gets the current training status (training may take a while)
import java.io.*;
import java.net.*;
import java.util.*;
import com.google.gson.*;
//
// AddUtterances container class. Holds LuisClient, LuisResponse, StatusException
//
public class AddUtterances {
// Enter information about your LUIS application and key below
static final String LUIS_APP_ID = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
static final String LUIS_APP_VERSION = "0.1";
static final String LUIS_AUTHORING_ID = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
// Update the host if your LUIS subscription is not in the West US region
static final String LUIS_BASE = "https://westus.api.cognitive.microsoft.com";
// File names for utterance and result files
static final String UTTERANCE_FILE = "./utterances.json";
static final String RESULTS_FILE = "./utterances_results.json";
static final String UTF8 = "UTF-8";
//
// LUIS Client class
// Contains the functionality for adding utterances to a LUIS application
//
static class LuisClient{
private final String PATH = "/luis/api/v2.0/apps/{app_id}/versions/{app_version}";
// endpoint method names
private final String TRAIN = "/train";
private final String EXAMPLES = "/examples";
private final String APP_INFO = "/";
// HTTP verbs
private final String GET = "GET";
private final String POST = "POST";
// Null string value for use in resolving method calls
private final String NO_DATA = null;
// Member variables
private final String key;
private final String host;
private final String path;
LuisClient(String host, String app_id, String app_version, String key) throws Exception {
this.path = PATH.replace("{app_id}", app_id).replace("{app_version}", app_version);
this.host = host;
this.key = key;
// Test configuration by getting the application info
this.get(APP_INFO).raiseForStatus();
}
private LuisResponse call(String endpoint, String method, byte[] data) throws Exception {
// initialize HTTP connection
URL url = new URL(this.host + this.path + endpoint);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setRequestMethod(method);
conn.setRequestProperty("Ocp-Apim-Subscription-Key", key);
// handle POST request
if (method.equals(POST)) {
if (data == null)
data = new byte[]{}; // make zero-length body for POST w/o data
conn.setDoOutput(true);
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("Content-Length", Integer.toString(data.length));
try (OutputStream ostream = conn.getOutputStream()) {
ostream.write(data, 0, data.length);
}
}
// Get response from API call. If response is an HTTP error, the JSON
// response is on the error string. Otherwise, it's on the input string.
InputStream stream;
try {
stream = conn.getInputStream();
} catch (IOException ex) {
stream = conn.getErrorStream();
}
String body = new Scanner(stream, UTF8).useDelimiter("\\A").next();
return new LuisResponse(body, conn.getResponseCode(), conn.getResponseMessage());
}
// Overload of call() with String data paramater
private LuisResponse call(String endpoint, String method, String data) throws Exception {
byte[] bytes = null;
if (data != null)
bytes = data.getBytes(UTF8);
return call(endpoint, method, bytes);
}
// Overload of call() with InputStream data paramater
private LuisResponse call(String endpoint, String method, InputStream stream) throws Exception {
String data = new Scanner(stream, UTF8).useDelimiter("\\A").next();
return call(endpoint, method, data);
}
// Shortcut for GET requests
private LuisResponse get(String endpoint) throws Exception {
return call(endpoint, GET, NO_DATA);
}
// Shortcut for POST requests -- byte[] data
private LuisResponse post(String endpoint, byte[] data) throws Exception {
return call(endpoint, POST, data);
}
// Shortcut for POST requests -- String data
private LuisResponse post(String endpoint, String data) throws Exception {
return call(endpoint, POST, data);
}
// Shortcut for POST requests -- InputStream data
private LuisResponse post(String endpoint, InputStream data) throws Exception {
return call(endpoint, POST, data);
}
// Shortcut for POST requests -- no data
private LuisResponse post(String endpoint) throws Exception {
return call(endpoint, POST, NO_DATA);
}
// Call to add utterances
public LuisResponse addUtterances(String filename) throws Exception {
try (FileInputStream stream = new FileInputStream(filename)) {
return post(EXAMPLES, stream);
}
}
public LuisResponse train() throws Exception {
return post(TRAIN);
}
public LuisResponse status() throws Exception {
return get(TRAIN);
}
}
//
// LUIS Response class
// Represents a response from the LUIS client. All methods return
// the instance so method calls can be chained.
//
static class LuisResponse {
private final String body;
private final int status;
private final String reason;
private JsonElement data;
LuisResponse(String body, int status, String reason) {
JsonParser parser = new JsonParser();
try {
this.data = parser.parse(body);
}
catch (JsonSyntaxException ex) {
this.data = parser.parse("{ \"message\": \"Invalid JSON response\" }");
}
this.body = new GsonBuilder().setPrettyPrinting().create().toJson(data);
this.status = status;
this.reason = reason;
}
LuisResponse write(String filename) throws Exception {
File file = new File(filename);
if (!file.exists()) file.createNewFile();
try (FileOutputStream stream = new FileOutputStream(file)) {
stream.write(this.body.getBytes(UTF8));
stream.flush();
}
return this;
}
LuisResponse print() {
System.out.println(this.body);
return this;
}
LuisResponse raiseForStatus() throws StatusException {
if (this.status < 200 || this.status > 299) {
throw new StatusException(this);
}
return this;
}
}
//
// LUIS Status Exception class
// Represents an exception raised by the LUIS client for HTTP status errors
// Includes details extracted from the JSON response and the HTTP status
//
static class StatusException extends Exception {
private String details = "";
private final int status;
StatusException(LuisResponse response) {
super(String.format("%d %s", response.status, response.reason));
JsonObject jsonInfo = (JsonObject)response.data;
if (jsonInfo.has("error"))
jsonInfo = (JsonObject)jsonInfo.get("error");
if (jsonInfo.has("message"))
this.details = jsonInfo.get("message").getAsString();
this.status = response.status;
}
String getDetails() {
return this.details;
}
int getStatus() {
return this.status;
}
}
static void printExceptionMsg(Exception ex) {
System.out.println(String.format("%s: %s",
ex.getClass().getSimpleName(), ex.getMessage()));
StackTraceElement caller = ex.getStackTrace()[1];
System.out.println(String.format(" in %s (line %d?)",
caller.getFileName(), caller.getLineNumber()));
if (ex instanceof StatusException)
System.out.println(((StatusException)ex).getDetails());
}
// ------------------------------------------------------------------------
//
// Command-line entry point
//
public static void main(String[] args) {
// uncomment a line below to simulate command line options
// if (args.length == 0) args = new String[]{"-train"};
// if (args.length == 0) args = new String[]{"-status"};
LuisClient luis = null;
try {
luis = new LuisClient(LUIS_BASE, LUIS_APP_ID,
LUIS_APP_VERSION,LUIS_AUTHORING_ID);
} catch (StatusException ex) {
int status = ex.getStatus();
switch (status) {
case 401:
System.out.println("Invalid access key. Set the variable LUIS_AUTHORING_ID to a valid LUIS access key");
System.out.println("in the Java source file " + ex.getStackTrace()[0].getFileName());
break;
case 400:
System.out.println("Invalid app ID or version. Set the variable LUIS_APP_ID to a valid LUIS app ID");
System.out.println("and the variable LUIS_APP_VERSION to a valid version of that application");
System.out.println("in the Java source file " + ex.getStackTrace()[0].getFileName());
break;
default:
printExceptionMsg(ex);
break;
}
System.exit(0);
} catch (Exception ex) {
printExceptionMsg(ex);
System.exit(0);
}
try {
if (args.length > 0) { // handle command line flags
String option = args[0].toLowerCase();
if (option.startsWith("-")) // strip leading hyphens
option = option.substring(option.lastIndexOf('-') + 1);
if (option.equals("train")) {
System.out.println("Adding utterance(s).");
luis.addUtterances(UTTERANCE_FILE)
.write(RESULTS_FILE)
.raiseForStatus();
System.out.println("Added utterance(s). Requesting training.");
luis.train()
.write(RESULTS_FILE)
.raiseForStatus();
System.out.println("Requested training. Requesting training status.");
luis.status()
.write(RESULTS_FILE)
.raiseForStatus();
} else if (option.equals("status")) {
System.out.println("Requesting training status.");
luis.status()
.write(RESULTS_FILE)
.raiseForStatus();
}
} else {
System.out.println("Adding utterance(s).");
luis.addUtterances(UTTERANCE_FILE)
.write(RESULTS_FILE)
.raiseForStatus();
}
System.out.println("Success! Results in " + RESULTS_FILE);
} catch (Exception ex) {
printExceptionMsg(ex);
}
}
}
// Add Utterances to LUIS Application - AddUtterances.java
// Language Understanding Intelligent Service
// Microsoft Cognitive Services, a part of Microsoft Azure
//
// Requires JDK 1.7 or later
//
// Package required: Google's GSON JSON library
// Download latest JAR from GitHub: https://github.com/google/gson/releases
// and place it in the same directory as AddUtterances.java
//
// Paste your LUIS application ID, version, and subscription key in the
// variables LUIS_APP_ID, LUIS_APP_VERSION, and LUIS_AUTHORING_ID below.
//
// To compile from command line:
// javac -classpath .;gson-2.8.2.jar AddUtterances.java
//
// To run from command line:
// java -classpath .;gson-2.8.2.jar AddUtterances
// java -classpath .;gson-2.8.2.jar AddUtterances -train
// java -classpath .;gson-2.8.2.jar AddUtterances -status
//
// (substitute the correct name of the GSON JAR file in tho commands above)
//
// The utterances in the file ./utterances.json are added to your LUIS app.
// The JSON response from the action is in the file utterances.results.json.
//
// You may add the following flags to the end of the run command:
// -train Adds the utterances, starts training, gets the training status
// -status Gets the current training status (training may take a while)
import java.io.*;
import java.net.*;
import java.util.*;
import com.google.gson.*;
//
// AddUtterances container class. Holds LuisClient, LuisResponse, StatusException
//
public class AddUtterances {
// Enter information about your LUIS application and key below
static final String LUIS_APP_ID = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
static final String LUIS_APP_VERSION = "0.1";
static final String LUIS_AUTHORING_ID = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
// Update the host if your LUIS subscription is not in the West US region
static final String LUIS_BASE = "https://westus.api.cognitive.microsoft.com";
// File names for utterance and result files
static final String UTTERANCE_FILE = "./utterances.json";
static final String RESULTS_FILE = "./utterances_results.json";
static final String UTF8 = "UTF-8";
//
// LUIS Client class
// Contains the functionality for adding utterances to a LUIS application
//
static class LuisClient{
private final String PATH = "/luis/api/v2.0/apps/{app_id}/versions/{app_version}";
// endpoint method names
private final String TRAIN = "/train";
private final String EXAMPLES = "/examples";
private final String APP_INFO = "/";
// HTTP verbs
private final String GET = "GET";
private final String POST = "POST";
// Null string value for use in resolving method calls
private final String NO_DATA = null;
// Member variables
private final String key;
private final String host;
private final String path;
LuisClient(String host, String app_id, String app_version, String key) throws Exception {
this.path = PATH.replace("{app_id}", app_id).replace("{app_version}", app_version);
this.host = host;
this.key = key;
// Test configuration by getting the application info
this.get(APP_INFO).raiseForStatus();
}
private LuisResponse call(String endpoint, String method, byte[] data) throws Exception {
// initialize HTTP connection
URL url = new URL(this.host + this.path + endpoint);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setRequestMethod(method);
conn.setRequestProperty("Ocp-Apim-Subscription-Key", key);
// handle POST request
if (method.equals(POST)) {
if (data == null)
data = new byte[]{}; // make zero-length body for POST w/o data
conn.setDoOutput(true);
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("Content-Length", Integer.toString(data.length));
try (OutputStream ostream = conn.getOutputStream()) {
ostream.write(data, 0, data.length);
}
}
// Get response from API call. If response is an HTTP error, the JSON
// response is on the error string. Otherwise, it's on the input string.
InputStream stream;
try {
stream = conn.getInputStream();
} catch (IOException ex) {
stream = conn.getErrorStream();
}
String body = new Scanner(stream, UTF8).useDelimiter("\\A").next();
return new LuisResponse(body, conn.getResponseCode(), conn.getResponseMessage());
}
// Overload of call() with String data paramater
private LuisResponse call(String endpoint, String method, String data) throws Exception {
byte[] bytes = null;
if (data != null)
bytes = data.getBytes(UTF8);
return call(endpoint, method, bytes);
}
// Overload of call() with InputStream data paramater
private LuisResponse call(String endpoint, String method, InputStream stream) throws Exception {
String data = new Scanner(stream, UTF8).useDelimiter("\\A").next();
return call(endpoint, method, data);
}
// Shortcut for GET requests
private LuisResponse get(String endpoint) throws Exception {
return call(endpoint, GET, NO_DATA);
}
// Shortcut for POST requests -- byte[] data
private LuisResponse post(String endpoint, byte[] data) throws Exception {
return call(endpoint, POST, data);
}
// Shortcut for POST requests -- String data
private LuisResponse post(String endpoint, String data) throws Exception {
return call(endpoint, POST, data);
}
// Shortcut for POST requests -- InputStream data
private LuisResponse post(String endpoint, InputStream data) throws Exception {
return call(endpoint, POST, data);
}
// Shortcut for POST requests -- no data
private LuisResponse post(String endpoint) throws Exception {
return call(endpoint, POST, NO_DATA);
}
// Call to add utterances
public LuisResponse addUtterances(String filename) throws Exception {
try (FileInputStream stream = new FileInputStream(filename)) {
return post(EXAMPLES, stream);
}
}
public LuisResponse train() throws Exception {
return post(TRAIN);
}
public LuisResponse status() throws Exception {
return get(TRAIN);
}
}
//
// LUIS Response class
// Represents a response from the LUIS client. All methods return
// the instance so method calls can be chained.
//
static class LuisResponse {
private final String body;
private final int status;
private final String reason;
private JsonElement data;
LuisResponse(String body, int status, String reason) {
JsonParser parser = new JsonParser();
try {
this.data = parser.parse(body);
}
catch (JsonSyntaxException ex) {
this.data = parser.parse("{ \"message\": \"Invalid JSON response\" }");
}
this.body = new GsonBuilder().setPrettyPrinting().create().toJson(data);
this.status = status;
this.reason = reason;
}
LuisResponse write(String filename) throws Exception {
File file = new File(filename);
if (!file.exists()) file.createNewFile();
try (FileOutputStream stream = new FileOutputStream(file)) {
stream.write(this.body.getBytes(UTF8));
stream.flush();
}
return this;
}
LuisResponse print() {
System.out.println(this.body);
return this;
}
LuisResponse raiseForStatus() throws StatusException {
if (this.status < 200 || this.status > 299) {
throw new StatusException(this);
}
return this;
}
}
//
// LUIS Status Exception class
// Represents an exception raised by the LUIS client for HTTP status errors
// Includes details extracted from the JSON response and the HTTP status
//
static class StatusException extends Exception {
private String details = "";
private final int status;
StatusException(LuisResponse response) {
super(String.format("%d %s", response.status, response.reason));
JsonObject jsonInfo = (JsonObject)response.data;
if (jsonInfo.has("error"))
jsonInfo = (JsonObject)jsonInfo.get("error");
if (jsonInfo.has("message"))
this.details = jsonInfo.get("message").getAsString();
this.status = response.status;
}
String getDetails() {
return this.details;
}
int getStatus() {
return this.status;
}
}
static void printExceptionMsg(Exception ex) {
System.out.println(String.format("%s: %s",
ex.getClass().getSimpleName(), ex.getMessage()));
StackTraceElement caller = ex.getStackTrace()[1];
System.out.println(String.format(" in %s (line %d?)",
caller.getFileName(), caller.getLineNumber()));
if (ex instanceof StatusException)
System.out.println(((StatusException)ex).getDetails());
}
// ------------------------------------------------------------------------
//
// Command-line entry point
//
public static void main(String[] args) {
// uncomment a line below to simulate command line options
// if (args.length == 0) args = new String[]{"-train"};
// if (args.length == 0) args = new String[]{"-status"};
LuisClient luis = null;
try {
luis = new LuisClient(LUIS_BASE, LUIS_APP_ID,
LUIS_APP_VERSION,LUIS_AUTHORING_ID);
} catch (StatusException ex) {
int status = ex.getStatus();
switch (status) {
case 401:
System.out.println("Invalid access key. Set the variable LUIS_AUTHORING_ID to a valid LUIS access key");
System.out.println("in the Java source file " + ex.getStackTrace()[0].getFileName());
break;
case 400:
System.out.println("Invalid app ID or version. Set the variable LUIS_APP_ID to a valid LUIS app ID");
System.out.println("and the variable LUIS_APP_VERSION to a valid version of that application");
System.out.println("in the Java source file " + ex.getStackTrace()[0].getFileName());
break;
default:
printExceptionMsg(ex);
break;
}
System.exit(0);
} catch (Exception ex) {
printExceptionMsg(ex);
System.exit(0);
}
try {
if (args.length > 0) { // handle command line flags
String option = args[0].toLowerCase();
if (option.startsWith("-")) // strip leading hyphens
option = option.substring(option.lastIndexOf('-') + 1);
if (option.equals("train")) {
System.out.println("Adding utterance(s).");
luis.addUtterances(UTTERANCE_FILE)
.write(RESULTS_FILE)
.raiseForStatus();
System.out.println("Added utterance(s). Requesting training.");
luis.train()
.write(RESULTS_FILE)
.raiseForStatus();
System.out.println("Requested training. Requesting training status.");
luis.status()
.write(RESULTS_FILE)
.raiseForStatus();
} else if (option.equals("status")) {
System.out.println("Requesting training status.");
luis.status()
.write(RESULTS_FILE)
.raiseForStatus();
}
} else {
System.out.println("Adding utterance(s).");
luis.addUtterances(UTTERANCE_FILE)
.write(RESULTS_FILE)
.raiseForStatus();
}
System.out.println("Success! Results in " + RESULTS_FILE);
} catch (Exception ex) {
printExceptionMsg(ex);
}
}
}

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

@ -1,122 +1,122 @@
<?php
// NOTE: Be sure to uncomment the following line in your php.ini file.
// ;extension=php_openssl.dll
// **********************************************
// *** Update or verify the following values. ***
// **********************************************
// NOTE: Replace this example LUIS application ID with the ID of your LUIS application.
$appID = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
// NOTE: Replace this example LUIS application version number with the version number of your LUIS application.
$appVersion = "0.1";
// NOTE: Replace this example LUIS authoring key with a valid key.
$key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$host = "https://westus.api.cognitive.microsoft.com";
$path = "/luis/api/v2.0/apps/" . $appID . "/versions/" . $appVersion . "/";
$uri = $host . $path;
$usage = "Usage:
add-utterances <input file>
add-utterances -train <input file>
add-utterances -status
The contents of <input file> must be in the format described at: https://aka.ms/add-utterance-json-format
";
function SendGet ($uri, $key) {
echo "GET " . $uri;
$headers = "Content-type: text/json\r\n" .
"Ocp-Apim-Subscription-Key: $key\r\n";
// NOTE: Use the key 'http' even if you are making an HTTPS request. See:
// http://php.net/manual/en/function.stream-context-create.php
$options = array (
'http' => array (
'header' => $headers,
'method' => 'GET',
)
);
// Perform the Web request and get the JSON response
$context = stream_context_create ($options);
$result = file_get_contents ($uri, false, $context);
return $result;
}
function SendPost ($uri, $key, $content) {
echo "POST " . $uri;
$headers = "Content-type: text/json\r\n" .
"Ocp-Apim-Subscription-Key: $key\r\n";
// NOTE: Use the key 'http' even if you are making an HTTPS request. See:
// http://php.net/manual/en/function.stream-context-create.php
$options = array (
'http' => array (
'header' => $headers,
'method' => 'POST',
'content' => $content
)
);
// Perform the Web request and get the JSON response
$context = stream_context_create ($options);
$result = file_get_contents ($uri, false, $context);
return $result;
}
function AddUtterances($uri, $key, $input_file) {
$content = file_get_contents ($input_file);
echo "Added utterances.\n";
$result = SendPost ($uri . "examples", $key, $content);
echo json_encode (json_decode ($result), JSON_PRETTY_PRINT);
}
function Train($uri, $key, $input_file) {
$content = file_get_contents ($input_file);
echo "Sent training request.\n";
$result = SendPost ($uri . "train", $key, $content);
echo json_encode (json_decode ($result), JSON_PRETTY_PRINT);
echo "\n";
Status($uri, $key);
}
function Status($uri, $key) {
echo "Requested training status.\n";
$result = SendGet ($uri . "train", $key);
echo json_encode (json_decode ($result), JSON_PRETTY_PRINT);
}
if ($argc < 2)
{
echo $usage;
}
else
{
if (0 === strcasecmp($argv[1], "-train")) {
if ($argc > 2)
{
Train($uri, $key, $argv[2]);
}
else
{
echo $usage;
}
}
else if (0 === strcasecmp($argv[1], "-status"))
{
Status($uri, $key);
}
else
{
AddUtterances($uri, $key, $argv[1]);
}
}
<?php
// NOTE: Be sure to uncomment the following line in your php.ini file.
// ;extension=php_openssl.dll
// **********************************************
// *** Update or verify the following values. ***
// **********************************************
// NOTE: Replace this example LUIS application ID with the ID of your LUIS application.
$appID = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
// NOTE: Replace this example LUIS application version number with the version number of your LUIS application.
$appVersion = "0.1";
// NOTE: Replace this example LUIS authoring key with a valid key.
$key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$host = "https://westus.api.cognitive.microsoft.com";
$path = "/luis/api/v2.0/apps/" . $appID . "/versions/" . $appVersion . "/";
$uri = $host . $path;
$usage = "Usage:
add-utterances <input file>
add-utterances -train <input file>
add-utterances -status
The contents of <input file> must be in the format described at: https://aka.ms/add-utterance-json-format
";
function SendGet ($uri, $key) {
echo "GET " . $uri;
$headers = "Content-type: text/json\r\n" .
"Ocp-Apim-Subscription-Key: $key\r\n";
// NOTE: Use the key 'http' even if you are making an HTTPS request. See:
// http://php.net/manual/en/function.stream-context-create.php
$options = array (
'http' => array (
'header' => $headers,
'method' => 'GET',
)
);
// Perform the Web request and get the JSON response
$context = stream_context_create ($options);
$result = file_get_contents ($uri, false, $context);
return $result;
}
function SendPost ($uri, $key, $content) {
echo "POST " . $uri;
$headers = "Content-type: text/json\r\n" .
"Ocp-Apim-Subscription-Key: $key\r\n";
// NOTE: Use the key 'http' even if you are making an HTTPS request. See:
// http://php.net/manual/en/function.stream-context-create.php
$options = array (
'http' => array (
'header' => $headers,
'method' => 'POST',
'content' => $content
)
);
// Perform the Web request and get the JSON response
$context = stream_context_create ($options);
$result = file_get_contents ($uri, false, $context);
return $result;
}
function AddUtterances($uri, $key, $input_file) {
$content = file_get_contents ($input_file);
echo "Added utterances.\n";
$result = SendPost ($uri . "examples", $key, $content);
echo json_encode (json_decode ($result), JSON_PRETTY_PRINT);
}
function Train($uri, $key, $input_file) {
$content = file_get_contents ($input_file);
echo "Sent training request.\n";
$result = SendPost ($uri . "train", $key, $content);
echo json_encode (json_decode ($result), JSON_PRETTY_PRINT);
echo "\n";
Status($uri, $key);
}
function Status($uri, $key) {
echo "Requested training status.\n";
$result = SendGet ($uri . "train", $key);
echo json_encode (json_decode ($result), JSON_PRETTY_PRINT);
}
if ($argc < 2)
{
echo $usage;
}
else
{
if (0 === strcasecmp($argv[1], "-train")) {
if ($argc > 2)
{
Train($uri, $key, $argv[2]);
}
else
{
echo $usage;
}
}
else if (0 === strcasecmp($argv[1], "-status"))
{
Status($uri, $key);
}
else
{
AddUtterances($uri, $key, $argv[1]);
}
}
?>

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

@ -1,93 +1,93 @@
require 'json'
require 'net/https'
require 'uri'
# **********************************************
# *** Update or verify the following values. ***
# **********************************************
# NOTE: Replace this with LUIS application ID.
appID = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
# NOTE: Replace this example LUIS application version number with the version number of your LUIS application.
appVersion = "0.1"
# NOTE: Replace this with LUIS AUTHORING KEY.
$key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
host = "https://westus.api.cognitive.microsoft.com"
path = "/luis/api/v2.0/apps/" + appID + "/versions/" + appVersion + "/"
$uri = host + path;
usage = "Usage:
add-utterances <input file>
add-utterances -train <input file>
add-utterances -status
The contents of <input file> must be in the format described at: https://aka.ms/add-utterance-json-format
"
def SendGet(uri)
uri = URI(uri)
request = Net::HTTP::Get.new(uri)
request['Ocp-Apim-Subscription-Key'] = $key
response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
http.request (request)
end
return response.body
end
def SendPost(uri, body)
uri = URI(uri)
request = Net::HTTP::Post.new(uri)
request['Content-type'] = 'text/json'
request['Ocp-Apim-Subscription-Key'] = $key
request.body = body
response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
http.request (request)
end
return response.body
end
def AddUtterances(input_file)
content = File.read(input_file)
puts "Added utterances."
result = SendPost($uri+"examples",content)
puts JSON.pretty_generate(JSON(result))
end
def Train(input_file)
content = File.read(input_file)
puts "Sent training request."
result = SendPost($uri+"train",content)
puts JSON.pretty_generate(JSON(result))
Status()
end
def Status()
puts "Requested training status."
result = SendGet($uri+"train")
puts JSON.pretty_generate(JSON(result))
end
args = ARGV
if (args.length < 1) then
puts(usage)
else
if (0 == args[0].casecmp("-train"))
if (args.length > 1) then
Train(args[1])
else
puts(usage)
end
elsif (0 == args[0].casecmp("-status")) then
Status()
else
AddUtterances(args[0])
end
end
require 'json'
require 'net/https'
require 'uri'
# **********************************************
# *** Update or verify the following values. ***
# **********************************************
# NOTE: Replace this with LUIS application ID.
appID = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
# NOTE: Replace this example LUIS application version number with the version number of your LUIS application.
appVersion = "0.1"
# NOTE: Replace this with LUIS AUTHORING KEY.
$key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
host = "https://westus.api.cognitive.microsoft.com"
path = "/luis/api/v2.0/apps/" + appID + "/versions/" + appVersion + "/"
$uri = host + path;
usage = "Usage:
add-utterances <input file>
add-utterances -train <input file>
add-utterances -status
The contents of <input file> must be in the format described at: https://aka.ms/add-utterance-json-format
"
def SendGet(uri)
uri = URI(uri)
request = Net::HTTP::Get.new(uri)
request['Ocp-Apim-Subscription-Key'] = $key
response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
http.request (request)
end
return response.body
end
def SendPost(uri, body)
uri = URI(uri)
request = Net::HTTP::Post.new(uri)
request['Content-type'] = 'text/json'
request['Ocp-Apim-Subscription-Key'] = $key
request.body = body
response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
http.request (request)
end
return response.body
end
def AddUtterances(input_file)
content = File.read(input_file)
puts "Added utterances."
result = SendPost($uri+"examples",content)
puts JSON.pretty_generate(JSON(result))
end
def Train(input_file)
content = File.read(input_file)
puts "Sent training request."
result = SendPost($uri+"train",content)
puts JSON.pretty_generate(JSON(result))
Status()
end
def Status()
puts "Requested training status."
result = SendGet($uri+"train")
puts JSON.pretty_generate(JSON(result))
end
args = ARGV
if (args.length < 1) then
puts(usage)
else
if (0 == args[0].casecmp("-train"))
if (args.length > 1) then
Train(args[1])
else
puts(usage)
end
elsif (0 == args[0].casecmp("-status")) then
Status()
else
AddUtterances(args[0])
end
end

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

@ -1,27 +1,27 @@
# BUILD IMAGE
# $ docker build --no-cache -t luis-endpoint-java .
#
# RUN CODE
#
# WINDOWS BASH COMMAND
# $ winpty docker run -it --rm --name luis-endpoint-java luis-endpoint-java
#
# NON-WINDOWS
# $ docker run -it --rm --name luis-endpoint-java luis-endpoint-java tail
FROM openjdk:7
COPY . /usr/src/LUIS
COPY lib/ /lib/
WORKDIR /usr/src/LUIS
# rename file to LuisGetRequest.java
RUN cp ./call-endpoint.java ./LuisGetRequest.java
RUN ls
#RUN rm /call-endpoint.java
# linux moby syntax
RUN javac -cp ":lib/*" LuisGetRequest.java
ENTRYPOINT ["java", "-cp",":lib/*", "LuisGetRequest"]
# BUILD IMAGE
# $ docker build --no-cache -t luis-endpoint-java .
#
# RUN CODE
#
# WINDOWS BASH COMMAND
# $ winpty docker run -it --rm --name luis-endpoint-java luis-endpoint-java
#
# NON-WINDOWS
# $ docker run -it --rm --name luis-endpoint-java luis-endpoint-java tail
FROM openjdk:7
COPY . /usr/src/LUIS
COPY lib/ /lib/
WORKDIR /usr/src/LUIS
# rename file to LuisGetRequest.java
RUN cp ./call-endpoint.java ./LuisGetRequest.java
RUN ls
#RUN rm /call-endpoint.java
# linux moby syntax
RUN javac -cp ":lib/*" LuisGetRequest.java
ENTRYPOINT ["java", "-cp",":lib/*", "LuisGetRequest"]

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

До

Ширина:  |  Высота:  |  Размер: 29 KiB

После

Ширина:  |  Высота:  |  Размер: 29 KiB

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

@ -1,64 +1,64 @@
# LUIS Endpoint query with Java
This example calls into the LUIS endpoint of the public IoT LUIS application and returns a query.
## Prerequisites
* In call-endpoint.java, change the `SubscriptionKey` value to your own LUIS subscription key found under your User account in [LUIS.ai](https://www.luis.ai).
* [Docker](https://www.docker.com/) or [Java](https://www.java.com/en/)
The dependency libraries are in the `lib` subdirectory.
## Run via Docker
You can run this example from a Docker container.
1. On the command-line, build the Docker image:
```
docker build --no-cache -t luis-endpoint-java .
```
2. On the command-line, run the Docker image:
```
docker run -it --rm --name luis-endpoint-java luis-endpoint-java tail
```
![Example of Docker commands and output](./command-line.png)
## Run via Java
You can run this example from Java.
1. Rename `call-endpoint.java` to `LuisGetRequest.java`.
2. On the command-line, compile the file:
```
javac -cp ":lib/*" LuisGetRequest.java
```
3. On the command-line, run the file:
```
java -cp :lib/* LuisGetRequest
```
4. LUIS Response
```
{
"query": "turn on the left light",
"topScoringIntent": {
"intent": "HomeAutomation.TurnOn",
"score": 0.933549
},
"entities": [
{
"entity": "left",
"type": "HomeAutomation.Room",
"startIndex": 12,
"endIndex": 15,
"score": 0.540835142
}
]
}
# LUIS Endpoint query with Java
This example calls into the LUIS endpoint of the public IoT LUIS application and returns a query.
## Prerequisites
* In call-endpoint.java, change the `SubscriptionKey` value to your own LUIS subscription key found under your User account in [LUIS.ai](https://www.luis.ai).
* [Docker](https://www.docker.com/) or [Java](https://www.java.com/en/)
The dependency libraries are in the `lib` subdirectory.
## Run via Docker
You can run this example from a Docker container.
1. On the command-line, build the Docker image:
```
docker build --no-cache -t luis-endpoint-java .
```
2. On the command-line, run the Docker image:
```
docker run -it --rm --name luis-endpoint-java luis-endpoint-java tail
```
![Example of Docker commands and output](./command-line.png)
## Run via Java
You can run this example from Java.
1. Rename `call-endpoint.java` to `LuisGetRequest.java`.
2. On the command-line, compile the file:
```
javac -cp ":lib/*" LuisGetRequest.java
```
3. On the command-line, run the file:
```
java -cp :lib/* LuisGetRequest
```
4. LUIS Response
```
{
"query": "turn on the left light",
"topScoringIntent": {
"intent": "HomeAutomation.TurnOn",
"score": 0.933549
},
"entities": [
{
"entity": "left",
"type": "HomeAutomation.Room",
"startIndex": 12,
"endIndex": 15,
"score": 0.540835142
}
]
}
```

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

@ -0,0 +1,2 @@
LUIS_APP_ID=df67dcdb-c37d-46af-88e1-8b97951ca1c2
LUIS_SUBSCRIPTION_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

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

@ -1,16 +1,16 @@
# BUILD IMAGE
# $ docker build --no-cache -t luis-endpoint-node .
#
# RUN CODE
#
# WINDOWS BASH COMMAND
# $ winpty docker run -it --rm --name luis-endpoint-node luis-endpoint-node
#
# NON-WINDOWS
# $ docker run -it --rm --name luis-endpoint-node luis-endpoint-node tail
FROM node:latest
COPY . /usr/src/LUIS
WORKDIR /usr/src/LUIS
RUN npm install
# BUILD IMAGE
# $ docker build --no-cache -t luis-endpoint-node .
#
# RUN CODE
#
# WINDOWS BASH COMMAND
# $ winpty docker run -it --rm --name luis-endpoint-node luis-endpoint-node
#
# NON-WINDOWS
# $ docker run -it --rm --name luis-endpoint-node luis-endpoint-node tail
FROM node:latest
COPY . /usr/src/LUIS
WORKDIR /usr/src/LUIS
RUN npm install
ENTRYPOINT [ "npm", "start" ]

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

До

Ширина:  |  Высота:  |  Размер: 39 KiB

После

Ширина:  |  Высота:  |  Размер: 39 KiB

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

@ -1,51 +1,51 @@
# LUIS Endpoint query with Node.js
This example calls into the LUIS endpoint of the public IoT LUIS application and returns a query.
## Prerequisites
* In .env, change the `LUIS_SUBSCRIPTION_KEY` value to your own LUIS subscription key found under your User account in [LUIS.ai](https://www.luis.ai).
* [Docker](https://www.docker.com/) or [Nodejs](https://nodejs.org)
## Run via Docker
You can run this example from a Docker container.
1. On the command-line, build the Docker image:
```
docker build --no-cache -t luis-endpoint-node .
```
2. On the command-line, run the Docker image:
```
docker run -it --rm --name luis-endpoint-node luis-endpoint-node tail
```
![Example of Docker commands and output](./command-line.png)
## Run via Node
You can run this example from Node.js.
1. On the command-line, install dependencies:
```
npm install
```
3. On the command-line, run the file:
```
npm start
```
4. LUIS Response
```
Query: turn on the left light
Top Intent: HomeAutomation.TurnOn
Intents:
[ { intent: 'HomeAutomation.TurnOn', score: 0.933549 },
{ intent: 'None', score: 0.09975206 },
{ intent: 'HomeAutomation.TurnOff', score: 0.0276397187 } ]
# LUIS Endpoint query with Node.js
This example calls into the LUIS endpoint of the public IoT LUIS application and returns a query.
## Prerequisites
* In .env, change the `LUIS_SUBSCRIPTION_KEY` value to your own LUIS subscription key found under your User account in [LUIS.ai](https://www.luis.ai).
* [Docker](https://www.docker.com/) or [Nodejs](https://nodejs.org)
## Run via Docker
You can run this example from a Docker container.
1. On the command-line, build the Docker image:
```
docker build --no-cache -t luis-endpoint-node .
```
2. On the command-line, run the Docker image:
```
docker run -it --rm --name luis-endpoint-node luis-endpoint-node tail
```
![Example of Docker commands and output](./command-line.png)
## Run via Node
You can run this example from Node.js.
1. On the command-line, install dependencies:
```
npm install
```
3. On the command-line, run the file:
```
npm start
```
4. LUIS Response
```
Query: turn on the left light
Top Intent: HomeAutomation.TurnOn
Intents:
[ { intent: 'HomeAutomation.TurnOn', score: 0.933549 },
{ intent: 'None', score: 0.09975206 },
{ intent: 'HomeAutomation.TurnOff', score: 0.0276397187 } ]
```

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

@ -1,31 +0,0 @@
[
{
"text": "drive me home",
"intent": "None",
"entities": []
},
{
"text": "2 tickets to paris on air france for next monday",
"intent": "BookFlight",
"entities": [
{
"entity": "air france",
"type": "Airline",
"startIndex": 22,
"endIndex": 31
}
]
},
{
"text": "book a flight to orlando on the 25th",
"intent": "BookFlight",
"entities": [
{
"entity": "orlando",
"type": "Location",
"startIndex": 17,
"endIndex": 23
}
]
}
]

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

@ -1,2 +0,0 @@
LUIS_APP_ID=df67dcdb-c37d-46af-88e1-8b97951ca1c2
LUIS_SUBSCRIPTION_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

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

@ -1,32 +0,0 @@
[
{
"text": "lobby on please",
"intent": "HomeAutomation.TurnOn",
"entities": []
},
{
"text": "change temperature to seventy one degrees",
"intent": "HomeAutomation.TurnOn",
"entities": []
},
{
"text": "where is my pizza",
"intent": "None",
"entities": []
},
{
"text": "help",
"intent": "None",
"entities": []
},
{
"text": "breezeway off please",
"intent": "HomeAutomation.TurnOff",
"entities": []
},
{
"text": "coffee bar off please",
"intent": "HomeAutomation.TurnOff",
"entities": []
}
]

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

@ -1,56 +0,0 @@
[
{
"text": "lobby on please",
"intent": "HomeAutomation.TurnOn",
"entities": [
{
"entity": "HomeAutomation.Room",
"startPos": 0,
"endPos": 4
}
]
},
{
"text": "change temperature to seventy one degrees",
"intent": "HomeAutomation.TurnOn",
"entities": [
{
"entity": "HomeAutomation.Operation",
"startPos": 7,
"endPos": 17
}
]
},
{
"text": "where is my pizza",
"intent": "None",
"entities": []
},
{
"text": "help",
"intent": "None",
"entities": []
},
{
"text": "breezeway off please",
"intent": "HomeAutomation.TurnOff",
"entities": [
{
"entity": "HomeAutomation.Room",
"startPos": 0,
"endPos": 9
}
]
},
{
"text": "coffee bar off please",
"intent": "HomeAutomation.TurnOff",
"entities": [
{
"entity": "HomeAutomation.Room",
"startPos": 0,
"endPos": 10
}
]
}
]

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

@ -1,587 +0,0 @@
{
"luis_schema_version": "2.1.0",
"versionId": "0.1",
"name": "HomeAutomation",
"desc": "",
"culture": "en-us",
"intents": [
{
"name": "HomeAutomation.TurnOff",
"inherits": {
"domain_name": "HomeAutomation",
"model_name": "TurnOff"
}
},
{
"name": "HomeAutomation.TurnOn",
"inherits": {
"domain_name": "HomeAutomation",
"model_name": "TurnOn"
}
},
{
"name": "None"
}
],
"entities": [
{
"name": "HomeAutomation.Device",
"inherits": {
"domain_name": "HomeAutomation",
"model_name": "Device"
}
},
{
"name": "HomeAutomation.Operation",
"inherits": {
"domain_name": "HomeAutomation",
"model_name": "Operation"
}
},
{
"name": "HomeAutomation.Room",
"inherits": {
"domain_name": "HomeAutomation",
"model_name": "Room"
}
}
],
"composites": [],
"closedLists": [],
"bing_entities": [],
"model_features": [],
"regex_features": [],
"utterances": [
{
"text": "breezeway on please",
"intent": "HomeAutomation.TurnOn",
"entities": [
{
"entity": "HomeAutomation.Room",
"startPos": 0,
"endPos": 8
},
{
"entity": "HomeAutomation.Operation",
"startPos": 10,
"endPos": 11
}
]
},
{
"text": "change temperature to seventy two degrees",
"intent": "HomeAutomation.TurnOn",
"entities": [
{
"entity": "HomeAutomation.Operation",
"startPos": 7,
"endPos": 17
}
]
},
{
"text": "coffee bar on please",
"intent": "HomeAutomation.TurnOn",
"entities": [
{
"entity": "HomeAutomation.Device",
"startPos": 0,
"endPos": 9
},
{
"entity": "HomeAutomation.Operation",
"startPos": 11,
"endPos": 12
}
]
},
{
"text": "decrease temperature for me please",
"intent": "None",
"entities": [
{
"entity": "HomeAutomation.Operation",
"startPos": 9,
"endPos": 19
}
]
},
{
"text": "dim kitchen lights to 25 .",
"intent": "None",
"entities": [
{
"entity": "HomeAutomation.Room",
"startPos": 4,
"endPos": 10
},
{
"entity": "HomeAutomation.Device",
"startPos": 12,
"endPos": 17
}
]
},
{
"text": "fish pond off please",
"intent": "HomeAutomation.TurnOff",
"entities": [
{
"entity": "HomeAutomation.Device",
"startPos": 0,
"endPos": 8
},
{
"entity": "HomeAutomation.Operation",
"startPos": 10,
"endPos": 12
}
]
},
{
"text": "fish pond on please",
"intent": "HomeAutomation.TurnOn",
"entities": []
},
{
"text": "illuminate please",
"intent": "HomeAutomation.TurnOn",
"entities": [
{
"entity": "HomeAutomation.Device",
"startPos": 0,
"endPos": 9
}
]
},
{
"text": "living room lamp on please",
"intent": "HomeAutomation.TurnOn",
"entities": [
{
"entity": "HomeAutomation.Room",
"startPos": 0,
"endPos": 10
},
{
"entity": "HomeAutomation.Device",
"startPos": 12,
"endPos": 15
},
{
"entity": "HomeAutomation.Operation",
"startPos": 17,
"endPos": 18
}
]
},
{
"text": "living room lamps off please",
"intent": "HomeAutomation.TurnOff",
"entities": [
{
"entity": "HomeAutomation.Room",
"startPos": 0,
"endPos": 10
}
]
},
{
"text": "lock the doors for me please",
"intent": "HomeAutomation.TurnOff",
"entities": [
{
"entity": "HomeAutomation.Device",
"startPos": 9,
"endPos": 13
}
]
},
{
"text": "lower your volume",
"intent": "None",
"entities": [
{
"entity": "HomeAutomation.Operation",
"startPos": 11,
"endPos": 16
}
]
},
{
"text": "make camera 1 off please",
"intent": "HomeAutomation.TurnOff",
"entities": [
{
"entity": "HomeAutomation.Device",
"startPos": 5,
"endPos": 10
}
]
},
{
"text": "make some coffee",
"intent": "HomeAutomation.TurnOn",
"entities": [
{
"entity": "HomeAutomation.Device",
"startPos": 10,
"endPos": 15
}
]
},
{
"text": "play dvd",
"intent": "HomeAutomation.TurnOn",
"entities": [
{
"entity": "HomeAutomation.Device",
"startPos": 5,
"endPos": 7
}
]
},
{
"text": "set lights bright",
"intent": "HomeAutomation.TurnOn",
"entities": [
{
"entity": "HomeAutomation.Device",
"startPos": 4,
"endPos": 9
},
{
"entity": "HomeAutomation.Operation",
"startPos": 11,
"endPos": 16
}
]
},
{
"text": "set lights concentrate",
"intent": "HomeAutomation.TurnOn",
"entities": [
{
"entity": "HomeAutomation.Device",
"startPos": 4,
"endPos": 9
},
{
"entity": "HomeAutomation.Operation",
"startPos": 11,
"endPos": 21
}
]
},
{
"text": "set lights out bedroom",
"intent": "HomeAutomation.TurnOff",
"entities": [
{
"entity": "HomeAutomation.Device",
"startPos": 4,
"endPos": 9
},
{
"entity": "HomeAutomation.Room",
"startPos": 15,
"endPos": 21
}
]
},
{
"text": "shut down my work computer",
"intent": "HomeAutomation.TurnOff",
"entities": [
{
"entity": "HomeAutomation.Device",
"startPos": 18,
"endPos": 25
}
]
},
{
"text": "silence the phone",
"intent": "HomeAutomation.TurnOff",
"entities": [
{
"entity": "HomeAutomation.Device",
"startPos": 12,
"endPos": 16
}
]
},
{
"text": "snap switch fan fifty percent",
"intent": "HomeAutomation.TurnOn",
"entities": [
{
"entity": "HomeAutomation.Device",
"startPos": 12,
"endPos": 14
},
{
"entity": "HomeAutomation.Operation",
"startPos": 16,
"endPos": 28
}
]
},
{
"text": "start master bedroom light .",
"intent": "HomeAutomation.TurnOn",
"entities": [
{
"entity": "HomeAutomation.Room",
"startPos": 6,
"endPos": 19
},
{
"entity": "HomeAutomation.Device",
"startPos": 21,
"endPos": 25
}
]
},
{
"text": "theater on please",
"intent": "HomeAutomation.TurnOn",
"entities": [
{
"entity": "HomeAutomation.Room",
"startPos": 0,
"endPos": 6
},
{
"entity": "HomeAutomation.Operation",
"startPos": 8,
"endPos": 9
}
]
},
{
"text": "turn dimmer off",
"intent": "HomeAutomation.TurnOff",
"entities": [
{
"entity": "HomeAutomation.Device",
"startPos": 5,
"endPos": 10
},
{
"entity": "HomeAutomation.Operation",
"startPos": 12,
"endPos": 14
}
]
},
{
"text": "turn off ac please",
"intent": "HomeAutomation.TurnOff",
"entities": [
{
"entity": "HomeAutomation.Operation",
"startPos": 5,
"endPos": 7
},
{
"entity": "HomeAutomation.Device",
"startPos": 9,
"endPos": 10
}
]
},
{
"text": "turn off foyer lights",
"intent": "HomeAutomation.TurnOff",
"entities": [
{
"entity": "HomeAutomation.Operation",
"startPos": 5,
"endPos": 7
},
{
"entity": "HomeAutomation.Room",
"startPos": 9,
"endPos": 13
},
{
"entity": "HomeAutomation.Device",
"startPos": 15,
"endPos": 20
}
]
},
{
"text": "turn off living room light",
"intent": "HomeAutomation.TurnOff",
"entities": [
{
"entity": "HomeAutomation.Room",
"startPos": 9,
"endPos": 19
},
{
"entity": "HomeAutomation.Device",
"startPos": 21,
"endPos": 25
}
]
},
{
"text": "turn off staircase",
"intent": "HomeAutomation.TurnOff",
"entities": [
{
"entity": "HomeAutomation.Operation",
"startPos": 5,
"endPos": 7
},
{
"entity": "HomeAutomation.Device",
"startPos": 9,
"endPos": 17
}
]
},
{
"text": "turn off venice lamp",
"intent": "HomeAutomation.TurnOff",
"entities": [
{
"entity": "HomeAutomation.Operation",
"startPos": 5,
"endPos": 7
},
{
"entity": "HomeAutomation.Device",
"startPos": 16,
"endPos": 19
}
]
},
{
"text": "turn on bathroom heater",
"intent": "HomeAutomation.TurnOn",
"entities": [
{
"entity": "HomeAutomation.Operation",
"startPos": 5,
"endPos": 6
},
{
"entity": "HomeAutomation.Room",
"startPos": 8,
"endPos": 15
},
{
"entity": "HomeAutomation.Device",
"startPos": 17,
"endPos": 22
}
]
},
{
"text": "turn on external speaker",
"intent": "HomeAutomation.TurnOn",
"entities": [
{
"entity": "HomeAutomation.Operation",
"startPos": 5,
"endPos": 6
},
{
"entity": "HomeAutomation.Device",
"startPos": 8,
"endPos": 23
}
]
},
{
"text": "turn on my bedroom lights .",
"intent": "HomeAutomation.TurnOn",
"entities": [
{
"entity": "HomeAutomation.Operation",
"startPos": 5,
"endPos": 6
},
{
"entity": "HomeAutomation.Room",
"startPos": 11,
"endPos": 17
},
{
"entity": "HomeAutomation.Device",
"startPos": 19,
"endPos": 24
}
]
},
{
"text": "turn on the furnace room lights",
"intent": "HomeAutomation.TurnOn",
"entities": [
{
"entity": "HomeAutomation.Room",
"startPos": 12,
"endPos": 23
},
{
"entity": "HomeAutomation.Device",
"startPos": 25,
"endPos": 30
}
]
},
{
"text": "turn on the internet in my bedroom please",
"intent": "None",
"entities": [
{
"entity": "HomeAutomation.Room",
"startPos": 27,
"endPos": 33
}
]
},
{
"text": "turn on thermostat please",
"intent": "HomeAutomation.TurnOn",
"entities": [
{
"entity": "HomeAutomation.Operation",
"startPos": 5,
"endPos": 6
},
{
"entity": "HomeAutomation.Device",
"startPos": 8,
"endPos": 17
}
]
},
{
"text": "turn the fan to high",
"intent": "HomeAutomation.TurnOn",
"entities": [
{
"entity": "HomeAutomation.Device",
"startPos": 9,
"endPos": 11
}
]
},
{
"text": "turn thermostat on 70 .",
"intent": "HomeAutomation.TurnOn",
"entities": [
{
"entity": "HomeAutomation.Device",
"startPos": 5,
"endPos": 14
}
]
}
]
}

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

@ -1,32 +0,0 @@
[
{
"text": "Are there any janitorial jobs currently open?",
"intent": "GetJobInformation",
"entities": []
},
{
"text": "Today here is my application for the plumber's assistant job",
"intent": "ApplyForJob",
"entities": [ {
"entity": "Job",
"startPos": 30,
"endPos": 48
}]
},
{
"text": "How old is HRF-123987? When was it last updated?",
"intent": "FindForm",
"entities": []
},
{
"text": "Jill Jones did a great job producing the negative sampling report for the premier client",
"intent": "EmployeeFeedback",
"entities": []
},
{
"text": "please relocate Jill Jones to a-1234",
"intent": "MoveEmployee",
"entities": [
]
}
]

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

@ -1,102 +0,0 @@
[
{
"text": "Is a janitor job open?",
"intent": "GetJobInformation",
"entities": [
"type": "Job",
"startIndex": 5,
"endIndex": 11
]
},
{
"text": "Is a janitorial job open?",
"intent": "GetJobInformation",
"entities": [
"type": "Job",
"startIndex": 5,
"endIndex": 14
]
},
{
"text": "Move Jill Jones from a-1234 to z-2345 on March 3 2 p.m",
"intent": "MoveEmployee",
"entities": [
{
"entity": "march 3 2 p.m",
"type": "builtin.datetimeV2.datetime",
"startIndex": 41,
"endIndex": 54,
"resolution": {
"values": [
{
"timex": "XXXX-03-03T14",
"type": "datetime",
"value": "2018-03-03 14:00:00"
},
{
"timex": "XXXX-03-03T14",
"type": "datetime",
"value": "2019-03-03 14:00:00"
}
]
}
},
{
"entity": "jill jones",
"type": "Employee",
"startIndex": 5,
"endIndex": 14,
"resolution": {
"values": [
"Employee-45612"
]
}
},
{
"entity": "z - 2345",
"type": "Locations::Destination",
"startIndex": 31,
"endIndex": 36,
"score": 0.9690751
},
{
"entity": "a - 1234",
"type": "Locations::Origin",
"startIndex": 21,
"endIndex": 26,
"score": 0.9713137
},
{
"entity": "jill jones from a - 1234 to z - 2345 on march 3 2 p . m",
"type": "requestemployeemove",
"startIndex": 5,
"endIndex": 54,
"score": 0.4027723
}
],
"compositeEntities": [
{
"parentType": "requestemployeemove",
"value": "jill jones from a - 1234 to z - 2345 on march 3 2 p . m",
"children": [
{
"type": "builtin.datetimeV2.datetime",
"value": "march 3 2 p.m"
},
{
"type": "Locations::Destination",
"value": "z - 2345"
},
{
"type": "Employee",
"value": "jill jones"
},
{
"type": "Locations::Origin",
"value": "a - 1234"
}
]
}
]
}
]

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

@ -1,164 +0,0 @@
{
"luis_schema_version": "2.3.0",
"versionId": "0.1",
"name": "HumanResources",
"desc": "",
"culture": "en-us",
"intents": [
{
"name": "GetEmployeeBenefits"
},
{
"name": "GetEmployeeOrgChart"
},
{
"name": "None"
}
],
"entities": [
{
"name": "Employee",
"roles": []
}
],
"composites": [],
"closedLists": [],
"patternAnyEntities": [],
"regex_entities": [],
"prebuiltEntities": [
{
"name": "number",
"roles": []
}
],
"model_features": [],
"regex_features": [],
"patterns": [],
"utterances": [
{
"text": "did you watch the show last night?",
"intent": "None",
"entities": []
},
{
"text": "does ilene chavez have any sl?",
"intent": "GetEmployeeBenefits",
"entities": [
{
"entity": "Employee",
"startPos": 5,
"endPos": 16
}
]
},
{
"text": "does lottie change have 40 hours of pto?",
"intent": "GetEmployeeBenefits",
"entities": [
{
"entity": "Employee",
"startPos": 5,
"endPos": 17
}
]
},
{
"text": "how many days of sick leave does santos mahaffey have?",
"intent": "GetEmployeeBenefits",
"entities": [
{
"entity": "Employee",
"startPos": 33,
"endPos": 47
}
]
},
{
"text": "how many hours of paid time off does jody pardo have?",
"intent": "GetEmployeeBenefits",
"entities": [
{
"entity": "Employee",
"startPos": 37,
"endPos": 46
}
]
},
{
"text": "is helen walton on maternity leave?",
"intent": "GetEmployeeBenefits",
"entities": [
{
"entity": "Employee",
"startPos": 3,
"endPos": 14
}
]
},
{
"text": "is there blue in the color green?",
"intent": "None",
"entities": []
},
{
"text": "that is too hot!",
"intent": "None",
"entities": []
},
{
"text": "who are virgie benjamin's subordinates?",
"intent": "GetEmployeeOrgChart",
"entities": [
{
"entity": "Employee",
"startPos": 8,
"endPos": 22
}
]
},
{
"text": "who does adrian garcia report to?",
"intent": "GetEmployeeOrgChart",
"entities": [
{
"entity": "Employee",
"startPos": 9,
"endPos": 21
}
]
},
{
"text": "who is dina's manager?",
"intent": "GetEmployeeOrgChart",
"entities": [
{
"entity": "Employee",
"startPos": 7,
"endPos": 10
}
]
},
{
"text": "who is mattie rivas manager?",
"intent": "GetEmployeeOrgChart",
"entities": [
{
"entity": "Employee",
"startPos": 7,
"endPos": 18
}
]
},
{
"text": "who reports to magdalena joseph",
"intent": "GetEmployeeOrgChart",
"entities": [
{
"entity": "Employee",
"startPos": 15,
"endPos": 30
}
]
}
]
}