diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/CHANGELOG.md b/sdk/textanalytics/Azure.AI.TextAnalytics/CHANGELOG.md index 02a1f20817647..75c1be5b0f649 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/CHANGELOG.md +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/CHANGELOG.md @@ -22,6 +22,7 @@ - Changed type `AnalyzeActionsOptions.IncludeStatistics` from `bool` to `bool?`. - Removed property `Statistics` from `AnalyzeActionsResult` as it is not currently returned by the service even if the user passes `IncludeStatistics = true`. - Removed property `StringIndexType` from `TextAnalyticsRequestOptions`. This SDK will keep using `UTF-16` code unit as the default encoding. +- Removed type `ExtractKeyPhrasesOptions` and respective exposure. ## 5.1.0-beta.7 (2021-05-18) ### New features diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/api/Azure.AI.TextAnalytics.netstandard2.0.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/api/Azure.AI.TextAnalytics.netstandard2.0.cs index 346cf2c1f236f..77c44855336a0 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/api/Azure.AI.TextAnalytics.netstandard2.0.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/api/Azure.AI.TextAnalytics.netstandard2.0.cs @@ -223,19 +223,17 @@ internal EntityDataSource() { } public string EntityId { get { throw null; } } public string Name { get { throw null; } } } - public partial class ExtractKeyPhrasesAction : Azure.AI.TextAnalytics.ExtractKeyPhrasesOptions + public partial class ExtractKeyPhrasesAction { public ExtractKeyPhrasesAction() { } + public bool? DisableServiceLogs { get { throw null; } set { } } + public string ModelVersion { get { throw null; } set { } } } public partial class ExtractKeyPhrasesActionResult : Azure.AI.TextAnalytics.TextAnalyticsActionResult { internal ExtractKeyPhrasesActionResult() { } public Azure.AI.TextAnalytics.ExtractKeyPhrasesResultCollection Result { get { throw null; } } } - public partial class ExtractKeyPhrasesOptions : Azure.AI.TextAnalytics.TextAnalyticsRequestOptions - { - public ExtractKeyPhrasesOptions() { } - } public partial class ExtractKeyPhrasesResult : Azure.AI.TextAnalytics.TextAnalyticsResult { internal ExtractKeyPhrasesResult() { } @@ -726,22 +724,11 @@ public TextAnalyticsClient(System.Uri endpoint, Azure.Core.TokenCredential crede public override bool Equals(object obj) { throw null; } public virtual Azure.Response ExtractKeyPhrases(string document, string language = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> ExtractKeyPhrasesAsync(string document, string language = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response ExtractKeyPhrasesBatch(System.Collections.Generic.IEnumerable documents, Azure.AI.TextAnalytics.ExtractKeyPhrasesOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public virtual Azure.Response ExtractKeyPhrasesBatch(System.Collections.Generic.IEnumerable documents, Azure.AI.TextAnalytics.TextAnalyticsRequestOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public virtual Azure.Response ExtractKeyPhrasesBatch(System.Collections.Generic.IEnumerable documents, Azure.AI.TextAnalytics.TextAnalyticsRequestOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response ExtractKeyPhrasesBatch(System.Collections.Generic.IEnumerable documents, string language = null, Azure.AI.TextAnalytics.ExtractKeyPhrasesOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public virtual Azure.Response ExtractKeyPhrasesBatch(System.Collections.Generic.IEnumerable documents, string language, Azure.AI.TextAnalytics.TextAnalyticsRequestOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> ExtractKeyPhrasesBatchAsync(System.Collections.Generic.IEnumerable documents, Azure.AI.TextAnalytics.ExtractKeyPhrasesOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public virtual System.Threading.Tasks.Task> ExtractKeyPhrasesBatchAsync(System.Collections.Generic.IEnumerable documents, Azure.AI.TextAnalytics.TextAnalyticsRequestOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public virtual System.Threading.Tasks.Task> ExtractKeyPhrasesBatchAsync(System.Collections.Generic.IEnumerable documents, Azure.AI.TextAnalytics.TextAnalyticsRequestOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> ExtractKeyPhrasesBatchAsync(System.Collections.Generic.IEnumerable documents, string language = null, Azure.AI.TextAnalytics.ExtractKeyPhrasesOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public virtual System.Threading.Tasks.Task> ExtractKeyPhrasesBatchAsync(System.Collections.Generic.IEnumerable documents, string language, Azure.AI.TextAnalytics.TextAnalyticsRequestOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response ExtractKeyPhrasesBatch(System.Collections.Generic.IEnumerable documents, Azure.AI.TextAnalytics.TextAnalyticsRequestOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response ExtractKeyPhrasesBatch(System.Collections.Generic.IEnumerable documents, string language = null, Azure.AI.TextAnalytics.TextAnalyticsRequestOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExtractKeyPhrasesBatchAsync(System.Collections.Generic.IEnumerable documents, Azure.AI.TextAnalytics.TextAnalyticsRequestOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExtractKeyPhrasesBatchAsync(System.Collections.Generic.IEnumerable documents, string language = null, Azure.AI.TextAnalytics.TextAnalyticsRequestOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override int GetHashCode() { throw null; } public virtual Azure.Response RecognizeEntities(string document, string language = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample3_ExtractKeyPhrases.md b/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample3_ExtractKeyPhrases.md index 68a93b1dfb7fc..005a18f3cf223 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample3_ExtractKeyPhrases.md +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample3_ExtractKeyPhrases.md @@ -144,7 +144,7 @@ var documents = new List new TextDocumentInput("4", string.Empty) }; -var options = new ExtractKeyPhrasesOptions { IncludeStatistics = true }; +var options = new TextAnalyticsRequestOptions { IncludeStatistics = true }; Response response = client.ExtractKeyPhrasesBatch(documents, options); ExtractKeyPhrasesResultCollection keyPhrasesInDocuments = response.Value; diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/ExtractKeyPhrasesAction.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/ExtractKeyPhrasesAction.cs index 24dbb11b98c12..15db2eeb23bb2 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/ExtractKeyPhrasesAction.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/ExtractKeyPhrasesAction.cs @@ -8,7 +8,7 @@ namespace Azure.AI.TextAnalytics /// an Extract KeyPhrases action in a set of documents. /// For example, set model version, disable service logging, and more. /// - public class ExtractKeyPhrasesAction : ExtractKeyPhrasesOptions + public class ExtractKeyPhrasesAction { /// /// Initializes a new instance of the @@ -19,5 +19,22 @@ public class ExtractKeyPhrasesAction : ExtractKeyPhrasesOptions public ExtractKeyPhrasesAction() { } + /// + /// Gets or sets a value that, if set, indicates the version of the text + /// analytics model that will be used to generate the result. For supported + /// model versions, see operation-specific documentation, for example: + /// . + /// + public string ModelVersion { get; set; } + + /// + /// The default value of this property is 'false'. This means, Text Analytics service logs your input text for 48 hours, + /// solely to allow for troubleshooting issues. + /// Setting this property to true, disables input logging and may limit our ability to investigate issues that occur. + /// + /// + /// This property only applies for and up. + /// + public bool? DisableServiceLogs { get; set; } } } diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/ExtractKeyPhrasesOptions.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/ExtractKeyPhrasesOptions.cs deleted file mode 100644 index e1ad9d9cfc304..0000000000000 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/ExtractKeyPhrasesOptions.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -namespace Azure.AI.TextAnalytics -{ - /// - /// Options that allow callers to specify details about how the operation - /// is run. For example, set model version, whether to include statistics, and more. - /// - public class ExtractKeyPhrasesOptions : TextAnalyticsRequestOptions - { - /// - /// Initializes a new instance of the - /// class which allows callers to specify details about how the operation - /// is run. For example, set model version, whether to include statistics, and more. - /// - public ExtractKeyPhrasesOptions() - { - } - } -} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsClient.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsClient.cs index 08ff97a178b65..a328a8b9a566c 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsClient.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsClient.cs @@ -1798,29 +1798,6 @@ public virtual Response ExtractKeyPhrases(string document, } } - /// - /// Runs a model to identify a collection of significant phrases - /// found in the passed-in documents. - /// For example, for the document "The food was delicious and there - /// were wonderful staff", the API returns the main talking points: "food" - /// and "wonderful staff". - /// For document length limits, maximum batch size, and supported text encoding, see - /// . - /// - /// The documents to analyze. - /// used to - /// select the version of the predictive model to run, and whether - /// statistics are returned in the response. - /// A - /// controlling the request lifetime. - /// A result containing the collection of key phrases identified - /// in each of the documents. - /// Service returned a non-success - /// status code. - [EditorBrowsable(EditorBrowsableState.Never)] - public virtual async Task> ExtractKeyPhrasesBatchAsync(IEnumerable documents, TextAnalyticsRequestOptions options, CancellationToken cancellationToken = default) => - await ExtractKeyPhrasesBatchAsync(documents, null, options, cancellationToken).ConfigureAwait(false); - /// /// Runs a model to identify a collection of significant phrases /// found in the passed-in documents. @@ -1847,68 +1824,15 @@ public virtual async Task> ExtractKe /// in each of the documents. /// Service returned a non-success /// status code. - [EditorBrowsable(EditorBrowsableState.Never)] - public virtual async Task> ExtractKeyPhrasesBatchAsync(IEnumerable documents, string language, TextAnalyticsRequestOptions options, CancellationToken cancellationToken = default) + public virtual async Task> ExtractKeyPhrasesBatchAsync(IEnumerable documents, string language = default, TextAnalyticsRequestOptions options = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(documents, nameof(documents)); - options ??= new ExtractKeyPhrasesOptions(); + options ??= new TextAnalyticsRequestOptions(); MultiLanguageBatchInput documentInputs = ConvertToMultiLanguageInputs(documents, language); return await ExtractKeyPhrasesBatchAsync(documentInputs, options, cancellationToken).ConfigureAwait(false); } - /// - /// Runs a model to identify a collection of significant phrases - /// found in the passed-in documents. - /// For example, for the document "The food was delicious and there - /// were wonderful staff", the API returns the main talking points: "food" - /// and "wonderful staff". - /// For a list of languages supported by this operation, see - /// . - /// For document length limits, maximum batch size, and supported text encoding, see - /// . - /// - /// The documents to analyze. - /// The language that all the documents are - /// written in. If unspecified, this value will be set to the default - /// language in in the request - /// sent to the service. If set to an empty string, the service will apply a model - /// where the language is explicitly set to "None". - /// used to - /// select the version of the predictive model to run, and whether - /// statistics are returned in the response. - /// A - /// controlling the request lifetime. - /// A result containing the collection of key phrases identified - /// in each of the documents. - /// Service returned a non-success - /// status code. - public virtual async Task> ExtractKeyPhrasesBatchAsync(IEnumerable documents, string language = default, ExtractKeyPhrasesOptions options = default, CancellationToken cancellationToken = default) => - await ExtractKeyPhrasesBatchAsync(documents, language, (TextAnalyticsRequestOptions)options, cancellationToken).ConfigureAwait(false); - - /// - /// Runs a model to identify a collection of significant phrases - /// found in the passed-in documents. - /// For example, for the document "The food was delicious and there - /// were wonderful staff", the API returns the main talking points: "food" - /// and "wonderful staff". - /// For document length limits, maximum batch size, and supported text encoding, see - /// . - /// - /// The documents to analyze. - /// used to - /// select the version of the predictive model to run, and whether - /// statistics are returned in the response. - /// A - /// controlling the request lifetime. - /// A result containing the collection of key phrases identified - /// in each of the documents. - /// Service returned a non-success - /// status code. - [EditorBrowsable(EditorBrowsableState.Never)] - public virtual Response ExtractKeyPhrasesBatch(IEnumerable documents, TextAnalyticsRequestOptions options, CancellationToken cancellationToken = default) => - ExtractKeyPhrasesBatch(documents, null, options, cancellationToken); - /// /// Runs a model to identify a collection of significant phrases /// found in the passed-in documents. @@ -1935,45 +1859,15 @@ public virtual Response ExtractKeyPhrasesBatc /// in each of the documents. /// Service returned a non-success /// status code. - [EditorBrowsable(EditorBrowsableState.Never)] - public virtual Response ExtractKeyPhrasesBatch(IEnumerable documents, string language, TextAnalyticsRequestOptions options, CancellationToken cancellationToken = default) + public virtual Response ExtractKeyPhrasesBatch(IEnumerable documents, string language = default, TextAnalyticsRequestOptions options = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(documents, nameof(documents)); - options ??= new ExtractKeyPhrasesOptions(); + options ??= new TextAnalyticsRequestOptions(); MultiLanguageBatchInput documentInputs = ConvertToMultiLanguageInputs(documents, language); return ExtractKeyPhrasesBatch(documentInputs, options, cancellationToken); } - /// - /// Runs a model to identify a collection of significant phrases - /// found in the passed-in documents. - /// For example, for the document "The food was delicious and there - /// were wonderful staff", the API returns the main talking points: "food" - /// and "wonderful staff". - /// For a list of languages supported by this operation, see - /// . - /// For document length limits, maximum batch size, and supported text encoding, see - /// . - /// - /// The documents to analyze. - /// The language that all the documents are - /// written in. If unspecified, this value will be set to the default - /// language in in the request - /// sent to the service. If set to an empty string, the service will apply a model - /// where the language is explicitly set to "None". - /// used to - /// select the version of the predictive model to run, and whether - /// statistics are returned in the response. - /// A - /// controlling the request lifetime. - /// A result containing the collection of key phrases identified - /// in each of the documents. - /// Service returned a non-success - /// status code. - public virtual Response ExtractKeyPhrasesBatch(IEnumerable documents, string language = default, ExtractKeyPhrasesOptions options = default, CancellationToken cancellationToken = default) => - ExtractKeyPhrasesBatch(documents, language, (TextAnalyticsRequestOptions)options, cancellationToken); - /// /// Runs a model to identify a collection of significant phrases /// found in the passed-in documents. @@ -1995,40 +1889,15 @@ public virtual Response ExtractKeyPhrasesBatc /// in each of the documents. /// Service returned a non-success /// status code. - [EditorBrowsable(EditorBrowsableState.Never)] - public virtual async Task> ExtractKeyPhrasesBatchAsync(IEnumerable documents, TextAnalyticsRequestOptions options, CancellationToken cancellationToken = default) + public virtual async Task> ExtractKeyPhrasesBatchAsync(IEnumerable documents, TextAnalyticsRequestOptions options = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(documents, nameof(documents)); - options ??= new ExtractKeyPhrasesOptions(); + options ??= new TextAnalyticsRequestOptions(); MultiLanguageBatchInput documentInputs = ConvertToMultiLanguageInputs(documents); return await ExtractKeyPhrasesBatchAsync(documentInputs, options, cancellationToken).ConfigureAwait(false); } - /// - /// Runs a model to identify a collection of significant phrases - /// found in the passed-in documents. - /// For example, for the document "The food was delicious and there - /// were wonderful staff", the API returns the main talking points: "food" - /// and "wonderful staff". - /// For a list of languages supported by this operation, see - /// . - /// For document length limits, maximum batch size, and supported text encoding, see - /// . - /// - /// The documents to analyze. - /// used to - /// select the version of the predictive model to run, and whether - /// statistics are returned in the response. - /// A - /// controlling the request lifetime. - /// A result containing the collection of key phrases identified - /// in each of the documents. - /// Service returned a non-success - /// status code. - public virtual async Task> ExtractKeyPhrasesBatchAsync(IEnumerable documents, ExtractKeyPhrasesOptions options = default, CancellationToken cancellationToken = default) => - await ExtractKeyPhrasesBatchAsync(documents, (TextAnalyticsRequestOptions)options, cancellationToken).ConfigureAwait(false); - /// /// Runs a model to identify a collection of significant phrases /// found in the passed-in documents. @@ -2051,39 +1920,15 @@ public virtual async Task> ExtractKe /// Service returned a non-success /// status code. [EditorBrowsable(EditorBrowsableState.Never)] - public virtual Response ExtractKeyPhrasesBatch(IEnumerable documents, TextAnalyticsRequestOptions options, CancellationToken cancellationToken = default) + public virtual Response ExtractKeyPhrasesBatch(IEnumerable documents, TextAnalyticsRequestOptions options = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(documents, nameof(documents)); - options ??= new ExtractKeyPhrasesOptions(); + options ??= new TextAnalyticsRequestOptions(); MultiLanguageBatchInput documentInputs = ConvertToMultiLanguageInputs(documents); return ExtractKeyPhrasesBatch(documentInputs, options, cancellationToken); } - /// - /// Runs a model to identify a collection of significant phrases - /// found in the passed-in documents. - /// For example, for the document "The food was delicious and there - /// were wonderful staff", the API returns the main talking points: "food" - /// and "wonderful staff". - /// For a list of languages supported by this operation, see - /// . - /// For document length limits, maximum batch size, and supported text encoding, see - /// . - /// - /// The documents to analyze. - /// used to - /// select the version of the predictive model to run, and whether - /// statistics are returned in the response. - /// A - /// controlling the request lifetime. - /// A result containing the collection of key phrases identified - /// in each of the documents. - /// Service returned a non-success - /// status code. - public virtual Response ExtractKeyPhrasesBatch(IEnumerable documents, ExtractKeyPhrasesOptions options = default, CancellationToken cancellationToken = default) => - ExtractKeyPhrasesBatch(documents, (TextAnalyticsRequestOptions)options, cancellationToken); - private async Task> ExtractKeyPhrasesBatchAsync(MultiLanguageBatchInput batchInput, TextAnalyticsRequestOptions options, CancellationToken cancellationToken) { using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(TextAnalyticsClient)}.{nameof(ExtractKeyPhrasesBatch)}"); diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/ExtractKeyPhrasesTests.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/ExtractKeyPhrasesTests.cs index efa6cc91b7848..726dc5418bcff 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/ExtractKeyPhrasesTests.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/ExtractKeyPhrasesTests.cs @@ -86,7 +86,7 @@ public async Task ExtractKeyPhrasesWithWarningTest() TextAnalyticsClient client = GetClient(); string document = "Anthony runs his own personal training business so thisisaverylongtokenwhichwillbetruncatedtoshowushowwarningsareemittedintheapi"; - ExtractKeyPhrasesResultCollection keyPhrasesCollection = await client.ExtractKeyPhrasesBatchAsync(new List { document }, "es", new ExtractKeyPhrasesOptions() { ModelVersion = "2020-07-01" }); + ExtractKeyPhrasesResultCollection keyPhrasesCollection = await client.ExtractKeyPhrasesBatchAsync(new List { document }, "es", new TextAnalyticsRequestOptions() { ModelVersion = "2020-07-01" }); KeyPhraseCollection keyPhrases = keyPhrasesCollection.FirstOrDefault().KeyPhrases; ValidateInDocumenResult(keyPhrases, 1); @@ -145,24 +145,6 @@ public async Task ExtractKeyPhrasesBatchConvenienceWithStatisticsTest() Assert.IsNull(options.ModelVersion); } - [RecordedTest] - public async Task ExtractKeyPhrasesBatchConvenienceWithExtractKeyPhrasesOptionsStatisticsTest() - { - var options = new ExtractKeyPhrasesOptions { IncludeStatistics = true }; - TextAnalyticsClient client = GetClient(); - var documents = batchConvenienceDocuments; - - ExtractKeyPhrasesResultCollection results = await client.ExtractKeyPhrasesBatchAsync(documents, "en", options); - - ValidateBatchDocumentsResult(results, 3, includeStatistics: true); - - Assert.AreEqual(documents.Count, results.Statistics.DocumentCount); - - // Assert the options classes since overloads were added and the original now instantiates a RecognizeEntitiesOptions. - Assert.IsTrue(options.IncludeStatistics); - Assert.IsNull(options.ModelVersion); - } - [RecordedTest] public async Task ExtractKeyPhrasesBatchTest() { @@ -192,24 +174,6 @@ public async Task ExtractKeyPhrasesBatchWithSatisticsTest() Assert.IsNull(options.ModelVersion); } - [RecordedTest] - public async Task ExtractKeyPhrasesBatchWithExtractKeyPhrasesOptionsSatisticsTest() - { - var options = new ExtractKeyPhrasesOptions { IncludeStatistics = true }; - TextAnalyticsClient client = GetClient(); - List documents = batchDocuments; - - ExtractKeyPhrasesResultCollection results = await client.ExtractKeyPhrasesBatchAsync(documents, options); - - ValidateBatchDocumentsResult(results, 3, includeStatistics: true); - - Assert.AreEqual(documents.Count, results.Statistics.DocumentCount); - - // Assert the options classes since overloads were added and the original now instantiates a RecognizeEntitiesOptions. - Assert.IsTrue(options.IncludeStatistics); - Assert.IsNull(options.ModelVersion); - } - [RecordedTest] public void ExtractKeyPhrasesBatchWithNullIdTest() { diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/ExtractKeyPhrasesTests/ExtractKeyPhrasesBatchConvenienceWithExtractKeyPhrasesOptionsStatisticsTest.json b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/ExtractKeyPhrasesTests/ExtractKeyPhrasesBatchConvenienceWithExtractKeyPhrasesOptionsStatisticsTest.json deleted file mode 100644 index e87189b3dd197..0000000000000 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/ExtractKeyPhrasesTests/ExtractKeyPhrasesBatchConvenienceWithExtractKeyPhrasesOptionsStatisticsTest.json +++ /dev/null @@ -1,86 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://mariari-westus2-s.cognitiveservices.azure.com/text/analytics/v3.1-preview.5/keyPhrases?showStats=true", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "application/json, text/json", - "Content-Length": "191", - "Content-Type": "application/json", - "Ocp-Apim-Subscription-Key": "Sanitized", - "traceparent": "00-412986168a9dff4ea64646d7a0c872cb-52c2e156de62d647-00", - "User-Agent": "azsdk-net-AI.TextAnalytics/5.1.0-alpha.20210511.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19042 )", - "x-ms-client-request-id": "4dfa2958a1568d79bc14e1b570d63d15", - "x-ms-return-client-request-id": "true" - }, - "RequestBody": { - "documents": [ - { - "id": "0", - "text": "Microsoft was founded by Bill Gates and Paul Allen.", - "language": "en" - }, - { - "id": "1", - "text": "My cat and my dog might need to see a veterinarian.", - "language": "en" - } - ] - }, - "StatusCode": 200, - "ResponseHeaders": { - "apim-request-id": "098998ab-7578-449b-b529-edeb75309508", - "Content-Type": "application/json; charset=utf-8", - "csp-billing-usage": "CognitiveServices.TextAnalytics.BatchScoring=2,CognitiveServices.TextAnalytics.TextRecords=2", - "Date": "Tue, 11 May 2021 16:08:29 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", - "Transfer-Encoding": "chunked", - "x-content-type-options": "nosniff", - "x-envoy-upstream-service-time": "11" - }, - "ResponseBody": { - "statistics": { - "documentsCount": 2, - "validDocumentsCount": 2, - "erroneousDocumentsCount": 0, - "transactionsCount": 2 - }, - "documents": [ - { - "id": "0", - "keyPhrases": [ - "Bill Gates", - "Paul Allen", - "Microsoft" - ], - "statistics": { - "charactersCount": 51, - "transactionsCount": 1 - }, - "warnings": [] - }, - { - "id": "1", - "keyPhrases": [ - "dog", - "cat", - "veterinarian" - ], - "statistics": { - "charactersCount": 51, - "transactionsCount": 1 - }, - "warnings": [] - } - ], - "errors": [], - "modelVersion": "2020-07-01" - } - } - ], - "Variables": { - "RandomSeed": "1074286074", - "TEXT_ANALYTICS_API_KEY": "Sanitized", - "TEXT_ANALYTICS_ENDPOINT": "https://mariari-westus2-s.cognitiveservices.azure.com/" - } -} \ No newline at end of file diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/ExtractKeyPhrasesTests/ExtractKeyPhrasesBatchConvenienceWithExtractKeyPhrasesOptionsStatisticsTestAsync.json b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/ExtractKeyPhrasesTests/ExtractKeyPhrasesBatchConvenienceWithExtractKeyPhrasesOptionsStatisticsTestAsync.json deleted file mode 100644 index 88fb1cb8ef5eb..0000000000000 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/ExtractKeyPhrasesTests/ExtractKeyPhrasesBatchConvenienceWithExtractKeyPhrasesOptionsStatisticsTestAsync.json +++ /dev/null @@ -1,86 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://mariari-westus2-s.cognitiveservices.azure.com/text/analytics/v3.1-preview.5/keyPhrases?showStats=true", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "application/json, text/json", - "Content-Length": "191", - "Content-Type": "application/json", - "Ocp-Apim-Subscription-Key": "Sanitized", - "traceparent": "00-c1147937f623a3459f1ae96d07906617-073ef9893b8efe46-00", - "User-Agent": "azsdk-net-AI.TextAnalytics/5.1.0-alpha.20210511.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19042 )", - "x-ms-client-request-id": "f8f1e114d697e804255315d1c7e9b6ab", - "x-ms-return-client-request-id": "true" - }, - "RequestBody": { - "documents": [ - { - "id": "0", - "text": "Microsoft was founded by Bill Gates and Paul Allen.", - "language": "en" - }, - { - "id": "1", - "text": "My cat and my dog might need to see a veterinarian.", - "language": "en" - } - ] - }, - "StatusCode": 200, - "ResponseHeaders": { - "apim-request-id": "aed3a119-4a80-4040-b5bb-e37c6fb21faa", - "Content-Type": "application/json; charset=utf-8", - "csp-billing-usage": "CognitiveServices.TextAnalytics.BatchScoring=2,CognitiveServices.TextAnalytics.TextRecords=2", - "Date": "Tue, 11 May 2021 16:08:31 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", - "Transfer-Encoding": "chunked", - "x-content-type-options": "nosniff", - "x-envoy-upstream-service-time": "11" - }, - "ResponseBody": { - "statistics": { - "documentsCount": 2, - "validDocumentsCount": 2, - "erroneousDocumentsCount": 0, - "transactionsCount": 2 - }, - "documents": [ - { - "id": "0", - "keyPhrases": [ - "Bill Gates", - "Paul Allen", - "Microsoft" - ], - "statistics": { - "charactersCount": 51, - "transactionsCount": 1 - }, - "warnings": [] - }, - { - "id": "1", - "keyPhrases": [ - "dog", - "cat", - "veterinarian" - ], - "statistics": { - "charactersCount": 51, - "transactionsCount": 1 - }, - "warnings": [] - } - ], - "errors": [], - "modelVersion": "2020-07-01" - } - } - ], - "Variables": { - "RandomSeed": "1602869274", - "TEXT_ANALYTICS_API_KEY": "Sanitized", - "TEXT_ANALYTICS_ENDPOINT": "https://mariari-westus2-s.cognitiveservices.azure.com/" - } -} \ No newline at end of file diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/ExtractKeyPhrasesTests/ExtractKeyPhrasesBatchWithExtractKeyPhrasesOptionsSatisticsTest.json b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/ExtractKeyPhrasesTests/ExtractKeyPhrasesBatchWithExtractKeyPhrasesOptionsSatisticsTest.json deleted file mode 100644 index c32d0a4894b24..0000000000000 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/ExtractKeyPhrasesTests/ExtractKeyPhrasesBatchWithExtractKeyPhrasesOptionsSatisticsTest.json +++ /dev/null @@ -1,86 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://mariari-westus2-s.cognitiveservices.azure.com/text/analytics/v3.1-preview.5/keyPhrases?showStats=true", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "application/json, text/json", - "Content-Length": "188", - "Content-Type": "application/json", - "Ocp-Apim-Subscription-Key": "Sanitized", - "traceparent": "00-9aaf956d0260ab4ba79da502968a6d37-35911a3dcc7e4943-00", - "User-Agent": "azsdk-net-AI.TextAnalytics/5.1.0-alpha.20210511.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19042 )", - "x-ms-client-request-id": "481340828d769a0d6f19ecfe6b0d9666", - "x-ms-return-client-request-id": "true" - }, - "RequestBody": { - "documents": [ - { - "id": "1", - "text": "Microsoft was founded by Bill Gates and Paul Allen.", - "language": "en" - }, - { - "id": "2", - "text": "Mi perro y mi gato tienen que ir al veterinario.", - "language": "es" - } - ] - }, - "StatusCode": 200, - "ResponseHeaders": { - "apim-request-id": "838ebe2b-c873-44f6-b10f-4f3756e713a0", - "Content-Type": "application/json; charset=utf-8", - "csp-billing-usage": "CognitiveServices.TextAnalytics.BatchScoring=2,CognitiveServices.TextAnalytics.TextRecords=2", - "Date": "Tue, 11 May 2021 16:08:30 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", - "Transfer-Encoding": "chunked", - "x-content-type-options": "nosniff", - "x-envoy-upstream-service-time": "15" - }, - "ResponseBody": { - "statistics": { - "documentsCount": 2, - "validDocumentsCount": 2, - "erroneousDocumentsCount": 0, - "transactionsCount": 2 - }, - "documents": [ - { - "id": "1", - "keyPhrases": [ - "Bill Gates", - "Paul Allen", - "Microsoft" - ], - "statistics": { - "charactersCount": 51, - "transactionsCount": 1 - }, - "warnings": [] - }, - { - "id": "2", - "keyPhrases": [ - "gato", - "perro", - "veterinario" - ], - "statistics": { - "charactersCount": 48, - "transactionsCount": 1 - }, - "warnings": [] - } - ], - "errors": [], - "modelVersion": "2020-07-01" - } - } - ], - "Variables": { - "RandomSeed": "1134123605", - "TEXT_ANALYTICS_API_KEY": "Sanitized", - "TEXT_ANALYTICS_ENDPOINT": "https://mariari-westus2-s.cognitiveservices.azure.com/" - } -} \ No newline at end of file diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/ExtractKeyPhrasesTests/ExtractKeyPhrasesBatchWithExtractKeyPhrasesOptionsSatisticsTestAsync.json b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/ExtractKeyPhrasesTests/ExtractKeyPhrasesBatchWithExtractKeyPhrasesOptionsSatisticsTestAsync.json deleted file mode 100644 index 795b870938d5a..0000000000000 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/ExtractKeyPhrasesTests/ExtractKeyPhrasesBatchWithExtractKeyPhrasesOptionsSatisticsTestAsync.json +++ /dev/null @@ -1,86 +0,0 @@ -{ - "Entries": [ - { - "RequestUri": "https://mariari-westus2-s.cognitiveservices.azure.com/text/analytics/v3.1-preview.5/keyPhrases?showStats=true", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "application/json, text/json", - "Content-Length": "188", - "Content-Type": "application/json", - "Ocp-Apim-Subscription-Key": "Sanitized", - "traceparent": "00-ced998417c3cef4ea2639a1743d24a99-e55611b2aa860d48-00", - "User-Agent": "azsdk-net-AI.TextAnalytics/5.1.0-alpha.20210511.1 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19042 )", - "x-ms-client-request-id": "fcabdefd3d51a89852601fc0d61f3468", - "x-ms-return-client-request-id": "true" - }, - "RequestBody": { - "documents": [ - { - "id": "1", - "text": "Microsoft was founded by Bill Gates and Paul Allen.", - "language": "en" - }, - { - "id": "2", - "text": "Mi perro y mi gato tienen que ir al veterinario.", - "language": "es" - } - ] - }, - "StatusCode": 200, - "ResponseHeaders": { - "apim-request-id": "14c10804-1ac7-44cb-8d83-5afc8639c0bd", - "Content-Type": "application/json; charset=utf-8", - "csp-billing-usage": "CognitiveServices.TextAnalytics.BatchScoring=2,CognitiveServices.TextAnalytics.TextRecords=2", - "Date": "Tue, 11 May 2021 16:08:32 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", - "Transfer-Encoding": "chunked", - "x-content-type-options": "nosniff", - "x-envoy-upstream-service-time": "15" - }, - "ResponseBody": { - "statistics": { - "documentsCount": 2, - "validDocumentsCount": 2, - "erroneousDocumentsCount": 0, - "transactionsCount": 2 - }, - "documents": [ - { - "id": "1", - "keyPhrases": [ - "Bill Gates", - "Paul Allen", - "Microsoft" - ], - "statistics": { - "charactersCount": 51, - "transactionsCount": 1 - }, - "warnings": [] - }, - { - "id": "2", - "keyPhrases": [ - "gato", - "perro", - "veterinario" - ], - "statistics": { - "charactersCount": 48, - "transactionsCount": 1 - }, - "warnings": [] - } - ], - "errors": [], - "modelVersion": "2020-07-01" - } - } - ], - "Variables": { - "RandomSeed": "1658669752", - "TEXT_ANALYTICS_API_KEY": "Sanitized", - "TEXT_ANALYTICS_ENDPOINT": "https://mariari-westus2-s.cognitiveservices.azure.com/" - } -} \ No newline at end of file diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/TextAnalyticsClientTests.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/TextAnalyticsClientTests.cs index b9001a3c63f5e..3f4adecbe839d 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/TextAnalyticsClientTests.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/TextAnalyticsClientTests.cs @@ -110,17 +110,9 @@ public void ExtractKeyPhrasesArgumentValidation() Assert.ThrowsAsync(() => Client.ExtractKeyPhrasesBatchAsync((TextDocumentInput[])null)); Assert.ThrowsAsync(() => Client.ExtractKeyPhrasesBatchAsync(Array.Empty())); Assert.ThrowsAsync(() => Client.ExtractKeyPhrasesBatchAsync(Array.Empty())); - Assert.ThrowsAsync(() => Client.ExtractKeyPhrasesBatchAsync((string[])null, new TextAnalyticsRequestOptions())); - Assert.ThrowsAsync(() => Client.ExtractKeyPhrasesBatchAsync((TextDocumentInput[])null, new TextAnalyticsRequestOptions())); - Assert.ThrowsAsync(() => Client.ExtractKeyPhrasesBatchAsync((string[])null, new ExtractKeyPhrasesOptions())); - Assert.ThrowsAsync(() => Client.ExtractKeyPhrasesBatchAsync(null, new ExtractKeyPhrasesOptions())); - - // Variations to ensure call-compatibility after adding method-specific options class to parameters. Assert.ThrowsAsync(() => Client.ExtractKeyPhrasesBatchAsync((string[])null, options: new TextAnalyticsRequestOptions())); Assert.ThrowsAsync(() => Client.ExtractKeyPhrasesBatchAsync((TextDocumentInput[])null, options: new TextAnalyticsRequestOptions())); Assert.ThrowsAsync(() => Client.ExtractKeyPhrasesBatchAsync(null, null, new TextAnalyticsRequestOptions())); - Assert.ThrowsAsync(() => Client.ExtractKeyPhrasesBatchAsync(null, new ExtractKeyPhrasesOptions())); - Assert.ThrowsAsync(() => Client.ExtractKeyPhrasesBatchAsync(null, null, new ExtractKeyPhrasesOptions())); } [Test] diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample3_ExtractKeyPhrasesBatch.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample3_ExtractKeyPhrasesBatch.cs index ba1c9244178e7..353908d81674d 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample3_ExtractKeyPhrasesBatch.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample3_ExtractKeyPhrasesBatch.cs @@ -57,7 +57,7 @@ The spa was clean and felt very peaceful. Overall the whole experience was great new TextDocumentInput("4", string.Empty) }; - var options = new ExtractKeyPhrasesOptions { IncludeStatistics = true }; + var options = new TextAnalyticsRequestOptions { IncludeStatistics = true }; Response response = client.ExtractKeyPhrasesBatch(documents, options); ExtractKeyPhrasesResultCollection keyPhrasesInDocuments = response.Value; diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample3_ExtractKeyPhrasesBatchAsync.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample3_ExtractKeyPhrasesBatchAsync.cs index caa5ea1e7fa00..dea65ada15f2b 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample3_ExtractKeyPhrasesBatchAsync.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample3_ExtractKeyPhrasesBatchAsync.cs @@ -57,7 +57,7 @@ The spa was clean and felt very peaceful. Overall the whole experience was great new TextDocumentInput("4", string.Empty) }; - var options = new ExtractKeyPhrasesOptions { IncludeStatistics = true }; + var options = new TextAnalyticsRequestOptions { IncludeStatistics = true }; Response response = await client.ExtractKeyPhrasesBatchAsync(documents, options); ExtractKeyPhrasesResultCollection keyPhrasesInDocuments = response.Value; diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample3_ExtractKeyPhrasesWithWarnings.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample3_ExtractKeyPhrasesWithWarnings.cs index 3f78953090be1..67396ed380cf4 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample3_ExtractKeyPhrasesWithWarnings.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample3_ExtractKeyPhrasesWithWarnings.cs @@ -4,6 +4,8 @@ using Azure.Core.TestFramework; using NUnit.Framework; using System; +using System.Collections.Generic; +using System.Linq; namespace Azure.AI.TextAnalytics.Samples { @@ -23,8 +25,9 @@ public void ExtractKeyPhrasesWithWarnings() try { - Response response = client.ExtractKeyPhrases(document); - KeyPhraseCollection keyPhrases = response.Value; + Response response = client.ExtractKeyPhrasesBatch(new List() { document }, options: new TextAnalyticsRequestOptions() { ModelVersion = "2020-07-01" }); + ExtractKeyPhrasesResultCollection keyPhrasesInDocuments = response.Value; + KeyPhraseCollection keyPhrases = keyPhrasesInDocuments.FirstOrDefault().KeyPhrases; if (keyPhrases.Warnings.Count > 0) {