Skip to content

Commit bf77cd8

Browse files
authored
[TA] Add pii category to simple api (Azure#19087)
* add pii category to simple api * add changelog * pr feedback
1 parent 68bf6c9 commit bf77cd8

File tree

34 files changed

+1917
-344
lines changed

34 files changed

+1917
-344
lines changed

sdk/textanalytics/Azure.AI.TextAnalytics/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
# Release History
22

33
## 5.1.0-beta.5 (Unreleased)
4+
### New features
5+
- Added ability to filter the categories returned in a Personally Identifiable Information recognition with the optional parameter `CategoriesFilter` in `RecognizePiiEntitiesOptions`.
6+
47
### Breaking changes
58
- Renamed `AspectSentiment` to `TargetSentiment`.
69
- Renamed `MinedOpinion` to `SentenceOpinion`.
710
- Renamed `OpinionSentiment` to `AssessmentSentiment`.
11+
- For `PiiEntity.Category` the type of the property is now `PiiEntityCategory` instead of `EntityCategory`.
812

913
## 5.1.0-beta.4 (2021-02-10)
1014
### New features

sdk/textanalytics/Azure.AI.TextAnalytics/api/Azure.AI.TextAnalytics.netstandard2.0.cs

Lines changed: 191 additions & 1 deletion
Large diffs are not rendered by default.

sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample5_RecognizePiiEntities.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ Console.WriteLine("");
191191
To see the full example source files, see:
192192
* [Synchronous RecognizePiiEntities](https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample5_RecognizePiiEntities.cs)
193193
* [Asynchronous RecognizePiiEntities](https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample5_RecognizePiiEntitiesAsync.cs)
194+
* [Recognize PII Entities with specific categories](https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample5_RecognizePiiEntitiesWithCategoriesFilter.cs)
194195
* [Synchronous RecognizePiiEntitiesBatch](https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample5_RecognizePiiEntitiesBatch.cs)
195196
* [Asynchronous RecognizePiiEntitiesBatch](https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample5_RecognizePiiEntitiesBatchAsync.cs)
196197
* [Synchronous RecognizePiiEntitiesBatchConvenience](https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample5_RecognizePiiEntitiesBatchConvenience.cs)

sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/PiiCategory.cs renamed to sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/PiiEntityCategory.cs

Lines changed: 185 additions & 185 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/PiiTaskParameters.cs

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/TextAnalyticsRestClient.cs

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/textanalytics/Azure.AI.TextAnalytics/src/PiiEntity.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ internal PiiEntity(Entity entity)
2929
public string Text { get; }
3030

3131
/// <summary>
32-
/// Gets the entity category inferred by the Text Analytics service's
32+
/// Gets the PII entity category inferred by the Text Analytics service's
3333
/// named entity recognition model, such as Financial Account
3434
/// Identification/Social Security Number/Phone Number, etc.
3535
/// The list of available categories is described at
3636
/// <a href="https://aka.ms/tanerpii"/>.
3737
/// </summary>
38-
public EntityCategory Category { get; }
38+
public PiiEntityCategory Category { get; }
3939

4040
/// <summary>
4141
/// Gets the sub category of the entity inferred by the Text Analytics service's

sdk/textanalytics/Azure.AI.TextAnalytics/src/PiiCategory.cs renamed to sdk/textanalytics/Azure.AI.TextAnalytics/src/PiiEntityCategory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
using Azure.Core;
55

6-
namespace Azure.AI.TextAnalytics.Models
6+
namespace Azure.AI.TextAnalytics
77
{
88
[CodeGenModel("PiiCategory")]
9-
internal readonly partial struct PiiCategory
9+
public readonly partial struct PiiEntityCategory
1010
{
1111
}
1212
}

sdk/textanalytics/Azure.AI.TextAnalytics/src/RecognizePiiEntitiesOptions.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4+
using System.Collections.Generic;
5+
46
namespace Azure.AI.TextAnalytics
57
{
68
/// <summary>
@@ -25,5 +27,10 @@ public RecognizePiiEntitiesOptions()
2527
/// For more information see <a href="https://aka.ms/tanerpii"/>.
2628
/// </summary>
2729
public PiiEntityDomainType DomainFilter { get; set; }
30+
31+
/// <summary>
32+
/// Filters the response entities to entities that match the <see cref="PiiEntityCategory"/> specified.
33+
/// </summary>
34+
public IList<PiiEntityCategory> CategoriesFilter { get; internal set; } = new List<PiiEntityCategory>();
2835
}
2936
}

sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsClient.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,7 @@ public virtual async Task<Response<PiiEntityCollection>> RecognizePiiEntitiesAsy
737737
options.IncludeStatistics,
738738
options.DomainFilter.GetString(),
739739
options.StringIndexType,
740+
options.CategoriesFilter.Count == 0 ? null : options.CategoriesFilter,
740741
cancellationToken: cancellationToken).ConfigureAwait(false);
741742
Response response = result.GetRawResponse();
742743

@@ -802,6 +803,7 @@ public virtual Response<PiiEntityCollection> RecognizePiiEntities(string documen
802803
options.IncludeStatistics,
803804
options.DomainFilter.GetString(),
804805
options.StringIndexType,
806+
options.CategoriesFilter.Count == 0 ? null : options.CategoriesFilter,
805807
cancellationToken: cancellationToken);
806808
Response response = result.GetRawResponse();
807809

@@ -968,7 +970,7 @@ private async Task<Response<RecognizePiiEntitiesResultCollection>> RecognizePiiE
968970
options.IncludeStatistics,
969971
options.DomainFilter.GetString(),
970972
options.StringIndexType,
971-
default, // TODO: Implement PIICategory for Preview.4 https://github.com/Azure/azure-sdk-for-net/issues/18985
973+
options.CategoriesFilter.Count == 0 ? null : options.CategoriesFilter,
972974
cancellationToken).ConfigureAwait(false);
973975
var response = result.GetRawResponse();
974976

@@ -996,7 +998,7 @@ private Response<RecognizePiiEntitiesResultCollection> RecognizePiiEntitiesBatch
996998
options.IncludeStatistics,
997999
options.DomainFilter.GetString(),
9981000
options.StringIndexType,
999-
default, // TODO: Implement PIICategory for Preview.4 https://github.com/Azure/azure-sdk-for-net/issues/18985
1001+
options.CategoriesFilter.Count == 0 ? null : options.CategoriesFilter,
10001002
cancellationToken);
10011003
var response = result.GetRawResponse();
10021004

0 commit comments

Comments
 (0)