diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/CHANGELOG.md b/sdk/textanalytics/Azure.AI.TextAnalytics/CHANGELOG.md index d8abb1eb35db..d053fa2b5e2f 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/CHANGELOG.md +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/CHANGELOG.md @@ -5,6 +5,8 @@ ### Features Added - Added property `SingleCategoryClassifyAction` to `TextAnalyticsActions` to support the new 'Custom Single Classification' API. This action can be used to get a custom classification for an input document or batch of documents. +- Added property `MultiCategoryClassifyAction` to `TextAnalyticsActions` to support the new 'Custom Multiple Classification' API. This action can be used to get multiple custom classifications for an input document or batch of documents. + ### Breaking Changes ### Bugs Fixed 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 bbca9d7dbb6b..5ccade399602 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 @@ -37,6 +37,7 @@ internal AnalyzeActionsResult() { } public System.Collections.Generic.IReadOnlyCollection AnalyzeSentimentResults { get { throw null; } } public System.Collections.Generic.IReadOnlyCollection ExtractKeyPhrasesResults { get { throw null; } } public System.Collections.Generic.IReadOnlyCollection ExtractSummaryResults { get { throw null; } } + public System.Collections.Generic.IReadOnlyCollection MultiCategoryClassifyResults { get { throw null; } } public System.Collections.Generic.IReadOnlyCollection RecognizeEntitiesResults { get { throw null; } } public System.Collections.Generic.IReadOnlyCollection RecognizeLinkedEntitiesResults { get { throw null; } } public System.Collections.Generic.IReadOnlyCollection RecognizePiiEntitiesResults { get { throw null; } } @@ -148,6 +149,11 @@ public readonly partial struct ClassificationCategory public string Category { get { throw null; } } public double ConfidenceScore { get { throw null; } } } + public partial class ClassificationCategoryCollection : System.Collections.ObjectModel.ReadOnlyCollection + { + internal ClassificationCategoryCollection() : base (default(System.Collections.Generic.IList)) { } + public System.Collections.Generic.IReadOnlyCollection Warnings { get { throw null; } } + } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct DetectedLanguage { @@ -429,6 +435,31 @@ public readonly partial struct LinkedEntityMatch public int Offset { get { throw null; } } public string Text { get { throw null; } } } + public partial class MultiCategoryClassifyAction + { + public MultiCategoryClassifyAction(string projectName, string deploymentName) { } + public string DeploymentName { get { throw null; } } + public bool? DisableServiceLogs { get { throw null; } set { } } + public string ProjectName { get { throw null; } } + } + public partial class MultiCategoryClassifyActionResult : Azure.AI.TextAnalytics.TextAnalyticsActionResult + { + internal MultiCategoryClassifyActionResult() { } + public Azure.AI.TextAnalytics.MultiCategoryClassifyResultCollection DocumentsResults { get { throw null; } } + } + public partial class MultiCategoryClassifyResult : Azure.AI.TextAnalytics.TextAnalyticsResult + { + internal MultiCategoryClassifyResult() { } + public Azure.AI.TextAnalytics.ClassificationCategoryCollection Classifications { get { throw null; } } + public System.Collections.Generic.IReadOnlyCollection Warnings { get { throw null; } } + } + public partial class MultiCategoryClassifyResultCollection : System.Collections.ObjectModel.ReadOnlyCollection + { + internal MultiCategoryClassifyResultCollection() : base (default(System.Collections.Generic.IList)) { } + public string DeploymentName { get { throw null; } } + public string ProjectName { get { throw null; } } + public Azure.AI.TextAnalytics.TextDocumentBatchStatistics Statistics { get { throw null; } } + } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct PiiEntity { @@ -760,7 +791,7 @@ internal SingleCategoryClassifyActionResult() { } public partial class SingleCategoryClassifyResult : Azure.AI.TextAnalytics.TextAnalyticsResult { internal SingleCategoryClassifyResult() { } - public Azure.AI.TextAnalytics.ClassificationCategory ClassificationCategory { get { throw null; } } + public Azure.AI.TextAnalytics.ClassificationCategory Classification { get { throw null; } } public System.Collections.Generic.IReadOnlyCollection Warnings { get { throw null; } } } public partial class SingleCategoryClassifyResultCollection : System.Collections.ObjectModel.ReadOnlyCollection @@ -815,6 +846,7 @@ public TextAnalyticsActions() { } public string DisplayName { get { throw null; } set { } } public System.Collections.Generic.IReadOnlyCollection ExtractKeyPhrasesActions { get { throw null; } set { } } public System.Collections.Generic.IReadOnlyCollection ExtractSummaryActions { get { throw null; } set { } } + public System.Collections.Generic.IReadOnlyCollection MultiCategoryClassifyActions { get { throw null; } set { } } public System.Collections.Generic.IReadOnlyCollection RecognizeEntitiesActions { get { throw null; } set { } } public System.Collections.Generic.IReadOnlyCollection RecognizeLinkedEntitiesActions { get { throw null; } set { } } public System.Collections.Generic.IReadOnlyCollection RecognizePiiEntitiesActions { get { throw null; } set { } } @@ -951,7 +983,7 @@ public static partial class TextAnalyticsModelFactory { [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public static Azure.AI.TextAnalytics.AnalyzeActionsResult AnalyzeActionsResult(System.Collections.Generic.IEnumerable extractKeyPhrasesActionResult, System.Collections.Generic.IEnumerable recognizeEntitiesActionResults, System.Collections.Generic.IEnumerable recognizePiiEntitiesActionResults, System.Collections.Generic.IEnumerable recognizeLinkedEntitiesActionsResults, System.Collections.Generic.IEnumerable analyzeSentimentActionsResults) { throw null; } - public static Azure.AI.TextAnalytics.AnalyzeActionsResult AnalyzeActionsResult(System.Collections.Generic.IEnumerable extractKeyPhrasesActionResults, System.Collections.Generic.IEnumerable recognizeEntitiesActionResults, System.Collections.Generic.IEnumerable recognizePiiEntitiesActionResults, System.Collections.Generic.IEnumerable recognizeLinkedEntitiesActionResults, System.Collections.Generic.IEnumerable analyzeSentimentActionResults, System.Collections.Generic.IEnumerable extractSummaryActionResults, System.Collections.Generic.IEnumerable singleCategoryClassifyActionResults) { throw null; } + public static Azure.AI.TextAnalytics.AnalyzeActionsResult AnalyzeActionsResult(System.Collections.Generic.IEnumerable extractKeyPhrasesActionResults, System.Collections.Generic.IEnumerable recognizeEntitiesActionResults, System.Collections.Generic.IEnumerable recognizePiiEntitiesActionResults, System.Collections.Generic.IEnumerable recognizeLinkedEntitiesActionResults, System.Collections.Generic.IEnumerable analyzeSentimentActionResults, System.Collections.Generic.IEnumerable extractSummaryActionResults, System.Collections.Generic.IEnumerable singleCategoryClassifyActionResults, System.Collections.Generic.IEnumerable multiCategoryClassifyActionResults) { throw null; } public static Azure.AI.TextAnalytics.AnalyzeHealthcareEntitiesResult AnalyzeHealthcareEntitiesResult(string id, Azure.AI.TextAnalytics.TextDocumentStatistics statistics, System.Collections.Generic.IEnumerable healthcareEntities, System.Collections.Generic.IEnumerable entityRelations, System.Collections.Generic.IEnumerable warnings) { throw null; } public static Azure.AI.TextAnalytics.AnalyzeHealthcareEntitiesResult AnalyzeHealthcareEntitiesResult(string id, string code, string message) { throw null; } public static Azure.AI.TextAnalytics.AnalyzeHealthcareEntitiesResultCollection AnalyzeHealthcareEntitiesResultCollection(System.Collections.Generic.IEnumerable list, Azure.AI.TextAnalytics.TextDocumentBatchStatistics statistics, string modelVersion) { throw null; } @@ -966,6 +998,7 @@ public static partial class TextAnalyticsModelFactory public static Azure.AI.TextAnalytics.CategorizedEntity CategorizedEntity(string text, string category, string subCategory, double score, int offset, int length) { throw null; } public static Azure.AI.TextAnalytics.CategorizedEntityCollection CategorizedEntityCollection(System.Collections.Generic.IList entities, System.Collections.Generic.IList warnings = null) { throw null; } public static Azure.AI.TextAnalytics.ClassificationCategory ClassificationCategory(string category, double confidenceScore) { throw null; } + public static Azure.AI.TextAnalytics.ClassificationCategoryCollection ClassificationCategoryCollection(System.Collections.Generic.IEnumerable classificationList, System.Collections.Generic.IEnumerable warnings) { throw null; } public static Azure.AI.TextAnalytics.DetectedLanguage DetectedLanguage(string name, string iso6391Name, double confidenceScore, System.Collections.Generic.IList warnings = null) { throw null; } public static Azure.AI.TextAnalytics.DetectLanguageResult DetectLanguageResult(string id, Azure.AI.TextAnalytics.TextAnalyticsError error) { throw null; } public static Azure.AI.TextAnalytics.DetectLanguageResult DetectLanguageResult(string id, Azure.AI.TextAnalytics.TextDocumentStatistics statistics, Azure.AI.TextAnalytics.DetectedLanguage detectedLanguage) { throw null; } @@ -994,6 +1027,11 @@ public static partial class TextAnalyticsModelFactory [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public static Azure.AI.TextAnalytics.LinkedEntityMatch LinkedEntityMatch(string text, double score) { throw null; } public static Azure.AI.TextAnalytics.LinkedEntityMatch LinkedEntityMatch(string text, double score, int offset, int length) { throw null; } + public static Azure.AI.TextAnalytics.MultiCategoryClassifyActionResult MultiCategoryClassifyActionResult(Azure.AI.TextAnalytics.MultiCategoryClassifyResultCollection result, System.DateTimeOffset completedOn) { throw null; } + public static Azure.AI.TextAnalytics.MultiCategoryClassifyActionResult MultiCategoryClassifyActionResult(System.DateTimeOffset completedOn, string code, string message) { throw null; } + public static Azure.AI.TextAnalytics.MultiCategoryClassifyResult MultiCategoryClassifyResult(string id, Azure.AI.TextAnalytics.TextAnalyticsError error) { throw null; } + public static Azure.AI.TextAnalytics.MultiCategoryClassifyResult MultiCategoryClassifyResult(string id, Azure.AI.TextAnalytics.TextDocumentStatistics statistics, Azure.AI.TextAnalytics.ClassificationCategoryCollection documentClassificationCollection, System.Collections.Generic.IEnumerable warnings = null) { throw null; } + public static Azure.AI.TextAnalytics.MultiCategoryClassifyResultCollection MultiCategoryClassifyResultCollection(System.Collections.Generic.IEnumerable classificationResultList, Azure.AI.TextAnalytics.TextDocumentBatchStatistics statistics, string projectName, string deploymentName) { throw null; } public static Azure.AI.TextAnalytics.PiiEntity PiiEntity(string text, string category, string subCategory, double score, int offset, int length) { throw null; } public static Azure.AI.TextAnalytics.PiiEntityCollection PiiEntityCollection(System.Collections.Generic.IEnumerable entities, string redactedText, System.Collections.Generic.IEnumerable warnings = null) { throw null; } public static Azure.AI.TextAnalytics.RecognizeEntitiesActionResult RecognizeEntitiesActionResult(Azure.AI.TextAnalytics.RecognizeEntitiesResultCollection result, System.DateTimeOffset completedOn) { throw null; } @@ -1019,7 +1057,7 @@ public static partial class TextAnalyticsModelFactory public static Azure.AI.TextAnalytics.SingleCategoryClassifyActionResult SingleCategoryClassifyActionResult(Azure.AI.TextAnalytics.SingleCategoryClassifyResultCollection result, System.DateTimeOffset completedOn) { throw null; } public static Azure.AI.TextAnalytics.SingleCategoryClassifyActionResult SingleCategoryClassifyActionResult(System.DateTimeOffset completedOn, string code, string message) { throw null; } public static Azure.AI.TextAnalytics.SingleCategoryClassifyResult SingleCategoryClassifyResult(string id, Azure.AI.TextAnalytics.TextAnalyticsError error) { throw null; } - public static Azure.AI.TextAnalytics.SingleCategoryClassifyResult SingleCategoryClassifyResult(string id, Azure.AI.TextAnalytics.TextDocumentStatistics statistics, Azure.AI.TextAnalytics.ClassificationCategory classificationCategory, System.Collections.Generic.IEnumerable warnings = null) { throw null; } + public static Azure.AI.TextAnalytics.SingleCategoryClassifyResult SingleCategoryClassifyResult(string id, Azure.AI.TextAnalytics.TextDocumentStatistics statistics, Azure.AI.TextAnalytics.ClassificationCategory classification, System.Collections.Generic.IEnumerable warnings = null) { throw null; } public static Azure.AI.TextAnalytics.SingleCategoryClassifyResultCollection SingleCategoryClassifyResultCollection(System.Collections.Generic.IEnumerable classificationResultList, Azure.AI.TextAnalytics.TextDocumentBatchStatistics statistics, string projectName, string deploymentName) { throw null; } public static Azure.AI.TextAnalytics.SummarySentence SummarySentence(string text, double rankScore, int offset, int length) { throw null; } public static Azure.AI.TextAnalytics.SummarySentenceCollection SummarySentenceCollection(System.Collections.Generic.IEnumerable sentences, System.Collections.Generic.IEnumerable warnings = null) { throw null; } diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample10_SingleCategoryClassify.md b/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample10_SingleCategoryClassify.md index d57116c89e17..b38e11c6859a 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample10_SingleCategoryClassify.md +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample10_SingleCategoryClassify.md @@ -72,7 +72,7 @@ await foreach (AnalyzeActionsResult documentsInPage in operation.Value) { foreach (SingleCategoryClassifyResult documentResults in classificationActionResults.DocumentsResults) { - Console.WriteLine($" Class category \"{documentResults.ClassificationCategory.Category}\" predicted with a confidence score of {documentResults.ClassificationCategory.ConfidenceScore}."); + Console.WriteLine($" Class category \"{documentResults.Classification.Category}\" predicted with a confidence score of {documentResults.Classification.ConfidenceScore}."); Console.WriteLine(); } } diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample11_ClassifyCustomCategories.md b/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample11_ClassifyCustomCategories.md new file mode 100644 index 000000000000..e61c664fbd92 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample11_ClassifyCustomCategories.md @@ -0,0 +1,99 @@ +# Perform Custom Multiple Category Classification in Documents +This sample demonstrates how to run a Multi Category Classification action in one or more documents. To get started you will need a Text Analytics endpoint and credentials. See [README][README] for links and instructions. + +## Creating a `TextAnalyticsClient` + +To create a new `TextAnalyticsClient` to perform a custom multi category classification on a document, you need a Text Analytics endpoint and credentials. You can use the [DefaultAzureCredential][DefaultAzureCredential] to try a number of common authentication methods optimized for both running as a service and development. In the sample below, however, you'll use a Text Analytics API key credential by creating an `AzureKeyCredential` object, that if needed, will allow you to update the API key without creating a new client. + +You can set `endpoint` and `apiKey` based on an environment variable, a configuration setting, or any way that works for your application. + +```C# Snippet:CreateTextAnalyticsClient +string endpoint = ""; +string apiKey = ""; +var client = new TextAnalyticsClient(new Uri(endpoint), new AzureKeyCredential(apiKey)); +``` + +## Performing Custom Multiple Category Classification in one or multiple documents + +To perform Multiple Category Classification in one or multiple documents, set up a `MultiCategoryClassifyAction` and call `StartAnalyzeActionsAsync` on the documents. The result is a Long Running Operation of type `AnalyzeActionsOperation` which polls for the results from the API. + +```C# Snippet:TextAnalyticsMultiCategoryClassifyAsync +// Get input document. +string document = @"I need a reservation for an indoor restaurant in China. Please don't stop the music. Play music and add it to my playlist."; + +// Prepare analyze operation input. You can add multiple documents to this list and perform the same +// operation to all of them. +var batchInput = new List +{ + document +}; + +// Set project and deployment names of the target model +string projectName = ""; +string deploymentName = ""; + +var multiCategoryClassifyAction = new MultiCategoryClassifyAction(projectName, deploymentName); + +TextAnalyticsActions actions = new TextAnalyticsActions() +{ + MultiCategoryClassifyActions = new List() { multiCategoryClassifyAction } +}; + +// Start analysis process. +AnalyzeActionsOperation operation = await client.StartAnalyzeActionsAsync(batchInput, actions); + +await operation.WaitForCompletionAsync(); +``` + +The returned `AnalyzeActionsOperation` contains general information about the status of the operation. It can be requested while the operation is running or when it has completed. For example: + +```C# Snippet:TextAnalyticsMultiCategoryClassifyOperationStatus +// View operation status. +Console.WriteLine($"AnalyzeActions operation has completed"); +Console.WriteLine(); + +Console.WriteLine($"Created On : {operation.CreatedOn}"); +Console.WriteLine($"Expires On : {operation.ExpiresOn}"); +Console.WriteLine($"Id : {operation.Id}"); +Console.WriteLine($"Status : {operation.Status}"); +Console.WriteLine($"Last Modified: {operation.LastModified}"); +Console.WriteLine(); +``` + +To view the final results of the long-running operation: + +```C# Snippet:TextAnalyticsMultiCategoryClassifyAsyncViewResults +// View operation results. +await foreach (AnalyzeActionsResult documentsInPage in operation.Value) +{ + IReadOnlyCollection multiClassificationActionResults = documentsInPage.MultiCategoryClassifyResults; + + foreach (MultiCategoryClassifyActionResult classificationActionResults in multiClassificationActionResults) + { + foreach (MultiCategoryClassifyResult documentResults in classificationActionResults.DocumentsResults) + { + if (documentResults.Classifications.Count > 0) + { + Console.WriteLine($" The following classes were predicted for this document:"); + + foreach (ClassificationCategory classification in documentResults.Classifications) + { + Console.WriteLine($" Class category \"{classification.Category}\" predicted with a confidence score of {classification.ConfidenceScore}."); + } + + Console.WriteLine(); + } + } + } +} +``` + +To see the full example source files, see: + +* [Synchronously Multi Category Classify](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample11_MultiCategoryClassify.cs) +* [Asynchronously Multi Category Classify](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample11_MultiCategoryClassifyAsync.cs) +* [Synchronously Multi Category Classify Convenience](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample11_MultiCategoryClassifyConvenience.cs) +* [Asynchronously Multi Category Classify Convenience](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample11_MultiCategoryClassifyConvenienceAsync.cs) + +[DefaultAzureCredential]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/README.md +[README]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/textanalytics/Azure.AI.TextAnalytics/README.md diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/AnalyzeActionsResult.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/AnalyzeActionsResult.cs index d2e4ea2201ce..36c5a00a87b4 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/AnalyzeActionsResult.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/AnalyzeActionsResult.cs @@ -17,7 +17,8 @@ internal AnalyzeActionsResult( IReadOnlyCollection recognizeLinkedEntitiesActionResults, IReadOnlyCollection analyzeSentimentActionResults, IReadOnlyCollection extractSummaryActionResults, - IReadOnlyCollection singleCategoryClassifyActionResults + IReadOnlyCollection singleCategoryClassifyActionResults, + IReadOnlyCollection multiCategoryClassifyActionResults ) { ExtractKeyPhrasesResults = extractKeyPhrasesActionResults; @@ -27,6 +28,7 @@ IReadOnlyCollection singleCategoryClassifyAc AnalyzeSentimentResults = analyzeSentimentActionResults; ExtractSummaryResults = extractSummaryActionResults; SingleCategoryClassifyResults = singleCategoryClassifyActionResults; + MultiCategoryClassifyResults = multiCategoryClassifyActionResults; } /// @@ -63,5 +65,10 @@ IReadOnlyCollection singleCategoryClassifyAc /// Determines the collection of . /// public IReadOnlyCollection SingleCategoryClassifyResults { get; } + + /// + /// Determines the collection of . + /// + public IReadOnlyCollection MultiCategoryClassifyResults { get; } } } diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/ClassificationCategoryCollection.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/ClassificationCategoryCollection.cs new file mode 100644 index 000000000000..6789abae4880 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/ClassificationCategoryCollection.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Linq; + +namespace Azure.AI.TextAnalytics +{ + /// + /// Collection of objects in a document, + /// and warnings encountered while processing the document. + /// + [DebuggerTypeProxy(typeof(ClassificationCategoryCollectionDebugView))] + public class ClassificationCategoryCollection : ReadOnlyCollection + { + internal ClassificationCategoryCollection(IList classificationCategories, IList warnings) + : base(classificationCategories) + { + Warnings = new ReadOnlyCollection(warnings); + } + + /// + /// Warnings encountered while processing the document. + /// + public IReadOnlyCollection Warnings { get; } + + /// + /// Debugger Proxy class for . + /// + internal class ClassificationCategoryCollectionDebugView + { + private ClassificationCategoryCollection BaseCollection { get; } + + public ClassificationCategoryCollectionDebugView(ClassificationCategoryCollection collection) + { + BaseCollection = collection; + } + + [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] + public List Items + { + get + { + return BaseCollection.ToList(); + } + } + + public IReadOnlyCollection Warnings + { + get + { + return BaseCollection.Warnings; + } + } + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/AnalyzeTasks.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/AnalyzeTasks.Serialization.cs index da14b8a0e8f9..48ad9b8bbee5 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/AnalyzeTasks.Serialization.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/AnalyzeTasks.Serialization.cs @@ -27,7 +27,7 @@ internal static AnalyzeTasks DeserializeAnalyzeTasks(JsonElement element) Optional> extractiveSummarizationTasks = default; Optional> customEntityRecognitionTasks = default; Optional> customSingleClassificationTasks = default; - Optional> customMultiClassificationTasks = default; + Optional> customMultiClassificationTasks = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("completed")) @@ -177,10 +177,10 @@ internal static AnalyzeTasks DeserializeAnalyzeTasks(JsonElement element) property.ThrowNonNullablePropertyIsNull(); continue; } - List array = new List(); + List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(TasksStateTasksCustomMultiClassificationTasksItem.DeserializeTasksStateTasksCustomMultiClassificationTasksItem(item)); + array.Add(CustomMultiClassificationTasksItem.DeserializeCustomMultiClassificationTasksItem(item)); } customMultiClassificationTasks = array; continue; diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/AnalyzeTasks.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/AnalyzeTasks.cs index 36e71d78e761..0c53c42d5576 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/AnalyzeTasks.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/AnalyzeTasks.cs @@ -32,7 +32,7 @@ internal AnalyzeTasks(int completed, int failed, int inProgress, int total) ExtractiveSummarizationTasks = new ChangeTrackingList(); CustomEntityRecognitionTasks = new ChangeTrackingList(); CustomSingleClassificationTasks = new ChangeTrackingList(); - CustomMultiClassificationTasks = new ChangeTrackingList(); + CustomMultiClassificationTasks = new ChangeTrackingList(); } /// Initializes a new instance of AnalyzeTasks. @@ -49,7 +49,7 @@ internal AnalyzeTasks(int completed, int failed, int inProgress, int total) /// /// /// - internal AnalyzeTasks(int completed, int failed, int inProgress, int total, IReadOnlyList entityRecognitionTasks, IReadOnlyList entityRecognitionPiiTasks, IReadOnlyList keyPhraseExtractionTasks, IReadOnlyList entityLinkingTasks, IReadOnlyList sentimentAnalysisTasks, IReadOnlyList extractiveSummarizationTasks, IReadOnlyList customEntityRecognitionTasks, IReadOnlyList customSingleClassificationTasks, IReadOnlyList customMultiClassificationTasks) + internal AnalyzeTasks(int completed, int failed, int inProgress, int total, IReadOnlyList entityRecognitionTasks, IReadOnlyList entityRecognitionPiiTasks, IReadOnlyList keyPhraseExtractionTasks, IReadOnlyList entityLinkingTasks, IReadOnlyList sentimentAnalysisTasks, IReadOnlyList extractiveSummarizationTasks, IReadOnlyList customEntityRecognitionTasks, IReadOnlyList customSingleClassificationTasks, IReadOnlyList customMultiClassificationTasks) { Completed = completed; Failed = failed; @@ -78,6 +78,6 @@ internal AnalyzeTasks(int completed, int failed, int inProgress, int total, IRea public IReadOnlyList ExtractiveSummarizationTasks { get; } public IReadOnlyList CustomEntityRecognitionTasks { get; } public IReadOnlyList CustomSingleClassificationTasks { get; } - public IReadOnlyList CustomMultiClassificationTasks { get; } + public IReadOnlyList CustomMultiClassificationTasks { get; } } } diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksStateTasksCustomMultiClassificationTasksItem.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomMultiClassificationTasksItem.Serialization.cs similarity index 82% rename from sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksStateTasksCustomMultiClassificationTasksItem.Serialization.cs rename to sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomMultiClassificationTasksItem.Serialization.cs index 2aeb6bd14005..ba2befd49d30 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksStateTasksCustomMultiClassificationTasksItem.Serialization.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomMultiClassificationTasksItem.Serialization.cs @@ -12,9 +12,9 @@ namespace Azure.AI.TextAnalytics.Models { - internal partial class TasksStateTasksCustomMultiClassificationTasksItem + internal partial class CustomMultiClassificationTasksItem { - internal static TasksStateTasksCustomMultiClassificationTasksItem DeserializeTasksStateTasksCustomMultiClassificationTasksItem(JsonElement element) + internal static CustomMultiClassificationTasksItem DeserializeCustomMultiClassificationTasksItem(JsonElement element) { Optional results = default; DateTimeOffset lastUpdateDateTime = default; @@ -48,7 +48,7 @@ internal static TasksStateTasksCustomMultiClassificationTasksItem DeserializeTas continue; } } - return new TasksStateTasksCustomMultiClassificationTasksItem(lastUpdateDateTime, taskName.Value, status, results.Value); + return new CustomMultiClassificationTasksItem(lastUpdateDateTime, taskName.Value, status, results.Value); } } } diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksStateTasksCustomMultiClassificationTasksItem.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomMultiClassificationTasksItem.cs similarity index 50% rename from sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksStateTasksCustomMultiClassificationTasksItem.cs rename to sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomMultiClassificationTasksItem.cs index 229186041f2c..b29ced9f4c77 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/TasksStateTasksCustomMultiClassificationTasksItem.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/CustomMultiClassificationTasksItem.cs @@ -11,21 +11,21 @@ namespace Azure.AI.TextAnalytics.Models { /// The TasksStateTasksCustomMultiClassificationTasksItem. - internal partial class TasksStateTasksCustomMultiClassificationTasksItem : TaskState + internal partial class CustomMultiClassificationTasksItem : TaskState { - /// Initializes a new instance of TasksStateTasksCustomMultiClassificationTasksItem. + /// Initializes a new instance of CustomMultiClassificationTasksItem. /// /// - internal TasksStateTasksCustomMultiClassificationTasksItem(DateTimeOffset lastUpdateDateTime, TextAnalyticsOperationStatus status) : base(lastUpdateDateTime, status) + internal CustomMultiClassificationTasksItem(DateTimeOffset lastUpdateDateTime, TextAnalyticsOperationStatus status) : base(lastUpdateDateTime, status) { } - /// Initializes a new instance of TasksStateTasksCustomMultiClassificationTasksItem. + /// Initializes a new instance of CustomMultiClassificationTasksItem. /// /// /// /// - internal TasksStateTasksCustomMultiClassificationTasksItem(DateTimeOffset lastUpdateDateTime, string taskName, TextAnalyticsOperationStatus status, CustomMultiClassificationResult results) : base(lastUpdateDateTime, taskName, status) + internal CustomMultiClassificationTasksItem(DateTimeOffset lastUpdateDateTime, string taskName, TextAnalyticsOperationStatus status, CustomMultiClassificationResult results) : base(lastUpdateDateTime, taskName, status) { Results = results; } diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/JobManifestTasks.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/JobManifestTasks.cs index 59d858f79b42..faba44bdb062 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/JobManifestTasks.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/JobManifestTasks.cs @@ -28,6 +28,5 @@ public JobManifestTasks() CustomMultiClassificationTasks = new ChangeTrackingList(); } public IList CustomEntityRecognitionTasks { get; } - public IList CustomMultiClassificationTasks { get; } } } diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Internal/CustomMultiClassificationTasksItem.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Internal/CustomMultiClassificationTasksItem.cs new file mode 100644 index 000000000000..6433d4be4679 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Internal/CustomMultiClassificationTasksItem.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; + +namespace Azure.AI.TextAnalytics.Models +{ + /// + /// CustomMultiClassificationTasksItem. + /// + [CodeGenModel("TasksStateTasksCustomMultiClassificationTasksItem")] + internal partial class CustomMultiClassificationTasksItem { } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/JobManifestTasks.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/JobManifestTasks.cs index 04d0dcc47a04..e77a931509e3 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/JobManifestTasks.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/JobManifestTasks.cs @@ -47,5 +47,10 @@ internal partial class JobManifestTasks /// CustomSingleClassificationTasks /// internal IList CustomSingleClassificationTasks { get; set; } + + /// + /// CustomMultiClassificationTasks + /// + internal IList CustomMultiClassificationTasks { get; set; } } } diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/MultiCategoryClassifyAction.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/MultiCategoryClassifyAction.cs new file mode 100644 index 000000000000..5a66ac500e7b --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/MultiCategoryClassifyAction.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Azure.AI.TextAnalytics +{ + /// + /// Configurations that allow callers to specify details about how to execute + /// a Multi Category Classification action on a set of documents. This corresponds + /// to a Multi Classification task in the Text Analytics service. + /// For example, the target project and deployment names are required + /// for a successful custom classification action. + /// + public class MultiCategoryClassifyAction + { + /// + /// Initializes a new instance of the + /// class which allows callers to specify details about how to execute + /// a Multi Category Classification action on a set of documents. + /// Sets the and properties. + /// + public MultiCategoryClassifyAction(string projectName, string deploymentName) + { + DeploymentName = deploymentName; + ProjectName = projectName; + } + + /// + /// Gets the value of the property corresponding to the name of the target project + /// + public string ProjectName { get; } + + /// + /// Gets the value of the property corresponding to the name of the target deployment. + /// + public string DeploymentName { get; } + + /// + /// 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. + /// + /// Please see Cognitive Services Compliance and Privacy notes at for additional details, + /// and Microsoft Responsible AI principles at . + /// + /// + public bool? DisableServiceLogs { get; set; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/MultiCategoryClassifyActionResult.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/MultiCategoryClassifyActionResult.cs new file mode 100644 index 000000000000..915b16652d3b --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/MultiCategoryClassifyActionResult.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Azure.AI.TextAnalytics.Models; + +namespace Azure.AI.TextAnalytics +{ + /// + /// The result of the execution of a on the input documents. + /// + public class MultiCategoryClassifyActionResult : TextAnalyticsActionResult + { + private readonly MultiCategoryClassifyResultCollection _documentsResults; + + /// + /// Successful action. + /// + internal MultiCategoryClassifyActionResult(MultiCategoryClassifyResultCollection result, DateTimeOffset completedOn) + : base(completedOn) + { + _documentsResults = result; + } + + /// + /// Action with an error. + /// + internal MultiCategoryClassifyActionResult(DateTimeOffset completedOn, TextAnalyticsErrorInternal error) + : base(completedOn, error) { } + + /// + /// Gets the result of the execution of a per each input document. + /// + public MultiCategoryClassifyResultCollection DocumentsResults + { + get + { + if (HasError) + { +#pragma warning disable CA1065 // Do not raise exceptions in unexpected locations + throw new InvalidOperationException($"Cannot access the results of this action, due to error {Error.ErrorCode}: {Error.Message}"); +#pragma warning restore CA1065 // Do not raise exceptions in unexpected locations + } + return _documentsResults; + } + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/MultiCategoryClassifyResult.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/MultiCategoryClassifyResult.cs new file mode 100644 index 000000000000..c6e48a80b28c --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/MultiCategoryClassifyResult.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; + +namespace Azure.AI.TextAnalytics +{ + /// + /// The result of the Multi Category Classification operation on a document, + /// containing the collection of objects + /// predicted for that document. + /// + public class MultiCategoryClassifyResult : TextAnalyticsResult + { + private readonly ClassificationCategoryCollection _classifications; + internal MultiCategoryClassifyResult(string id, TextDocumentStatistics statistics, ClassificationCategoryCollection classifications, IReadOnlyCollection warnings) + : base(id, statistics) + { + _classifications = classifications; + Warnings = warnings; + } + + internal MultiCategoryClassifyResult(string id, TextAnalyticsError error) : base(id, error) { } + + /// + /// Warnings encountered while processing the document. + /// + public IReadOnlyCollection Warnings { get; } + + /// + /// Gets the collection of objects predicted for the corresponding document. + /// + public ClassificationCategoryCollection Classifications + { + get + { + if (HasError) + { + throw new InvalidOperationException($"Cannot access result for document {Id}, due to error {Error.ErrorCode}: {Error.Message}"); + } + return _classifications; + } + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/MultiCategoryClassifyResultCollection.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/MultiCategoryClassifyResultCollection.cs new file mode 100644 index 000000000000..ccfa0718f423 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/MultiCategoryClassifyResultCollection.cs @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Linq; + +namespace Azure.AI.TextAnalytics +{ + /// + /// Collection of objects corresponding + /// to a batch of documents, and information about the batch operation. + /// + [DebuggerTypeProxy(typeof(MultiCategoryClassifyResultCollectionDebugView))] + public class MultiCategoryClassifyResultCollection : ReadOnlyCollection + { + internal MultiCategoryClassifyResultCollection(IList list, TextDocumentBatchStatistics statistics, + string projectName, string deploymentName) : base(list) + { + Statistics = statistics; + ProjectName = projectName; + DeploymentName = deploymentName; + } + + /// + /// Gets statistics about the documents and how it was processed + /// by the service. This property will have a value when IncludeStatistics + /// is set to true in the client call. + /// + public TextDocumentBatchStatistics Statistics { get; } + + /// + /// Gets the value of the property corresponding to the name of the + /// target project that produced these results. This should be the same + /// as the project name set when creating the + /// object used to start the operation. + /// + public string ProjectName { get; } + + /// + /// Gets the value of the property corresponding to the deployment name + /// of the project that produced these results. This should be the same + /// as the deployment name set when creating the + /// object used to start the operation. + /// + public string DeploymentName { get; } + + /// + /// Debugger Proxy class for . + /// + internal class MultiCategoryClassifyResultCollectionDebugView + { + private MultiCategoryClassifyResultCollection BaseCollection { get; } + + public MultiCategoryClassifyResultCollectionDebugView(MultiCategoryClassifyResultCollection collection) + { + BaseCollection = collection; + } + + [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] + public List Items + { + get + { + return BaseCollection.ToList(); + } + } + + public TextDocumentBatchStatistics Statistics + { + get + { + return BaseCollection.Statistics; + } + } + + public string ProjectName + { + get + { + return BaseCollection.ProjectName; + } + } + + public string DeploymentName + { + get + { + return BaseCollection.DeploymentName; + } + } + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/SingleCategoryClassifyResult.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/SingleCategoryClassifyResult.cs index 9be060734bcc..80de446f13d3 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/SingleCategoryClassifyResult.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/SingleCategoryClassifyResult.cs @@ -13,11 +13,11 @@ namespace Azure.AI.TextAnalytics /// public class SingleCategoryClassifyResult : TextAnalyticsResult { - private readonly ClassificationCategory _classificationCategory; + private readonly ClassificationCategory _classification; internal SingleCategoryClassifyResult(string id, TextDocumentStatistics statistics, ClassificationCategory classificationCategory , IReadOnlyCollection warnings) : base(id, statistics) { - _classificationCategory = classificationCategory; + _classification = classificationCategory; Warnings = warnings; } @@ -31,7 +31,7 @@ internal SingleCategoryClassifyResult(string id, TextAnalyticsError error) : bas /// /// Gets the object predicted for the corresponding document. /// - public ClassificationCategory ClassificationCategory + public ClassificationCategory Classification { get { @@ -39,7 +39,7 @@ public ClassificationCategory ClassificationCategory { throw new InvalidOperationException($"Cannot access result for document {Id}, due to error {Error.ErrorCode}: {Error.Message}"); } - return _classificationCategory; + return _classification; } } } diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsActions.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsActions.cs index 873564b79eed..7d8bb0863c6c 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsActions.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsActions.cs @@ -69,5 +69,14 @@ public TextAnalyticsActions() /// This property only applies for and up. /// public IReadOnlyCollection SingleCategoryClassifyActions { get; set; } + + /// + /// The set of that will get executed on the input documents. + /// Note that currently only one is supported. + /// + /// + /// This property only applies for and up. + /// + public IReadOnlyCollection MultiCategoryClassifyActions { get; set; } } } diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsClient.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsClient.cs index 243290efdae4..7dd19a6f1c62 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsClient.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsClient.cs @@ -2478,6 +2478,10 @@ private static JobManifestTasks CreateTasks(TextAnalyticsActions actions) { tasks.CustomSingleClassificationTasks = Transforms.ConvertFromSingleCategoryClassifyActionsToTasks(actions.SingleCategoryClassifyActions); } + if (actions.MultiCategoryClassifyActions != null) + { + tasks.CustomMultiClassificationTasks = Transforms.ConvertFromMultiCategoryClassifyActionsToTasks(actions.MultiCategoryClassifyActions); + } return tasks; } @@ -2489,7 +2493,9 @@ private static void ValidateActions(TextAnalyticsActions actions) actions.ExtractKeyPhrasesActions?.Count > 1 || actions.AnalyzeSentimentActions?.Count > 1 || actions.ExtractSummaryActions?.Count > 1 || - actions.SingleCategoryClassifyActions?.Count > 1) + actions.SingleCategoryClassifyActions?.Count > 1 || + actions.MultiCategoryClassifyActions?.Count > 1 + ) { throw new ArgumentException("Multiple of the same action is not currently supported."); } diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsModelFactory.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsModelFactory.cs index f698cca0344d..e4b8e3e147f0 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsModelFactory.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsModelFactory.cs @@ -518,18 +518,67 @@ public static SummarySentenceCollection SummarySentenceCollection(IEnumerable + /// Initializes a new instance of for mocking purposes. + /// + /// Sets the property. + /// Sets the property. + /// Sets the of . + /// Sets the collection of . + /// A new instance of for mocking purposes. + public static MultiCategoryClassifyResult MultiCategoryClassifyResult(string id, TextDocumentStatistics statistics, ClassificationCategoryCollection documentClassificationCollection, IEnumerable warnings = default) + { + return new MultiCategoryClassifyResult(id, statistics, documentClassificationCollection, warnings.ToList()); + } + + /// + /// Initializes a new instance of for mocking purposes. + /// + /// Sets the property. + /// Sets the property. + /// A new instance of for mocking purposes. + public static MultiCategoryClassifyResult MultiCategoryClassifyResult(string id, TextAnalyticsError error) + { + return new MultiCategoryClassifyResult(id, error); + } + /// + /// Initializes a new instance of for mocking purposes. + /// + /// Sets the collection of . + /// Sets the property. + /// Sets the property. + /// Sets the property. + /// A new instance of for mocking purposes. + public static MultiCategoryClassifyResultCollection MultiCategoryClassifyResultCollection(IEnumerable classificationResultList, TextDocumentBatchStatistics statistics, string projectName, string deploymentName) + { + return new MultiCategoryClassifyResultCollection(classificationResultList.ToList(), statistics, projectName, deploymentName); + } + + /// + /// Initializes a new instance of for mocking purposes. + /// + /// Sets the collection of . + /// Sets the property. + /// A new instance of for mocking purposes. + public static ClassificationCategoryCollection ClassificationCategoryCollection(IEnumerable classificationList, IEnumerable warnings) + { + return new ClassificationCategoryCollection(classificationList.ToList(), warnings.ToList()); + } + #endregion + #region Single Category Classify /// /// Initializes a new instance of for mocking purposes. /// /// Sets the property. /// Sets the property. - /// Sets the of . + /// Sets the of . /// Sets the collection of . /// A new instance of for mocking purposes. - public static SingleCategoryClassifyResult SingleCategoryClassifyResult(string id, TextDocumentStatistics statistics, ClassificationCategory classificationCategory, IEnumerable warnings = default) + public static SingleCategoryClassifyResult SingleCategoryClassifyResult(string id, TextDocumentStatistics statistics, ClassificationCategory classification, IEnumerable warnings = default) { - return new SingleCategoryClassifyResult(id, statistics, classificationCategory, warnings.ToList()); + return new SingleCategoryClassifyResult(id, statistics, classification, warnings.ToList()); } /// @@ -726,7 +775,9 @@ public static AnalyzeActionsResult AnalyzeActionsResult( recognizeLinkedEntitiesActionsResults.ToList(), analyzeSentimentActionsResults.ToList(), new List(), - new List()); + new List(), + new List() + ); } /// @@ -739,6 +790,7 @@ public static AnalyzeActionsResult AnalyzeActionsResult( /// Sets the collection of . /// Sets the collection of . /// Sets the collection of . + /// Sets the collection of . /// A new instance of for mocking purposes. public static AnalyzeActionsResult AnalyzeActionsResult( IEnumerable extractKeyPhrasesActionResults, @@ -747,7 +799,8 @@ public static AnalyzeActionsResult AnalyzeActionsResult( IEnumerable recognizeLinkedEntitiesActionResults, IEnumerable analyzeSentimentActionResults, IEnumerable extractSummaryActionResults, - IEnumerable singleCategoryClassifyActionResults + IEnumerable singleCategoryClassifyActionResults, + IEnumerable multiCategoryClassifyActionResults ) { return new AnalyzeActionsResult( @@ -757,7 +810,9 @@ IEnumerable singleCategoryClassifyActionResu recognizeLinkedEntitiesActionResults.ToList(), analyzeSentimentActionResults.ToList(), extractSummaryActionResults.ToList(), - singleCategoryClassifyActionResults.ToList()); + singleCategoryClassifyActionResults.ToList(), + multiCategoryClassifyActionResults.ToList() + ); } /// @@ -816,6 +871,34 @@ public static ExtractSummaryActionResult ExtractSummaryActionResult( return new ExtractSummaryActionResult(completedOn, new TextAnalyticsErrorInternal(code, message)); } + /// + /// Initializes a new instance of for mocking purposes. + /// + /// Sets the property. + /// Sets the property. + /// A new instance of for mocking purposes. + public static MultiCategoryClassifyActionResult MultiCategoryClassifyActionResult( + MultiCategoryClassifyResultCollection result, + DateTimeOffset completedOn) + { + return new MultiCategoryClassifyActionResult(result, completedOn); + } + + /// + /// Initializes a new instance of for mocking purposes. + /// + /// Sets the property. + /// Sets the property. + /// Sets the property. + /// A new instance of for mocking purposes. + public static MultiCategoryClassifyActionResult MultiCategoryClassifyActionResult( + DateTimeOffset completedOn, + string code, + string message) + { + return new MultiCategoryClassifyActionResult(completedOn, new TextAnalyticsErrorInternal(code, message)); + } + /// /// Initializes a new instance of for mocking purposes. /// @@ -843,6 +926,7 @@ public static SingleCategoryClassifyActionResult SingleCategoryClassifyActionRes { return new SingleCategoryClassifyActionResult(completedOn, new TextAnalyticsErrorInternal(code, message)); } + /// /// Initializes a new instance of for mocking purposes. /// diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Transforms.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Transforms.cs index 0bca2de36643..aa55d4ae31c1 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Transforms.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Transforms.cs @@ -351,6 +351,37 @@ internal static ExtractSummaryResultCollection ConvertToExtractSummaryResultColl #endregion + #region Multi Category Classify + internal static List ConvertToClassificationCategoryList(List classifications) + => classifications.Select((classification) => new ClassificationCategory(classification)).ToList(); + + internal static ClassificationCategoryCollection ConvertToClassificationCategoryCollection(MultiClassificationDocument extractedClassificationsDocuments) + { + return new ClassificationCategoryCollection(ConvertToClassificationCategoryList(extractedClassificationsDocuments.Classifications.ToList()), ConvertToWarnings(extractedClassificationsDocuments.Warnings)); + } + + internal static MultiCategoryClassifyResultCollection ConvertToMultiCategoryClassifyResultCollection(CustomMultiClassificationResult results, IDictionary idToIndexMap) + { + var classifiedCustomCategoryResults = new List(); + + //Read errors + foreach (DocumentError error in results.Errors) + { + classifiedCustomCategoryResults.Add(new MultiCategoryClassifyResult(error.Id, ConvertToError(error.Error))); + } + + //Read classifications + foreach (MultiClassificationDocument classificationsDocument in results.Documents) + { + classifiedCustomCategoryResults.Add(new MultiCategoryClassifyResult(classificationsDocument.Id, classificationsDocument.Statistics ?? default, ConvertToClassificationCategoryCollection(classificationsDocument), ConvertToWarnings(classificationsDocument.Warnings))); + } + + classifiedCustomCategoryResults = SortHeterogeneousCollection(classifiedCustomCategoryResults, idToIndexMap); + + return new MultiCategoryClassifyResultCollection(classifiedCustomCategoryResults, results.Statistics, results.ProjectName, results.DeploymentName); + } + #endregion + #region SingleCategoryClassifyResult internal static SingleCategoryClassifyResultCollection ConvertToSingleCategoryClassifyResultCollection(CustomSingleClassificationResult results, IDictionary idToIndexMap) { @@ -463,6 +494,7 @@ internal static ExtractiveSummarizationTask ConvertToExtractiveSummarizationTask } }; } + internal static CustomSingleClassificationTask ConvertToCustomSingleClassificationTask(SingleCategoryClassifyAction action) { return new CustomSingleClassificationTask() @@ -474,6 +506,17 @@ internal static CustomSingleClassificationTask ConvertToCustomSingleClassificati }; } + internal static CustomMultiClassificationTask ConvertToCustomMultiClassificationTask(MultiCategoryClassifyAction action) + { + return new CustomMultiClassificationTask() + { + Parameters = new CustomMultiClassificationTaskParameters(action.ProjectName, action.DeploymentName) + { + LoggingOptOut = action.DisableServiceLogs, + } + }; + } + internal static IList ConvertFromRecognizeLinkedEntitiesActionsToTasks(IReadOnlyCollection recognizeLinkedEntitiesActions) { List list = new List(); @@ -545,6 +588,17 @@ internal static IList ConvertFromExtractSummaryActi return list; } + internal static IList ConvertFromMultiCategoryClassifyActionsToTasks(IReadOnlyCollection MultiCategoryClassifyActions) + { + List list = new List(); + + foreach (MultiCategoryClassifyAction action in MultiCategoryClassifyActions) + { + list.Add(ConvertToCustomMultiClassificationTask(action)); + } + + return list; + } internal static IList ConvertFromSingleCategoryClassifyActionsToTasks(IReadOnlyCollection singleCategoryClassifyActions) { @@ -564,7 +618,7 @@ private static string[] parseActionErrorTarget(string targetReference) { throw new InvalidOperationException("Expected an error with a target field referencing an action but did not get one"); } - Regex _targetRegex = new Regex("#/tasks/(keyPhraseExtractionTasks|entityRecognitionPiiTasks|entityRecognitionTasks|entityLinkingTasks|sentimentAnalysisTasks|extractiveSummarizationTasks|customSingleClassificationTasks)/(\\d+)", RegexOptions.Compiled, TimeSpan.FromSeconds(2)); + Regex _targetRegex = new Regex("#/tasks/(keyPhraseExtractionTasks|entityRecognitionPiiTasks|entityRecognitionTasks|entityLinkingTasks|sentimentAnalysisTasks|extractiveSummarizationTasks|customSingleClassificationTasks|customMultiClassificationTasks)/(\\d+)", RegexOptions.Compiled, TimeSpan.FromSeconds(2)); // action could be failed and the target reference is "#/tasks/keyPhraseExtractionTasks/0"; Match targetMatch = _targetRegex.Match(targetReference); @@ -588,6 +642,7 @@ internal static AnalyzeActionsResult ConvertToAnalyzeActionsResult(AnalyzeJobSta IDictionary analyzeSentimentErrors = new Dictionary(); IDictionary extractSummaryErrors = new Dictionary(); IDictionary singleCategoryClassifyErrors = new Dictionary(); + IDictionary multiCategoryClassifyErrors = new Dictionary(); if (jobState.Errors.Any()) { @@ -628,6 +683,10 @@ internal static AnalyzeActionsResult ConvertToAnalyzeActionsResult(AnalyzeJobSta { singleCategoryClassifyErrors.Add(taskIndex, error); } + else if ("customMultiClassificationTasks".Equals(taskName)) + { + multiCategoryClassifyErrors.Add(taskIndex, error); + } else { throw new InvalidOperationException($"Invalid task name in target reference - {taskName}. \n Additional information: Error code: {error.Code} Error message: {error.Message}"); @@ -642,7 +701,31 @@ internal static AnalyzeActionsResult ConvertToAnalyzeActionsResult(AnalyzeJobSta ConvertToRecognizeLinkedEntitiesActionsResults(jobState, map, entitiesLinkingRecognitionErrors), ConvertToAnalyzeSentimentActionsResults(jobState, map, analyzeSentimentErrors), ConvertToExtractSummaryActionsResults(jobState, map, extractSummaryErrors), - ConvertToSingleCategoryClassifyResults(jobState, map, singleCategoryClassifyErrors)); + ConvertToSingleCategoryClassifyResults(jobState, map, singleCategoryClassifyErrors), + ConvertToMultiCategoryClassifyActionsResults(jobState, map, multiCategoryClassifyErrors) + ); + } + + private static IReadOnlyCollection ConvertToMultiCategoryClassifyActionsResults(AnalyzeJobState jobState, IDictionary idToIndexMap, IDictionary tasksErrors) + { + var collection = new List(); + int index = 0; + foreach (CustomMultiClassificationTasksItem task in jobState.Tasks.CustomMultiClassificationTasks) + { + tasksErrors.TryGetValue(index, out TextAnalyticsErrorInternal taskError); + + if (taskError != null) + { + collection.Add(new MultiCategoryClassifyActionResult(task.LastUpdateDateTime, taskError)); + } + else + { + collection.Add(new MultiCategoryClassifyActionResult(ConvertToMultiCategoryClassifyResultCollection(task.Results, idToIndexMap), task.LastUpdateDateTime)); + } + index++; + } + + return collection; } private static IReadOnlyCollection ConvertToSingleCategoryClassifyResults(AnalyzeJobState jobState, IDictionary idToIndexMap, IDictionary tasksErrors) diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/AnalyzeOperationMockTests.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/AnalyzeOperationMockTests.cs index 8f50e33d4277..69b04b7f92b3 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/AnalyzeOperationMockTests.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/AnalyzeOperationMockTests.cs @@ -776,6 +776,72 @@ public void AnalyzeOperationExtractSummaryWithTwoActions() #endregion Extract summary + #region Multi Category Classify + + [Test] + public async Task AnalyzeOperationMultiCategoryClassifyWithDisableServiceLogs() + { + var mockResponse = new MockResponse(202); + mockResponse.AddHeader(new HttpHeader("Operation-Location", "something/jobs/2a96a91f-7edf-4931-a880-3fdee1d56f15")); + + var mockTransport = new MockTransport(new[] { mockResponse, mockResponse }); + var client = CreateTestClient(mockTransport); + + var documents = new List + { + "Elon Musk is the CEO of SpaceX and Tesla." + }; + + var actions = new MultiCategoryClassifyAction(FakeProjectName, FakeDeploymentName) + { + DisableServiceLogs = true + }; + + TextAnalyticsActions batchActions = new TextAnalyticsActions() + { + MultiCategoryClassifyActions = new List() { actions }, + }; + + await client.StartAnalyzeActionsAsync(documents, batchActions); + + var contentString = GetString(mockTransport.Requests.Single().Content); + string logging = contentString.Substring(contentString.IndexOf("loggingOptOut"), 19); + + var expectedContent = "loggingOptOut\":true"; + Assert.AreEqual(expectedContent, logging); + } + + [Test] + public void AnalyzeOperationMultiCategoryClassifyWithTwoActions() + { + var mockResponse = new MockResponse(202); + mockResponse.AddHeader(new HttpHeader("Operation-Location", "something/jobs/2a96a91f-7edf-4931-a880-3fdee1d56f15")); + + var mockTransport = new MockTransport(new[] { mockResponse, mockResponse }); + var client = CreateTestClient(mockTransport); + + var documents = new List + { + "Elon Musk is the CEO of SpaceX and Tesla." + }; + + TextAnalyticsActions batchActions = new() + { + MultiCategoryClassifyActions = new List() + { + new MultiCategoryClassifyAction(FakeProjectName, FakeDeploymentName), + new MultiCategoryClassifyAction(FakeProjectName, FakeDeploymentName) + { + DisableServiceLogs = true + } + }, + }; + + ArgumentException ex = Assert.ThrowsAsync(async () => await client.StartAnalyzeActionsAsync(documents, batchActions)); + Assert.AreEqual("Multiple of the same action is not currently supported.", ex.Message); + } + #endregion + #region Single Category Classify [Test] @@ -888,6 +954,11 @@ public async Task AnalyzeOperationWithActionsError() ""code"": ""InvalidRequest"", ""message"": ""Some error"", ""target"": ""#/tasks/customSingleClassificationTasks/0"" + }, + { + ""code"": ""InvalidRequest"", + ""message"": ""Some error"", + ""target"": ""#/tasks/customMultiClassificationTasks/0"" } ], ""tasks"": { @@ -941,7 +1012,14 @@ public async Task AnalyzeOperationWithActionsError() ""state"": ""failed"" } ], - ""customSingleClassificationTasks"": [ + ""customSingleClassificationTasks"": [ + { + ""lastUpdateDateTime"": ""2021-03-03T22:39:37.1716697Z"", + ""taskName"": ""something"", + ""state"": ""failed"" + } + ], + ""customMultiClassificationTasks"": [ { ""lastUpdateDateTime"": ""2021-03-03T22:39:37.1716697Z"", ""taskName"": ""something"", @@ -971,6 +1049,7 @@ public async Task AnalyzeOperationWithActionsError() AnalyzeSentimentActions = new List() { new AnalyzeSentimentAction() }, ExtractSummaryActions = new List() { new ExtractSummaryAction() }, SingleCategoryClassifyActions = new List { new SingleCategoryClassifyAction(FakeProjectName, FakeDeploymentName)}, + MultiCategoryClassifyActions = new List() { new MultiCategoryClassifyAction(FakeProjectName, FakeDeploymentName) }, DisplayName = "AnalyzeOperationBatchWithErrorTest" }; @@ -992,6 +1071,7 @@ public async Task AnalyzeOperationWithActionsError() AnalyzeSentimentActionResult analyzeSentimentActionsResults = resultCollection.AnalyzeSentimentResults.FirstOrDefault(); ExtractSummaryActionResult extractSummaryActionsResults = resultCollection.ExtractSummaryResults.FirstOrDefault(); SingleCategoryClassifyActionResult singleCategoryClassifyActionResult = resultCollection.SingleCategoryClassifyResults.FirstOrDefault(); + MultiCategoryClassifyActionResult multiCategoryClassifyActionResult = resultCollection.MultiCategoryClassifyResults.FirstOrDefault(); Assert.IsTrue(entitiesActionsResults.HasError); Assert.Throws(() => entitiesActionsResults.DocumentsResults.GetType()); @@ -1013,6 +1093,9 @@ public async Task AnalyzeOperationWithActionsError() Assert.IsTrue(singleCategoryClassifyActionResult.HasError); Assert.Throws(() => singleCategoryClassifyActionResult.DocumentsResults.GetType()); + + Assert.IsTrue(multiCategoryClassifyActionResult.HasError); + Assert.Throws(() => multiCategoryClassifyActionResult.DocumentsResults.GetType()); } [Test] diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/AnalyzeOperationTests.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/AnalyzeOperationTests.cs index 39c7a721e43d..3ec5a33cd82c 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/AnalyzeOperationTests.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/AnalyzeOperationTests.cs @@ -84,6 +84,7 @@ public async Task AnalyzeOperationTest() IReadOnlyCollection analyzeSentimentActionsResults = resultCollection.AnalyzeSentimentResults; IReadOnlyCollection extractSummaryActionsResults = resultCollection.ExtractSummaryResults; IReadOnlyCollection singleCategoryClassifyResults = resultCollection.SingleCategoryClassifyResults; + IReadOnlyCollection multiCategoryClassifyResults = resultCollection.MultiCategoryClassifyResults; Assert.IsNotNull(keyPhrasesActionsResults); Assert.IsNotNull(entitiesActionsResults); @@ -92,6 +93,7 @@ public async Task AnalyzeOperationTest() Assert.IsNotNull(analyzeSentimentActionsResults); Assert.IsNotNull(extractSummaryActionsResults); Assert.IsNotNull(singleCategoryClassifyResults); + Assert.IsNotNull(multiCategoryClassifyResults); var keyPhrasesListId1 = new List { "CEO", "SpaceX", "Elon Musk", "Tesla" }; var keyPhrasesListId2 = new List { "Tesla stock" }; diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/Infrastructure/TextAnalyticsTestEnvironment.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/Infrastructure/TextAnalyticsTestEnvironment.cs index 11c2ad2b7925..9404d52f6e81 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/Infrastructure/TextAnalyticsTestEnvironment.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/Infrastructure/TextAnalyticsTestEnvironment.cs @@ -11,5 +11,7 @@ public class TextAnalyticsTestEnvironment: TestEnvironment public string ApiKey => GetRecordedVariable("TEXT_ANALYTICS_API_KEY", options => options.IsSecret()); public string SingleClassificationProjectName = "659c1851-be0b-4142-b12a-087da9785926"; public string SingleClassificationDeploymentName = "659c1851-be0b-4142-b12a-087da9785926"; + public string MultiClassificationProjectName = "7cdace98-537b-494a-b69a-c19754718025"; + public string MultiClassificationDeploymentName = "7cdace98-537b-494a-b69a-c19754718025"; } } diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/MultiCategoryClassifyTests.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/MultiCategoryClassifyTests.cs new file mode 100644 index 000000000000..3d9a1e1a23ab --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/MultiCategoryClassifyTests.cs @@ -0,0 +1,266 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Azure.Core.TestFramework; +using NUnit.Framework; + +namespace Azure.AI.TextAnalytics.Tests +{ + [ServiceVersion(Min = TextAnalyticsClientOptions.ServiceVersion.V3_2_Preview_2)] + public class MultiCategoryClassifyTests : TextAnalyticsClientLiveTestBase + { + public MultiCategoryClassifyTests(bool isAsync, TextAnalyticsClientOptions.ServiceVersion serviceVersion) + : base(isAsync, serviceVersion) + { + } + + private const string MultiCategoryClassifyDocument1 = + "I need a reservation for an indoor restaurant in China. Please don't stop the music. Play music and add it to my playlist"; + + private const string MultiCategoryClassifyDocument2 = + "David Schmidt, senior vice president--Food Safety, International Food Information Council (IFIC), Washington, D.C., discussed the physical activity component."; + + private static readonly List s_multiCategoryClassifyBatchConvenienceDocuments = new List + { + MultiCategoryClassifyDocument1, + MultiCategoryClassifyDocument2 + }; + + private static List s_multiCategoryClassifyBatchDocuments = new List + { + new TextDocumentInput("1", MultiCategoryClassifyDocument1) + { + Language = "en", + }, + new TextDocumentInput("2", MultiCategoryClassifyDocument2) + { + Language = "en", + } + }; + + [RecordedTest] + public async Task MultiCategoryClassifyWithDisableServiceLogs() + { + TextAnalyticsClient client = GetClient(); + + TextAnalyticsActions batchActions = new TextAnalyticsActions() + { + MultiCategoryClassifyActions = new List() { new MultiCategoryClassifyAction(TestEnvironment.MultiClassificationProjectName, TestEnvironment.MultiClassificationDeploymentName) { DisableServiceLogs = true } } + }; + + AnalyzeActionsOperation operation = await client.StartAnalyzeActionsAsync(s_multiCategoryClassifyBatchConvenienceDocuments, batchActions); + + await operation.WaitForCompletionAsync(); + + // Take the first page + AnalyzeActionsResult resultCollection = operation.Value.ToEnumerableAsync().Result.FirstOrDefault(); + + IReadOnlyCollection multiCategoryClassifyActionsResults = resultCollection.MultiCategoryClassifyResults; + + Assert.IsNotNull(multiCategoryClassifyActionsResults); + Assert.AreEqual(2, multiCategoryClassifyActionsResults.FirstOrDefault().DocumentsResults.Count); + } + + [RecordedTest] + public async Task MultiCategoryClassifyBatchWithErrorTest() + { + TextAnalyticsClient client = GetClient(); + + var documents = new List + { + "Subject is taking 100mg of ibuprofen twice daily", + "", + }; + TextAnalyticsActions batchActions = new TextAnalyticsActions() + { + MultiCategoryClassifyActions = new List() + { + new MultiCategoryClassifyAction(TestEnvironment.MultiClassificationProjectName, TestEnvironment.MultiClassificationDeploymentName) + } + }; + + AnalyzeActionsOperation operation = await client.StartAnalyzeActionsAsync(documents, batchActions, "en"); + await operation.WaitForCompletionAsync(); + + // Take the first page + AnalyzeActionsResult resultCollection = operation.Value.ToEnumerableAsync().Result.FirstOrDefault(); + + List multiCategoryClassifyActions = resultCollection.MultiCategoryClassifyResults.ToList(); + + Assert.AreEqual(1, multiCategoryClassifyActions.Count); + + MultiCategoryClassifyResultCollection documentsResults = multiCategoryClassifyActions[0].DocumentsResults; + Assert.IsFalse(documentsResults[0].HasError); + Assert.IsTrue(documentsResults[1].HasError); + Assert.AreEqual(TextAnalyticsErrorCode.InvalidDocument, documentsResults[1].Error.ErrorCode.ToString()); + } + + [RecordedTest] + public async Task MultiCategoryClassifyBatchConvenienceTest() + { + TextAnalyticsClient client = GetClient(); + + TextAnalyticsActions batchActions = new TextAnalyticsActions() + { + MultiCategoryClassifyActions = new List() + { + new MultiCategoryClassifyAction(TestEnvironment.MultiClassificationProjectName, TestEnvironment.MultiClassificationDeploymentName) + } + }; + + AnalyzeActionsOperation operation = await client.StartAnalyzeActionsAsync(s_multiCategoryClassifyBatchConvenienceDocuments, batchActions); + + await operation.WaitForCompletionAsync(); + + // Take the first page + AnalyzeActionsResult resultCollection = operation.Value.ToEnumerableAsync().Result.FirstOrDefault(); + + IReadOnlyCollection multiCategoryClassifyActionsResults = resultCollection.MultiCategoryClassifyResults; + MultiCategoryClassifyResultCollection multiCategoryClassifyResults = multiCategoryClassifyActionsResults.FirstOrDefault().DocumentsResults; + + ValidateSummaryBatchResult(multiCategoryClassifyResults); + } + + [RecordedTest] + public async Task MultiCategoryClassifyBatchConvenienceWithStatisticsTest() + { + TextAnalyticsClient client = GetClient(); + + TextAnalyticsActions batchActions = new TextAnalyticsActions() + { + MultiCategoryClassifyActions = new List() + { + new MultiCategoryClassifyAction(TestEnvironment.MultiClassificationProjectName, TestEnvironment.MultiClassificationDeploymentName) + } + }; + + AnalyzeActionsOptions options = new AnalyzeActionsOptions() + { + IncludeStatistics = true + }; + + AnalyzeActionsOperation operation = await client.StartAnalyzeActionsAsync(s_multiCategoryClassifyBatchConvenienceDocuments, batchActions, "en", options); + + await operation.WaitForCompletionAsync(); + + // Take the first page + AnalyzeActionsResult resultCollection = operation.Value.ToEnumerableAsync().Result.FirstOrDefault(); + + IReadOnlyCollection multiCategoryClassifyActionsResults = resultCollection.MultiCategoryClassifyResults; + MultiCategoryClassifyResultCollection multiCategoryClassifyResults = multiCategoryClassifyActionsResults.FirstOrDefault().DocumentsResults; + + ValidateSummaryBatchResult(multiCategoryClassifyResults, includeStatistics: true); + } + + [RecordedTest] + public async Task MultiCategoryClassifyBatchTest() + { + TextAnalyticsClient client = GetClient(); + + TextAnalyticsActions batchActions = new TextAnalyticsActions() + { + MultiCategoryClassifyActions = new List() + { + new MultiCategoryClassifyAction(TestEnvironment.MultiClassificationProjectName, TestEnvironment.MultiClassificationDeploymentName) + } + }; + + AnalyzeActionsOperation operation = await client.StartAnalyzeActionsAsync(s_multiCategoryClassifyBatchDocuments, batchActions); + + await operation.WaitForCompletionAsync(); + + // Take the first page + AnalyzeActionsResult resultCollection = operation.Value.ToEnumerableAsync().Result.FirstOrDefault(); + + IReadOnlyCollection multiCategoryClassifyActionsResults = resultCollection.MultiCategoryClassifyResults; + MultiCategoryClassifyResultCollection multiCategoryClassifyResults = multiCategoryClassifyActionsResults.FirstOrDefault().DocumentsResults; + + ValidateSummaryBatchResult(multiCategoryClassifyResults); + } + + [RecordedTest] + public async Task MultiCategoryClassifyBatchWithStatisticsTest() + { + TextAnalyticsClient client = GetClient(); + + TextAnalyticsActions batchActions = new TextAnalyticsActions() + { + MultiCategoryClassifyActions = new List() + { + new MultiCategoryClassifyAction(TestEnvironment.MultiClassificationProjectName, TestEnvironment.MultiClassificationDeploymentName) + } + }; + + AnalyzeActionsOptions options = new AnalyzeActionsOptions() + { + IncludeStatistics = true + }; + + AnalyzeActionsOperation operation = await client.StartAnalyzeActionsAsync(s_multiCategoryClassifyBatchDocuments, batchActions, options); + + await operation.WaitForCompletionAsync(); + + // Take the first page + AnalyzeActionsResult resultCollection = operation.Value.ToEnumerableAsync().Result.FirstOrDefault(); + + IReadOnlyCollection multiCategoryClassifyActionsResults = resultCollection.MultiCategoryClassifyResults; + MultiCategoryClassifyResultCollection multiCategoryClassifyResults = multiCategoryClassifyActionsResults.FirstOrDefault().DocumentsResults; + + ValidateSummaryBatchResult(multiCategoryClassifyResults, includeStatistics: true); + } + + private void ValidateSummaryDocumentResult(ClassificationCategoryCollection classificationCollection) + { + Assert.IsNotNull(classificationCollection.Warnings); + + foreach (var classification in classificationCollection) + { + Assert.GreaterOrEqual(classification.ConfidenceScore, 0); + Assert.LessOrEqual(classification.ConfidenceScore, 1); + Assert.NotNull(classification.Category); + } + } + + private void ValidateSummaryBatchResult(MultiCategoryClassifyResultCollection results, bool includeStatistics = false) + { + Assert.AreEqual(results.ProjectName, TestEnvironment.MultiClassificationProjectName); + Assert.AreEqual(results.DeploymentName, TestEnvironment.MultiClassificationDeploymentName); + + if (includeStatistics) + { + Assert.IsNotNull(results.Statistics); + Assert.Greater(results.Statistics.DocumentCount, 0); + Assert.Greater(results.Statistics.TransactionCount, 0); + Assert.GreaterOrEqual(results.Statistics.InvalidDocumentCount, 0); + Assert.GreaterOrEqual(results.Statistics.ValidDocumentCount, 0); + } + else + { + Assert.IsNull(results.Statistics); + } + + foreach (MultiCategoryClassifyResult result in results) + { + Assert.That(result.Id, Is.Not.Null.And.Not.Empty); + Assert.False(result.HasError); + Assert.IsNotNull(result.Warnings); + + if (includeStatistics) + { + Assert.GreaterOrEqual(result.Statistics.CharacterCount, 0); + Assert.Greater(result.Statistics.TransactionCount, 0); + } + else + { + Assert.AreEqual(0, result.Statistics.CharacterCount); + Assert.AreEqual(0, result.Statistics.TransactionCount); + } + + ValidateSummaryDocumentResult(result.Classifications); + } + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/MultiCategoryClassifyTests/MultiCategoryClassifyBatchConvenienceTest.json b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/MultiCategoryClassifyTests/MultiCategoryClassifyBatchConvenienceTest.json new file mode 100644 index 000000000000..3e97be1218ea --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/MultiCategoryClassifyTests/MultiCategoryClassifyBatchConvenienceTest.json @@ -0,0 +1,266 @@ +{ + "Entries": [ + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Content-Length": "564", + "Content-Type": "application/json", + "Ocp-Apim-Subscription-Key": "Sanitized", + "traceparent": "00-02d73dabfeb1c24eb4b415c279c5000a-fabdf2988567034a-00", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "f239d83ee3161157ec92517fefbbda7e", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": { + "analysisInput": { + "documents": [ + { + "id": "0", + "text": "I need a reservation for an indoor restaurant in China. Please don\u0027t stop the music. Play music and add it to my playlist", + "language": "en" + }, + { + "id": "1", + "text": "David Schmidt, senior vice president--Food Safety, International Food Information Council (IFIC), Washington, D.C., discussed the physical activity component.", + "language": "en" + } + ] + }, + "tasks": { + "customMultiClassificationTasks": [ + { + "parameters": { + "project-name": "7cdace98-537b-494a-b69a-c19754718025", + "deployment-name": "7cdace98-537b-494a-b69a-c19754718025" + } + } + ] + } + }, + "StatusCode": 202, + "ResponseHeaders": { + "apim-request-id": "ad99d7d4-90ed-4e2f-a4c9-a116eb5ab489", + "Date": "Sun, 26 Sep 2021 18:37:39 GMT", + "operation-location": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/e457ede2-ebd1-47ed-88b1-79e2dd68bde2", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "773" + }, + "ResponseBody": [] + }, + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/e457ede2-ebd1-47ed-88b1-79e2dd68bde2", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Ocp-Apim-Subscription-Key": "Sanitized", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "7ec04fe460fa3eef35d0d229a390e245", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "apim-request-id": "f9ed40ae-1c75-481e-aee2-56fb5e35c9f1", + "Content-Type": "application/json; charset=utf-8", + "Date": "Sun, 26 Sep 2021 18:37:39 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "174" + }, + "ResponseBody": { + "jobId": "e457ede2-ebd1-47ed-88b1-79e2dd68bde2", + "lastUpdateDateTime": "2021-09-26T18:37:39Z", + "createdDateTime": "2021-09-26T18:37:38Z", + "expirationDateTime": "2021-09-27T18:37:38Z", + "status": "notStarted", + "errors": [], + "displayName": "NA", + "tasks": { + "completed": 0, + "failed": 0, + "inProgress": 1, + "total": 1 + } + } + }, + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/e457ede2-ebd1-47ed-88b1-79e2dd68bde2", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Ocp-Apim-Subscription-Key": "Sanitized", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "86a67303a3d1040789a52cdc11e926a2", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "apim-request-id": "3e116eb0-a066-48d0-a0fc-301101585aba", + "Content-Type": "application/json; charset=utf-8", + "Date": "Sun, 26 Sep 2021 18:37:40 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "62" + }, + "ResponseBody": { + "jobId": "e457ede2-ebd1-47ed-88b1-79e2dd68bde2", + "lastUpdateDateTime": "2021-09-26T18:37:39Z", + "createdDateTime": "2021-09-26T18:37:38Z", + "expirationDateTime": "2021-09-27T18:37:38Z", + "status": "running", + "errors": [], + "displayName": "NA", + "tasks": { + "completed": 0, + "failed": 0, + "inProgress": 1, + "total": 1 + } + } + }, + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/e457ede2-ebd1-47ed-88b1-79e2dd68bde2", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Ocp-Apim-Subscription-Key": "Sanitized", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "7116e4bdc810de38e9fbbd46102d6d5c", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "apim-request-id": "e661af9e-998e-47fc-8228-bdb11a26fb49", + "Content-Type": "application/json; charset=utf-8", + "Date": "Sun, 26 Sep 2021 18:37:41 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "8" + }, + "ResponseBody": { + "jobId": "e457ede2-ebd1-47ed-88b1-79e2dd68bde2", + "lastUpdateDateTime": "2021-09-26T18:37:39Z", + "createdDateTime": "2021-09-26T18:37:38Z", + "expirationDateTime": "2021-09-27T18:37:38Z", + "status": "running", + "errors": [], + "displayName": "NA", + "tasks": { + "completed": 0, + "failed": 0, + "inProgress": 1, + "total": 1 + } + } + }, + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/e457ede2-ebd1-47ed-88b1-79e2dd68bde2", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Ocp-Apim-Subscription-Key": "Sanitized", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "7c7c0caf531441ad47bcf55533122c4c", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "apim-request-id": "19fd3fe8-3e7a-449e-b3ef-9fe44b472ab7", + "Content-Type": "application/json; charset=utf-8", + "Date": "Sun, 26 Sep 2021 18:37:43 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "220" + }, + "ResponseBody": { + "jobId": "e457ede2-ebd1-47ed-88b1-79e2dd68bde2", + "lastUpdateDateTime": "2021-09-26T18:37:42Z", + "createdDateTime": "2021-09-26T18:37:38Z", + "expirationDateTime": "2021-09-27T18:37:38Z", + "status": "succeeded", + "errors": [], + "displayName": "NA", + "tasks": { + "completed": 1, + "failed": 0, + "inProgress": 0, + "total": 1, + "customMultiClassificationTasks": [ + { + "lastUpdateDateTime": "2021-09-26T18:37:42.9616602Z", + "state": "succeeded", + "results": { + "documents": [ + { + "id": "0", + "classifications": [ + { + "category": "BookRestaurant", + "confidenceScore": 0.97 + } + ], + "warnings": [] + }, + { + "id": "1", + "classifications": [], + "warnings": [] + } + ], + "errors": [], + "projectName": "7cdace98-537b-494a-b69a-c19754718025", + "deploymentName": "7cdace98-537b-494a-b69a-c19754718025" + } + } + ] + } + } + } + ], + "Variables": { + "RandomSeed": "306457240", + "TEXT_ANALYTICS_API_KEY": "Sanitized", + "TEXT_ANALYTICS_ENDPOINT": "https://cognitiveweppe.azure-api.net" + } +} \ No newline at end of file diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/MultiCategoryClassifyTests/MultiCategoryClassifyBatchConvenienceTestAsync.json b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/MultiCategoryClassifyTests/MultiCategoryClassifyBatchConvenienceTestAsync.json new file mode 100644 index 000000000000..a2128f0d75e7 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/MultiCategoryClassifyTests/MultiCategoryClassifyBatchConvenienceTestAsync.json @@ -0,0 +1,180 @@ +{ + "Entries": [ + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Content-Length": "564", + "Content-Type": "application/json", + "Ocp-Apim-Subscription-Key": "Sanitized", + "traceparent": "00-9263bc8b9cfa464fa16f6fdb1b007b15-0754cd64ae803e41-00", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "718a5a8721a7c47b28a6d6f40fa42e90", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": { + "analysisInput": { + "documents": [ + { + "id": "0", + "text": "I need a reservation for an indoor restaurant in China. Please don\u0027t stop the music. Play music and add it to my playlist", + "language": "en" + }, + { + "id": "1", + "text": "David Schmidt, senior vice president--Food Safety, International Food Information Council (IFIC), Washington, D.C., discussed the physical activity component.", + "language": "en" + } + ] + }, + "tasks": { + "customMultiClassificationTasks": [ + { + "parameters": { + "project-name": "7cdace98-537b-494a-b69a-c19754718025", + "deployment-name": "7cdace98-537b-494a-b69a-c19754718025" + } + } + ] + } + }, + "StatusCode": 202, + "ResponseHeaders": { + "apim-request-id": "2b272e35-5f6a-4852-b14e-615f562e06c4", + "Date": "Sun, 26 Sep 2021 18:37:55 GMT", + "operation-location": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/16eb16dd-9c06-4486-8b5b-68d092b59469", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "261" + }, + "ResponseBody": [] + }, + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/16eb16dd-9c06-4486-8b5b-68d092b59469", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Ocp-Apim-Subscription-Key": "Sanitized", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "52d011f3b82af3f309e064b1bf001af7", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "apim-request-id": "96a8b076-7014-4e8f-9cd1-ea47b30b3c4d", + "Content-Type": "application/json; charset=utf-8", + "Date": "Sun, 26 Sep 2021 18:37:55 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "51" + }, + "ResponseBody": { + "jobId": "16eb16dd-9c06-4486-8b5b-68d092b59469", + "lastUpdateDateTime": "2021-09-26T18:37:55Z", + "createdDateTime": "2021-09-26T18:37:55Z", + "expirationDateTime": "2021-09-27T18:37:55Z", + "status": "notStarted", + "errors": [], + "displayName": "NA", + "tasks": { + "completed": 0, + "failed": 0, + "inProgress": 1, + "total": 1 + } + } + }, + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/16eb16dd-9c06-4486-8b5b-68d092b59469", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Ocp-Apim-Subscription-Key": "Sanitized", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "2e9ba3ef2af0771918680395314e3c1c", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "apim-request-id": "b8ece7e7-21f2-4004-8c08-8678d3307cd0", + "Content-Type": "application/json; charset=utf-8", + "Date": "Sun, 26 Sep 2021 18:37:56 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "73" + }, + "ResponseBody": { + "jobId": "16eb16dd-9c06-4486-8b5b-68d092b59469", + "lastUpdateDateTime": "2021-09-26T18:37:56Z", + "createdDateTime": "2021-09-26T18:37:55Z", + "expirationDateTime": "2021-09-27T18:37:55Z", + "status": "succeeded", + "errors": [], + "displayName": "NA", + "tasks": { + "completed": 1, + "failed": 0, + "inProgress": 0, + "total": 1, + "customMultiClassificationTasks": [ + { + "lastUpdateDateTime": "2021-09-26T18:37:56.2504231Z", + "state": "succeeded", + "results": { + "documents": [ + { + "id": "0", + "classifications": [ + { + "category": "BookRestaurant", + "confidenceScore": 0.97 + } + ], + "warnings": [] + }, + { + "id": "1", + "classifications": [], + "warnings": [] + } + ], + "errors": [], + "projectName": "7cdace98-537b-494a-b69a-c19754718025", + "deploymentName": "7cdace98-537b-494a-b69a-c19754718025" + } + } + ] + } + } + } + ], + "Variables": { + "RandomSeed": "243582775", + "TEXT_ANALYTICS_API_KEY": "Sanitized", + "TEXT_ANALYTICS_ENDPOINT": "https://cognitiveweppe.azure-api.net" + } +} \ No newline at end of file diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/MultiCategoryClassifyTests/MultiCategoryClassifyBatchConvenienceWithStatisticsTest.json b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/MultiCategoryClassifyTests/MultiCategoryClassifyBatchConvenienceWithStatisticsTest.json new file mode 100644 index 000000000000..baea9443251c --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/MultiCategoryClassifyTests/MultiCategoryClassifyBatchConvenienceWithStatisticsTest.json @@ -0,0 +1,194 @@ +{ + "Entries": [ + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Content-Length": "564", + "Content-Type": "application/json", + "Ocp-Apim-Subscription-Key": "Sanitized", + "traceparent": "00-d9dad020148efc4696fec3f209283eed-f1f8f7fc5f37ed42-00", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "d058597bceb0808d39f520df873cc702", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": { + "analysisInput": { + "documents": [ + { + "id": "0", + "text": "I need a reservation for an indoor restaurant in China. Please don\u0027t stop the music. Play music and add it to my playlist", + "language": "en" + }, + { + "id": "1", + "text": "David Schmidt, senior vice president--Food Safety, International Food Information Council (IFIC), Washington, D.C., discussed the physical activity component.", + "language": "en" + } + ] + }, + "tasks": { + "customMultiClassificationTasks": [ + { + "parameters": { + "project-name": "7cdace98-537b-494a-b69a-c19754718025", + "deployment-name": "7cdace98-537b-494a-b69a-c19754718025" + } + } + ] + } + }, + "StatusCode": 202, + "ResponseHeaders": { + "apim-request-id": "dfac3045-3219-4f1a-9a74-63818e55c1ef", + "Date": "Sun, 26 Sep 2021 18:37:43 GMT", + "operation-location": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/0e9780de-de39-44a6-9f2b-b02a5dc30ccf", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "534" + }, + "ResponseBody": [] + }, + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/0e9780de-de39-44a6-9f2b-b02a5dc30ccf?showStats=true", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Ocp-Apim-Subscription-Key": "Sanitized", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "9053fcdd622640c445116a104b8599b8", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "apim-request-id": "f20765e5-6d54-4707-89ae-4e1644a9f489", + "Content-Type": "application/json; charset=utf-8", + "Date": "Sun, 26 Sep 2021 18:37:43 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "9" + }, + "ResponseBody": { + "jobId": "0e9780de-de39-44a6-9f2b-b02a5dc30ccf", + "lastUpdateDateTime": "2021-09-26T18:37:43Z", + "createdDateTime": "2021-09-26T18:37:43Z", + "expirationDateTime": "2021-09-27T18:37:43Z", + "status": "running", + "errors": [], + "displayName": "NA", + "tasks": { + "completed": 0, + "failed": 0, + "inProgress": 1, + "total": 1 + } + } + }, + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/0e9780de-de39-44a6-9f2b-b02a5dc30ccf?showStats=true", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Ocp-Apim-Subscription-Key": "Sanitized", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "5bbdb49dd997808e5a9132fc5dcad991", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "apim-request-id": "00fcf02e-6a8b-4fb7-9e11-f55128c20eea", + "Content-Type": "application/json; charset=utf-8", + "Date": "Sun, 26 Sep 2021 18:37:44 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "79" + }, + "ResponseBody": { + "jobId": "0e9780de-de39-44a6-9f2b-b02a5dc30ccf", + "lastUpdateDateTime": "2021-09-26T18:37:44Z", + "createdDateTime": "2021-09-26T18:37:43Z", + "expirationDateTime": "2021-09-27T18:37:43Z", + "status": "succeeded", + "errors": [], + "displayName": "NA", + "tasks": { + "completed": 1, + "failed": 0, + "inProgress": 0, + "total": 1, + "customMultiClassificationTasks": [ + { + "lastUpdateDateTime": "2021-09-26T18:37:44.1350634Z", + "state": "succeeded", + "results": { + "statistics": { + "documentsCount": 2, + "validDocumentsCount": 2, + "erroneousDocumentsCount": 0, + "transactionsCount": 2 + }, + "documents": [ + { + "id": "0", + "classifications": [ + { + "category": "BookRestaurant", + "confidenceScore": 0.97 + } + ], + "statistics": { + "charactersCount": 121, + "transactionsCount": 1 + }, + "warnings": [] + }, + { + "id": "1", + "classifications": [], + "statistics": { + "charactersCount": 158, + "transactionsCount": 1 + }, + "warnings": [] + } + ], + "errors": [], + "projectName": "7cdace98-537b-494a-b69a-c19754718025", + "deploymentName": "7cdace98-537b-494a-b69a-c19754718025" + } + } + ] + } + } + } + ], + "Variables": { + "RandomSeed": "1030528731", + "TEXT_ANALYTICS_API_KEY": "Sanitized", + "TEXT_ANALYTICS_ENDPOINT": "https://cognitiveweppe.azure-api.net" + } +} \ No newline at end of file diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/MultiCategoryClassifyTests/MultiCategoryClassifyBatchConvenienceWithStatisticsTestAsync.json b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/MultiCategoryClassifyTests/MultiCategoryClassifyBatchConvenienceWithStatisticsTestAsync.json new file mode 100644 index 000000000000..a716eeb3b8e1 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/MultiCategoryClassifyTests/MultiCategoryClassifyBatchConvenienceWithStatisticsTestAsync.json @@ -0,0 +1,194 @@ +{ + "Entries": [ + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Content-Length": "564", + "Content-Type": "application/json", + "Ocp-Apim-Subscription-Key": "Sanitized", + "traceparent": "00-69a6a68e02741a4eab4537b054bbb732-497e0ccf34119345-00", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "d3acc983e1836ddde491f31a2c505a60", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": { + "analysisInput": { + "documents": [ + { + "id": "0", + "text": "I need a reservation for an indoor restaurant in China. Please don\u0027t stop the music. Play music and add it to my playlist", + "language": "en" + }, + { + "id": "1", + "text": "David Schmidt, senior vice president--Food Safety, International Food Information Council (IFIC), Washington, D.C., discussed the physical activity component.", + "language": "en" + } + ] + }, + "tasks": { + "customMultiClassificationTasks": [ + { + "parameters": { + "project-name": "7cdace98-537b-494a-b69a-c19754718025", + "deployment-name": "7cdace98-537b-494a-b69a-c19754718025" + } + } + ] + } + }, + "StatusCode": 202, + "ResponseHeaders": { + "apim-request-id": "a6db4736-71ee-4e05-a204-b73c532edc7f", + "Date": "Sun, 26 Sep 2021 18:37:58 GMT", + "operation-location": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/84084a9e-ef7d-4060-b1c0-98a382e1d444", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "2233" + }, + "ResponseBody": [] + }, + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/84084a9e-ef7d-4060-b1c0-98a382e1d444?showStats=true", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Ocp-Apim-Subscription-Key": "Sanitized", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "05165df81797b263847ae86c0bea97b4", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "apim-request-id": "b7eb1e97-024f-4421-8fbb-2ff038727151", + "Content-Type": "application/json; charset=utf-8", + "Date": "Sun, 26 Sep 2021 18:37:58 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "9" + }, + "ResponseBody": { + "jobId": "84084a9e-ef7d-4060-b1c0-98a382e1d444", + "lastUpdateDateTime": "2021-09-26T18:37:59Z", + "createdDateTime": "2021-09-26T18:37:56Z", + "expirationDateTime": "2021-09-27T18:37:56Z", + "status": "notStarted", + "errors": [], + "displayName": "NA", + "tasks": { + "completed": 0, + "failed": 0, + "inProgress": 1, + "total": 1 + } + } + }, + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/84084a9e-ef7d-4060-b1c0-98a382e1d444?showStats=true", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Ocp-Apim-Subscription-Key": "Sanitized", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "d84eaa6132a7c9bbf0e418f64a0495e9", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "apim-request-id": "dac0d2b9-45f7-485f-8ff8-cc720f8d716b", + "Content-Type": "application/json; charset=utf-8", + "Date": "Sun, 26 Sep 2021 18:38:00 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "73" + }, + "ResponseBody": { + "jobId": "84084a9e-ef7d-4060-b1c0-98a382e1d444", + "lastUpdateDateTime": "2021-09-26T18:37:59Z", + "createdDateTime": "2021-09-26T18:37:56Z", + "expirationDateTime": "2021-09-27T18:37:56Z", + "status": "succeeded", + "errors": [], + "displayName": "NA", + "tasks": { + "completed": 1, + "failed": 0, + "inProgress": 0, + "total": 1, + "customMultiClassificationTasks": [ + { + "lastUpdateDateTime": "2021-09-26T18:37:59.5109722Z", + "state": "succeeded", + "results": { + "statistics": { + "documentsCount": 2, + "validDocumentsCount": 2, + "erroneousDocumentsCount": 0, + "transactionsCount": 2 + }, + "documents": [ + { + "id": "0", + "classifications": [ + { + "category": "BookRestaurant", + "confidenceScore": 0.97 + } + ], + "statistics": { + "charactersCount": 121, + "transactionsCount": 1 + }, + "warnings": [] + }, + { + "id": "1", + "classifications": [], + "statistics": { + "charactersCount": 158, + "transactionsCount": 1 + }, + "warnings": [] + } + ], + "errors": [], + "projectName": "7cdace98-537b-494a-b69a-c19754718025", + "deploymentName": "7cdace98-537b-494a-b69a-c19754718025" + } + } + ] + } + } + } + ], + "Variables": { + "RandomSeed": "249617768", + "TEXT_ANALYTICS_API_KEY": "Sanitized", + "TEXT_ANALYTICS_ENDPOINT": "https://cognitiveweppe.azure-api.net" + } +} \ No newline at end of file diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/MultiCategoryClassifyTests/MultiCategoryClassifyBatchTest.json b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/MultiCategoryClassifyTests/MultiCategoryClassifyBatchTest.json new file mode 100644 index 000000000000..e58299ab5a73 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/MultiCategoryClassifyTests/MultiCategoryClassifyBatchTest.json @@ -0,0 +1,180 @@ +{ + "Entries": [ + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Content-Length": "564", + "Content-Type": "application/json", + "Ocp-Apim-Subscription-Key": "Sanitized", + "traceparent": "00-884e725b7c34b64d9d44875d8b56cfe2-51f7c2bf82e7fb41-00", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "f9a445d1945350412d315d0677481a7f", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": { + "analysisInput": { + "documents": [ + { + "id": "1", + "text": "I need a reservation for an indoor restaurant in China. Please don\u0027t stop the music. Play music and add it to my playlist", + "language": "en" + }, + { + "id": "2", + "text": "David Schmidt, senior vice president--Food Safety, International Food Information Council (IFIC), Washington, D.C., discussed the physical activity component.", + "language": "en" + } + ] + }, + "tasks": { + "customMultiClassificationTasks": [ + { + "parameters": { + "project-name": "7cdace98-537b-494a-b69a-c19754718025", + "deployment-name": "7cdace98-537b-494a-b69a-c19754718025" + } + } + ] + } + }, + "StatusCode": 202, + "ResponseHeaders": { + "apim-request-id": "8823e990-51ae-47fd-beb4-0c505ee6584a", + "Date": "Sun, 26 Sep 2021 18:37:44 GMT", + "operation-location": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/bcc19ef9-c122-4f6c-8bae-f77f71a3830f", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "169" + }, + "ResponseBody": [] + }, + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/bcc19ef9-c122-4f6c-8bae-f77f71a3830f", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Ocp-Apim-Subscription-Key": "Sanitized", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "65613fb5afe0d6dda7bcc933fe40034b", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "apim-request-id": "bab72ea3-c266-46c1-99cf-f5cd3bf52efd", + "Content-Type": "application/json; charset=utf-8", + "Date": "Sun, 26 Sep 2021 18:37:44 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "8" + }, + "ResponseBody": { + "jobId": "bcc19ef9-c122-4f6c-8bae-f77f71a3830f", + "lastUpdateDateTime": "2021-09-26T18:37:45Z", + "createdDateTime": "2021-09-26T18:37:45Z", + "expirationDateTime": "2021-09-27T18:37:45Z", + "status": "notStarted", + "errors": [], + "displayName": "NA", + "tasks": { + "completed": 0, + "failed": 0, + "inProgress": 1, + "total": 1 + } + } + }, + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/bcc19ef9-c122-4f6c-8bae-f77f71a3830f", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Ocp-Apim-Subscription-Key": "Sanitized", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "90f7abee75aa105484220d8a1c28422b", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "apim-request-id": "91a44607-a742-462c-a94f-31619aa5d8c5", + "Content-Type": "application/json; charset=utf-8", + "Date": "Sun, 26 Sep 2021 18:37:46 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "79" + }, + "ResponseBody": { + "jobId": "bcc19ef9-c122-4f6c-8bae-f77f71a3830f", + "lastUpdateDateTime": "2021-09-26T18:37:46Z", + "createdDateTime": "2021-09-26T18:37:45Z", + "expirationDateTime": "2021-09-27T18:37:45Z", + "status": "succeeded", + "errors": [], + "displayName": "NA", + "tasks": { + "completed": 1, + "failed": 0, + "inProgress": 0, + "total": 1, + "customMultiClassificationTasks": [ + { + "lastUpdateDateTime": "2021-09-26T18:37:46.1831369Z", + "state": "succeeded", + "results": { + "documents": [ + { + "id": "1", + "classifications": [ + { + "category": "BookRestaurant", + "confidenceScore": 0.97 + } + ], + "warnings": [] + }, + { + "id": "2", + "classifications": [], + "warnings": [] + } + ], + "errors": [], + "projectName": "7cdace98-537b-494a-b69a-c19754718025", + "deploymentName": "7cdace98-537b-494a-b69a-c19754718025" + } + } + ] + } + } + } + ], + "Variables": { + "RandomSeed": "1987453593", + "TEXT_ANALYTICS_API_KEY": "Sanitized", + "TEXT_ANALYTICS_ENDPOINT": "https://cognitiveweppe.azure-api.net" + } +} \ No newline at end of file diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/MultiCategoryClassifyTests/MultiCategoryClassifyBatchTestAsync.json b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/MultiCategoryClassifyTests/MultiCategoryClassifyBatchTestAsync.json new file mode 100644 index 000000000000..c9d1723d37bf --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/MultiCategoryClassifyTests/MultiCategoryClassifyBatchTestAsync.json @@ -0,0 +1,180 @@ +{ + "Entries": [ + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Content-Length": "564", + "Content-Type": "application/json", + "Ocp-Apim-Subscription-Key": "Sanitized", + "traceparent": "00-d83ce7d210e16846a1f3d3bc96945df4-b6c0d583a4f2964c-00", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "a6386bfba6299a3233a2dfd0f0d681ac", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": { + "analysisInput": { + "documents": [ + { + "id": "1", + "text": "I need a reservation for an indoor restaurant in China. Please don\u0027t stop the music. Play music and add it to my playlist", + "language": "en" + }, + { + "id": "2", + "text": "David Schmidt, senior vice president--Food Safety, International Food Information Council (IFIC), Washington, D.C., discussed the physical activity component.", + "language": "en" + } + ] + }, + "tasks": { + "customMultiClassificationTasks": [ + { + "parameters": { + "project-name": "7cdace98-537b-494a-b69a-c19754718025", + "deployment-name": "7cdace98-537b-494a-b69a-c19754718025" + } + } + ] + } + }, + "StatusCode": 202, + "ResponseHeaders": { + "apim-request-id": "623a527a-e13d-4254-953c-c0688c208f4b", + "Date": "Sun, 26 Sep 2021 18:38:00 GMT", + "operation-location": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/22393095-ec98-4a21-9a05-4695868d3bb7", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "154" + }, + "ResponseBody": [] + }, + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/22393095-ec98-4a21-9a05-4695868d3bb7", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Ocp-Apim-Subscription-Key": "Sanitized", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "99df5d7a9160810d2c4cc6a396618219", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "apim-request-id": "657f11ff-891e-41bd-97e8-42dbe18b87be", + "Content-Type": "application/json; charset=utf-8", + "Date": "Sun, 26 Sep 2021 18:38:00 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "8" + }, + "ResponseBody": { + "jobId": "22393095-ec98-4a21-9a05-4695868d3bb7", + "lastUpdateDateTime": "2021-09-26T18:38:00Z", + "createdDateTime": "2021-09-26T18:38:00Z", + "expirationDateTime": "2021-09-27T18:38:00Z", + "status": "notStarted", + "errors": [], + "displayName": "NA", + "tasks": { + "completed": 0, + "failed": 0, + "inProgress": 1, + "total": 1 + } + } + }, + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/22393095-ec98-4a21-9a05-4695868d3bb7", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Ocp-Apim-Subscription-Key": "Sanitized", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "bee2f736dbdadf841f035712b1c9634d", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "apim-request-id": "040bc84b-b16d-4648-905b-9583d24d8f2c", + "Content-Type": "application/json; charset=utf-8", + "Date": "Sun, 26 Sep 2021 18:38:01 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "68" + }, + "ResponseBody": { + "jobId": "22393095-ec98-4a21-9a05-4695868d3bb7", + "lastUpdateDateTime": "2021-09-26T18:38:01Z", + "createdDateTime": "2021-09-26T18:38:00Z", + "expirationDateTime": "2021-09-27T18:38:00Z", + "status": "succeeded", + "errors": [], + "displayName": "NA", + "tasks": { + "completed": 1, + "failed": 0, + "inProgress": 0, + "total": 1, + "customMultiClassificationTasks": [ + { + "lastUpdateDateTime": "2021-09-26T18:38:01.3413113Z", + "state": "succeeded", + "results": { + "documents": [ + { + "id": "1", + "classifications": [ + { + "category": "BookRestaurant", + "confidenceScore": 0.97 + } + ], + "warnings": [] + }, + { + "id": "2", + "classifications": [], + "warnings": [] + } + ], + "errors": [], + "projectName": "7cdace98-537b-494a-b69a-c19754718025", + "deploymentName": "7cdace98-537b-494a-b69a-c19754718025" + } + } + ] + } + } + } + ], + "Variables": { + "RandomSeed": "542519583", + "TEXT_ANALYTICS_API_KEY": "Sanitized", + "TEXT_ANALYTICS_ENDPOINT": "https://cognitiveweppe.azure-api.net" + } +} \ No newline at end of file diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/MultiCategoryClassifyTests/MultiCategoryClassifyBatchWithErrorTest.json b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/MultiCategoryClassifyTests/MultiCategoryClassifyBatchWithErrorTest.json new file mode 100644 index 000000000000..909953656e2f --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/MultiCategoryClassifyTests/MultiCategoryClassifyBatchWithErrorTest.json @@ -0,0 +1,311 @@ +{ + "Entries": [ + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Content-Length": "328", + "Content-Type": "application/json", + "Ocp-Apim-Subscription-Key": "Sanitized", + "traceparent": "00-13a06e1deedf2148b8b798a6251cc0c3-7ab3734356fc9542-00", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "b3f00d59ecdaec71d23ecfd808fcaa3b", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": { + "analysisInput": { + "documents": [ + { + "id": "0", + "text": "Subject is taking 100mg of ibuprofen twice daily", + "language": "en" + }, + { + "id": "1", + "text": "", + "language": "en" + } + ] + }, + "tasks": { + "customMultiClassificationTasks": [ + { + "parameters": { + "project-name": "7cdace98-537b-494a-b69a-c19754718025", + "deployment-name": "7cdace98-537b-494a-b69a-c19754718025" + } + } + ] + } + }, + "StatusCode": 202, + "ResponseHeaders": { + "apim-request-id": "61a6a2f0-77a8-4241-a585-0734872b315a", + "Date": "Sun, 26 Sep 2021 18:37:46 GMT", + "operation-location": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/9580a26d-74d0-4c56-b4c8-57432b6d8da3", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "230" + }, + "ResponseBody": [] + }, + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/9580a26d-74d0-4c56-b4c8-57432b6d8da3", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Ocp-Apim-Subscription-Key": "Sanitized", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "dea2929332df74905c54c3965e08e957", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "apim-request-id": "53e0ff42-b9d2-4e52-ae6a-238d099f9b8c", + "Content-Type": "application/json; charset=utf-8", + "Date": "Sun, 26 Sep 2021 18:37:46 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "9" + }, + "ResponseBody": { + "jobId": "9580a26d-74d0-4c56-b4c8-57432b6d8da3", + "lastUpdateDateTime": "2021-09-26T18:37:47Z", + "createdDateTime": "2021-09-26T18:37:46Z", + "expirationDateTime": "2021-09-27T18:37:46Z", + "status": "notStarted", + "errors": [], + "displayName": "NA", + "tasks": { + "completed": 0, + "failed": 0, + "inProgress": 1, + "total": 1 + } + } + }, + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/9580a26d-74d0-4c56-b4c8-57432b6d8da3", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Ocp-Apim-Subscription-Key": "Sanitized", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "0c7a0cb56d21b31947ac409a90ebc30d", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "apim-request-id": "4ee221ba-b525-4de3-9b44-cd1c7d97c269", + "Content-Type": "application/json; charset=utf-8", + "Date": "Sun, 26 Sep 2021 18:37:48 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "10" + }, + "ResponseBody": { + "jobId": "9580a26d-74d0-4c56-b4c8-57432b6d8da3", + "lastUpdateDateTime": "2021-09-26T18:37:47Z", + "createdDateTime": "2021-09-26T18:37:46Z", + "expirationDateTime": "2021-09-27T18:37:46Z", + "status": "running", + "errors": [], + "displayName": "NA", + "tasks": { + "completed": 0, + "failed": 0, + "inProgress": 1, + "total": 1 + } + } + }, + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/9580a26d-74d0-4c56-b4c8-57432b6d8da3", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Ocp-Apim-Subscription-Key": "Sanitized", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "bdf42c59a9ff26547d7c578529da8dc9", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "apim-request-id": "34c627a9-f5a5-4f93-80d2-20bcee1f798a", + "Content-Type": "application/json; charset=utf-8", + "Date": "Sun, 26 Sep 2021 18:37:49 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "7" + }, + "ResponseBody": { + "jobId": "9580a26d-74d0-4c56-b4c8-57432b6d8da3", + "lastUpdateDateTime": "2021-09-26T18:37:47Z", + "createdDateTime": "2021-09-26T18:37:46Z", + "expirationDateTime": "2021-09-27T18:37:46Z", + "status": "running", + "errors": [], + "displayName": "NA", + "tasks": { + "completed": 0, + "failed": 0, + "inProgress": 1, + "total": 1 + } + } + }, + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/9580a26d-74d0-4c56-b4c8-57432b6d8da3", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Ocp-Apim-Subscription-Key": "Sanitized", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "fc2277549d81251978ee9733f2f5e370", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "apim-request-id": "31a00c55-ee67-4a29-b9f2-64ecc5b42893", + "Content-Type": "application/json; charset=utf-8", + "Date": "Sun, 26 Sep 2021 18:37:50 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "8" + }, + "ResponseBody": { + "jobId": "9580a26d-74d0-4c56-b4c8-57432b6d8da3", + "lastUpdateDateTime": "2021-09-26T18:37:47Z", + "createdDateTime": "2021-09-26T18:37:46Z", + "expirationDateTime": "2021-09-27T18:37:46Z", + "status": "running", + "errors": [], + "displayName": "NA", + "tasks": { + "completed": 0, + "failed": 0, + "inProgress": 1, + "total": 1 + } + } + }, + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/9580a26d-74d0-4c56-b4c8-57432b6d8da3", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Ocp-Apim-Subscription-Key": "Sanitized", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "323db5902c140b58b8548ea515938a6c", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "apim-request-id": "da7b36a3-0312-4129-9368-eb2cf1ac5801", + "Content-Type": "application/json; charset=utf-8", + "Date": "Sun, 26 Sep 2021 18:37:51 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "86" + }, + "ResponseBody": { + "jobId": "9580a26d-74d0-4c56-b4c8-57432b6d8da3", + "lastUpdateDateTime": "2021-09-26T18:37:50Z", + "createdDateTime": "2021-09-26T18:37:46Z", + "expirationDateTime": "2021-09-27T18:37:46Z", + "status": "succeeded", + "errors": [], + "displayName": "NA", + "tasks": { + "completed": 1, + "failed": 0, + "inProgress": 0, + "total": 1, + "customMultiClassificationTasks": [ + { + "lastUpdateDateTime": "2021-09-26T18:37:50.7704268Z", + "state": "succeeded", + "results": { + "documents": [ + { + "id": "0", + "classifications": [], + "warnings": [] + } + ], + "errors": [ + { + "id": "1", + "error": { + "code": "InvalidArgument", + "message": "Invalid document in request.", + "innererror": { + "code": "InvalidDocument", + "message": "Document text is empty." + } + } + } + ], + "projectName": "7cdace98-537b-494a-b69a-c19754718025", + "deploymentName": "7cdace98-537b-494a-b69a-c19754718025" + } + } + ] + } + } + } + ], + "Variables": { + "RandomSeed": "651258290", + "TEXT_ANALYTICS_API_KEY": "Sanitized", + "TEXT_ANALYTICS_ENDPOINT": "https://cognitiveweppe.azure-api.net" + } +} \ No newline at end of file diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/MultiCategoryClassifyTests/MultiCategoryClassifyBatchWithErrorTestAsync.json b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/MultiCategoryClassifyTests/MultiCategoryClassifyBatchWithErrorTestAsync.json new file mode 100644 index 000000000000..49fdbe12b527 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/MultiCategoryClassifyTests/MultiCategoryClassifyBatchWithErrorTestAsync.json @@ -0,0 +1,182 @@ +{ + "Entries": [ + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Content-Length": "328", + "Content-Type": "application/json", + "Ocp-Apim-Subscription-Key": "Sanitized", + "traceparent": "00-9af02393cc01c544a01af7f480b0768d-2f536da3f9a2cc4b-00", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "30f3d0aaed959b158d1c03a1c38ed196", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": { + "analysisInput": { + "documents": [ + { + "id": "0", + "text": "Subject is taking 100mg of ibuprofen twice daily", + "language": "en" + }, + { + "id": "1", + "text": "", + "language": "en" + } + ] + }, + "tasks": { + "customMultiClassificationTasks": [ + { + "parameters": { + "project-name": "7cdace98-537b-494a-b69a-c19754718025", + "deployment-name": "7cdace98-537b-494a-b69a-c19754718025" + } + } + ] + } + }, + "StatusCode": 202, + "ResponseHeaders": { + "apim-request-id": "465345ff-5570-48d1-90fd-b999dc732c45", + "Date": "Sun, 26 Sep 2021 18:38:01 GMT", + "operation-location": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/dc370ca0-347e-4326-85a4-343ebd44f701", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "151" + }, + "ResponseBody": [] + }, + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/dc370ca0-347e-4326-85a4-343ebd44f701", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Ocp-Apim-Subscription-Key": "Sanitized", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "c825cb4a1b45c0a38d00c26413634bd4", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "apim-request-id": "ca2baa62-eb40-49e4-8b79-a1181b25ef46", + "Content-Type": "application/json; charset=utf-8", + "Date": "Sun, 26 Sep 2021 18:38:01 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "8" + }, + "ResponseBody": { + "jobId": "dc370ca0-347e-4326-85a4-343ebd44f701", + "lastUpdateDateTime": "2021-09-26T18:38:02Z", + "createdDateTime": "2021-09-26T18:38:02Z", + "expirationDateTime": "2021-09-27T18:38:02Z", + "status": "running", + "errors": [], + "displayName": "NA", + "tasks": { + "completed": 0, + "failed": 0, + "inProgress": 1, + "total": 1 + } + } + }, + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/dc370ca0-347e-4326-85a4-343ebd44f701", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Ocp-Apim-Subscription-Key": "Sanitized", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "cbdf5eda5e441b482047cd1f76afb55d", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "apim-request-id": "ec3df33f-724a-47c7-b09e-d55444b9a2a5", + "Content-Type": "application/json; charset=utf-8", + "Date": "Sun, 26 Sep 2021 18:38:03 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "77" + }, + "ResponseBody": { + "jobId": "dc370ca0-347e-4326-85a4-343ebd44f701", + "lastUpdateDateTime": "2021-09-26T18:38:02Z", + "createdDateTime": "2021-09-26T18:38:02Z", + "expirationDateTime": "2021-09-27T18:38:02Z", + "status": "succeeded", + "errors": [], + "displayName": "NA", + "tasks": { + "completed": 1, + "failed": 0, + "inProgress": 0, + "total": 1, + "customMultiClassificationTasks": [ + { + "lastUpdateDateTime": "2021-09-26T18:38:02.4139547Z", + "state": "succeeded", + "results": { + "documents": [ + { + "id": "0", + "classifications": [], + "warnings": [] + } + ], + "errors": [ + { + "id": "1", + "error": { + "code": "InvalidArgument", + "message": "Invalid document in request.", + "innererror": { + "code": "InvalidDocument", + "message": "Document text is empty." + } + } + } + ], + "projectName": "7cdace98-537b-494a-b69a-c19754718025", + "deploymentName": "7cdace98-537b-494a-b69a-c19754718025" + } + } + ] + } + } + } + ], + "Variables": { + "RandomSeed": "1364887234", + "TEXT_ANALYTICS_API_KEY": "Sanitized", + "TEXT_ANALYTICS_ENDPOINT": "https://cognitiveweppe.azure-api.net" + } +} \ No newline at end of file diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/MultiCategoryClassifyTests/MultiCategoryClassifyBatchWithStatisticsTest.json b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/MultiCategoryClassifyTests/MultiCategoryClassifyBatchWithStatisticsTest.json new file mode 100644 index 000000000000..69b46076d79f --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/MultiCategoryClassifyTests/MultiCategoryClassifyBatchWithStatisticsTest.json @@ -0,0 +1,194 @@ +{ + "Entries": [ + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Content-Length": "564", + "Content-Type": "application/json", + "Ocp-Apim-Subscription-Key": "Sanitized", + "traceparent": "00-a734d594c9d9da4ca366b06a19dcddb1-7216aa4d97934b40-00", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "1d267b1dc6373f818e2ae2b8b6729718", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": { + "analysisInput": { + "documents": [ + { + "id": "1", + "text": "I need a reservation for an indoor restaurant in China. Please don\u0027t stop the music. Play music and add it to my playlist", + "language": "en" + }, + { + "id": "2", + "text": "David Schmidt, senior vice president--Food Safety, International Food Information Council (IFIC), Washington, D.C., discussed the physical activity component.", + "language": "en" + } + ] + }, + "tasks": { + "customMultiClassificationTasks": [ + { + "parameters": { + "project-name": "7cdace98-537b-494a-b69a-c19754718025", + "deployment-name": "7cdace98-537b-494a-b69a-c19754718025" + } + } + ] + } + }, + "StatusCode": 202, + "ResponseHeaders": { + "apim-request-id": "619c4219-f366-4c4a-850a-8a40fb12eaf3", + "Date": "Sun, 26 Sep 2021 18:37:51 GMT", + "operation-location": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/9d17ec2c-7068-4ad1-8a5b-f7aa17ae7fba", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "154" + }, + "ResponseBody": [] + }, + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/9d17ec2c-7068-4ad1-8a5b-f7aa17ae7fba?showStats=true", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Ocp-Apim-Subscription-Key": "Sanitized", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "d6a026686d0319ef4fd032da4c5ed795", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "apim-request-id": "0c58573a-522b-4c93-bb36-2b579dc6996f", + "Content-Type": "application/json; charset=utf-8", + "Date": "Sun, 26 Sep 2021 18:37:51 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "8" + }, + "ResponseBody": { + "jobId": "9d17ec2c-7068-4ad1-8a5b-f7aa17ae7fba", + "lastUpdateDateTime": "2021-09-26T18:37:52Z", + "createdDateTime": "2021-09-26T18:37:51Z", + "expirationDateTime": "2021-09-27T18:37:51Z", + "status": "running", + "errors": [], + "displayName": "NA", + "tasks": { + "completed": 0, + "failed": 0, + "inProgress": 1, + "total": 1 + } + } + }, + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/9d17ec2c-7068-4ad1-8a5b-f7aa17ae7fba?showStats=true", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Ocp-Apim-Subscription-Key": "Sanitized", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "9bd4d20f26905b2abbe44e8557974917", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "apim-request-id": "1f696025-dfc9-4096-93a4-fb1feb077b57", + "Content-Type": "application/json; charset=utf-8", + "Date": "Sun, 26 Sep 2021 18:37:53 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "73" + }, + "ResponseBody": { + "jobId": "9d17ec2c-7068-4ad1-8a5b-f7aa17ae7fba", + "lastUpdateDateTime": "2021-09-26T18:37:52Z", + "createdDateTime": "2021-09-26T18:37:51Z", + "expirationDateTime": "2021-09-27T18:37:51Z", + "status": "succeeded", + "errors": [], + "displayName": "NA", + "tasks": { + "completed": 1, + "failed": 0, + "inProgress": 0, + "total": 1, + "customMultiClassificationTasks": [ + { + "lastUpdateDateTime": "2021-09-26T18:37:52.207536Z", + "state": "succeeded", + "results": { + "statistics": { + "documentsCount": 2, + "validDocumentsCount": 2, + "erroneousDocumentsCount": 0, + "transactionsCount": 2 + }, + "documents": [ + { + "id": "1", + "classifications": [ + { + "category": "BookRestaurant", + "confidenceScore": 0.97 + } + ], + "statistics": { + "charactersCount": 121, + "transactionsCount": 1 + }, + "warnings": [] + }, + { + "id": "2", + "classifications": [], + "statistics": { + "charactersCount": 158, + "transactionsCount": 1 + }, + "warnings": [] + } + ], + "errors": [], + "projectName": "7cdace98-537b-494a-b69a-c19754718025", + "deploymentName": "7cdace98-537b-494a-b69a-c19754718025" + } + } + ] + } + } + } + ], + "Variables": { + "RandomSeed": "1494605637", + "TEXT_ANALYTICS_API_KEY": "Sanitized", + "TEXT_ANALYTICS_ENDPOINT": "https://cognitiveweppe.azure-api.net" + } +} \ No newline at end of file diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/MultiCategoryClassifyTests/MultiCategoryClassifyBatchWithStatisticsTestAsync.json b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/MultiCategoryClassifyTests/MultiCategoryClassifyBatchWithStatisticsTestAsync.json new file mode 100644 index 000000000000..958ba8eaf7e3 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/MultiCategoryClassifyTests/MultiCategoryClassifyBatchWithStatisticsTestAsync.json @@ -0,0 +1,194 @@ +{ + "Entries": [ + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Content-Length": "564", + "Content-Type": "application/json", + "Ocp-Apim-Subscription-Key": "Sanitized", + "traceparent": "00-c2714305fbbc544fbdaf8ce12d06cb5a-7af9a8ca7992654e-00", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "906b58cad58335a5847440566fdf9175", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": { + "analysisInput": { + "documents": [ + { + "id": "1", + "text": "I need a reservation for an indoor restaurant in China. Please don\u0027t stop the music. Play music and add it to my playlist", + "language": "en" + }, + { + "id": "2", + "text": "David Schmidt, senior vice president--Food Safety, International Food Information Council (IFIC), Washington, D.C., discussed the physical activity component.", + "language": "en" + } + ] + }, + "tasks": { + "customMultiClassificationTasks": [ + { + "parameters": { + "project-name": "7cdace98-537b-494a-b69a-c19754718025", + "deployment-name": "7cdace98-537b-494a-b69a-c19754718025" + } + } + ] + } + }, + "StatusCode": 202, + "ResponseHeaders": { + "apim-request-id": "b8b9c71d-e20d-4616-924b-9bf33e1f5b80", + "Date": "Sun, 26 Sep 2021 18:38:03 GMT", + "operation-location": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/7d7bc432-9155-4740-b33c-5fd2dafe8789", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "179" + }, + "ResponseBody": [] + }, + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/7d7bc432-9155-4740-b33c-5fd2dafe8789?showStats=true", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Ocp-Apim-Subscription-Key": "Sanitized", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "d7bd2b96de4822366676f3e88d30af2c", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "apim-request-id": "0b62bd24-ec0e-421e-9087-115b6a7aa365", + "Content-Type": "application/json; charset=utf-8", + "Date": "Sun, 26 Sep 2021 18:38:03 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "8" + }, + "ResponseBody": { + "jobId": "7d7bc432-9155-4740-b33c-5fd2dafe8789", + "lastUpdateDateTime": "2021-09-26T18:38:03Z", + "createdDateTime": "2021-09-26T18:38:03Z", + "expirationDateTime": "2021-09-27T18:38:03Z", + "status": "notStarted", + "errors": [], + "displayName": "NA", + "tasks": { + "completed": 0, + "failed": 0, + "inProgress": 1, + "total": 1 + } + } + }, + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/7d7bc432-9155-4740-b33c-5fd2dafe8789?showStats=true", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Ocp-Apim-Subscription-Key": "Sanitized", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "0b245d4008ebad99d3b8e00231144551", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "apim-request-id": "e6fbc09f-e01b-4143-9854-284e2dbad044", + "Content-Type": "application/json; charset=utf-8", + "Date": "Sun, 26 Sep 2021 18:38:05 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "75" + }, + "ResponseBody": { + "jobId": "7d7bc432-9155-4740-b33c-5fd2dafe8789", + "lastUpdateDateTime": "2021-09-26T18:38:04Z", + "createdDateTime": "2021-09-26T18:38:03Z", + "expirationDateTime": "2021-09-27T18:38:03Z", + "status": "succeeded", + "errors": [], + "displayName": "NA", + "tasks": { + "completed": 1, + "failed": 0, + "inProgress": 0, + "total": 1, + "customMultiClassificationTasks": [ + { + "lastUpdateDateTime": "2021-09-26T18:38:04.438308Z", + "state": "succeeded", + "results": { + "statistics": { + "documentsCount": 2, + "validDocumentsCount": 2, + "erroneousDocumentsCount": 0, + "transactionsCount": 2 + }, + "documents": [ + { + "id": "1", + "classifications": [ + { + "category": "BookRestaurant", + "confidenceScore": 0.97 + } + ], + "statistics": { + "charactersCount": 121, + "transactionsCount": 1 + }, + "warnings": [] + }, + { + "id": "2", + "classifications": [], + "statistics": { + "charactersCount": 158, + "transactionsCount": 1 + }, + "warnings": [] + } + ], + "errors": [], + "projectName": "7cdace98-537b-494a-b69a-c19754718025", + "deploymentName": "7cdace98-537b-494a-b69a-c19754718025" + } + } + ] + } + } + } + ], + "Variables": { + "RandomSeed": "156613535", + "TEXT_ANALYTICS_API_KEY": "Sanitized", + "TEXT_ANALYTICS_ENDPOINT": "https://cognitiveweppe.azure-api.net" + } +} \ No newline at end of file diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/MultiCategoryClassifyTests/MultiCategoryClassifyWithDisableServiceLogs.json b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/MultiCategoryClassifyTests/MultiCategoryClassifyWithDisableServiceLogs.json new file mode 100644 index 000000000000..aefebd413985 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/MultiCategoryClassifyTests/MultiCategoryClassifyWithDisableServiceLogs.json @@ -0,0 +1,181 @@ +{ + "Entries": [ + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Content-Length": "585", + "Content-Type": "application/json", + "Ocp-Apim-Subscription-Key": "Sanitized", + "traceparent": "00-c5ef0d263be436429b9751876001e38c-519027e4812b7242-00", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "240aa7eee3f5791310c87f0aea43f279", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": { + "analysisInput": { + "documents": [ + { + "id": "0", + "text": "I need a reservation for an indoor restaurant in China. Please don\u0027t stop the music. Play music and add it to my playlist", + "language": "en" + }, + { + "id": "1", + "text": "David Schmidt, senior vice president--Food Safety, International Food Information Council (IFIC), Washington, D.C., discussed the physical activity component.", + "language": "en" + } + ] + }, + "tasks": { + "customMultiClassificationTasks": [ + { + "parameters": { + "project-name": "7cdace98-537b-494a-b69a-c19754718025", + "deployment-name": "7cdace98-537b-494a-b69a-c19754718025", + "loggingOptOut": true + } + } + ] + } + }, + "StatusCode": 202, + "ResponseHeaders": { + "apim-request-id": "68b8b827-3c95-4012-80d5-07e869d86d7b", + "Date": "Sun, 26 Sep 2021 18:37:53 GMT", + "operation-location": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/f1c090c9-e2dd-4a1a-b901-d81d253477af", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "188" + }, + "ResponseBody": [] + }, + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/f1c090c9-e2dd-4a1a-b901-d81d253477af", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Ocp-Apim-Subscription-Key": "Sanitized", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "033483e2516ec9aa820c90ec10e84892", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "apim-request-id": "ce762aba-e99c-485c-9028-de67986fe77c", + "Content-Type": "application/json; charset=utf-8", + "Date": "Sun, 26 Sep 2021 18:37:53 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "8" + }, + "ResponseBody": { + "jobId": "f1c090c9-e2dd-4a1a-b901-d81d253477af", + "lastUpdateDateTime": "2021-09-26T18:37:53Z", + "createdDateTime": "2021-09-26T18:37:53Z", + "expirationDateTime": "2021-09-27T18:37:53Z", + "status": "notStarted", + "errors": [], + "displayName": "NA", + "tasks": { + "completed": 0, + "failed": 0, + "inProgress": 1, + "total": 1 + } + } + }, + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/f1c090c9-e2dd-4a1a-b901-d81d253477af", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Ocp-Apim-Subscription-Key": "Sanitized", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "ac8394b2f677be1091d284ab791b8c09", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "apim-request-id": "f63d24c7-4100-4327-9bd6-ade3253f06c7", + "Content-Type": "application/json; charset=utf-8", + "Date": "Sun, 26 Sep 2021 18:37:55 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "93" + }, + "ResponseBody": { + "jobId": "f1c090c9-e2dd-4a1a-b901-d81d253477af", + "lastUpdateDateTime": "2021-09-26T18:37:54Z", + "createdDateTime": "2021-09-26T18:37:53Z", + "expirationDateTime": "2021-09-27T18:37:53Z", + "status": "succeeded", + "errors": [], + "displayName": "NA", + "tasks": { + "completed": 1, + "failed": 0, + "inProgress": 0, + "total": 1, + "customMultiClassificationTasks": [ + { + "lastUpdateDateTime": "2021-09-26T18:37:54.2581916Z", + "state": "succeeded", + "results": { + "documents": [ + { + "id": "0", + "classifications": [ + { + "category": "BookRestaurant", + "confidenceScore": 0.97 + } + ], + "warnings": [] + }, + { + "id": "1", + "classifications": [], + "warnings": [] + } + ], + "errors": [], + "projectName": "7cdace98-537b-494a-b69a-c19754718025", + "deploymentName": "7cdace98-537b-494a-b69a-c19754718025" + } + } + ] + } + } + } + ], + "Variables": { + "RandomSeed": "1222401182", + "TEXT_ANALYTICS_API_KEY": "Sanitized", + "TEXT_ANALYTICS_ENDPOINT": "https://cognitiveweppe.azure-api.net" + } +} \ No newline at end of file diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/MultiCategoryClassifyTests/MultiCategoryClassifyWithDisableServiceLogsAsync.json b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/MultiCategoryClassifyTests/MultiCategoryClassifyWithDisableServiceLogsAsync.json new file mode 100644 index 000000000000..a37014c4df64 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/MultiCategoryClassifyTests/MultiCategoryClassifyWithDisableServiceLogsAsync.json @@ -0,0 +1,181 @@ +{ + "Entries": [ + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Content-Length": "585", + "Content-Type": "application/json", + "Ocp-Apim-Subscription-Key": "Sanitized", + "traceparent": "00-bebbdf6a93e0da4cb8bce44a539d4c08-53d03d48247aa54a-00", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "0cc53751b5e8088ad70bde584eea5b24", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": { + "analysisInput": { + "documents": [ + { + "id": "0", + "text": "I need a reservation for an indoor restaurant in China. Please don\u0027t stop the music. Play music and add it to my playlist", + "language": "en" + }, + { + "id": "1", + "text": "David Schmidt, senior vice president--Food Safety, International Food Information Council (IFIC), Washington, D.C., discussed the physical activity component.", + "language": "en" + } + ] + }, + "tasks": { + "customMultiClassificationTasks": [ + { + "parameters": { + "project-name": "7cdace98-537b-494a-b69a-c19754718025", + "deployment-name": "7cdace98-537b-494a-b69a-c19754718025", + "loggingOptOut": true + } + } + ] + } + }, + "StatusCode": 202, + "ResponseHeaders": { + "apim-request-id": "b7dd0470-0b60-4d59-a78f-77f43e03c512", + "Date": "Sun, 26 Sep 2021 18:38:05 GMT", + "operation-location": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/df191a86-500d-40c8-93a5-0f3fdfca8063", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "168" + }, + "ResponseBody": [] + }, + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/df191a86-500d-40c8-93a5-0f3fdfca8063", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Ocp-Apim-Subscription-Key": "Sanitized", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "920ad4e241f22235a613d50d0c9708ba", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "apim-request-id": "425340ab-51a1-4433-8ea3-972190949e14", + "Content-Type": "application/json; charset=utf-8", + "Date": "Sun, 26 Sep 2021 18:38:05 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "8" + }, + "ResponseBody": { + "jobId": "df191a86-500d-40c8-93a5-0f3fdfca8063", + "lastUpdateDateTime": "2021-09-26T18:38:05Z", + "createdDateTime": "2021-09-26T18:38:05Z", + "expirationDateTime": "2021-09-27T18:38:05Z", + "status": "notStarted", + "errors": [], + "displayName": "NA", + "tasks": { + "completed": 0, + "failed": 0, + "inProgress": 1, + "total": 1 + } + } + }, + { + "RequestUri": "https://cognitiveweppe.azure-api.net/text/analytics/v3.2-preview.2/analyze/jobs/df191a86-500d-40c8-93a5-0f3fdfca8063", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": [ + "application/json", + "text/json" + ], + "Ocp-Apim-Subscription-Key": "Sanitized", + "User-Agent": [ + "azsdk-net-AI.TextAnalytics/5.2.0-alpha.20210926.1", + "(.NET Core 3.1.19; Microsoft Windows 10.0.19043)" + ], + "x-ms-client-request-id": "40e24aa3090e5727acea7d71b9400e84", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "apim-request-id": "26a16e0b-a39d-4ea7-bed2-1530514550ec", + "Content-Type": "application/json; charset=utf-8", + "Date": "Sun, 26 Sep 2021 18:38:06 GMT", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-envoy-upstream-service-time": "73" + }, + "ResponseBody": { + "jobId": "df191a86-500d-40c8-93a5-0f3fdfca8063", + "lastUpdateDateTime": "2021-09-26T18:38:06Z", + "createdDateTime": "2021-09-26T18:38:05Z", + "expirationDateTime": "2021-09-27T18:38:05Z", + "status": "succeeded", + "errors": [], + "displayName": "NA", + "tasks": { + "completed": 1, + "failed": 0, + "inProgress": 0, + "total": 1, + "customMultiClassificationTasks": [ + { + "lastUpdateDateTime": "2021-09-26T18:38:06.4863445Z", + "state": "succeeded", + "results": { + "documents": [ + { + "id": "0", + "classifications": [ + { + "category": "BookRestaurant", + "confidenceScore": 0.97 + } + ], + "warnings": [] + }, + { + "id": "1", + "classifications": [], + "warnings": [] + } + ], + "errors": [], + "projectName": "7cdace98-537b-494a-b69a-c19754718025", + "deploymentName": "7cdace98-537b-494a-b69a-c19754718025" + } + } + ] + } + } + } + ], + "Variables": { + "RandomSeed": "1982339428", + "TEXT_ANALYTICS_API_KEY": "Sanitized", + "TEXT_ANALYTICS_ENDPOINT": "https://cognitiveweppe.azure-api.net" + } +} \ No newline at end of file diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SingleCategoryClassifyTests.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SingleCategoryClassifyTests.cs index be8c64f49107..ccfcb674212c 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SingleCategoryClassifyTests.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SingleCategoryClassifyTests.cs @@ -254,7 +254,7 @@ private void ValidateSummaryBatchResult(SingleCategoryClassifyResultCollection r Assert.AreEqual(0, result.Statistics.TransactionCount); } - ValidateSummaryDocumentResult(result.ClassificationCategory); + ValidateSummaryDocumentResult(result.Classification); } } } diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/TextAnalyticsModelFactoryTests.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/TextAnalyticsModelFactoryTests.cs index 54a064ca12aa..220d24d7e21b 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/TextAnalyticsModelFactoryTests.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/TextAnalyticsModelFactoryTests.cs @@ -142,6 +142,12 @@ public void AnalyzeActionsResult() TextAnalyticsModelFactory.SingleCategoryClassifyActionResult(default, default) }; + var multiCategoryClassifyActionResults = new List() + { + TextAnalyticsModelFactory.MultiCategoryClassifyActionResult(default, default), + TextAnalyticsModelFactory.MultiCategoryClassifyActionResult(default, default) + }; + var actionsResult = TextAnalyticsModelFactory.AnalyzeActionsResult( extractKeyPhrasesActionResults, recognizeEntitiesActionResults, @@ -169,7 +175,8 @@ public void AnalyzeActionsResult() recognizeLinkedEntitiesActionResults, analyzeSentimentActionResults, extractSummaryActionResults, - singleCategoryClassifyActionResults); + singleCategoryClassifyActionResults, + multiCategoryClassifyActionResults); CollectionAssert.AreEquivalent(extractKeyPhrasesActionResults, actionsResult.ExtractKeyPhrasesResults); CollectionAssert.AreEquivalent(recognizeEntitiesActionResults, actionsResult.RecognizeEntitiesResults); @@ -178,6 +185,7 @@ public void AnalyzeActionsResult() CollectionAssert.AreEquivalent(analyzeSentimentActionResults, actionsResult.AnalyzeSentimentResults); CollectionAssert.AreEquivalent(extractSummaryActionResults, actionsResult.ExtractSummaryResults); CollectionAssert.AreEquivalent(singleCategoryClassifyActionResults, actionsResult.SingleCategoryClassifyResults); + CollectionAssert.AreEquivalent(multiCategoryClassifyActionResults, actionsResult.MultiCategoryClassifyResults); } [Test] diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample10_SingleCategoryClassify.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample10_SingleCategoryClassify.cs index c2df6873b201..775193a0457f 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample10_SingleCategoryClassify.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample10_SingleCategoryClassify.cs @@ -35,13 +35,8 @@ public void SingleCategoryClassify() }; // Set project and deployment names of the target model -#if SNIPPET - string projectName = ""; - string deploymentName = ""; -#else string projectName = TestEnvironment.SingleClassificationProjectName; string deploymentName = TestEnvironment.SingleClassificationDeploymentName; -#endif var singleCategoryClassifyAction = new SingleCategoryClassifyAction(projectName, deploymentName); @@ -88,7 +83,7 @@ public void SingleCategoryClassify() { foreach (SingleCategoryClassifyResult documentResults in classificationActionResults.DocumentsResults) { - Console.WriteLine($" Class category \"{documentResults.ClassificationCategory.Category}\" predicted with a confidence score of {documentResults.ClassificationCategory.ConfidenceScore}."); + Console.WriteLine($" Class category \"{documentResults.Classification.Category}\" predicted with a confidence score of {documentResults.Classification.ConfidenceScore}."); Console.WriteLine(); } } diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample10_SingleCategoryClassifyAsync.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample10_SingleCategoryClassifyAsync.cs index 312e3c3cc972..ccb583d26aab 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample10_SingleCategoryClassifyAsync.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample10_SingleCategoryClassifyAsync.cs @@ -35,13 +35,8 @@ public async Task SingleCategoryClassifyAsync() }; // Set project and deployment names of the target model -#if SNIPPET - string projectName = ""; - string deploymentName = ""; -#else string projectName = TestEnvironment.SingleClassificationProjectName; string deploymentName = TestEnvironment.SingleClassificationDeploymentName; -#endif var singleCategoryClassifyAction = new SingleCategoryClassifyAction(projectName, deploymentName); @@ -75,7 +70,7 @@ public async Task SingleCategoryClassifyAsync() { foreach (SingleCategoryClassifyResult documentResults in classificationActionResults.DocumentsResults) { - Console.WriteLine($" Class category \"{documentResults.ClassificationCategory.Category}\" predicted with a confidence score of {documentResults.ClassificationCategory.ConfidenceScore}."); + Console.WriteLine($" Class category \"{documentResults.Classification.Category}\" predicted with a confidence score of {documentResults.Classification.ConfidenceScore}."); Console.WriteLine(); } } diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample10_SingleCategoryClassifyConvenience.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample10_SingleCategoryClassifyConvenience.cs index 156dffef5970..5f38abc706e3 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample10_SingleCategoryClassifyConvenience.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample10_SingleCategoryClassifyConvenience.cs @@ -32,13 +32,8 @@ public void SingleCategoryClassifyConvenience() }; // Set project and deployment names of the target model -#if SNIPPET - string projectName = ""; - string deploymentName = ""; -#else string projectName = TestEnvironment.SingleClassificationProjectName; string deploymentName = TestEnvironment.SingleClassificationDeploymentName; -#endif var singleCategoryClassifyAction = new SingleCategoryClassifyAction(projectName, deploymentName); @@ -85,7 +80,7 @@ public void SingleCategoryClassifyConvenience() { foreach (SingleCategoryClassifyResult documentResults in classificationActionResults.DocumentsResults) { - Console.WriteLine($" Class category \"{documentResults.ClassificationCategory.Category}\" predicted with a confidence score of {documentResults.ClassificationCategory.ConfidenceScore}."); + Console.WriteLine($" Class category \"{documentResults.Classification.Category}\" predicted with a confidence score of {documentResults.Classification.ConfidenceScore}."); Console.WriteLine(); } } diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample10_SingleCategoryClassifyConvenienceAsync.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample10_SingleCategoryClassifyConvenienceAsync.cs index c80940617233..53d4e0f28e02 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample10_SingleCategoryClassifyConvenienceAsync.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample10_SingleCategoryClassifyConvenienceAsync.cs @@ -77,7 +77,7 @@ public async Task SingleCategoryClassifyConvenienceAsync() { foreach (SingleCategoryClassifyResult documentResults in classificationActionResults.DocumentsResults) { - Console.WriteLine($" Class category \"{documentResults.ClassificationCategory.Category}\" predicted with a confidence score of {documentResults.ClassificationCategory.ConfidenceScore}."); + Console.WriteLine($" Class category \"{documentResults.Classification.Category}\" predicted with a confidence score of {documentResults.Classification.ConfidenceScore}."); Console.WriteLine(); } } diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample11_MultiCategoryClassify.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample11_MultiCategoryClassify.cs new file mode 100644 index 000000000000..20eea3d305ea --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample11_MultiCategoryClassify.cs @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Threading; +using Azure.AI.TextAnalytics.Tests; +using Azure.Core.TestFramework; +using NUnit.Framework; + +namespace Azure.AI.TextAnalytics.Samples +{ + public partial class TextAnalyticsSamples : SamplesBase + { + [Test] + public void MultiCategoryClassify() + { + // Create a text analytics client. + string endpoint = TestEnvironment.Endpoint; + string apiKey = TestEnvironment.ApiKey; + + var client = new TextAnalyticsClient(new Uri(endpoint), new AzureKeyCredential(apiKey)); + + // Get input document. + string document = @"I need a reservation for an indoor restaurant in China. Please don't stop the music. Play music and add it to my playlist."; + + // Prepare analyze operation input. You can add multiple documents to this list and perform the same + // operation to all of them. + var batchDocuments = new List + { + new TextDocumentInput("1", document) + { + Language = "en", + } + }; + + // Set project and deployment names of the target model + string projectName = TestEnvironment.MultiClassificationProjectName; + string deploymentName = TestEnvironment.MultiClassificationDeploymentName; + + var multiCategoryClassifyAction = new MultiCategoryClassifyAction(projectName, deploymentName); + + TextAnalyticsActions actions = new TextAnalyticsActions() + { + MultiCategoryClassifyActions = new List() { multiCategoryClassifyAction } + }; + + // Start analysis process. + AnalyzeActionsOperation operation = client.StartAnalyzeActions(batchDocuments, actions); + + // Wait for completion with manual polling. + TimeSpan pollingInterval = new TimeSpan(1000); + + while (true) + { + Console.WriteLine($"Status: {operation.Status}"); + operation.UpdateStatus(); + if (operation.HasCompleted) + { + break; + } + + Thread.Sleep(pollingInterval); + } + + // View operation status. + Console.WriteLine($"AnalyzeActions operation has completed"); + Console.WriteLine(); + + Console.WriteLine($"Created On : {operation.CreatedOn}"); + Console.WriteLine($"Expires On : {operation.ExpiresOn}"); + Console.WriteLine($"Id : {operation.Id}"); + Console.WriteLine($"Status : {operation.Status}"); + Console.WriteLine($"Last Modified: {operation.LastModified}"); + Console.WriteLine(); + + // View operation results. + foreach (AnalyzeActionsResult documentsInPage in operation.GetValues()) + { + IReadOnlyCollection multiClassificationActionResults = documentsInPage.MultiCategoryClassifyResults; + + foreach (MultiCategoryClassifyActionResult classificationActionResults in multiClassificationActionResults) + { + foreach (MultiCategoryClassifyResult documentResults in classificationActionResults.DocumentsResults) + { + if (documentResults.Classifications.Count > 0) + { + Console.WriteLine($" The following classes were predicted for this document:"); + + foreach (ClassificationCategory classification in documentResults.Classifications) + { + Console.WriteLine($" Class category \"{classification.Category}\" predicted with a confidence score of {classification.ConfidenceScore}."); + } + + Console.WriteLine(); + } + } + } + } + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample11_MultiCategoryClassifyAsync.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample11_MultiCategoryClassifyAsync.cs new file mode 100644 index 000000000000..6ce186d23361 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample11_MultiCategoryClassifyAsync.cs @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure.AI.TextAnalytics.Tests; +using Azure.Core.TestFramework; +using NUnit.Framework; + +namespace Azure.AI.TextAnalytics.Samples +{ + public partial class TextAnalyticsSamples : SamplesBase + { + [Test] + public async Task MultiCategoryClassifyAsync() + { + // Create a text analytics client. + string endpoint = TestEnvironment.Endpoint; + string apiKey = TestEnvironment.ApiKey; + + var client = new TextAnalyticsClient(new Uri(endpoint), new AzureKeyCredential(apiKey)); + + // Get input document. + string document = @"I need a reservation for an indoor restaurant in China. Please don't stop the music. Play music and add it to my playlist."; + + // Prepare analyze operation input. You can add multiple documents to this list and perform the same + // operation to all of them. + var batchDocuments = new List + { + new TextDocumentInput("1", document) + { + Language = "en", + } + }; + + // Set project and deployment names of the target model + string projectName = TestEnvironment.MultiClassificationProjectName; + string deploymentName = TestEnvironment.MultiClassificationDeploymentName; + + var multiCategoryClassifyAction = new MultiCategoryClassifyAction(projectName, deploymentName); + + TextAnalyticsActions actions = new TextAnalyticsActions() + { + MultiCategoryClassifyActions = new List() { multiCategoryClassifyAction } + }; + + // Start analysis process. + AnalyzeActionsOperation operation = await client.StartAnalyzeActionsAsync(batchDocuments, actions); + + await operation.WaitForCompletionAsync(); + + // View operation status. + Console.WriteLine($"AnalyzeActions operation has completed"); + Console.WriteLine(); + + Console.WriteLine($"Created On : {operation.CreatedOn}"); + Console.WriteLine($"Expires On : {operation.ExpiresOn}"); + Console.WriteLine($"Id : {operation.Id}"); + Console.WriteLine($"Status : {operation.Status}"); + Console.WriteLine($"Last Modified: {operation.LastModified}"); + Console.WriteLine(); + + // View operation results. + await foreach (AnalyzeActionsResult documentsInPage in operation.Value) + { + IReadOnlyCollection multiClassificationActionResults = documentsInPage.MultiCategoryClassifyResults; + + foreach (MultiCategoryClassifyActionResult classificationActionResults in multiClassificationActionResults) + { + foreach (MultiCategoryClassifyResult documentResults in classificationActionResults.DocumentsResults) + { + if (documentResults.Classifications.Count > 0) + { + Console.WriteLine($" The following classes were predicted for this document:"); + + foreach (ClassificationCategory classification in documentResults.Classifications) + { + Console.WriteLine($" Class category \"{classification.Category}\" predicted with a confidence score of {classification.ConfidenceScore}."); + } + + Console.WriteLine(); + } + } + } + } + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample11_MultiCategoryClassifyConvenience.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample11_MultiCategoryClassifyConvenience.cs new file mode 100644 index 000000000000..c67c243e4e57 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample11_MultiCategoryClassifyConvenience.cs @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Threading; +using Azure.AI.TextAnalytics.Tests; +using Azure.Core.TestFramework; +using NUnit.Framework; + +namespace Azure.AI.TextAnalytics.Samples +{ + public partial class TextAnalyticsSamples : SamplesBase + { + [Test] + public void MultiCategoryClassifyConvenience() + { + // Create a text analytics client. + string endpoint = TestEnvironment.Endpoint; + string apiKey = TestEnvironment.ApiKey; + + var client = new TextAnalyticsClient(new Uri(endpoint), new AzureKeyCredential(apiKey)); + + // Get input document. + string document = @"I need a reservation for an indoor restaurant in China. Please don't stop the music. Play music and add it to my playlist."; + + // Prepare analyze operation input. You can add multiple documents to this list and perform the same + // operation to all of them. + var batchInput = new List + { + document + }; + + // Set project and deployment names of the target model + string projectName = TestEnvironment.MultiClassificationProjectName; + string deploymentName = TestEnvironment.MultiClassificationDeploymentName; + + var multiCategoryClassifyAction = new MultiCategoryClassifyAction(projectName, deploymentName); + + TextAnalyticsActions actions = new TextAnalyticsActions() + { + MultiCategoryClassifyActions = new List() { multiCategoryClassifyAction } + }; + + // Start analysis process. + AnalyzeActionsOperation operation = client.StartAnalyzeActions(batchInput, actions); + + // Wait for completion with manual polling. + TimeSpan pollingInterval = new TimeSpan(1000); + + while (true) + { + Console.WriteLine($"Status: {operation.Status}"); + operation.UpdateStatus(); + if (operation.HasCompleted) + { + break; + } + + Thread.Sleep(pollingInterval); + } + + // View operation status. + Console.WriteLine($"AnalyzeActions operation has completed"); + Console.WriteLine(); + + Console.WriteLine($"Created On : {operation.CreatedOn}"); + Console.WriteLine($"Expires On : {operation.ExpiresOn}"); + Console.WriteLine($"Id : {operation.Id}"); + Console.WriteLine($"Status : {operation.Status}"); + Console.WriteLine($"Last Modified: {operation.LastModified}"); + Console.WriteLine(); + + // View operation results. + foreach (AnalyzeActionsResult documentsInPage in operation.GetValues()) + { + IReadOnlyCollection multiClassificationActionResults = documentsInPage.MultiCategoryClassifyResults; + + foreach (MultiCategoryClassifyActionResult classificationActionResults in multiClassificationActionResults) + { + foreach (MultiCategoryClassifyResult documentResults in classificationActionResults.DocumentsResults) + { + if (documentResults.Classifications.Count > 0) + { + Console.WriteLine($" The following classes were predicted for this document:"); + + foreach (ClassificationCategory classification in documentResults.Classifications) + { + Console.WriteLine($" Class category \"{classification.Category}\" predicted with a confidence score of {classification.ConfidenceScore}."); + } + + Console.WriteLine(); + } + } + } + } + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample11_MultiCategoryClassifyConvenienceAsync.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample11_MultiCategoryClassifyConvenienceAsync.cs new file mode 100644 index 000000000000..e538ca37f6e2 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample11_MultiCategoryClassifyConvenienceAsync.cs @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure.AI.TextAnalytics.Tests; +using Azure.Core.TestFramework; +using NUnit.Framework; + +namespace Azure.AI.TextAnalytics.Samples +{ + public partial class TextAnalyticsSamples : SamplesBase + { + [Test] + public async Task MultiCategoryClassifyConvenienceAsync() + { + // Create a text analytics client. + string endpoint = TestEnvironment.Endpoint; + string apiKey = TestEnvironment.ApiKey; + + var client = new TextAnalyticsClient(new Uri(endpoint), new AzureKeyCredential(apiKey)); + + #region Snippet:TextAnalyticsMultiCategoryClassifyAsync + // Get input document. + string document = @"I need a reservation for an indoor restaurant in China. Please don't stop the music. Play music and add it to my playlist."; + + // Prepare analyze operation input. You can add multiple documents to this list and perform the same + // operation to all of them. + var batchInput = new List + { + document + }; + + // Set project and deployment names of the target model +#if SNIPPET + string projectName = ""; + string deploymentName = ""; +#else + string projectName = TestEnvironment.MultiClassificationProjectName; + string deploymentName = TestEnvironment.MultiClassificationDeploymentName; +#endif + + var multiCategoryClassifyAction = new MultiCategoryClassifyAction(projectName, deploymentName); + + TextAnalyticsActions actions = new TextAnalyticsActions() + { + MultiCategoryClassifyActions = new List() { multiCategoryClassifyAction } + }; + + // Start analysis process. + AnalyzeActionsOperation operation = await client.StartAnalyzeActionsAsync(batchInput, actions); + + await operation.WaitForCompletionAsync(); + #endregion Snippet:TextAnalyticsMultiCategoryClassifyAsync + + #region Snippet:TextAnalyticsMultiCategoryClassifyOperationStatus + // View operation status. + Console.WriteLine($"AnalyzeActions operation has completed"); + Console.WriteLine(); + + Console.WriteLine($"Created On : {operation.CreatedOn}"); + Console.WriteLine($"Expires On : {operation.ExpiresOn}"); + Console.WriteLine($"Id : {operation.Id}"); + Console.WriteLine($"Status : {operation.Status}"); + Console.WriteLine($"Last Modified: {operation.LastModified}"); + Console.WriteLine(); + #endregion Snippet:TextAnalyticsMultiCategoryClassifyOperationStatus + + #region Snippet:TextAnalyticsMultiCategoryClassifyAsyncViewResults + // View operation results. + await foreach (AnalyzeActionsResult documentsInPage in operation.Value) + { + IReadOnlyCollection multiClassificationActionResults = documentsInPage.MultiCategoryClassifyResults; + + foreach (MultiCategoryClassifyActionResult classificationActionResults in multiClassificationActionResults) + { + foreach (MultiCategoryClassifyResult documentResults in classificationActionResults.DocumentsResults) + { + if (documentResults.Classifications.Count > 0) + { + Console.WriteLine($" The following classes were predicted for this document:"); + + foreach (ClassificationCategory classification in documentResults.Classifications) + { + Console.WriteLine($" Class category \"{classification.Category}\" predicted with a confidence score of {classification.ConfidenceScore}."); + } + + Console.WriteLine(); + } + } + } + } + #endregion Snippet:TextAnalyticsMultiCategoryClassifyAsyncViewResults + } + } +}