added sln and auth key name change (#82)

This commit is contained in:
Dina Berry 2018-02-20 12:30:34 -08:00 коммит произвёл GitHub
Родитель 3b0a3fdc15
Коммит e6c41f580f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
6 изменённых файлов: 315 добавлений и 0 удалений

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

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2009
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp1", "ConsoleApp1\ConsoleApp1.csproj", "{D14C33BE-AF26-43B2-A1D3-7937EC111007}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D14C33BE-AF26-43B2-A1D3-7937EC111007}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D14C33BE-AF26-43B2-A1D3-7937EC111007}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D14C33BE-AF26-43B2-A1D3-7937EC111007}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D14C33BE-AF26-43B2-A1D3-7937EC111007}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {37BC7E1D-1D65-4175-B89D-342EC125FC3A}
EndGlobalSection
EndGlobal

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

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>

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

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{D14C33BE-AF26-43B2-A1D3-7937EC111007}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>ConsoleApp1</RootNamespace>
<AssemblyName>ConsoleApp1</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<Content Include="utterances.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

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

@ -0,0 +1,174 @@
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 authoring key with a valid key.
static string authoringKey = "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", authoringKey);
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", authoringKey);
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();
}
}
}
}
}

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

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ConsoleApp1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ConsoleApp1")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("d14c33be-af26-43b2-a1d3-7937ec111007")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

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

@ -0,0 +1,18 @@
[
{
"text": "go to Seattle",
"intentName": "BookFlight",
"entityLabels": [
{
"entityName": "Location::LocationTo",
"startCharIndex": 6,
"endCharIndex": 12
}
]
},
{
"text": "book a flight",
"intentName": "BookFlight",
"entityLabels": []
}
]