From df69fc28595149ea6d8a3baf56dca3c1d91a699e Mon Sep 17 00:00:00 2001 From: Assaf Israel Date: Fri, 19 Jul 2019 15:58:07 -0700 Subject: [PATCH] Text Analytics SDK v4.0.0 - New project structure (#6647) * non-async + non-batch operations + correct order of params * Update .csproj v3.0.0 -> v3.1.0 + Release notes * Update .csproj to v4.0.0 --- .../TextAnalytics/Models/LanguageInput.cs | 14 +- .../Models/MultiLanguageInput.cs | 14 +- .../TextAnalyticsClientExtensions.cs | 569 ++++++++++++++++++ .../TextAnalyticsClientExtensions.cs | 147 ----- ...tiveServices.Language.TextAnalytics.csproj | 12 +- .../DetectLanguageAsync.json | 55 ++ .../DetectLanguageBatch.json | 55 ++ .../LanguageBatchAsync.json | 55 ++ .../EntitiesAsync.json | 55 ++ .../EntitiesBatch.json | 55 ++ .../EntitiesBatchAsync.json | 55 ++ .../KeyPhrasesAsync.json | 55 ++ .../KeyPhrasesBatch.json | 55 ++ .../KeyPhrasesBatchAsync.json | 55 ++ .../SentimentAsync.json | 55 ++ .../SentimentBatch.json | 55 ++ .../SentimentBatchAsync.json | 55 ++ .../TextAnalytics/DetectLanguageTests.cs | 62 +- .../tests/TextAnalytics/EntitiesTests.cs | 74 ++- .../tests/TextAnalytics/KeyPhrasesTests.cs | 59 +- .../tests/TextAnalytics/SentimentTests.cs | 58 +- 21 files changed, 1483 insertions(+), 186 deletions(-) rename sdk/cognitiveservices/Language.TextAnalytics/src/{Generated => Customizations}/TextAnalytics/Models/LanguageInput.cs (74%) rename sdk/cognitiveservices/Language.TextAnalytics/src/{Generated => Customizations}/TextAnalytics/Models/MultiLanguageInput.cs (78%) create mode 100644 sdk/cognitiveservices/Language.TextAnalytics/src/Customizations/TextAnalytics/TextAnalyticsClientExtensions.cs delete mode 100644 sdk/cognitiveservices/Language.TextAnalytics/src/Generated/TextAnalytics/TextAnalyticsClientExtensions.cs create mode 100644 sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.DetectLanguageTests/DetectLanguageAsync.json create mode 100644 sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.DetectLanguageTests/DetectLanguageBatch.json create mode 100644 sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.DetectLanguageTests/LanguageBatchAsync.json create mode 100644 sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.EntitiesTests/EntitiesAsync.json create mode 100644 sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.EntitiesTests/EntitiesBatch.json create mode 100644 sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.EntitiesTests/EntitiesBatchAsync.json create mode 100644 sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.KeyPhrasesTests/KeyPhrasesAsync.json create mode 100644 sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.KeyPhrasesTests/KeyPhrasesBatch.json create mode 100644 sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.KeyPhrasesTests/KeyPhrasesBatchAsync.json create mode 100644 sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.SentimentTests/SentimentAsync.json create mode 100644 sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.SentimentTests/SentimentBatch.json create mode 100644 sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.SentimentTests/SentimentBatchAsync.json diff --git a/sdk/cognitiveservices/Language.TextAnalytics/src/Generated/TextAnalytics/Models/LanguageInput.cs b/sdk/cognitiveservices/Language.TextAnalytics/src/Customizations/TextAnalytics/Models/LanguageInput.cs similarity index 74% rename from sdk/cognitiveservices/Language.TextAnalytics/src/Generated/TextAnalytics/Models/LanguageInput.cs rename to sdk/cognitiveservices/Language.TextAnalytics/src/Customizations/TextAnalytics/Models/LanguageInput.cs index d8ff5b429f40c..f6b0d8ecdf722 100644 --- a/sdk/cognitiveservices/Language.TextAnalytics/src/Generated/TextAnalytics/Models/LanguageInput.cs +++ b/sdk/cognitiveservices/Language.TextAnalytics/src/Customizations/TextAnalytics/Models/LanguageInput.cs @@ -1,12 +1,8 @@ -// +// // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// namespace Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Models { @@ -27,7 +23,7 @@ public LanguageInput() /// Initializes a new instance of the LanguageInput class. /// /// Unique, non-empty document identifier. - public LanguageInput(string countryHint = default(string), string id = default(string), string text = default(string)) + public LanguageInput(string id = default, string text = default, string countryHint = default) { CountryHint = countryHint; Id = id; @@ -42,18 +38,18 @@ public LanguageInput() /// /// - [JsonProperty(PropertyName = "countryHint")] + [JsonProperty(PropertyName = "countryHint", Order = 3)] public string CountryHint { get; set; } /// /// Gets or sets unique, non-empty document identifier. /// - [JsonProperty(PropertyName = "id")] + [JsonProperty(PropertyName = "id", Order = 1)] public string Id { get; set; } /// /// - [JsonProperty(PropertyName = "text")] + [JsonProperty(PropertyName = "text", Order = 2)] public string Text { get; set; } } diff --git a/sdk/cognitiveservices/Language.TextAnalytics/src/Generated/TextAnalytics/Models/MultiLanguageInput.cs b/sdk/cognitiveservices/Language.TextAnalytics/src/Customizations/TextAnalytics/Models/MultiLanguageInput.cs similarity index 78% rename from sdk/cognitiveservices/Language.TextAnalytics/src/Generated/TextAnalytics/Models/MultiLanguageInput.cs rename to sdk/cognitiveservices/Language.TextAnalytics/src/Customizations/TextAnalytics/Models/MultiLanguageInput.cs index c1fa451ecece8..c68fd432fa3d5 100644 --- a/sdk/cognitiveservices/Language.TextAnalytics/src/Generated/TextAnalytics/Models/MultiLanguageInput.cs +++ b/sdk/cognitiveservices/Language.TextAnalytics/src/Customizations/TextAnalytics/Models/MultiLanguageInput.cs @@ -1,12 +1,8 @@ -// +// // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// namespace Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Models { @@ -30,7 +26,7 @@ public MultiLanguageInput() /// representation of a language. For example, use "en" for English; /// "es" for Spanish etc., /// Unique, non-empty document identifier. - public MultiLanguageInput(string language = default(string), string id = default(string), string text = default(string)) + public MultiLanguageInput(string id = default, string text = default, string language = default) { Language = language; Id = id; @@ -47,18 +43,18 @@ public MultiLanguageInput() /// Gets or sets this is the 2 letter ISO 639-1 representation of a /// language. For example, use "en" for English; "es" for Spanish etc., /// - [JsonProperty(PropertyName = "language")] + [JsonProperty(PropertyName = "language", Order = 3)] public string Language { get; set; } /// /// Gets or sets unique, non-empty document identifier. /// - [JsonProperty(PropertyName = "id")] + [JsonProperty(PropertyName = "id", Order = 1)] public string Id { get; set; } /// /// - [JsonProperty(PropertyName = "text")] + [JsonProperty(PropertyName = "text", Order = 2)] public string Text { get; set; } } diff --git a/sdk/cognitiveservices/Language.TextAnalytics/src/Customizations/TextAnalytics/TextAnalyticsClientExtensions.cs b/sdk/cognitiveservices/Language.TextAnalytics/src/Customizations/TextAnalytics/TextAnalyticsClientExtensions.cs new file mode 100644 index 0000000000000..a41b70ba79b67 --- /dev/null +++ b/sdk/cognitiveservices/Language.TextAnalytics/src/Customizations/TextAnalytics/TextAnalyticsClientExtensions.cs @@ -0,0 +1,569 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// + +namespace Microsoft.Azure.CognitiveServices.Language.TextAnalytics +{ + using Models; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for TextAnalyticsClient. + /// + public static partial class TextAnalyticsClientExtensions + { + /// + /// The API returns the detected language and a numeric score between 0 and 1. + /// + /// + /// Scores close to 1 indicate 100% certainty that the identified language is + /// true. A total of 120 languages are supported. + /// + /// + /// The operations group for this extension method. + /// + /// + /// (optional) if set to true, response will contain input and document level + /// statistics. + /// + /// + /// Collection of documents to analyze. + /// + /// + /// The cancellation token. + /// + public static async Task DetectLanguageBatchAsync(this ITextAnalyticsClient operations, LanguageBatchInput languageBatchInput = default, bool? showStats = default, CancellationToken cancellationToken = default) + { + using (var _result = await operations.DetectLanguageWithHttpMessagesAsync(showStats, languageBatchInput, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// The API returns a list of recognized entities in a given document. + /// + /// + /// To get even more information on each recognized entity we recommend using + /// the Bing Entity Search API by querying for the recognized entities names. + /// See the <a + /// href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/text-analytics-supported-languages">Supported + /// languages in Text Analytics API</a> for the list of enabled + /// languages. + /// + /// + /// The operations group for this extension method. + /// + /// + /// (optional) if set to true, response will contain input and document level + /// statistics. + /// + /// + /// Collection of documents to analyze. + /// + /// + /// The cancellation token. + /// + public static async Task EntitiesBatchAsync(this ITextAnalyticsClient operations, MultiLanguageBatchInput multiLanguageBatchInput = default, bool? showStats = default, CancellationToken cancellationToken = default) + { + using (var _result = await operations.EntitiesWithHttpMessagesAsync(showStats, multiLanguageBatchInput, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// The API returns a list of strings denoting the key talking points in the + /// input text. + /// + /// + /// See the <a + /// href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview#supported-languages">Text + /// Analytics Documentation</a> for details about the languages that are + /// supported by key phrase extraction. + /// + /// + /// The operations group for this extension method. + /// + /// + /// (optional) if set to true, response will contain input and document level + /// statistics. + /// + /// + /// Collection of documents to analyze. Documents can now contain a language + /// field to indicate the text language + /// + /// + /// The cancellation token. + /// + public static async Task KeyPhrasesBatchAsync(this ITextAnalyticsClient operations, MultiLanguageBatchInput multiLanguageBatchInput = default, bool? showStats = default, CancellationToken cancellationToken = default) + { + using (var _result = await operations.KeyPhrasesWithHttpMessagesAsync(showStats, multiLanguageBatchInput, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// The API returns a numeric score between 0 and 1. + /// + /// + /// Scores close to 1 indicate positive sentiment, while scores close to 0 + /// indicate negative sentiment. A score of 0.5 indicates the lack of sentiment + /// (e.g. a factoid statement). See the <a + /// href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview#supported-languages">Text + /// Analytics Documentation</a> for details about the languages that are + /// supported by sentiment analysis. + /// + /// + /// The operations group for this extension method. + /// + /// + /// (optional) if set to true, response will contain input and document level + /// statistics. + /// + /// + /// Collection of documents to analyze. + /// + /// + /// The cancellation token. + /// + public static async Task SentimentBatchAsync(this ITextAnalyticsClient operations, MultiLanguageBatchInput multiLanguageBatchInput = default, bool? showStats = default, CancellationToken cancellationToken = default) + { + using (var _result = await operations.SentimentWithHttpMessagesAsync(showStats, multiLanguageBatchInput, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// The API returns the detected language and a numeric score between 0 and 1. + /// + /// + /// Scores close to 1 indicate 100% certainty that the identified language is + /// true. A total of 120 languages are supported. + /// + /// + /// The operations group for this extension method. + /// + /// + /// (optional) if set to true, response will contain input and document level + /// statistics. + /// + /// + /// Input text of one document. + /// + /// + /// Contry hint. + /// + /// + /// The cancellation token. + /// + public static async Task DetectLanguageAsync( + this ITextAnalyticsClient operations, + string inputText = default, + string countryHint = "en", + bool? showStats = default, + CancellationToken cancellationToken = default) + { + var languageBatchInput = new LanguageBatchInput(new List { new LanguageInput("1", inputText, countryHint) }); + using (var _result = await operations.DetectLanguageWithHttpMessagesAsync(showStats, languageBatchInput, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// The API returns a list of recognized entities in a given document. + /// + /// + /// To get even more information on each recognized entity we recommend using + /// the Bing Entity Search API by querying for the recognized entities names. + /// See the <a + /// href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/text-analytics-supported-languages">Supported + /// languages in Text Analytics API</a> for the list of enabled + /// languages. + /// + /// + /// The operations group for this extension method. + /// + /// + /// (optional) if set to true, response will contain input and document level + /// statistics. + /// + /// + /// Input text of one document. + /// + /// + /// Language code. + /// + /// + /// The cancellation token. + /// + public static async Task EntitiesAsync( + this ITextAnalyticsClient operations, + string inputText = default, + string language = "en", + bool? showStats = default, + CancellationToken cancellationToken = default) + { + var multiLanguageBatchInput = new MultiLanguageBatchInput(new List { new MultiLanguageInput("1", inputText, language) }); + using (var _result = await operations.EntitiesWithHttpMessagesAsync(showStats, multiLanguageBatchInput, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// The API returns a list of strings denoting the key talking points in the + /// input text. + /// + /// + /// See the <a + /// href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview#supported-languages">Text + /// Analytics Documentation</a> for details about the languages that are + /// supported by key phrase extraction. + /// + /// + /// The operations group for this extension method. + /// + /// + /// (optional) if set to true, response will contain input and document level + /// statistics. + /// + /// + /// Input text of one document. + /// + /// + /// Language code. + /// + /// + /// The cancellation token. + /// + public static async Task KeyPhrasesAsync( + this ITextAnalyticsClient operations, + string inputText = default, + string language = "en", + bool? showStats = default, + CancellationToken cancellationToken = default) + { + var multiLanguageBatchInput = new MultiLanguageBatchInput(new List { new MultiLanguageInput("1", inputText, language) }); + using (var _result = await operations.KeyPhrasesWithHttpMessagesAsync(showStats, multiLanguageBatchInput, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// The API returns a numeric score between 0 and 1. + /// + /// + /// Scores close to 1 indicate positive sentiment, while scores close to 0 + /// indicate negative sentiment. A score of 0.5 indicates the lack of sentiment + /// (e.g. a factoid statement). See the <a + /// href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview#supported-languages">Text + /// Analytics Documentation</a> for details about the languages that are + /// supported by sentiment analysis. + /// + /// + /// The operations group for this extension method. + /// + /// + /// (optional) if set to true, response will contain input and document level + /// statistics. + /// + /// + /// Input text of one document. + /// + /// + /// Language code. + /// + /// + /// The cancellation token. + /// + public static async Task SentimentAsync( + this ITextAnalyticsClient operations, + string inputText = default, + string language = "en", + bool? showStats = default, + CancellationToken cancellationToken = default) + { + var multiLanguageBatchInput = new MultiLanguageBatchInput(new List { new MultiLanguageInput("1", inputText, language) }); + using (var _result = await operations.SentimentWithHttpMessagesAsync(showStats, multiLanguageBatchInput, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// The API returns the detected language and a numeric score between 0 and 1. + /// + /// + /// Scores close to 1 indicate 100% certainty that the identified language is + /// true. A total of 120 languages are supported. + /// + /// + /// The operations group for this extension method. + /// + /// + /// (optional) if set to true, response will contain input and document level + /// statistics. + /// + /// + /// Collection of documents to analyze. + /// + /// + /// The cancellation token. + /// + public static LanguageBatchResult DetectLanguageBatch(this ITextAnalyticsClient operations, LanguageBatchInput languageBatchInput = default, bool? showStats = default, CancellationToken cancellationToken = default) + { + var _result = operations.DetectLanguageWithHttpMessagesAsync(showStats, languageBatchInput, null, cancellationToken).GetAwaiter().GetResult(); + return _result.Body; + } + + /// + /// The API returns a list of recognized entities in a given document. + /// + /// + /// To get even more information on each recognized entity we recommend using + /// the Bing Entity Search API by querying for the recognized entities names. + /// See the <a + /// href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/text-analytics-supported-languages">Supported + /// languages in Text Analytics API</a> for the list of enabled + /// languages. + /// + /// + /// The operations group for this extension method. + /// + /// + /// (optional) if set to true, response will contain input and document level + /// statistics. + /// + /// + /// Collection of documents to analyze. + /// + /// + /// The cancellation token. + /// + public static EntitiesBatchResult EntitiesBatch(this ITextAnalyticsClient operations, MultiLanguageBatchInput multiLanguageBatchInput = default, bool? showStats = default, CancellationToken cancellationToken = default) + { + var _result = operations.EntitiesWithHttpMessagesAsync(showStats, multiLanguageBatchInput, null, cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult(); + return _result.Body; + } + + /// + /// The API returns a list of strings denoting the key talking points in the + /// input text. + /// + /// + /// See the <a + /// href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview#supported-languages">Text + /// Analytics Documentation</a> for details about the languages that are + /// supported by key phrase extraction. + /// + /// + /// The operations group for this extension method. + /// + /// + /// (optional) if set to true, response will contain input and document level + /// statistics. + /// + /// + /// Collection of documents to analyze. Documents can now contain a language + /// field to indicate the text language + /// + /// + /// The cancellation token. + /// + public static KeyPhraseBatchResult KeyPhrasesBatch(this ITextAnalyticsClient operations, MultiLanguageBatchInput multiLanguageBatchInput = default, bool? showStats = default, CancellationToken cancellationToken = default) + { + var _result = operations.KeyPhrasesWithHttpMessagesAsync(showStats, multiLanguageBatchInput, null, cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult(); + return _result.Body; + } + + /// + /// The API returns a numeric score between 0 and 1. + /// + /// + /// Scores close to 1 indicate positive sentiment, while scores close to 0 + /// indicate negative sentiment. A score of 0.5 indicates the lack of sentiment + /// (e.g. a factoid statement). See the <a + /// href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview#supported-languages">Text + /// Analytics Documentation</a> for details about the languages that are + /// supported by sentiment analysis. + /// + /// + /// The operations group for this extension method. + /// + /// + /// (optional) if set to true, response will contain input and document level + /// statistics. + /// + /// + /// Collection of documents to analyze. + /// + /// + /// The cancellation token. + /// + public static SentimentBatchResult SentimentBatch(this ITextAnalyticsClient operations, MultiLanguageBatchInput multiLanguageBatchInput = default, bool? showStats = default, CancellationToken cancellationToken = default) + { + var _result = operations.SentimentWithHttpMessagesAsync(showStats, multiLanguageBatchInput, null, cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult(); + return _result.Body; + } + + /// + /// The API returns the detected language and a numeric score between 0 and 1. + /// + /// + /// Scores close to 1 indicate 100% certainty that the identified language is + /// true. A total of 120 languages are supported. + /// + /// + /// The operations group for this extension method. + /// + /// + /// (optional) if set to true, response will contain input and document level + /// statistics. + /// + /// + /// Input text of one document. + /// + /// + /// Contry hint. + /// + /// + /// The cancellation token. + /// + public static LanguageBatchResult DetectLanguage( + this ITextAnalyticsClient operations, + string inputText = default, + string countryHint = "en", + bool? showStats = default, + CancellationToken cancellationToken = default) + { + var languageBatchInput = new LanguageBatchInput(new List { new LanguageInput("1", inputText, countryHint) }); + var _result = operations.DetectLanguageWithHttpMessagesAsync(showStats, languageBatchInput, null, cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult(); + return _result.Body; + } + + /// + /// The API returns a list of recognized entities in a given document. + /// + /// + /// To get even more information on each recognized entity we recommend using + /// the Bing Entity Search API by querying for the recognized entities names. + /// See the <a + /// href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/text-analytics-supported-languages">Supported + /// languages in Text Analytics API</a> for the list of enabled + /// languages. + /// + /// + /// The operations group for this extension method. + /// + /// + /// (optional) if set to true, response will contain input and document level + /// statistics. + /// + /// + /// Input text of one document. + /// + /// + /// Language code. + /// + /// + /// The cancellation token. + /// + public static EntitiesBatchResult Entities( + this ITextAnalyticsClient operations, + string inputText = default, + string language = "en", + bool? showStats = default, + CancellationToken cancellationToken = default) + { + var multiLanguageBatchInput = new MultiLanguageBatchInput(new List { new MultiLanguageInput("1", inputText, language) }); + var _result = operations.EntitiesWithHttpMessagesAsync(showStats, multiLanguageBatchInput, null, cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult(); + return _result.Body; + } + + /// + /// The API returns a list of strings denoting the key talking points in the + /// input text. + /// + /// + /// See the <a + /// href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview#supported-languages">Text + /// Analytics Documentation</a> for details about the languages that are + /// supported by key phrase extraction. + /// + /// + /// The operations group for this extension method. + /// + /// + /// (optional) if set to true, response will contain input and document level + /// statistics. + /// + /// + /// Input text of one document. + /// + /// + /// Language code. + /// + /// + /// The cancellation token. + /// + public static KeyPhraseBatchResult KeyPhrases( + this ITextAnalyticsClient operations, + string inputText = default, + string language = "en", + bool? showStats = default, + CancellationToken cancellationToken = default) + { + var multiLanguageBatchInput = new MultiLanguageBatchInput(new List { new MultiLanguageInput("1", inputText, language) }); + var _result = operations.KeyPhrasesWithHttpMessagesAsync(showStats, multiLanguageBatchInput, null, cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult(); + return _result.Body; + } + + /// + /// The API returns a numeric score between 0 and 1. + /// + /// + /// Scores close to 1 indicate positive sentiment, while scores close to 0 + /// indicate negative sentiment. A score of 0.5 indicates the lack of sentiment + /// (e.g. a factoid statement). See the <a + /// href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview#supported-languages">Text + /// Analytics Documentation</a> for details about the languages that are + /// supported by sentiment analysis. + /// + /// + /// The operations group for this extension method. + /// + /// + /// (optional) if set to true, response will contain input and document level + /// statistics. + /// + /// + /// Input text of one document. + /// + /// + /// Language code. + /// + /// + /// The cancellation token. + /// + public static SentimentBatchResult Sentiment( + this ITextAnalyticsClient operations, + string inputText = default, + string language = "en", + bool? showStats = default, + CancellationToken cancellationToken = default) + { + var multiLanguageBatchInput = new MultiLanguageBatchInput(new List { new MultiLanguageInput("1", inputText, language) }); + var _result = operations.SentimentWithHttpMessagesAsync(showStats, multiLanguageBatchInput, null, cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult(); + return _result.Body; + } + } +} diff --git a/sdk/cognitiveservices/Language.TextAnalytics/src/Generated/TextAnalytics/TextAnalyticsClientExtensions.cs b/sdk/cognitiveservices/Language.TextAnalytics/src/Generated/TextAnalytics/TextAnalyticsClientExtensions.cs deleted file mode 100644 index f663e95ed6bdf..0000000000000 --- a/sdk/cognitiveservices/Language.TextAnalytics/src/Generated/TextAnalytics/TextAnalyticsClientExtensions.cs +++ /dev/null @@ -1,147 +0,0 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Microsoft.Azure.CognitiveServices.Language.TextAnalytics -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for TextAnalyticsClient. - /// - public static partial class TextAnalyticsClientExtensions - { - /// - /// The API returns the detected language and a numeric score between 0 and 1. - /// - /// - /// Scores close to 1 indicate 100% certainty that the identified language is - /// true. A total of 120 languages are supported. - /// - /// - /// The operations group for this extension method. - /// - /// - /// (optional) if set to true, response will contain input and document level - /// statistics. - /// - /// - /// Collection of documents to analyze. - /// - /// - /// The cancellation token. - /// - public static async Task DetectLanguageAsync(this ITextAnalyticsClient operations, bool? showStats = default(bool?), LanguageBatchInput languageBatchInput = default(LanguageBatchInput), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.DetectLanguageWithHttpMessagesAsync(showStats, languageBatchInput, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// The API returns a list of recognized entities in a given document. - /// - /// - /// To get even more information on each recognized entity we recommend using - /// the Bing Entity Search API by querying for the recognized entities names. - /// See the <a - /// href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/text-analytics-supported-languages">Supported - /// languages in Text Analytics API</a> for the list of enabled - /// languages. - /// - /// - /// The operations group for this extension method. - /// - /// - /// (optional) if set to true, response will contain input and document level - /// statistics. - /// - /// - /// Collection of documents to analyze. - /// - /// - /// The cancellation token. - /// - public static async Task EntitiesAsync(this ITextAnalyticsClient operations, bool? showStats = default(bool?), MultiLanguageBatchInput multiLanguageBatchInput = default(MultiLanguageBatchInput), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.EntitiesWithHttpMessagesAsync(showStats, multiLanguageBatchInput, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// The API returns a list of strings denoting the key talking points in the - /// input text. - /// - /// - /// See the <a - /// href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview#supported-languages">Text - /// Analytics Documentation</a> for details about the languages that are - /// supported by key phrase extraction. - /// - /// - /// The operations group for this extension method. - /// - /// - /// (optional) if set to true, response will contain input and document level - /// statistics. - /// - /// - /// Collection of documents to analyze. Documents can now contain a language - /// field to indicate the text language - /// - /// - /// The cancellation token. - /// - public static async Task KeyPhrasesAsync(this ITextAnalyticsClient operations, bool? showStats = default(bool?), MultiLanguageBatchInput multiLanguageBatchInput = default(MultiLanguageBatchInput), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.KeyPhrasesWithHttpMessagesAsync(showStats, multiLanguageBatchInput, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// The API returns a numeric score between 0 and 1. - /// - /// - /// Scores close to 1 indicate positive sentiment, while scores close to 0 - /// indicate negative sentiment. A score of 0.5 indicates the lack of sentiment - /// (e.g. a factoid statement). See the <a - /// href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview#supported-languages">Text - /// Analytics Documentation</a> for details about the languages that are - /// supported by sentiment analysis. - /// - /// - /// The operations group for this extension method. - /// - /// - /// (optional) if set to true, response will contain input and document level - /// statistics. - /// - /// - /// Collection of documents to analyze. - /// - /// - /// The cancellation token. - /// - public static async Task SentimentAsync(this ITextAnalyticsClient operations, bool? showStats = default(bool?), MultiLanguageBatchInput multiLanguageBatchInput = default(MultiLanguageBatchInput), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.SentimentWithHttpMessagesAsync(showStats, multiLanguageBatchInput, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} diff --git a/sdk/cognitiveservices/Language.TextAnalytics/src/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.csproj b/sdk/cognitiveservices/Language.TextAnalytics/src/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.csproj index 01c4087fdbb81..4442a5f32b570 100644 --- a/sdk/cognitiveservices/Language.TextAnalytics/src/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.csproj +++ b/sdk/cognitiveservices/Language.TextAnalytics/src/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.csproj @@ -2,20 +2,22 @@ Microsoft Azure Cognitive Services Language Text Analytics Client Library Provides API functions for consuming Microsoft Azure Cognitive Services Language Text Analytics APIs. - 3.0.0 + 4.0.0 Microsoft Cognitive Services;Cognitive Services;Cognitive Services SDK;Text Analytics API;Text Analytics;REST HTTP client;netcore451511 - + $(RequiredTargetFrameworks) diff --git a/sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.DetectLanguageTests/DetectLanguageAsync.json b/sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.DetectLanguageTests/DetectLanguageAsync.json new file mode 100644 index 0000000000000..bdcb893d066fb --- /dev/null +++ b/sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.DetectLanguageTests/DetectLanguageAsync.json @@ -0,0 +1,55 @@ +{ + "Entries": [ + { + "RequestUri": "/text/analytics/v2.1/languages", + "EncodedRequestUri": "L3RleHQvYW5hbHl0aWNzL3YyLjEvbGFuZ3VhZ2Vz", + "RequestMethod": "POST", + "RequestBody": "{\r\n \"documents\": [\r\n {\r\n \"id\": \"id\",\r\n \"text\": \"I love my team mates\"\r\n }\r\n ]\r\n}", + "RequestHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "98" + ], + "Ocp-Apim-Subscription-Key": [ + "" + ], + "User-Agent": [ + "FxVersion/4.6.25211.01", + "Microsoft.CognitiveServices.Language.TextAnalytics.TextAnalyticsAPI/1.0.0" + ] + }, + "ResponseBody": "{\r\n \"documents\": [\r\n {\r\n \"id\": \"id\",\r\n \"detectedLanguages\": [\r\n {\r\n \"name\": \"English\",\r\n \"iso6391Name\": \"en\",\r\n \"score\": 1.0\r\n }\r\n ]\r\n }\r\n ],\r\n \"errors\": []\r\n}", + "ResponseHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Date": [ + "Wed, 30 Aug 2017 02:11:18 GMT" + ], + "Transfer-Encoding": [ + "chunked" + ], + "x-ms-transaction-count": [ + "1" + ], + "x-aml-ta-request-id": [ + "473e3a1f-cf5e-4230-85b5-68fe2518370f" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "apim-request-id": [ + "69e6aeb0-e601-42ca-9468-f0cfaa408708" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains; preload" + ] + }, + "StatusCode": 200 + } + ], + "Names": {}, + "Variables": {} +} \ No newline at end of file diff --git a/sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.DetectLanguageTests/DetectLanguageBatch.json b/sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.DetectLanguageTests/DetectLanguageBatch.json new file mode 100644 index 0000000000000..bdcb893d066fb --- /dev/null +++ b/sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.DetectLanguageTests/DetectLanguageBatch.json @@ -0,0 +1,55 @@ +{ + "Entries": [ + { + "RequestUri": "/text/analytics/v2.1/languages", + "EncodedRequestUri": "L3RleHQvYW5hbHl0aWNzL3YyLjEvbGFuZ3VhZ2Vz", + "RequestMethod": "POST", + "RequestBody": "{\r\n \"documents\": [\r\n {\r\n \"id\": \"id\",\r\n \"text\": \"I love my team mates\"\r\n }\r\n ]\r\n}", + "RequestHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "98" + ], + "Ocp-Apim-Subscription-Key": [ + "" + ], + "User-Agent": [ + "FxVersion/4.6.25211.01", + "Microsoft.CognitiveServices.Language.TextAnalytics.TextAnalyticsAPI/1.0.0" + ] + }, + "ResponseBody": "{\r\n \"documents\": [\r\n {\r\n \"id\": \"id\",\r\n \"detectedLanguages\": [\r\n {\r\n \"name\": \"English\",\r\n \"iso6391Name\": \"en\",\r\n \"score\": 1.0\r\n }\r\n ]\r\n }\r\n ],\r\n \"errors\": []\r\n}", + "ResponseHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Date": [ + "Wed, 30 Aug 2017 02:11:18 GMT" + ], + "Transfer-Encoding": [ + "chunked" + ], + "x-ms-transaction-count": [ + "1" + ], + "x-aml-ta-request-id": [ + "473e3a1f-cf5e-4230-85b5-68fe2518370f" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "apim-request-id": [ + "69e6aeb0-e601-42ca-9468-f0cfaa408708" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains; preload" + ] + }, + "StatusCode": 200 + } + ], + "Names": {}, + "Variables": {} +} \ No newline at end of file diff --git a/sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.DetectLanguageTests/LanguageBatchAsync.json b/sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.DetectLanguageTests/LanguageBatchAsync.json new file mode 100644 index 0000000000000..bdcb893d066fb --- /dev/null +++ b/sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.DetectLanguageTests/LanguageBatchAsync.json @@ -0,0 +1,55 @@ +{ + "Entries": [ + { + "RequestUri": "/text/analytics/v2.1/languages", + "EncodedRequestUri": "L3RleHQvYW5hbHl0aWNzL3YyLjEvbGFuZ3VhZ2Vz", + "RequestMethod": "POST", + "RequestBody": "{\r\n \"documents\": [\r\n {\r\n \"id\": \"id\",\r\n \"text\": \"I love my team mates\"\r\n }\r\n ]\r\n}", + "RequestHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "98" + ], + "Ocp-Apim-Subscription-Key": [ + "" + ], + "User-Agent": [ + "FxVersion/4.6.25211.01", + "Microsoft.CognitiveServices.Language.TextAnalytics.TextAnalyticsAPI/1.0.0" + ] + }, + "ResponseBody": "{\r\n \"documents\": [\r\n {\r\n \"id\": \"id\",\r\n \"detectedLanguages\": [\r\n {\r\n \"name\": \"English\",\r\n \"iso6391Name\": \"en\",\r\n \"score\": 1.0\r\n }\r\n ]\r\n }\r\n ],\r\n \"errors\": []\r\n}", + "ResponseHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Date": [ + "Wed, 30 Aug 2017 02:11:18 GMT" + ], + "Transfer-Encoding": [ + "chunked" + ], + "x-ms-transaction-count": [ + "1" + ], + "x-aml-ta-request-id": [ + "473e3a1f-cf5e-4230-85b5-68fe2518370f" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "apim-request-id": [ + "69e6aeb0-e601-42ca-9468-f0cfaa408708" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains; preload" + ] + }, + "StatusCode": 200 + } + ], + "Names": {}, + "Variables": {} +} \ No newline at end of file diff --git a/sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.EntitiesTests/EntitiesAsync.json b/sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.EntitiesTests/EntitiesAsync.json new file mode 100644 index 0000000000000..4c64789d5cd9e --- /dev/null +++ b/sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.EntitiesTests/EntitiesAsync.json @@ -0,0 +1,55 @@ +{ + "Entries": [ + { + "RequestUri": "/text/analytics/v2.1/entities", + "EncodedRequestUri": "L3RleHQvYW5hbHl0aWNzL3YyLjEvZW50aXRpZXM=", + "RequestMethod": "POST", + "RequestBody": "{\r\n \"documents\": [\r\n {\r\n \"language\": \"en\",\r\n \"id\": \"id\",\r\n \"text\": \"Microsoft released Windows 10\"\r\n }\r\n ]\r\n}", + "RequestHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "123" + ], + "Ocp-Apim-Subscription-Key": [ + "" + ], + "User-Agent": [ + "FxVersion/4.6.25211.01", + "Microsoft.CognitiveServices.Language.TextAnalytics.TextAnalyticsAPI/1.0.0" + ] + }, + "ResponseBody": "{\"documents\":[{\"id\":\"id\",\"entities\":[{\"name\":\"Microsoft\",\"matches\":[{\"wikipediaScore\":0.12508682244047509,\"entityTypeScore\":0.99999618530273438,\"text\":\"Microsoft\",\"offset\":0,\"length\":9}],\"wikipediaLanguage\":\"en\",\"wikipediaId\":\"Microsoft\",\"wikipediaUrl\":\"https://en.wikipedia.org/wiki/Microsoft\",\"bingId\":\"a093e9b9-90f5-a3d5-c4b8-5855e1b01f85\",\"type\":\"Organization\"},{\"name\":\"Windows 10\",\"matches\":[{\"wikipediaScore\":0.35750355694656766,\"text\":\"Windows 10\",\"offset\":19,\"length\":10}],\"wikipediaLanguage\":\"en\",\"wikipediaId\":\"Windows 10\",\"wikipediaUrl\":\"https://en.wikipedia.org/wiki/Windows_10\",\"bingId\":\"5f9fbd03-49c4-39ef-cc95-de83ab897b94\"}]}\r\n ],\r\n \"errors\":[]\r\n}", + "ResponseHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Date": [ + "Wed, 30 Aug 2017 02:11:17 GMT" + ], + "Transfer-Encoding": [ + "chunked" + ], + "x-ms-transaction-count": [ + "1" + ], + "x-aml-ta-request-id": [ + "460baaca-7f57-42c1-8cc7-8852957d05b9" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "apim-request-id": [ + "3f09b1c9-fe3b-46bb-badf-98108c599825" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains; preload" + ] + }, + "StatusCode": 200 + } + ], + "Names": {}, + "Variables": {} +} \ No newline at end of file diff --git a/sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.EntitiesTests/EntitiesBatch.json b/sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.EntitiesTests/EntitiesBatch.json new file mode 100644 index 0000000000000..4c64789d5cd9e --- /dev/null +++ b/sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.EntitiesTests/EntitiesBatch.json @@ -0,0 +1,55 @@ +{ + "Entries": [ + { + "RequestUri": "/text/analytics/v2.1/entities", + "EncodedRequestUri": "L3RleHQvYW5hbHl0aWNzL3YyLjEvZW50aXRpZXM=", + "RequestMethod": "POST", + "RequestBody": "{\r\n \"documents\": [\r\n {\r\n \"language\": \"en\",\r\n \"id\": \"id\",\r\n \"text\": \"Microsoft released Windows 10\"\r\n }\r\n ]\r\n}", + "RequestHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "123" + ], + "Ocp-Apim-Subscription-Key": [ + "" + ], + "User-Agent": [ + "FxVersion/4.6.25211.01", + "Microsoft.CognitiveServices.Language.TextAnalytics.TextAnalyticsAPI/1.0.0" + ] + }, + "ResponseBody": "{\"documents\":[{\"id\":\"id\",\"entities\":[{\"name\":\"Microsoft\",\"matches\":[{\"wikipediaScore\":0.12508682244047509,\"entityTypeScore\":0.99999618530273438,\"text\":\"Microsoft\",\"offset\":0,\"length\":9}],\"wikipediaLanguage\":\"en\",\"wikipediaId\":\"Microsoft\",\"wikipediaUrl\":\"https://en.wikipedia.org/wiki/Microsoft\",\"bingId\":\"a093e9b9-90f5-a3d5-c4b8-5855e1b01f85\",\"type\":\"Organization\"},{\"name\":\"Windows 10\",\"matches\":[{\"wikipediaScore\":0.35750355694656766,\"text\":\"Windows 10\",\"offset\":19,\"length\":10}],\"wikipediaLanguage\":\"en\",\"wikipediaId\":\"Windows 10\",\"wikipediaUrl\":\"https://en.wikipedia.org/wiki/Windows_10\",\"bingId\":\"5f9fbd03-49c4-39ef-cc95-de83ab897b94\"}]}\r\n ],\r\n \"errors\":[]\r\n}", + "ResponseHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Date": [ + "Wed, 30 Aug 2017 02:11:17 GMT" + ], + "Transfer-Encoding": [ + "chunked" + ], + "x-ms-transaction-count": [ + "1" + ], + "x-aml-ta-request-id": [ + "460baaca-7f57-42c1-8cc7-8852957d05b9" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "apim-request-id": [ + "3f09b1c9-fe3b-46bb-badf-98108c599825" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains; preload" + ] + }, + "StatusCode": 200 + } + ], + "Names": {}, + "Variables": {} +} \ No newline at end of file diff --git a/sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.EntitiesTests/EntitiesBatchAsync.json b/sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.EntitiesTests/EntitiesBatchAsync.json new file mode 100644 index 0000000000000..4c64789d5cd9e --- /dev/null +++ b/sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.EntitiesTests/EntitiesBatchAsync.json @@ -0,0 +1,55 @@ +{ + "Entries": [ + { + "RequestUri": "/text/analytics/v2.1/entities", + "EncodedRequestUri": "L3RleHQvYW5hbHl0aWNzL3YyLjEvZW50aXRpZXM=", + "RequestMethod": "POST", + "RequestBody": "{\r\n \"documents\": [\r\n {\r\n \"language\": \"en\",\r\n \"id\": \"id\",\r\n \"text\": \"Microsoft released Windows 10\"\r\n }\r\n ]\r\n}", + "RequestHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "123" + ], + "Ocp-Apim-Subscription-Key": [ + "" + ], + "User-Agent": [ + "FxVersion/4.6.25211.01", + "Microsoft.CognitiveServices.Language.TextAnalytics.TextAnalyticsAPI/1.0.0" + ] + }, + "ResponseBody": "{\"documents\":[{\"id\":\"id\",\"entities\":[{\"name\":\"Microsoft\",\"matches\":[{\"wikipediaScore\":0.12508682244047509,\"entityTypeScore\":0.99999618530273438,\"text\":\"Microsoft\",\"offset\":0,\"length\":9}],\"wikipediaLanguage\":\"en\",\"wikipediaId\":\"Microsoft\",\"wikipediaUrl\":\"https://en.wikipedia.org/wiki/Microsoft\",\"bingId\":\"a093e9b9-90f5-a3d5-c4b8-5855e1b01f85\",\"type\":\"Organization\"},{\"name\":\"Windows 10\",\"matches\":[{\"wikipediaScore\":0.35750355694656766,\"text\":\"Windows 10\",\"offset\":19,\"length\":10}],\"wikipediaLanguage\":\"en\",\"wikipediaId\":\"Windows 10\",\"wikipediaUrl\":\"https://en.wikipedia.org/wiki/Windows_10\",\"bingId\":\"5f9fbd03-49c4-39ef-cc95-de83ab897b94\"}]}\r\n ],\r\n \"errors\":[]\r\n}", + "ResponseHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Date": [ + "Wed, 30 Aug 2017 02:11:17 GMT" + ], + "Transfer-Encoding": [ + "chunked" + ], + "x-ms-transaction-count": [ + "1" + ], + "x-aml-ta-request-id": [ + "460baaca-7f57-42c1-8cc7-8852957d05b9" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "apim-request-id": [ + "3f09b1c9-fe3b-46bb-badf-98108c599825" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains; preload" + ] + }, + "StatusCode": 200 + } + ], + "Names": {}, + "Variables": {} +} \ No newline at end of file diff --git a/sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.KeyPhrasesTests/KeyPhrasesAsync.json b/sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.KeyPhrasesTests/KeyPhrasesAsync.json new file mode 100644 index 0000000000000..4427ae2e56dcb --- /dev/null +++ b/sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.KeyPhrasesTests/KeyPhrasesAsync.json @@ -0,0 +1,55 @@ +{ + "Entries": [ + { + "RequestUri": "/text/analytics/v2.1/keyPhrases", + "EncodedRequestUri": "L3RleHQvYW5hbHl0aWNzL3YyLjEva2V5UGhyYXNlcw==", + "RequestMethod": "POST", + "RequestBody": "{\r\n \"documents\": [\r\n {\r\n \"language\": \"en\",\r\n \"id\": \"id\",\r\n \"text\": \"I love my team mates\"\r\n }\r\n ]\r\n}", + "RequestHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "123" + ], + "Ocp-Apim-Subscription-Key": [ + "" + ], + "User-Agent": [ + "FxVersion/4.6.25211.01", + "Microsoft.CognitiveServices.Language.TextAnalytics.TextAnalyticsAPI/1.0.0" + ] + }, + "ResponseBody": "{\r\n \"documents\": [\r\n {\r\n \"keyPhrases\": [\r\n \"team mates\"\r\n ],\r\n \"id\": \"id\"\r\n }\r\n ],\r\n \"errors\": []\r\n}", + "ResponseHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Date": [ + "Wed, 30 Aug 2017 02:11:17 GMT" + ], + "Transfer-Encoding": [ + "chunked" + ], + "x-ms-transaction-count": [ + "1" + ], + "x-aml-ta-request-id": [ + "460baaca-7f57-42c1-8cc7-8852957d05b9" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "apim-request-id": [ + "3f09b1c9-fe3b-46bb-badf-98108c599825" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains; preload" + ] + }, + "StatusCode": 200 + } + ], + "Names": {}, + "Variables": {} +} \ No newline at end of file diff --git a/sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.KeyPhrasesTests/KeyPhrasesBatch.json b/sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.KeyPhrasesTests/KeyPhrasesBatch.json new file mode 100644 index 0000000000000..4427ae2e56dcb --- /dev/null +++ b/sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.KeyPhrasesTests/KeyPhrasesBatch.json @@ -0,0 +1,55 @@ +{ + "Entries": [ + { + "RequestUri": "/text/analytics/v2.1/keyPhrases", + "EncodedRequestUri": "L3RleHQvYW5hbHl0aWNzL3YyLjEva2V5UGhyYXNlcw==", + "RequestMethod": "POST", + "RequestBody": "{\r\n \"documents\": [\r\n {\r\n \"language\": \"en\",\r\n \"id\": \"id\",\r\n \"text\": \"I love my team mates\"\r\n }\r\n ]\r\n}", + "RequestHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "123" + ], + "Ocp-Apim-Subscription-Key": [ + "" + ], + "User-Agent": [ + "FxVersion/4.6.25211.01", + "Microsoft.CognitiveServices.Language.TextAnalytics.TextAnalyticsAPI/1.0.0" + ] + }, + "ResponseBody": "{\r\n \"documents\": [\r\n {\r\n \"keyPhrases\": [\r\n \"team mates\"\r\n ],\r\n \"id\": \"id\"\r\n }\r\n ],\r\n \"errors\": []\r\n}", + "ResponseHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Date": [ + "Wed, 30 Aug 2017 02:11:17 GMT" + ], + "Transfer-Encoding": [ + "chunked" + ], + "x-ms-transaction-count": [ + "1" + ], + "x-aml-ta-request-id": [ + "460baaca-7f57-42c1-8cc7-8852957d05b9" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "apim-request-id": [ + "3f09b1c9-fe3b-46bb-badf-98108c599825" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains; preload" + ] + }, + "StatusCode": 200 + } + ], + "Names": {}, + "Variables": {} +} \ No newline at end of file diff --git a/sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.KeyPhrasesTests/KeyPhrasesBatchAsync.json b/sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.KeyPhrasesTests/KeyPhrasesBatchAsync.json new file mode 100644 index 0000000000000..4427ae2e56dcb --- /dev/null +++ b/sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.KeyPhrasesTests/KeyPhrasesBatchAsync.json @@ -0,0 +1,55 @@ +{ + "Entries": [ + { + "RequestUri": "/text/analytics/v2.1/keyPhrases", + "EncodedRequestUri": "L3RleHQvYW5hbHl0aWNzL3YyLjEva2V5UGhyYXNlcw==", + "RequestMethod": "POST", + "RequestBody": "{\r\n \"documents\": [\r\n {\r\n \"language\": \"en\",\r\n \"id\": \"id\",\r\n \"text\": \"I love my team mates\"\r\n }\r\n ]\r\n}", + "RequestHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "123" + ], + "Ocp-Apim-Subscription-Key": [ + "" + ], + "User-Agent": [ + "FxVersion/4.6.25211.01", + "Microsoft.CognitiveServices.Language.TextAnalytics.TextAnalyticsAPI/1.0.0" + ] + }, + "ResponseBody": "{\r\n \"documents\": [\r\n {\r\n \"keyPhrases\": [\r\n \"team mates\"\r\n ],\r\n \"id\": \"id\"\r\n }\r\n ],\r\n \"errors\": []\r\n}", + "ResponseHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Date": [ + "Wed, 30 Aug 2017 02:11:17 GMT" + ], + "Transfer-Encoding": [ + "chunked" + ], + "x-ms-transaction-count": [ + "1" + ], + "x-aml-ta-request-id": [ + "460baaca-7f57-42c1-8cc7-8852957d05b9" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "apim-request-id": [ + "3f09b1c9-fe3b-46bb-badf-98108c599825" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains; preload" + ] + }, + "StatusCode": 200 + } + ], + "Names": {}, + "Variables": {} +} \ No newline at end of file diff --git a/sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.SentimentTests/SentimentAsync.json b/sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.SentimentTests/SentimentAsync.json new file mode 100644 index 0000000000000..685c108482dd0 --- /dev/null +++ b/sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.SentimentTests/SentimentAsync.json @@ -0,0 +1,55 @@ +{ + "Entries": [ + { + "RequestUri": "/text/analytics/v2.1/sentiment", + "EncodedRequestUri": "L3RleHQvYW5hbHl0aWNzL3YyLjEvc2VudGltZW50", + "RequestMethod": "POST", + "RequestBody": "{\r\n \"documents\": [\r\n {\r\n \"language\": \"en\",\r\n \"id\": \"id\",\r\n \"text\": \"I love my team mates\"\r\n }\r\n ]\r\n}", + "RequestHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "123" + ], + "Ocp-Apim-Subscription-Key": [ + "" + ], + "User-Agent": [ + "FxVersion/4.6.25211.01", + "Microsoft.CognitiveServices.Language.TextAnalytics.TextAnalyticsAPI/1.0.0" + ] + }, + "ResponseBody": "{\r\n \"documents\": [\r\n {\r\n \"score\": 0.97380387783050537,\r\n \"id\": \"id\"\r\n }\r\n ],\r\n \"errors\": []\r\n}", + "ResponseHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Date": [ + "Wed, 30 Aug 2017 02:11:17 GMT" + ], + "Transfer-Encoding": [ + "chunked" + ], + "x-ms-transaction-count": [ + "1" + ], + "x-aml-ta-request-id": [ + "06db056b-1bf0-4994-933a-f08eacf94053" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "apim-request-id": [ + "63c5b90f-3a35-48c3-bb85-d89218d1202e" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains; preload" + ] + }, + "StatusCode": 200 + } + ], + "Names": {}, + "Variables": {} +} \ No newline at end of file diff --git a/sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.SentimentTests/SentimentBatch.json b/sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.SentimentTests/SentimentBatch.json new file mode 100644 index 0000000000000..685c108482dd0 --- /dev/null +++ b/sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.SentimentTests/SentimentBatch.json @@ -0,0 +1,55 @@ +{ + "Entries": [ + { + "RequestUri": "/text/analytics/v2.1/sentiment", + "EncodedRequestUri": "L3RleHQvYW5hbHl0aWNzL3YyLjEvc2VudGltZW50", + "RequestMethod": "POST", + "RequestBody": "{\r\n \"documents\": [\r\n {\r\n \"language\": \"en\",\r\n \"id\": \"id\",\r\n \"text\": \"I love my team mates\"\r\n }\r\n ]\r\n}", + "RequestHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "123" + ], + "Ocp-Apim-Subscription-Key": [ + "" + ], + "User-Agent": [ + "FxVersion/4.6.25211.01", + "Microsoft.CognitiveServices.Language.TextAnalytics.TextAnalyticsAPI/1.0.0" + ] + }, + "ResponseBody": "{\r\n \"documents\": [\r\n {\r\n \"score\": 0.97380387783050537,\r\n \"id\": \"id\"\r\n }\r\n ],\r\n \"errors\": []\r\n}", + "ResponseHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Date": [ + "Wed, 30 Aug 2017 02:11:17 GMT" + ], + "Transfer-Encoding": [ + "chunked" + ], + "x-ms-transaction-count": [ + "1" + ], + "x-aml-ta-request-id": [ + "06db056b-1bf0-4994-933a-f08eacf94053" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "apim-request-id": [ + "63c5b90f-3a35-48c3-bb85-d89218d1202e" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains; preload" + ] + }, + "StatusCode": 200 + } + ], + "Names": {}, + "Variables": {} +} \ No newline at end of file diff --git a/sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.SentimentTests/SentimentBatchAsync.json b/sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.SentimentTests/SentimentBatchAsync.json new file mode 100644 index 0000000000000..685c108482dd0 --- /dev/null +++ b/sdk/cognitiveservices/Language.TextAnalytics/tests/SessionRecords/Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests.SentimentTests/SentimentBatchAsync.json @@ -0,0 +1,55 @@ +{ + "Entries": [ + { + "RequestUri": "/text/analytics/v2.1/sentiment", + "EncodedRequestUri": "L3RleHQvYW5hbHl0aWNzL3YyLjEvc2VudGltZW50", + "RequestMethod": "POST", + "RequestBody": "{\r\n \"documents\": [\r\n {\r\n \"language\": \"en\",\r\n \"id\": \"id\",\r\n \"text\": \"I love my team mates\"\r\n }\r\n ]\r\n}", + "RequestHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "123" + ], + "Ocp-Apim-Subscription-Key": [ + "" + ], + "User-Agent": [ + "FxVersion/4.6.25211.01", + "Microsoft.CognitiveServices.Language.TextAnalytics.TextAnalyticsAPI/1.0.0" + ] + }, + "ResponseBody": "{\r\n \"documents\": [\r\n {\r\n \"score\": 0.97380387783050537,\r\n \"id\": \"id\"\r\n }\r\n ],\r\n \"errors\": []\r\n}", + "ResponseHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Date": [ + "Wed, 30 Aug 2017 02:11:17 GMT" + ], + "Transfer-Encoding": [ + "chunked" + ], + "x-ms-transaction-count": [ + "1" + ], + "x-aml-ta-request-id": [ + "06db056b-1bf0-4994-933a-f08eacf94053" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "apim-request-id": [ + "63c5b90f-3a35-48c3-bb85-d89218d1202e" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains; preload" + ] + }, + "StatusCode": 200 + } + ], + "Names": {}, + "Variables": {} +} \ No newline at end of file diff --git a/sdk/cognitiveservices/Language.TextAnalytics/tests/TextAnalytics/DetectLanguageTests.cs b/sdk/cognitiveservices/Language.TextAnalytics/tests/TextAnalytics/DetectLanguageTests.cs index b15cd4fb058ff..e8c15eb3ccacb 100644 --- a/sdk/cognitiveservices/Language.TextAnalytics/tests/TextAnalytics/DetectLanguageTests.cs +++ b/sdk/cognitiveservices/Language.TextAnalytics/tests/TextAnalytics/DetectLanguageTests.cs @@ -13,15 +13,52 @@ namespace Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests { public class DetectLanguageTests : BaseTests { - [Fact(Skip = "https://github.com/Azure/azure-sdk-for-net/issues/6212")] - public async Task DetectLanguage() + [Fact] + public async Task LanguageBatchAsync() { using (MockContext context = MockContext.Start(this.GetType().FullName)) { - HttpMockServer.Initialize(this.GetType().FullName, "DetectLanguage"); + HttpMockServer.Initialize(this.GetType().FullName, "LanguageBatchAsync"); + ITextAnalyticsClient client = GetClient(HttpMockServer.CreateInstance()); + LanguageBatchResult result = await client.DetectLanguageBatchAsync( + new LanguageBatchInput( + new List() + { + new LanguageInput("en","id","I love my team mates") + })); + + Assert.Equal("English", result.Documents[0].DetectedLanguages[0].Name); + Assert.Equal("en", result.Documents[0].DetectedLanguages[0].Iso6391Name); + Assert.True(result.Documents[0].DetectedLanguages[0].Score > 0.7); + context.Stop(); + } + } + + [Fact] + public async Task DetectLanguageAsync() + { + using (MockContext context = MockContext.Start(this.GetType().FullName)) + { + HttpMockServer.Initialize(this.GetType().FullName, "DetectLanguageAsync"); ITextAnalyticsClient client = GetClient(HttpMockServer.CreateInstance()); LanguageBatchResult result = await client.DetectLanguageAsync( - null, + "I love my team mates"); + + Assert.Equal("English", result.Documents[0].DetectedLanguages[0].Name); + Assert.Equal("en", result.Documents[0].DetectedLanguages[0].Iso6391Name); + Assert.True(result.Documents[0].DetectedLanguages[0].Score > 0.7); + context.Stop(); + } + } + + [Fact] + public void DetectLanguageBatch() + { + using (MockContext context = MockContext.Start(this.GetType().FullName)) + { + HttpMockServer.Initialize(this.GetType().FullName, "DetectLanguageBatch"); + ITextAnalyticsClient client = GetClient(HttpMockServer.CreateInstance()); + LanguageBatchResult result = client.DetectLanguageBatch( new LanguageBatchInput( new List() { @@ -34,5 +71,22 @@ public async Task DetectLanguage() context.Stop(); } } + + [Fact] + public void DetectLanguage() + { + using (MockContext context = MockContext.Start(this.GetType().FullName)) + { + HttpMockServer.Initialize(this.GetType().FullName, "DetectLanguage"); + ITextAnalyticsClient client = GetClient(HttpMockServer.CreateInstance()); + LanguageBatchResult result = client.DetectLanguage( + "I love my team mates"); + + Assert.Equal("English", result.Documents[0].DetectedLanguages[0].Name); + Assert.Equal("en", result.Documents[0].DetectedLanguages[0].Iso6391Name); + Assert.True(result.Documents[0].DetectedLanguages[0].Score > 0.7); + context.Stop(); + } + } } } diff --git a/sdk/cognitiveservices/Language.TextAnalytics/tests/TextAnalytics/EntitiesTests.cs b/sdk/cognitiveservices/Language.TextAnalytics/tests/TextAnalytics/EntitiesTests.cs index 65e45fab13160..a0d1b3088d3d0 100644 --- a/sdk/cognitiveservices/Language.TextAnalytics/tests/TextAnalytics/EntitiesTests.cs +++ b/sdk/cognitiveservices/Language.TextAnalytics/tests/TextAnalytics/EntitiesTests.cs @@ -10,15 +10,61 @@ namespace Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests { public class EntitiesTests : BaseTests { - [Fact(Skip = "https://github.com/Azure/azure-sdk-for-net/issues/6212")] - public async Task Entities() + [Fact] + public async Task EntitiesBatchAsync() { using (MockContext context = MockContext.Start(this.GetType().FullName)) { - HttpMockServer.Initialize(this.GetType().FullName, "Entities"); + HttpMockServer.Initialize(this.GetType().FullName, "EntitiesBatchAsync"); + ITextAnalyticsClient client = GetClient(HttpMockServer.CreateInstance()); + EntitiesBatchResult result = await client.EntitiesBatchAsync( + new MultiLanguageBatchInput( + new List() + { + new MultiLanguageInput() + { + Id ="id", + Text ="Microsoft released Windows 10", + Language ="en" + } + })); + + Assert.Equal("Microsoft", result.Documents[0].Entities[0].Name); + Assert.Equal("a093e9b9-90f5-a3d5-c4b8-5855e1b01f85", result.Documents[0].Entities[0].BingId); + Assert.Equal("Microsoft", result.Documents[0].Entities[0].Matches[0].Text); + Assert.Equal(0.12508682244047509, result.Documents[0].Entities[0].Matches[0].WikipediaScore); + Assert.Equal(0.99999618530273438, result.Documents[0].Entities[0].Matches[0].EntityTypeScore); + context.Stop(); + } + } + + [Fact] + public async Task EntitiesAsync() + { + using (MockContext context = MockContext.Start(this.GetType().FullName)) + { + HttpMockServer.Initialize(this.GetType().FullName, "EntitiesAsync"); ITextAnalyticsClient client = GetClient(HttpMockServer.CreateInstance()); EntitiesBatchResult result = await client.EntitiesAsync( - null, + "Microsoft released Windows 10"); + + Assert.Equal("Microsoft", result.Documents[0].Entities[0].Name); + Assert.Equal("a093e9b9-90f5-a3d5-c4b8-5855e1b01f85", result.Documents[0].Entities[0].BingId); + Assert.Equal("Microsoft", result.Documents[0].Entities[0].Matches[0].Text); + Assert.Equal(0.12508682244047509, result.Documents[0].Entities[0].Matches[0].WikipediaScore); + Assert.Equal(0.99999618530273438, result.Documents[0].Entities[0].Matches[0].EntityTypeScore); + context.Stop(); + } + } + + [Fact] + public void EntitiesBatch() + { + using (MockContext context = MockContext.Start(this.GetType().FullName)) + { + HttpMockServer.Initialize(this.GetType().FullName, "EntitiesBatch"); + ITextAnalyticsClient client = GetClient(HttpMockServer.CreateInstance()); + EntitiesBatchResult result = client.EntitiesBatch( new MultiLanguageBatchInput( new List() { @@ -38,5 +84,25 @@ public async Task Entities() context.Stop(); } } + + [Fact] + public void Entities() + { + using (MockContext context = MockContext.Start(this.GetType().FullName)) + { + HttpMockServer.Initialize(this.GetType().FullName, "Entities"); + ITextAnalyticsClient client = GetClient(HttpMockServer.CreateInstance()); + EntitiesBatchResult result = client.Entities( + "Microsoft released Windows 10"); + + Assert.Equal("Microsoft", result.Documents[0].Entities[0].Name); + Assert.Equal("a093e9b9-90f5-a3d5-c4b8-5855e1b01f85", result.Documents[0].Entities[0].BingId); + Assert.Equal("Microsoft", result.Documents[0].Entities[0].Matches[0].Text); + Assert.Equal(0.12508682244047509, result.Documents[0].Entities[0].Matches[0].WikipediaScore); + Assert.Equal(0.99999618530273438, result.Documents[0].Entities[0].Matches[0].EntityTypeScore); + context.Stop(); + } + } + } } diff --git a/sdk/cognitiveservices/Language.TextAnalytics/tests/TextAnalytics/KeyPhrasesTests.cs b/sdk/cognitiveservices/Language.TextAnalytics/tests/TextAnalytics/KeyPhrasesTests.cs index 2f9e37485f7fd..7e0c158cb36d1 100644 --- a/sdk/cognitiveservices/Language.TextAnalytics/tests/TextAnalytics/KeyPhrasesTests.cs +++ b/sdk/cognitiveservices/Language.TextAnalytics/tests/TextAnalytics/KeyPhrasesTests.cs @@ -13,15 +13,51 @@ namespace Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests { public class KeyPhrasesTests : BaseTests { - [Fact(Skip = "https://github.com/Azure/azure-sdk-for-net/issues/6212")] - public async Task KeyPhrases() + [Fact] + public async Task KeyPhrasesBatchAsync() { using (MockContext context = MockContext.Start(this.GetType().FullName)) { - HttpMockServer.Initialize(this.GetType().FullName, "KeyPhrases"); + HttpMockServer.Initialize(this.GetType().FullName, "KeyPhrasesBatchAsync"); + ITextAnalyticsClient client = GetClient(HttpMockServer.CreateInstance()); + KeyPhraseBatchResult result = await client.KeyPhrasesBatchAsync( + new MultiLanguageBatchInput( + new List() + { + new MultiLanguageInput() + { + Id ="id", + Text ="I love my team mates", + Language ="en" + } + })); + + Assert.Equal("team mates", result.Documents[0].KeyPhrases[0]); + } + } + + [Fact] + public async Task KeyPhrasesAsync() + { + using (MockContext context = MockContext.Start(this.GetType().FullName)) + { + HttpMockServer.Initialize(this.GetType().FullName, "KeyPhrasesAsync"); ITextAnalyticsClient client = GetClient(HttpMockServer.CreateInstance()); KeyPhraseBatchResult result = await client.KeyPhrasesAsync( - null, + "I love my team mates"); + + Assert.Equal("team mates", result.Documents[0].KeyPhrases[0]); + } + } + + [Fact] + public void KeyPhrasesBatch() + { + using (MockContext context = MockContext.Start(this.GetType().FullName)) + { + HttpMockServer.Initialize(this.GetType().FullName, "KeyPhrasesBatch"); + ITextAnalyticsClient client = GetClient(HttpMockServer.CreateInstance()); + KeyPhraseBatchResult result = client.KeyPhrasesBatch( new MultiLanguageBatchInput( new List() { @@ -36,5 +72,20 @@ public async Task KeyPhrases() Assert.Equal("team mates", result.Documents[0].KeyPhrases[0]); } } + + [Fact] + public void KeyPhrases() + { + using (MockContext context = MockContext.Start(this.GetType().FullName)) + { + HttpMockServer.Initialize(this.GetType().FullName, "KeyPhrases"); + ITextAnalyticsClient client = GetClient(HttpMockServer.CreateInstance()); + KeyPhraseBatchResult result = client.KeyPhrases( + "I love my team mates"); + + Assert.Equal("team mates", result.Documents[0].KeyPhrases[0]); + } + } + } } diff --git a/sdk/cognitiveservices/Language.TextAnalytics/tests/TextAnalytics/SentimentTests.cs b/sdk/cognitiveservices/Language.TextAnalytics/tests/TextAnalytics/SentimentTests.cs index 97cd506dbe463..464f82262879b 100644 --- a/sdk/cognitiveservices/Language.TextAnalytics/tests/TextAnalytics/SentimentTests.cs +++ b/sdk/cognitiveservices/Language.TextAnalytics/tests/TextAnalytics/SentimentTests.cs @@ -13,15 +13,51 @@ namespace Microsoft.Azure.CognitiveServices.Language.TextAnalytics.Tests { public class SentimentTests : BaseTests { - [Fact(Skip = "https://github.com/Azure/azure-sdk-for-net/issues/6212")] - public async Task Sentiment() + [Fact] + public async Task SentimentBatchAsync() { using (MockContext context = MockContext.Start(this.GetType().FullName)) { - HttpMockServer.Initialize(this.GetType().FullName, "Sentiment"); + HttpMockServer.Initialize(this.GetType().FullName, "SentimentBatchAsync"); + ITextAnalyticsClient client = GetClient(HttpMockServer.CreateInstance()); + SentimentBatchResult result = await client.SentimentBatchAsync( + new MultiLanguageBatchInput( + new List() + { + new MultiLanguageInput() + { + Id ="id", + Text ="I love my team mates", + Language ="en" + } + })); + + Assert.True(result.Documents[0].Score > 0); + } + } + + [Fact] + public async Task SentimentAsync() + { + using (MockContext context = MockContext.Start(this.GetType().FullName)) + { + HttpMockServer.Initialize(this.GetType().FullName, "SentimentAsync"); ITextAnalyticsClient client = GetClient(HttpMockServer.CreateInstance()); SentimentBatchResult result = await client.SentimentAsync( - null, + "I love my team mates"); + + Assert.True(result.Documents[0].Score > 0); + } + } + + [Fact] + public void SentimentBatch() + { + using (MockContext context = MockContext.Start(this.GetType().FullName)) + { + HttpMockServer.Initialize(this.GetType().FullName, "SentimentBatch"); + ITextAnalyticsClient client = GetClient(HttpMockServer.CreateInstance()); + SentimentBatchResult result = client.SentimentBatch( new MultiLanguageBatchInput( new List() { @@ -36,5 +72,19 @@ public async Task Sentiment() Assert.True(result.Documents[0].Score > 0); } } + + [Fact] + public void Sentiment() + { + using (MockContext context = MockContext.Start(this.GetType().FullName)) + { + HttpMockServer.Initialize(this.GetType().FullName, "Sentiment"); + ITextAnalyticsClient client = GetClient(HttpMockServer.CreateInstance()); + SentimentBatchResult result = client.Sentiment( + "I love my team mates"); + + Assert.True(result.Documents[0].Score > 0); + } + } } }