Allow host base URI as an argument to ctor

Also cleaned up some compiler warnings.
This commit is contained in:
Chris Thrasher 2016-08-30 18:10:15 -07:00
Родитель c752c3292d
Коммит f680b3fd56
6 изменённых файлов: 23 добавлений и 10 удалений

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

@ -11,11 +11,11 @@
<iconUrl>https://www.luis.ai/Content/images/luis_darker_logo.png</iconUrl>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<description>$description$</description>
<releaseNotes>Initial release.</releaseNotes>
<copyright>Copyright (c) 2015</copyright>
<releaseNotes>User-configurable hostname.</releaseNotes>
<copyright>Copyright (c) 2016</copyright>
<tags>Microsoft Cognitive Services LUIS</tags>
<dependencies>
<dependency id="Newtonsoft.Json" version="9.0.1" />
</dependencies>
</metadata>
</package>
</package>

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

@ -46,6 +46,8 @@ namespace Microsoft.Cognitive.LUIS
/// </summary>
public class LuisClient : IDisposable
{
private const string DEFAULT_BASE_URI = "https://api.projectoxford.ai/luis/v1/application";
/// <summary>
/// flag to indidicate whether to return full result of all intents not just the top scoring intent (for preview features only)
/// </summary>
@ -90,20 +92,31 @@ namespace Microsoft.Cognitive.LUIS
}
/// <summary>
///Construct a new Luis client with a shared <see cref="HttpClient"/> instance.
/// Construct a new Luis client with a shared <see cref="HttpClient"/> instance.
/// </summary>
/// <param name="appId">The application ID of the LUIS application</param>
/// <param name="appKey">The application subscription key of the LUIS application</param>
/// <param name="preview">A flag indicating whether to use preview features or not (Dialogue)</param>
/// top scoring in case of using the dialogue</param>
public LuisClient(string appId, string appKey, bool preview = false)
public LuisClient(string appId, string appKey, bool preview = false) : this(appId, appKey, DEFAULT_BASE_URI, preview) { }
/// <summary>
/// Construct a new Luis client with a shared <see cref="HttpClient"/> instance.
/// </summary>
/// <param name="appId">The application ID of the LUIS application</param>
/// <param name="appKey">The application subscription key of the LUIS application</param>
/// <param name="baseApiUrl">Root URI for the service endpoint.</param>
/// <param name="preview">A flag indicating whether to use preview features or not (Dialogue)</param>
/// top scoring in case of using the dialogue</param>
public LuisClient(string appId, string appKey, string baseApiUrl, bool preview = false)
{
if (String.IsNullOrWhiteSpace(appId)) throw new ArgumentException(nameof(appId));
if (String.IsNullOrWhiteSpace(appKey)) throw new ArgumentException(nameof(appKey));
if (String.IsNullOrWhiteSpace(baseApiUrl)) throw new ArgumentException(nameof(baseApiUrl));
HttpClient httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Add("OCP-APIM-Subscription-Key", appKey);
BASE_API_URL = "https://api.projectoxford.ai/luis/v1/application";
BASE_API_URL = baseApiUrl;
Preview = preview;
_appId = appId;

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

@ -7,7 +7,7 @@ using System.Runtime.InteropServices;
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Microsoft.Cognitive.LUIS")]
[assembly: AssemblyDescription("Microsoft.Cognitive.LUIS")]
[assembly: AssemblyDescription("Microsoft Cognitive Services LUIS Client Library")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Microsoft Cognitive Services")]
[assembly: AssemblyCopyright("Copyright © 2016 Microsoft")]

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

@ -70,7 +70,7 @@ namespace Microsoft.Cognitive.LUIS
var values = (JArray)compositeEntity["children"] ?? new JArray();
CompositeEntityChildren = ParseValuesArray(values);
}
catch (Exception e)
catch (Exception)
{
CompositeEntityChildren = null;
}

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

@ -81,7 +81,7 @@ namespace Microsoft.Cognitive.LUIS
{
Score = (double)entity["score"];
}
catch (Exception e)
catch (Exception)
{
Score = -1;
}

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

@ -72,7 +72,7 @@ namespace Microsoft.Cognitive.LUIS
var values = (JArray)parameter["value"] ?? new JArray();
ParameterValues = ParseValuesArray(values);
}
catch (Exception e)
catch (Exception)
{
ParameterValues = null;
}