-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
PiiEntity.cs
69 lines (60 loc) · 2.59 KB
/
PiiEntity.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using Azure.AI.TextAnalytics.Models;
namespace Azure.AI.TextAnalytics
{
/// <summary>
/// A word or phrase identified as a Personally Identifiable Information
/// that can be categorized as known type in a given taxonomy.
/// The set of categories recognized by the Language service is described at
/// <see href="https://aka.ms/azsdk/language/pii"/>.
/// </summary>
public readonly struct PiiEntity
{
internal PiiEntity(Entity entity)
: this(entity.Text, entity.Category, entity.Subcategory, entity.ConfidenceScore, entity.Offset, entity.Length)
{
}
internal PiiEntity(string text, string category, string subcategory, double confidenceScore, int offset, int length)
{
Text = text;
Category = category;
SubCategory = subcategory;
ConfidenceScore = confidenceScore;
Offset = offset;
Length = length;
}
/// <summary>
/// Gets the entity text as it appears in the input document.
/// </summary>
public string Text { get; }
/// <summary>
/// Gets the PII entity category inferred by the Text Analytics service's
/// named entity recognition model, such as Financial Account
/// Identification/Social Security Number/Phone Number, etc.
/// The list of available categories is described at
/// <see href="https://aka.ms/azsdk/language/pii"/>.
/// </summary>
public PiiEntityCategory Category { get; }
/// <summary>
/// Gets the subcategory of the entity inferred by the Language service's
/// named entity recognition model. This property may not have a value if
/// a subcategory doesn't exist for this entity. The list of available categories and
/// subcategories is described at <see href="https://aka.ms/azsdk/language/pii"/>.
/// </summary>
public string SubCategory { get; }
/// <summary>
/// Gets a score between 0 and 1, indicating the confidence that the
/// text substring matches this inferred entity.
/// </summary>
public double ConfidenceScore { get; }
/// <summary>
/// Gets the starting position for the matching text in the input document.
/// </summary>
public int Offset { get; }
/// <summary>
/// Gets the length of the matching text in the input document.
/// </summary>
public int Length { get; }
}
}