Skip to content
Open
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

This file was deleted.

13 changes: 7 additions & 6 deletions sdk/cognitivelanguage/Azure.AI.Language.Text/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# Release History

## 1.0.0-beta.4 (Unreleased)
## 1.0.0-beta.4 (2025-11-20)

### Features Added

### Breaking Changes
This version of the client library defaults to the service API version `2025-11-15-preview`.

### Bugs Fixed
### Features Added

### Other Changes
- Added support for **multiple redaction policies** in a single request.
- Added **synthetic replacement redaction**, enabling selected PII types (e.g., Person, Email) to be replaced with realistic synthetic values rather than masked.
- Added **confidence score thresholding**, allowing customers to define minimum confidence levels�globally or per-entity�so that only entities meeting the required confidence are returned.
- Added **entity validation control** with the `disableEntityValidation` parameter, allowing users to bypass entity validation when needed.

## 1.0.0-beta.3 (2025-06-23)

Expand Down
3 changes: 2 additions & 1 deletion sdk/cognitivelanguage/Azure.AI.Language.Text/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Text Analytics is part of the Azure Cognitive Service for Language, a cloud-base
[Source code][source_root] | [Package (NuGet)][package]| [API reference documentation][text_refdocs] | [Product documentation][text_docs] | [Samples][source_samples]

> [!NOTE]
> Text Authoring is not supported in version 2.0.0-beta.1. If you use Text Authoring, please continue to use version 1.1.0. You can find the [samples][textauthoring_samples] here.
> Text Authoring is not supported from version 2.0.0-beta.1. If you use Text Authoring, please use the separate Text Authoring SDK. You can find the [samples][textauthoring_samples] here.

## Getting started

Expand All @@ -31,6 +31,7 @@ dotnet add package Azure.AI.Language.Text --prerelease

|SDK version |Supported API version of service
|-------------|------------------------------------------------------------------------------------------------
|1.0.0-beta.4 | 2022-05-01, 2023-04-01, 2024-11-01, 2025-05-15-preview, 2025-11-15-preview (default)
|1.0.0-beta.3 | 2022-05-01, 2023-04-01, 2024-11-01, 2024-11-15-preview, 2025-05-15-preview (default)
|1.0.0-beta.2 | 2022-05-01, 2023-04-01, 2024-11-01, 2024-11-15-preview (default)
|1.0.0-beta.1 | 2022-05-01, 2023-04-01, 2023-11-15-preview (default)
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion sdk/cognitivelanguage/Azure.AI.Language.Text/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "net",
"TagPrefix": "net/cognitivelanguage/Azure.AI.Language.Text",
"Tag": "net/cognitivelanguage/Azure.AI.Language.Text_66a454ef6f"
"Tag": "net/cognitivelanguage/Azure.AI.Language.Text_48cbf61c49"
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The values of the `endpoint` and `apiKey` variables can be retrieved from enviro

## Detect the language of documents

To detect the language of a document, call `AnalyzeText` on the `TextAnalysisClient`, which returns a `AnalyzeTextLanguageDetectionResult` object with the name of the language, a confidence score, and more.
To detect the language of a document, call `AnalyzeTextAsync` on the `TextAnalysisClient`, which returns a `AnalyzeTextLanguageDetectionResult` object with the name of the language, a confidence score, and more.

```C# Snippet:Sample1_AnalyzeTextAsync_LanguageDetection
string textA =
Expand Down Expand Up @@ -81,11 +81,11 @@ catch (RequestFailedException exception)
}
```

To detect the language of a document, call `AnalyzeText` on the `TextAnalysisClient`, which returns a `AnalyzeTextLanguageDetectionResult` object with the name of the language, a confidence score, and more.
To detect the language of a document, call `AnalyzeTextAsync` on the `TextAnalysisClient`, which returns a `AnalyzeTextLanguageDetectionResult` object with the name of the language, a confidence score, and more.

## Detect the language of documents with country hints

If the country where a document originates from is known, you can aid the language detection model if you call `AnalyzeText` on the `TextAnalysisClient` while passing the documents as an `IEnumerable<LanguageInput>` parameter, having set the `CountryHint` property on each `LanguageInput` object accordingly.
If the country where a document originates from is known, you can aid the language detection model if you call `AnalyzeTextAsync` on the `TextAnalysisClient` while passing the documents as an `IEnumerable<LanguageInput>` parameter, having set the `CountryHint` property on each `LanguageInput` object accordingly.

```C# Snippet:Sample1_AnalyzeTextAsync_LanguageDetection_CountryHint
string textA =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The values of the `endpoint` and `apiKey` variables can be retrieved from enviro

## Extracting key phrases from multiple documents

To extract key phrases from multiple documents, call `AnalyzeText` on an `AnalyzeTextInput`. The results are returned as a `AnalyzeTextKeyPhraseResult`.
To extract key phrases from multiple documents, call `AnalyzeTextAsync` on an `AnalyzeTextInput`. The results are returned as a `AnalyzeTextKeyPhraseResult`.

```C# Snippet:Sample3_AnalyzeTextAsync_ExtractKeyPhrases
string textA =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The values of the `endpoint` and `apiKey` variables can be retrieved from enviro

## Recognize entities in multiple documents

To recognize entities in multiple documents, call `AnalyzeText` on the `TextAnalysisClient` by passing the documents as an `AnalyzeTextInput` parameter. This returns a `AnalyzeTextEntitiesResult`.
To recognize entities in multiple documents, call `AnalyzeTextAsync` on the `TextAnalysisClient` by passing the documents as an `AnalyzeTextInput` parameter. This returns a `AnalyzeTextEntitiesResult`.

```C# Snippet:Sample4_AnalyzeTextAsync_RecognizeEntities
string textA =
Expand Down Expand Up @@ -102,12 +102,12 @@ For more information on the changes in the preview API version, see [Preview API

To create a new `TextAnalysisClient` with the preview API version, you will need the service endpoint and credentials of your Language resource with the `TextAnalysisClientOptions` pointing to the preview API Version.

To recognize entities in multiple documents, call `AnalyzeText` on the `TextAnalysisClient` by passing the documents and actionContent as an `AnalyzeTextInput` parameter. This returns a `AnalyzeTextEntitiesResult`.
To recognize entities in multiple documents, call `AnalyzeTextAsync` on the `TextAnalysisClient` by passing the documents and actionContent as an `AnalyzeTextInput` parameter. This returns a `AnalyzeTextEntitiesResult`.

```C# Snippet:Sample4_AnalyzeTextAsync_RecognizeEntities_Preview
Uri endpoint = TestEnvironment.Endpoint;
AzureKeyCredential credential = new(TestEnvironment.ApiKey);
TextAnalysisClientOptions options = new TextAnalysisClientOptions(TextAnalysisClientOptions.ServiceVersion.V2024_11_15_Preview);
TextAnalysisClientOptions options = new TextAnalysisClientOptions(TextAnalysisClientOptions.ServiceVersion.V2025_11_15_Preview);
var client = new TextAnalysisClient(endpoint, credential, options);

string textA =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The values of the `endpoint` and `apiKey` variables can be retrieved from enviro

## Recognizing Personally Identifiable Information in multiple documents

To recognize Personally Identifiable Information in multiple documents, call `AnalyzeText` on an `TextPiiEntitiesRecognitionInput`. The results are returned as a `AnalyzeTextPiiResult`.
To recognize Personally Identifiable Information in multiple documents, call `AnalyzeTextAsync` on an `TextPiiEntitiesRecognitionInput`. The results are returned as a `AnalyzeTextPiiResult`.

```C# Snippet:Sample5_AnalyzeTextAsync_RecognizePii
string textA =
Expand Down Expand Up @@ -84,7 +84,7 @@ foreach (DocumentError analyzeTextDocumentError in piiTaskResult.Results.Errors)

## Recognizing Personally Identifiable Information in multiple documents with a redaction policy

To recognize Personally Identifiable Information in multiple documents, call `AnalyzeText` on an `TextPiiEntitiesRecognitionInput`. The results are returned as a `AnalyzeTextPiiResult`.
To recognize Personally Identifiable Information in multiple documents, call `AnalyzeTextAsync` on an `TextPiiEntitiesRecognitionInput`. The results are returned as a `AnalyzeTextPiiResult`.

```C# Snippet:Sample5_AnalyzeTextAsync_RecognizePii_RedactionPolicy
string textA =
Expand Down Expand Up @@ -114,7 +114,15 @@ AnalyzeTextInput body = new TextPiiEntitiesRecognitionInput()
{
ModelVersion = "latest",
// Avaliable RedactionPolicies: EntityMaskPolicyType, CharacterMaskPolicyType, and NoMaskPolicyType
RedactionPolicy = new EntityMaskPolicyType()
RedactionPolicies =
{
new EntityMaskPolicyType
{
// defaultPolicy: use entity mask for everything unless overridden
PolicyName = "defaultPolicy",
IsDefault = true,
}
}
}
};

Expand Down Expand Up @@ -352,6 +360,157 @@ foreach (DocumentError error in result.Results.Errors)
}
```

## Recognizing Personally Identifiable Information with multiple redaction policies and with synthetic mask

To recognize Personally Identifiable Information with multiple redaction policies, call `AnalyzeTextAsync` on an `TextPiiEntitiesRecognitionInput`. The results are returned as a `AnalyzeTextPiiResult`.

```C# Snippet:Sample5_AnalyzeTextAsync_RecognizePii_RedactionPolicies
string documentText = "My name is John Doe. My ssn is 123-45-6789. My email is [email protected]..";

AnalyzeTextInput body = new TextPiiEntitiesRecognitionInput
{
TextInput = new MultiLanguageTextInput
{
MultiLanguageInputs =
{
new MultiLanguageInput("A", documentText) { Language = "en" },
new MultiLanguageInput("B", documentText) { Language = "en" },
}
},
ActionContent = new PiiActionContent
{
PiiCategories = { PiiCategory.All },

RedactionPolicies =
{
new EntityMaskPolicyType
{
// defaultPolicy: use entity mask for everything unless overridden
PolicyName = "defaultPolicy",
IsDefault = true,
},
new CharacterMaskPolicyType
{
// customMaskForSSN: keep the last 4 digits of SSN, mask the rest
PolicyName = "customMaskForSSN",
UnmaskLength = 4,
UnmaskFromEnd = false,
EntityTypes =
{
PiiCategoriesExclude.UsSocialSecurityNumber
},
},
new SyntheticReplacementPolicyType
{
// syntheticMaskForPerson: generate synthetic values for Person and Email
PolicyName = "syntheticMaskForPerson",
EntityTypes =
{
PiiCategoriesExclude.Person,
PiiCategoriesExclude.Email
},
}
}
}
};

Response<AnalyzeTextResult> response = await client.AnalyzeTextAsync(body);
AnalyzeTextPiiResult piiTaskResult = (AnalyzeTextPiiResult)response.Value;

foreach (PiiActionResult piiResult in piiTaskResult.Results.Documents)
{
Console.WriteLine($"Result for document with Id = \"{piiResult.Id}\":");
Console.WriteLine($" Redacted Text: \"{piiResult.RedactedText}\"");
Console.WriteLine($" Recognized {piiResult.Entities.Count} entities:");

foreach (PiiEntity entity in piiResult.Entities)
{
Console.WriteLine($" Text: {entity.Text}");
Console.WriteLine($" Offset: {entity.Offset}");
Console.WriteLine($" Length: {entity.Length}");
Console.WriteLine($" Category: {entity.Category}");
if (!string.IsNullOrEmpty(entity.Subcategory))
{
Console.WriteLine($" SubCategory: {entity.Subcategory}");
}
Console.WriteLine($" Confidence score: {entity.ConfidenceScore}");
Console.WriteLine();
}

Console.WriteLine();
}

foreach (DocumentError analyzeTextDocumentError in piiTaskResult.Results.Errors)
{
Console.WriteLine($" Error on document {analyzeTextDocumentError.Id}!");
Console.WriteLine($" Document error code: {analyzeTextDocumentError.Error.Code}");
Console.WriteLine($" Message: {analyzeTextDocumentError.Error.Message}");
Console.WriteLine();
}
```

## Recognizing Personally Identifiable Information with confidence score threshold

To recognize Personally Identifiable Information with confidence score threshold, call `AnalyzeTextAsync` on an `TextPiiEntitiesRecognitionInput`. The results are returned as a `AnalyzeTextPiiResult`.

```C# Snippet:Sample5_AnalyzeTextAsync_RecognizePii_ConfidenceScoreThreshold
string text =
"My name is John Doe. My ssn is 222-45-6789. My email is [email protected]. John Doe is my name.";

// Input documents
MultiLanguageTextInput textInput = new MultiLanguageTextInput
{
MultiLanguageInputs =
{
new MultiLanguageInput("1", text) { Language = "en" }
}
};

// Confidence score overrides:
// default = 0.3
// SSN & Email overridden to 0.9 (so they get filtered out as entities)
ConfidenceScoreThreshold confidenceThreshold = new ConfidenceScoreThreshold(0.3f);
confidenceThreshold.Overrides.Add(
new ConfidenceScoreThresholdOverride(
value: 0.9f,
entity: PiiCategory.UsSocialSecurityNumber.ToString()
));
confidenceThreshold.Overrides.Add(
new ConfidenceScoreThresholdOverride(
value: 0.9f,
entity: PiiCategory.Email.ToString()
));

PiiActionContent actionContent = new PiiActionContent
{
PiiCategories = { PiiCategory.All },
DisableEntityValidation = true,
ConfidenceScoreThreshold = confidenceThreshold
};

AnalyzeTextInput body = new TextPiiEntitiesRecognitionInput
{
TextInput = textInput,
ActionContent = actionContent
};

Response<AnalyzeTextResult> response = await client.AnalyzeTextAsync(body);
AnalyzeTextPiiResult piiResult = (AnalyzeTextPiiResult)response.Value;

PiiActionResult doc = piiResult.Results.Documents[0];

Console.WriteLine($"Redacted text: \"{doc.RedactedText}\"");
Console.WriteLine("Recognized entities (after confidence score filtering):");

foreach (PiiEntity entity in doc.Entities)
{
Console.WriteLine($" Text: {entity.Text}");
Console.WriteLine($" Category: {entity.Category}");
Console.WriteLine($" Confidence score: {entity.ConfidenceScore}");
Console.WriteLine();
}
```

See the [README] of the Text Analytics client library for more information, including useful links and instructions.

[DefaultAzureCredential]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/README.md
Expand Down
Loading