Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions sdk/textanalytics/Azure.AI.TextAnalytics/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

### Features Added
- Adding support for three new actions in `StartAnalyzeActions`: `RecognizeCustomEntities`, `SingleCategoryClassify`, and `MultiCategoriesClassify`. The new actions allow you to use custom models to perform entity recognition and category classification.
- Added property `ActionName` to all `xxActions` input types so user can specify a name per action. If not provided, service will generate a name.
- Added property `ActionName` to all `xxActionResult` output types that displays the name of each action.
- Added suppport for multiple actions of the same type.

### Breaking Changes

Expand Down
1 change: 1 addition & 0 deletions sdk/textanalytics/Azure.AI.TextAnalytics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,7 @@ This functionality allows running multiple actions in one or more documents. Act
int docNumber = 1;
foreach (RecognizeEntitiesActionResult entitiesActionResults in entitiesResults)
{
Console.WriteLine($" Action name: {entitiesActionResults.ActionName}");
foreach (RecognizeEntitiesResult documentResults in entitiesActionResults.DocumentsResults)
{
Console.WriteLine($" Document #{docNumber++}");
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ await foreach (AnalyzeActionsResult documentsInPage in operation.Value)

foreach (SingleCategoryClassifyActionResult classificationActionResults in singleClassificationActionResults)
{
Console.WriteLine($" Action name: {classificationActionResults.ActionName}");
foreach (SingleCategoryClassifyResult documentResults in classificationActionResults.DocumentsResults)
{
Console.WriteLine($" Class category \"{documentResults.Classification.Category}\" predicted with a confidence score of {documentResults.Classification.ConfidenceScore}.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ await foreach (AnalyzeActionsResult documentsInPage in operation.Value)

foreach (MultiCategoryClassifyActionResult classificationActionResults in multiClassificationActionResults)
{
Console.WriteLine($" Action name: {classificationActionResults.ActionName}");
foreach (MultiCategoryClassifyResult documentResults in classificationActionResults.DocumentsResults)
{
if (documentResults.Classifications.Count > 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ await foreach (AnalyzeActionsResult documentsInPage in operation.Value)
IReadOnlyCollection<RecognizeCustomEntitiesActionResult> customEntitiesActionResults = documentsInPage.RecognizeCustomEntitiesResults;
foreach (RecognizeCustomEntitiesActionResult customEntitiesActionResult in customEntitiesActionResults)
{
Console.WriteLine($" Action name: {customEntitiesActionResult.ActionName}");
int docNumber = 1;
foreach (RecognizeEntitiesResult documentResults in customEntitiesActionResult.DocumentsResults)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ To run multiple actions in multiple documents, call `StartAnalyzeActionsAsync` o
int docNumber = 1;
foreach (RecognizeEntitiesActionResult entitiesActionResults in entitiesResults)
{
Console.WriteLine($" Action name: {entitiesActionResults.ActionName}");
foreach (RecognizeEntitiesResult documentResults in entitiesActionResults.DocumentsResults)
{
Console.WriteLine($" Document #{docNumber++}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,10 @@ public AnalyzeSentimentAction(AnalyzeSentimentOptions options)
/// This property only has value for <see cref="TextAnalyticsClientOptions.ServiceVersion.V3_1"/> and up.
/// </remarks>
public bool? IncludeOpinionMining { get; set; }

/// <summary>
/// Gets or sets a name for this action. If not provided, the service will generate one.
/// </summary>
public string ActionName { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ public class AnalyzeSentimentActionResult : TextAnalyticsActionResult
/// <summary>
/// Successful action.
/// </summary>
internal AnalyzeSentimentActionResult(AnalyzeSentimentResultCollection result, DateTimeOffset completedOn)
: base(completedOn)
internal AnalyzeSentimentActionResult(AnalyzeSentimentResultCollection result, string actionName, DateTimeOffset completedOn)
: base(actionName, completedOn)
{
_documentsResults = result;
}

/// <summary>
/// Action with an error.
/// </summary>
internal AnalyzeSentimentActionResult(DateTimeOffset completedOn, TextAnalyticsErrorInternal error)
: base(completedOn, error) { }
internal AnalyzeSentimentActionResult(string actionName, DateTimeOffset completedOn, TextAnalyticsErrorInternal error)
: base(actionName, completedOn, error) { }

/// <summary>
/// Gets the result of the execution of an <see cref="AnalyzeSentimentAction"/> per each input document.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,10 @@ public ExtractKeyPhrasesAction(TextAnalyticsRequestOptions options)
/// This property only applies for <see cref="TextAnalyticsClientOptions.ServiceVersion.V3_1"/> and up.
/// </remarks>
public bool? DisableServiceLogs { get; set; }

/// <summary>
/// Gets or sets a name for this action. If not provided, the service will generate one.
/// </summary>
public string ActionName { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ public class ExtractKeyPhrasesActionResult : TextAnalyticsActionResult
/// <summary>
/// Successful action.
/// </summary>
internal ExtractKeyPhrasesActionResult(ExtractKeyPhrasesResultCollection result, DateTimeOffset completedOn)
: base(completedOn)
internal ExtractKeyPhrasesActionResult(ExtractKeyPhrasesResultCollection result, string actionName, DateTimeOffset completedOn)
: base(actionName, completedOn)
{
_documentsResults = result;
}

/// <summary>
/// Action with an error.
/// </summary>
internal ExtractKeyPhrasesActionResult(DateTimeOffset completedOn, TextAnalyticsErrorInternal error)
: base(completedOn, error) { }
internal ExtractKeyPhrasesActionResult(string actionName, DateTimeOffset completedOn,TextAnalyticsErrorInternal error)
: base(actionName, completedOn, error) { }

/// <summary>
/// Gets the result of the execution of an <see cref="ExtractKeyPhrasesAction"/> per each input document.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,10 @@ public ExtractSummaryAction()
/// to the input document, as decided by the service. Defaults to <see cref="SummarySentencesOrder.Offset"/>.
/// </summary>
public SummarySentencesOrder? OrderBy { get; set; }

/// <summary>
/// Gets or sets a name for this action. If not provided, the service will generate one.
/// </summary>
public string ActionName { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ public class ExtractSummaryActionResult : TextAnalyticsActionResult
/// <summary>
/// Successful action.
/// </summary>
internal ExtractSummaryActionResult(ExtractSummaryResultCollection result, DateTimeOffset completedOn)
: base(completedOn)
internal ExtractSummaryActionResult(ExtractSummaryResultCollection result, string actionName, DateTimeOffset completedOn)
: base(actionName, completedOn)
{
_documentsResults = result;
}

/// <summary>
/// Action with an error.
/// </summary>
internal ExtractSummaryActionResult(DateTimeOffset completedOn, TextAnalyticsErrorInternal error)
: base(completedOn, error) { }
internal ExtractSummaryActionResult(string actionName, DateTimeOffset completedOn,TextAnalyticsErrorInternal error)
: base(actionName, completedOn, error) { }

/// <summary>
/// Gets the result of the execution of an <see cref="ExtractSummaryAction"/> per each input document.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,10 @@ public MultiCategoryClassifyAction(string projectName, string deploymentName)
/// </para>
/// </summary>
public bool? DisableServiceLogs { get; set; }

/// <summary>
/// Gets or sets a name for this action. If not provided, the service will generate one.
/// </summary>
public string ActionName { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ public class MultiCategoryClassifyActionResult : TextAnalyticsActionResult
/// <summary>
/// Successful action.
/// </summary>
internal MultiCategoryClassifyActionResult(MultiCategoryClassifyResultCollection result, DateTimeOffset completedOn)
: base(completedOn)
internal MultiCategoryClassifyActionResult(MultiCategoryClassifyResultCollection result, string actionName, DateTimeOffset completedOn)
: base(actionName, completedOn)
{
_documentsResults = result;
}

/// <summary>
/// Action with an error.
/// </summary>
internal MultiCategoryClassifyActionResult(DateTimeOffset completedOn, TextAnalyticsErrorInternal error)
: base(completedOn, error) { }
internal MultiCategoryClassifyActionResult(string actionName, DateTimeOffset completedOn, TextAnalyticsErrorInternal error)
: base(actionName, completedOn, error) { }

/// <summary>
/// Gets the result of the execution of a <see cref="MultiCategoryClassifyAction"/> per each input document.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,10 @@ public RecognizeCustomEntitiesAction(string projectName, string deploymentName)
/// </para>
/// </summary>
public bool? DisableServiceLogs { get; set; }

/// <summary>
/// Gets or sets a name for this action. If not provided, the service will generate one.
/// </summary>
public string ActionName { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ public class RecognizeCustomEntitiesActionResult : TextAnalyticsActionResult
/// <summary>
/// Successful action.
/// </summary>
internal RecognizeCustomEntitiesActionResult(RecognizeCustomEntitiesResultCollection result, DateTimeOffset completedOn)
: base(completedOn)
internal RecognizeCustomEntitiesActionResult(RecognizeCustomEntitiesResultCollection result, string actionName, DateTimeOffset completedOn)
: base(actionName, completedOn)
{
_documentsResults = result;
}

/// <summary>
/// Action with an error.
/// </summary>
internal RecognizeCustomEntitiesActionResult(DateTimeOffset completedOn, TextAnalyticsErrorInternal error)
: base(completedOn, error) { }
internal RecognizeCustomEntitiesActionResult(string actionName, DateTimeOffset completedOn,TextAnalyticsErrorInternal error)
: base(actionName, completedOn, error) { }

/// <summary>
/// Gets the result of the execution of a <see cref="RecognizeCustomEntitiesAction"/> per each input document.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,10 @@ public RecognizeEntitiesAction(TextAnalyticsRequestOptions options)
/// This property only applies for <see cref="TextAnalyticsClientOptions.ServiceVersion.V3_1"/> and up.
/// </remarks>
public bool? DisableServiceLogs { get; set; }

/// <summary>
/// Gets or sets a name for this action. If not provided, the service will generate one.
/// </summary>
public string ActionName { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ public class RecognizeEntitiesActionResult : TextAnalyticsActionResult
/// <summary>
/// Successful action.
/// </summary>
internal RecognizeEntitiesActionResult(RecognizeEntitiesResultCollection result, DateTimeOffset completedOn)
: base(completedOn)
internal RecognizeEntitiesActionResult(RecognizeEntitiesResultCollection result, string actionName, DateTimeOffset completedOn)
: base(actionName, completedOn)
{
_documentsResults = result;
}

/// <summary>
/// Action with an error.
/// </summary>
internal RecognizeEntitiesActionResult(DateTimeOffset completedOn, TextAnalyticsErrorInternal error)
: base(completedOn, error) { }
internal RecognizeEntitiesActionResult(string actionName, DateTimeOffset completedOn, TextAnalyticsErrorInternal error)
: base(actionName, completedOn, error) { }

/// <summary>
/// Gets the result of the execution of a <see cref="RecognizeEntitiesAction"/> per each input document.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,10 @@ public RecognizeLinkedEntitiesAction(TextAnalyticsRequestOptions options)
/// This property only applies for <see cref="TextAnalyticsClientOptions.ServiceVersion.V3_1"/> and up.
/// </remarks>
public bool? DisableServiceLogs { get; set; }

/// <summary>
/// Gets or sets a name for this action. If not provided, the service will generate one.
/// </summary>
public string ActionName { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ public class RecognizeLinkedEntitiesActionResult : TextAnalyticsActionResult
/// <summary>
/// Successful action.
/// </summary>
internal RecognizeLinkedEntitiesActionResult(RecognizeLinkedEntitiesResultCollection result, DateTimeOffset completedOn)
: base(completedOn)
internal RecognizeLinkedEntitiesActionResult(RecognizeLinkedEntitiesResultCollection result, string actionName, DateTimeOffset completedOn)
: base(actionName, completedOn)
{
_documentsResults = result;
}

/// <summary>
/// Action with an error.
/// </summary>
internal RecognizeLinkedEntitiesActionResult(DateTimeOffset completedOn, TextAnalyticsErrorInternal error)
: base(completedOn, error) { }
internal RecognizeLinkedEntitiesActionResult(string actionName, DateTimeOffset completedOn,TextAnalyticsErrorInternal error)
: base(actionName, completedOn, error) { }

/// <summary>
/// Gets the result of the execution of a <see cref="RecognizeLinkedEntitiesAction"/> per each input document.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,10 @@ public RecognizePiiEntitiesAction(RecognizePiiEntitiesOptions options)
/// Filters the response entities to entities that match the <see cref="PiiEntityCategory"/> specified.
/// </summary>
public IList<PiiEntityCategory> CategoriesFilter { get; internal set; } = new List<PiiEntityCategory>();

/// <summary>
/// Gets or sets a name for this action. If not provided, the service will generate one.
/// </summary>
public string ActionName { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ public class RecognizePiiEntitiesActionResult : TextAnalyticsActionResult
/// <summary>
/// Successful action.
/// </summary>
internal RecognizePiiEntitiesActionResult(RecognizePiiEntitiesResultCollection result, DateTimeOffset completedOn)
: base(completedOn)
internal RecognizePiiEntitiesActionResult(RecognizePiiEntitiesResultCollection result, string actionName, DateTimeOffset completedOn)
: base(actionName, completedOn)
{
_documentsResults = result;
}

/// <summary>
/// Action with an error.
/// </summary>
internal RecognizePiiEntitiesActionResult(DateTimeOffset completedOn, TextAnalyticsErrorInternal error)
: base(completedOn, error) { }
internal RecognizePiiEntitiesActionResult(string actionName, DateTimeOffset completedOn, TextAnalyticsErrorInternal error)
: base(actionName, completedOn, error) { }

/// <summary>
/// Gets the result of the execution of a <see cref="RecognizePiiEntitiesAction"/> per each input document.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,10 @@ public SingleCategoryClassifyAction(string projectName, string deploymentName)
/// </para>
/// </summary>
public bool? DisableServiceLogs { get; set; }

/// <summary>
/// Gets or sets a name for this action. If not provided, the service will generate one.
/// </summary>
public string ActionName { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ public class SingleCategoryClassifyActionResult : TextAnalyticsActionResult
/// <summary>
/// Successful action.
/// </summary>
internal SingleCategoryClassifyActionResult(SingleCategoryClassifyResultCollection result, DateTimeOffset completedOn)
: base(completedOn)
internal SingleCategoryClassifyActionResult(SingleCategoryClassifyResultCollection result, string actionName, DateTimeOffset completedOn)
: base(actionName, completedOn)
{
_documentsResults = result;
}

/// <summary>
/// Action with an error.
/// </summary>
internal SingleCategoryClassifyActionResult(DateTimeOffset completedOn, TextAnalyticsErrorInternal error)
: base(completedOn, error) { }
internal SingleCategoryClassifyActionResult(string actionName, DateTimeOffset completedOn,TextAnalyticsErrorInternal error)
: base(actionName, completedOn, error) { }

/// <summary>
/// Gets the result of the execution of a <see cref="SingleCategoryClassifyAction"/> per each input document.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ namespace Azure.AI.TextAnalytics
/// </summary>
public class TextAnalyticsActionResult
{
internal TextAnalyticsActionResult (DateTimeOffset completedOn, TextAnalyticsErrorInternal error)
internal TextAnalyticsActionResult(string actionName, DateTimeOffset completedOn, TextAnalyticsErrorInternal error)
{
ActionName = actionName;
CompletedOn = completedOn;
Error = error != null ? Transforms.ConvertToError(error) : default;
}

internal TextAnalyticsActionResult(DateTimeOffset completedOn)
internal TextAnalyticsActionResult(string actionName, DateTimeOffset completedOn)
{
ActionName = actionName;
CompletedOn = completedOn;
}

Expand All @@ -36,5 +38,10 @@ internal TextAnalyticsActionResult(DateTimeOffset completedOn)
/// Indicates that the document was not successfully processed and an error was returned for this document.
/// </summary>
public bool HasError => Error.ErrorCode != default;

/// <summary>
/// Gets the name for this action.
/// </summary>
public string ActionName { get; }
}
}
Loading