diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/README.md b/sdk/textanalytics/Azure.AI.TextAnalytics/README.md
index 165281cde0a0..49ae024f4cfc 100644
--- a/sdk/textanalytics/Azure.AI.TextAnalytics/README.md
+++ b/sdk/textanalytics/Azure.AI.TextAnalytics/README.md
@@ -6,8 +6,8 @@ Azure Cognitive Services Text Analytics is a cloud service that provides advance
* Named Entity Recognition
* Personally Identifiable Information (PII) Recognition
* Linked Entity Recognition
-* Healthcare Recognition beta
-* Running multiple actions in one or more documents beta
+* Healthcare Recognition
+* Running multiple actions in one or more documents
[Source code][textanalytics_client_src] | [Package (NuGet)][textanalytics_nuget_package] | [API reference documentation][textanalytics_refdocs] | [Product documentation][textanalytics_docs] | [Samples][textanalytics_samples]
@@ -130,7 +130,7 @@ A Return value collection, such as `AnalyzeSentimentResultCollection`, is a coll
For large documents which take a long time to execute, these operations are implemented as [**long-running operations**][dotnet_lro_guidelines]. Long-running operations consist of an initial request sent to the service to start an operation, followed by polling the service at intervals to determine whether the operation has completed or failed, and if it has succeeded, to get the result.
-For long running operations in the Azure SDK, the client exposes a `Start` method that returns an `Operation`. You can use the extension method `WaitForCompletionAsync()` to wait for the operation to complete and obtain its result. A sample code snippet is provided to illustrate using long-running operations [below](#recognize-healthcare-entities-asynchronously).
+For long running operations in the Azure SDK, the client exposes a `Start` method that returns an `Operation` or a `PageableOperation`. You can use the extension method `WaitForCompletionAsync()` to wait for the operation to complete and obtain its result. A sample code snippet is provided to illustrate using long-running operations [below](#recognize-healthcare-entities-asynchronously).
### Thread safety
We guarantee that all client instance methods are thread-safe and independent of each other ([guideline](https://azure.github.io/azure-sdk/dotnet_introduction.html#dotnet-service-methods-thread-safety)). This ensures that the recommendation of reusing client instances is always safe, even across threads.
@@ -146,7 +146,7 @@ We guarantee that all client instance methods are thread-safe and independent of
## Examples
-The following section provides several code snippets using the `client` [created above](#create-textanalyticsclient-with-azure-active-directory-credential), and covers the main functions of Text Analytics.
+The following section provides several code snippets using the `client` [created above](#create-textanalyticsclient-with-azure-active-directory-credential), and covers the main functions of Text Analytics. Although most of the snippets below make use of synchronous service calls, keep in mind that the Azure.AI.TextAnalytics package supports both synchronous and asynchronous APIs.
### Sync examples
* [Detect Language](#detect-language)
@@ -158,9 +158,9 @@ The following section provides several code snippets using the `client` [created
### Async examples
* [Detect Language Asynchronously](#detect-language-asynchronously)
-* [Recognize Entities Asyncronously](#recognize-entities-asynchronously)
-* [Recognize Healthcare Entities Asyncronously](#recognize-healthcare-entities-asynchronously)
-* [Run multiple actions Asyncronously](#run-multiple-actions-asynchronously)
+* [Recognize Entities Asynchronously](#recognize-entities-asynchronously)
+* [Analyze Healthcare Entities Asynchronously](#analyze-healthcare-entities-asynchronously)
+* [Run multiple actions Asynchronously](#run-multiple-actions-asynchronously)
### Detect Language
Run a Text Analytics predictive model to determine the language that the passed-in document or batch of documents are written in.
@@ -432,126 +432,118 @@ catch (RequestFailedException exception)
}
```
-### Recognize Healthcare Entities Asynchronously
+### Analyze Healthcare Entities Asynchronously
Text Analytics for health is a containerized service that extracts and labels relevant medical information from unstructured texts such as doctor's notes, discharge summaries, clinical documents, and electronic health records. For more information see [How to: Use Text Analytics for health][healthcare].
-```C# Snippet:Sample7_AnalyzeHealthcareEntitiesConvenience
- // get input documents
- string document1 = @"RECORD #333582770390100 | MH | 85986313 | | 054351 | 2/14/2001 12:00:00 AM | CORONARY ARTERY DISEASE | Signed | DIS | \
- Admission Date: 5/22/2001 Report Status: Signed Discharge Date: 4/24/2001 ADMISSION DIAGNOSIS: CORONARY ARTERY DISEASE. \
- HISTORY OF PRESENT ILLNESS: The patient is a 54-year-old gentleman with a history of progressive angina over the past several months. \
- The patient had a cardiac catheterization in July of this year revealing total occlusion of the RCA and 50% left main disease ,\
- with a strong family history of coronary artery disease with a brother dying at the age of 52 from a myocardial infarction and \
- another brother who is status post coronary artery bypass grafting. The patient had a stress echocardiogram done on July , 2001 , \
- which showed no wall motion abnormalities , but this was a difficult study due to body habitus. The patient went for six minutes with \
- minimal ST depressions in the anterior lateral leads , thought due to fatigue and wrist pain , his anginal equivalent. Due to the patient's \
- increased symptoms and family history and history left main disease with total occasional of his RCA was referred for revascularization with open heart surgery.";
-
- string document2 = "Prescribed 100mg ibuprofen, taken twice daily.";
-
- // prepare analyze operation input
- List batchInput = new List()
- {
- document1,
- document2,
- string.Empty
- };
- var options = new AnalyzeHealthcareEntitiesOptions { };
-
- // start analysis process
- AnalyzeHealthcareEntitiesOperation healthOperation = client.StartAnalyzeHealthcareEntities(batchInput, "en", options);
-
- await healthOperation.WaitForCompletionAsync();
-
- Console.WriteLine($"AnalyzeHealthcareEntities operation was completed");
-
- // view operation status
- Console.WriteLine($"Created On : {healthOperation.CreatedOn}");
- Console.WriteLine($"Expires On : {healthOperation.ExpiresOn}");
- Console.WriteLine($"Status : {healthOperation.Status}");
- Console.WriteLine($"Last Modified: {healthOperation.LastModified}");
+```C# Snippet:TextAnalyticsAnalyzeHealthcareEntitiesConvenienceAsyncAll
+// get input documents
+string document1 = @"RECORD #333582770390100 | MH | 85986313 | | 054351 | 2/14/2001 12:00:00 AM | CORONARY ARTERY DISEASE | Signed | DIS | \
+ Admission Date: 5/22/2001 Report Status: Signed Discharge Date: 4/24/2001 ADMISSION DIAGNOSIS: CORONARY ARTERY DISEASE. \
+ HISTORY OF PRESENT ILLNESS: The patient is a 54-year-old gentleman with a history of progressive angina over the past several months. \
+ The patient had a cardiac catheterization in July of this year revealing total occlusion of the RCA and 50% left main disease ,\
+ with a strong family history of coronary artery disease with a brother dying at the age of 52 from a myocardial infarction and \
+ another brother who is status post coronary artery bypass grafting. The patient had a stress echocardiogram done on July , 2001 , \
+ which showed no wall motion abnormalities , but this was a difficult study due to body habitus. The patient went for six minutes with \
+ minimal ST depressions in the anterior lateral leads , thought due to fatigue and wrist pain , his anginal equivalent. Due to the patient's \
+ increased symptoms and family history and history left main disease with total occasional of his RCA was referred for revascularization with open heart surgery.";
+
+string document2 = "Prescribed 100mg ibuprofen, taken twice daily.";
+
+// prepare analyze operation input
+List batchInput = new List()
+{
+ document1,
+ document2
+};
+
+// start analysis process
+AnalyzeHealthcareEntitiesOperation healthOperation = await client.StartAnalyzeHealthcareEntitiesAsync(batchInput);
+await healthOperation.WaitForCompletionAsync();
+
+// view operation status
+Console.WriteLine($"Created On : {healthOperation.CreatedOn}");
+Console.WriteLine($"Expires On : {healthOperation.ExpiresOn}");
+Console.WriteLine($"Status : {healthOperation.Status}");
+Console.WriteLine($"Last Modified: {healthOperation.LastModified}");
+
+// view operation results
+await foreach (AnalyzeHealthcareEntitiesResultCollection documentsInPage in healthOperation.Value)
+{
+ Console.WriteLine($"Results of Azure Text Analytics \"Healthcare Async\" Model, version: \"{documentsInPage.ModelVersion}\"");
+ Console.WriteLine("");
- // view operation results
- foreach (AnalyzeHealthcareEntitiesResultCollection documentsInPage in healthOperation.GetValues())
+ foreach (AnalyzeHealthcareEntitiesResult entitiesInDoc in documentsInPage)
{
- Console.WriteLine($"Results of Azure Text Analytics \"Healthcare\" Model, version: \"{documentsInPage.ModelVersion}\"");
- Console.WriteLine("");
-
- foreach (AnalyzeHealthcareEntitiesResult result in documentsInPage)
+ if (!entitiesInDoc.HasError)
{
- if (result.HasError)
- {
- Console.WriteLine(" Error!");
- Console.WriteLine($" Document error code: {result.Error.ErrorCode}.");
- Console.WriteLine($" Message: {result.Error.Message}");
- }
- else
+ foreach (var entity in entitiesInDoc.Entities)
{
- Console.WriteLine($" Recognized the following {result.Entities.Count} healthcare entities:");
-
// view recognized healthcare entities
- foreach (HealthcareEntity entity in result.Entities)
+ Console.WriteLine($" Entity: {entity.Text}");
+ Console.WriteLine($" Category: {entity.Category}");
+ Console.WriteLine($" Offset: {entity.Offset}");
+ Console.WriteLine($" Length: {entity.Length}");
+ Console.WriteLine($" NormalizedText: {entity.NormalizedText}");
+ Console.WriteLine($" Links:");
+
+ // view entity data sources
+ foreach (EntityDataSource entityDataSource in entity.DataSources)
+ {
+ Console.WriteLine($" Entity ID in Data Source: {entityDataSource.EntityId}");
+ Console.WriteLine($" DataSource: {entityDataSource.Name}");
+ }
+
+ // view assertion
+ if (entity.Assertion != null)
{
- Console.WriteLine($" Entity: {entity.Text}");
- Console.WriteLine($" Category: {entity.Category}");
- Console.WriteLine($" Offset: {entity.Offset}");
- Console.WriteLine($" Length: {entity.Length}");
- Console.WriteLine($" NormalizedText: {entity.NormalizedText}");
- Console.WriteLine($" Links:");
-
- // view entity data sources
- foreach (EntityDataSource entityDataSource in entity.DataSources)
+ Console.WriteLine($" Assertions:");
+
+ if (entity.Assertion?.Association != null)
{
- Console.WriteLine($" Entity ID in Data Source: {entityDataSource.EntityId}");
- Console.WriteLine($" DataSource: {entityDataSource.Name}");
+ Console.WriteLine($" Association: {entity.Assertion?.Association}");
}
- // view assertion
- if (entity.Assertion != null)
+ if (entity.Assertion?.Certainty != null)
{
- Console.WriteLine($" Assertions:");
-
- if (entity.Assertion?.Association != null)
- {
- Console.WriteLine($" Association: {entity.Assertion?.Association}");
- }
-
- if (entity.Assertion?.Certainty != null)
- {
- Console.WriteLine($" Certainty: {entity.Assertion?.Certainty}");
- }
- if (entity.Assertion?.Conditionality != null)
- {
- Console.WriteLine($" Conditionality: {entity.Assertion?.Conditionality}");
- }
+ Console.WriteLine($" Certainty: {entity.Assertion?.Certainty}");
}
-
- Console.WriteLine($" We found {result.EntityRelations.Count} relations in the current document:");
- Console.WriteLine("");
-
- // view recognized healthcare relations
- foreach (HealthcareEntityRelation relations in result.EntityRelations)
+ if (entity.Assertion?.Conditionality != null)
{
- Console.WriteLine($" Relation: {relations.RelationType}");
- Console.WriteLine($" For this relation there are {relations.Roles.Count} roles");
+ Console.WriteLine($" Conditionality: {entity.Assertion?.Conditionality}");
+ }
+ }
+ }
- // view relation roles
- foreach (HealthcareEntityRelationRole role in relations.Roles)
- {
- Console.WriteLine($" Role Name: {role.Name}");
+ Console.WriteLine($" We found {entitiesInDoc.EntityRelations.Count} relations in the current document:");
+ Console.WriteLine("");
- Console.WriteLine($" Associated Entity Text: {role.Entity.Text}");
- Console.WriteLine($" Associated Entity Category: {role.Entity.Category}");
+ // view recognized healthcare relations
+ foreach (HealthcareEntityRelation relations in entitiesInDoc.EntityRelations)
+ {
+ Console.WriteLine($" Relation: {relations.RelationType}");
+ Console.WriteLine($" For this relation there are {relations.Roles.Count} roles");
- Console.WriteLine("");
- }
+ // view relation roles
+ foreach (HealthcareEntityRelationRole role in relations.Roles)
+ {
+ Console.WriteLine($" Role Name: {role.Name}");
- Console.WriteLine("");
- }
+ Console.WriteLine($" Associated Entity Text: {role.Entity.Text}");
+ Console.WriteLine($" Associated Entity Category: {role.Entity.Category}");
+ Console.WriteLine("");
}
+
Console.WriteLine("");
}
}
+ else
+ {
+ Console.WriteLine(" Error!");
+ Console.WriteLine($" Document error code: {entitiesInDoc.Error.ErrorCode}.");
+ Console.WriteLine($" Message: {entitiesInDoc.Error.Message}");
+ }
+
+ Console.WriteLine("");
}
}
```
@@ -723,10 +715,6 @@ This functionality allows running multiple actions in one or more documents. Act
}
```
-### Known Issues
-- `StartAnalyzeHealthcareEntities` is in gated preview and can not be used with AAD credentials. For more information, see [the Text Analytics for Health documentation](https://docs.microsoft.com/azure/cognitive-services/text-analytics/how-tos/text-analytics-for-health?tabs=ner#request-access-to-the-public-preview).
-- At time of this SDK release, the `ModelVersion` option to `StartAnalyzeHealthcareEntities` is ignored by the service. The service always processes the operation using the `latest` model.
-
## Troubleshooting
### General
@@ -788,7 +776,7 @@ Samples are provided for each main functional area, and for each area, samples a
- [Recognize Entities][recognize_entities_sample]
- [Recognize PII Entities][recognize_pii_entities_sample]
- [Recognize Linked Entities][recognize_linked_entities_sample]
-- [Recognize Healthcare Entities][recognize_healthcare_sample]
+- [Recognize Healthcare Entities][analyze_healthcare_sample]
- [Run multiple actions][analyze_operation_sample]
### Advanced samples
@@ -813,12 +801,12 @@ This project has adopted the [Microsoft Open Source Code of Conduct][code_of_con
[textanalytics_refdocs]: https://aka.ms/azsdk-net-textanalytics-ref-docs
[textanalytics_nuget_package]: https://www.nuget.org/packages/Azure.AI.TextAnalytics
[textanalytics_samples]: https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/textanalytics/Azure.AI.TextAnalytics/samples/README.md
-[textanalytics_rest_api]: https://westcentralus.dev.cognitive.microsoft.com/docs/services/TextAnalytics-v3-1-Preview-3/operations/Languages
+[textanalytics_rest_api]: https://westcentralus.dev.cognitive.microsoft.com/docs/services/TextAnalytics-v3-1/operations/Languages
[cognitive_resource_portal]: https://docs.microsoft.com/azure/cognitive-services/cognitive-services-apis-create-account
[cognitive_resource_cli]: https://docs.microsoft.com/azure/cognitive-services/cognitive-services-apis-create-account-cli
[dotnet_lro_guidelines]: https://azure.github.io/azure-sdk/dotnet_introduction.html#dotnet-longrunning
-[recognize_healthcare_sample]: https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample_RecognizeHealthcareEntities.md
+[analyze_healthcare_sample]: https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample7_AnalyzeHealthcareEntities.md
[analyze_operation_sample]: https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample_AnalyzeActions.md
[analyze_operation_howto]: https://docs.microsoft.com/azure/cognitive-services/text-analytics/how-tos/text-analytics-how-to-call-api?tabs=synchronous#using-the-api-asynchronously
[healthcare]: https://docs.microsoft.com/azure/cognitive-services/text-analytics/how-tos/text-analytics-for-health?tabs=ner
@@ -837,7 +825,7 @@ This project has adopted the [Microsoft Open Source Code of Conduct][code_of_con
[custom_subdomain]: https://docs.microsoft.com/azure/cognitive-services/authentication#create-a-resource-with-a-custom-subdomain
[DefaultAzureCredential]: https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/identity/Azure.Identity/README.md
[logging]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/samples/Diagnostics.md
-[data_limits]: https://docs.microsoft.com/azure/cognitive-services/text-analytics/overview#data-limits
+[data_limits]: https://docs.microsoft.com/azure/cognitive-services/text-analytics/concepts/data-limits?tabs=version-3
[contributing]: https://github.com/Azure/azure-sdk-for-net/blob/main/CONTRIBUTING.md
[detect_language_sample]: https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample1_DetectLanguage.md
diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/samples/README.md b/sdk/textanalytics/Azure.AI.TextAnalytics/samples/README.md
index 64ed45a0f099..c7d5999ace0f 100644
--- a/sdk/textanalytics/Azure.AI.TextAnalytics/samples/README.md
+++ b/sdk/textanalytics/Azure.AI.TextAnalytics/samples/README.md
@@ -28,11 +28,13 @@ Azure Cognitive Services Text Analytics is a cloud service that provides advance
- [Recognize Entities](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample4_RecognizeEntities.md)
- [Recognize PII Entities](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample5_RecognizePiiEntities.md)
- [Recognize Linked Entities](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample6_RecognizeLinkedEntities.md)
-- [Recognize Healthcare Entities](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample_RecognizeHealthcareEntities.md)
+- [Analyze Healthcare Entities](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample7_AnalyzeHealthcareEntities.md)
## Advanced samples
- [Analyze Sentiment with Opinion Mining](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample2.1_AnalyzeSentimentWithOpinionMining.md)
- [Running multiple actions in one or more documents](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample_AnalyzeActions.md)
+- [Recognize PII Entities with specific categories](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample5_RecognizePiiEntitiesWithCategoriesFilter.cs)
+- [Polling Long Running Operations](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample_LROPolling.md)
- [Mock client](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample_MockClient.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/samples/Sample2.1_AnalyzeSentimentWithOpinionMining.md b/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample2.1_AnalyzeSentimentWithOpinionMining.md
index 2f29e22cf4ad..2122219791dc 100644
--- a/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample2.1_AnalyzeSentimentWithOpinionMining.md
+++ b/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample2.1_AnalyzeSentimentWithOpinionMining.md
@@ -1,11 +1,9 @@
# Analyze sentiment with Opinion Mining
-This sample demonstrates how to analyze sentiment of documents and get more granular information about the opinions related to targets of a product/service, also knows as Aspect-based Sentiment Analysis in Natural Language Processing (NLP). This feature is only available for clients with api version v3.1-preview.1 and higher.
+This sample demonstrates how to analyze sentiment of documents and get more granular information about the opinions related to targets of a product/service, also knows as Aspect-based Sentiment Analysis in Natural Language Processing (NLP). This feature is only available for clients with api version v3.1 and higher.
For example, if a customer leaves feedback about a hotel such as "The room was great, but the staff was unfriendly.", Opinion Mining will locate targets in the text, and their associated opinion and sentiments. Sentiment Analysis might only report a negative sentiment.
-
-
For the purpose of the sample, we will be the administrator of a hotel and we've set a system to look at the online reviews customers are posting to identify the major complaints about our hotel.
In order to do so, we will use the Sentiment Analysis feature of the Text Analytics client library. To get started you'll need a Text Analytics endpoint and credentials. See [README][README] for links and instructions.
diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample5_RecognizePiiEntities.md b/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample5_RecognizePiiEntities.md
index 9859e50884e4..86617636bacc 100644
--- a/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample5_RecognizePiiEntities.md
+++ b/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample5_RecognizePiiEntities.md
@@ -189,9 +189,9 @@ Console.WriteLine("");
```
To see the full example source files, see:
+* [Recognize PII Entities with specific categories](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample5_RecognizePiiEntitiesWithCategoriesFilter.cs)
* [Synchronous RecognizePiiEntities](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample5_RecognizePiiEntities.cs)
* [Asynchronous RecognizePiiEntities](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample5_RecognizePiiEntitiesAsync.cs)
-* [Recognize PII Entities with specific categories](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample5_RecognizePiiEntitiesWithCategoriesFilter.cs)
* [Synchronous RecognizePiiEntitiesBatch](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample5_RecognizePiiEntitiesBatch.cs)
* [Asynchronous RecognizePiiEntitiesBatch](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample5_RecognizePiiEntitiesBatchAsync.cs)
* [Synchronous RecognizePiiEntitiesBatchConvenience](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample5_RecognizePiiEntitiesBatchConvenience.cs)
diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample_RecognizeHealthcareEntities.md b/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample7_AnalyzeHealthcareEntities.md
similarity index 66%
rename from sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample_RecognizeHealthcareEntities.md
rename to sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample7_AnalyzeHealthcareEntities.md
index af38c7397603..fb4ae089dc8c 100644
--- a/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample_RecognizeHealthcareEntities.md
+++ b/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample7_AnalyzeHealthcareEntities.md
@@ -1,5 +1,5 @@
-# Recognizing Healthcare Entities from Documents
-This sample demonstrates how to recognize healthcare entities in one or more documents. To get started you will need a Text Analytics endpoint and credentials. See [README][README] for links and instructions.
+# Analyze Healthcare Entities from Documents
+This sample demonstrates how to analyze healthcare entities 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`
@@ -14,9 +14,9 @@ var client = new TextAnalyticsClient(new Uri(endpoint), new AzureKeyCredential(a
```
## Analyze Documents
-To recognize healthcare entities in multiple documents, call `StartAnalyzeHealthcareEntities` on an `IEnumerable` of strings. The result is a Long Running operation of type `AnalyzeHealthcareEntitiesOperation` which polls for the results from the API.
+To analyze healthcare entities in multiple documents, call `StartAnalyzeHealthcareEntities` on an `IEnumerable` of strings. The result is a Long Running operation of type `AnalyzeHealthcareEntitiesOperation` which polls for the results from the API.
-```C# Snippet:TextAnalyticsSampleHealthcareConvenienceAnalyzeDocumentsAsync
+```C# Snippet:TextAnalyticsAnalyzeHealthcareEntitiesConvenienceAsync
// get input documents
string document1 = @"RECORD #333582770390100 | MH | 85986313 | | 054351 | 2/14/2001 12:00:00 AM | CORONARY ARTERY DISEASE | Signed | DIS | \
Admission Date: 5/22/2001 Report Status: Signed Discharge Date: 4/24/2001 ADMISSION DIAGNOSIS: CORONARY ARTERY DISEASE. \
@@ -34,19 +34,15 @@ string document2 = "Prescribed 100mg ibuprofen, taken twice daily.";
List batchInput = new List()
{
document1,
- document2,
- string.Empty
+ document2
};
-var options = new AnalyzeHealthcareEntitiesOptions { };
-
// start analysis process
-AnalyzeHealthcareEntitiesOperation healthOperation = await client.StartAnalyzeHealthcareEntitiesAsync(batchInput, "en", options);
-
+AnalyzeHealthcareEntitiesOperation healthOperation = await client.StartAnalyzeHealthcareEntitiesAsync(batchInput);
await healthOperation.WaitForCompletionAsync();
```
-The returned healthcare operation contains general information about the status of the operation. It can be requested while the operation is running or when it completed. For example:
+The returned healthcare operation contains general information about the status of the operation. It can be requested while the operation is running or when it completed. For example:
```C# Snippet:TextAnalyticsSampleHealthcareOperationStatus
// view operation status
@@ -55,7 +51,9 @@ Console.WriteLine($"Expires On : {healthOperation.ExpiresOn}");
Console.WriteLine($"Status : {healthOperation.Status}");
Console.WriteLine($"Last Modified: {healthOperation.LastModified}");
```
+
To view the final results of the long-running operation:
+
```C# Snippet:TextAnalyticsSampleHealthcareConvenienceAsyncViewResults
// view operation results
await foreach (AnalyzeHealthcareEntitiesResultCollection documentsInPage in healthOperation.Value)
@@ -70,58 +68,57 @@ await foreach (AnalyzeHealthcareEntitiesResultCollection documentsInPage in heal
foreach (var entity in entitiesInDoc.Entities)
{
// view recognized healthcare entities
- Console.WriteLine($" Entity: {entity.Text}");
- Console.WriteLine($" Category: {entity.Category}");
- Console.WriteLine($" Offset: {entity.Offset}");
- Console.WriteLine($" Length: {entity.Length}");
- Console.WriteLine($" NormalizedText: {entity.NormalizedText}");
- Console.WriteLine($" Links:");
+ Console.WriteLine($" Entity: {entity.Text}");
+ Console.WriteLine($" Category: {entity.Category}");
+ Console.WriteLine($" Offset: {entity.Offset}");
+ Console.WriteLine($" Length: {entity.Length}");
+ Console.WriteLine($" NormalizedText: {entity.NormalizedText}");
+ Console.WriteLine($" Links:");
// view entity data sources
foreach (EntityDataSource entityDataSource in entity.DataSources)
{
- Console.WriteLine($" Entity ID in Data Source: {entityDataSource.EntityId}");
- Console.WriteLine($" DataSource: {entityDataSource.Name}");
+ Console.WriteLine($" Entity ID in Data Source: {entityDataSource.EntityId}");
+ Console.WriteLine($" DataSource: {entityDataSource.Name}");
}
// view assertion
if (entity.Assertion != null)
{
- Console.WriteLine($" Assertions:");
+ Console.WriteLine($" Assertions:");
if (entity.Assertion?.Association != null)
{
- Console.WriteLine($" Association: {entity.Assertion?.Association}");
+ Console.WriteLine($" Association: {entity.Assertion?.Association}");
}
if (entity.Assertion?.Certainty != null)
{
- Console.WriteLine($" Certainty: {entity.Assertion?.Certainty}");
+ Console.WriteLine($" Certainty: {entity.Assertion?.Certainty}");
}
if (entity.Assertion?.Conditionality != null)
{
- Console.WriteLine($" Conditionality: {entity.Assertion?.Conditionality}");
+ Console.WriteLine($" Conditionality: {entity.Assertion?.Conditionality}");
}
}
}
- Console.WriteLine($" We found {entitiesInDoc.EntityRelations.Count} relations in the current document:");
+ Console.WriteLine($" We found {entitiesInDoc.EntityRelations.Count} relations in the current document:");
Console.WriteLine("");
// view recognized healthcare relations
foreach (HealthcareEntityRelation relations in entitiesInDoc.EntityRelations)
{
- Console.WriteLine($" Relation: {relations.RelationType}");
- Console.WriteLine($" For this relation there are {relations.Roles.Count} roles");
+ Console.WriteLine($" Relation: {relations.RelationType}");
+ Console.WriteLine($" For this relation there are {relations.Roles.Count} roles");
// view relation roles
foreach (HealthcareEntityRelationRole role in relations.Roles)
{
- Console.WriteLine($" Role Name: {role.Name}");
-
- Console.WriteLine($" Associated Entity Text: {role.Entity.Text}");
- Console.WriteLine($" Associated Entity Category: {role.Entity.Category}");
+ Console.WriteLine($" Role Name: {role.Name}");
+ Console.WriteLine($" Associated Entity Text: {role.Entity.Text}");
+ Console.WriteLine($" Associated Entity Category: {role.Entity.Category}");
Console.WriteLine("");
}
@@ -144,10 +141,8 @@ To see the full example source files, see:
* [Synchronous AnalyzeHealthcareEntities](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntities.cs)
* [Asynchronous AnalyzeHealthcareEntities](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntitiesAsync.cs)
-* [Automatic Polling AnalyzeHealthcareEntities ](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntitiesAsync_AutomaticPolling.cs)
-* [Manual Polling AnalyzeHealthcareEntities ](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntities_ManualPolling.cs)
-* [Automatic Polling AnalyzeHealthcareEntities Convenience](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntitiesConvenienceAsync_AutomaticPolling.cs)
-* [Manual Polling AnalyzeHealthcareEntities Convenience ](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntitiesConvenience_ManualPolling.cs)
+* [Synchronous AnalyzeHealthcareEntities Convenience](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntitiesConvenience.cs)
+* [Asynchronous AnalyzeHealthcareEntities Convenience ](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntitiesConvenienceAsync.cs)
* [Synchronous AnalyzeHealthcareEntities Cancellation](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntities_Cancellation.cs)
* [Asynchronous AnalyzeHealthcareEntitiesAsync Cancellation](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntitiesAsync_Cancellation.cs)
diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample_LROPolling.md b/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample_LROPolling.md
index d4e983766d2c..ac11c77cc182 100644
--- a/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample_LROPolling.md
+++ b/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample_LROPolling.md
@@ -1,9 +1,9 @@
# Polling Long Running Operations
-This sample demonstrates the different ways to consume or poll the status of a Text Analytics client Long Running Operation. It uses the (Analyze Operation)[https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/textanalytics/Azure.AI.TextAnalytics#run-analyze-operation-asynchronously] as an example
+This sample demonstrates the different ways to consume or poll the status of a Text Analytics client Long Running Operation. It uses the [Analyze Healthcare Entities][analyze-healthcare-entities] functionality as an example.
## Creating a `TextAnalyticsClient`
-To create a new `TextAnalyticsClient` to run analyze operation for 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.
+To create a new `TextAnalyticsClient` to analyze healthcare entities for 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.
@@ -13,140 +13,89 @@ string apiKey = "";
var client = new TextAnalyticsClient(new Uri(endpoint), new AzureKeyCredential(apiKey));
```
-## Polling using `WaitForCompletionAsync()`
+## Automatic polling
In the below snippet the polling is happening by default when we call `WaitForCompletionAsync()` method.
-```C#
- string document = @"We went to Contoso Steakhouse located at midtown NYC last week for a dinner party,
- and we adore the spot! They provide marvelous food and they have a great menu. The
- chief cook happens to be the owner (I think his name is John Doe) and he is super
- nice, coming out of the kitchen and greeted us all. We enjoyed very much dining in
- the place! The Sirloin steak I ordered was tender and juicy, and the place was impeccably
- clean. You can even pre-order from their online menu at www.contososteakhouse.com,
- call 312-555-0176 or send email to order@contososteakhouse.com! The only complaint
- I have is the food didn't come fast enough. Overall I highly recommend it!";
-
- var batchDocuments = new List { document };
-
- AnalyzeOperationOptions operationOptions = new AnalyzeOperationOptions()
- {
- KeyPhrasesTaskParameters = new KeyPhrasesTaskParameters(),
- EntitiesTaskParameters = new EntitiesTaskParameters(),
- PiiTaskParameters = new PiiTaskParameters(),
- DisplayName = "AnalyzeOperationSample"
- };
-
- AnalyzeOperation operation = client.StartAnalyzeOperationBatch(batchDocuments, operationOptions);
-
- await operation.WaitForCompletionAsync();
-
- AnalyzeOperationResult resultCollection = operation.Value;
-
- RecognizeEntitiesResultCollection entitiesResult = resultCollection.Tasks.EntityRecognitionTasks[0].Results;
-
- ExtractKeyPhrasesResultCollection keyPhrasesResult = resultCollection.Tasks.KeyPhraseExtractionTasks[0].Results;
-
- RecognizePiiEntitiesResultCollection piiResult = resultCollection.Tasks.EntityRecognitionPiiTasks[0].Results;
+```C# Snippet:TextAnalyticsAnalyzeHealthcareEntitiesConvenienceAsync
+// get input documents
+string document1 = @"RECORD #333582770390100 | MH | 85986313 | | 054351 | 2/14/2001 12:00:00 AM | CORONARY ARTERY DISEASE | Signed | DIS | \
+ Admission Date: 5/22/2001 Report Status: Signed Discharge Date: 4/24/2001 ADMISSION DIAGNOSIS: CORONARY ARTERY DISEASE. \
+ HISTORY OF PRESENT ILLNESS: The patient is a 54-year-old gentleman with a history of progressive angina over the past several months. \
+ The patient had a cardiac catheterization in July of this year revealing total occlusion of the RCA and 50% left main disease ,\
+ with a strong family history of coronary artery disease with a brother dying at the age of 52 from a myocardial infarction and \
+ another brother who is status post coronary artery bypass grafting. The patient had a stress echocardiogram done on July , 2001 , \
+ which showed no wall motion abnormalities , but this was a difficult study due to body habitus. The patient went for six minutes with \
+ minimal ST depressions in the anterior lateral leads , thought due to fatigue and wrist pain , his anginal equivalent. Due to the patient's \
+ increased symptoms and family history and history left main disease with total occasional of his RCA was referred for revascularization with open heart surgery.";
+
+string document2 = "Prescribed 100mg ibuprofen, taken twice daily.";
+
+// prepare analyze operation input
+List batchInput = new List()
+{
+ document1,
+ document2
+};
+
+// start analysis process
+AnalyzeHealthcareEntitiesOperation healthOperation = await client.StartAnalyzeHealthcareEntitiesAsync(batchInput);
+await healthOperation.WaitForCompletionAsync();
```
By default the polling happens every 1 second when there is no `pollingInterval` sent.
-
-## Polling using `WaitForCompletionAsync(TimeSpan pollingInterval)`
-
-For a custom `pollingInterval`, we will call `WaitForCompletionAsync()` method with `TimeSpan` object as an argument.
-
-```C#
- string document = @"We went to Contoso Steakhouse located at midtown NYC last week for a dinner party,
- and we adore the spot! They provide marvelous food and they have a great menu. The
- chief cook happens to be the owner (I think his name is John Doe) and he is super
- nice, coming out of the kitchen and greeted us all. We enjoyed very much dining in
- the place! The Sirloin steak I ordered was tender and juicy, and the place was impeccably
- clean. You can even pre-order from their online menu at www.contososteakhouse.com,
- call 312-555-0176 or send email to order@contososteakhouse.com! The only complaint
- I have is the food didn't come fast enough. Overall I highly recommend it!";
-
- var batchDocuments = new List { document };
-
- AnalyzeOperationOptions operationOptions = new AnalyzeOperationOptions()
- {
- KeyPhrasesTaskParameters = new KeyPhrasesTaskParameters(),
- EntitiesTaskParameters = new EntitiesTaskParameters(),
- PiiTaskParameters = new PiiTaskParameters(),
- DisplayName = "AnalyzeOperationSample"
- };
-
- AnalyzeOperation operation = client.StartAnalyzeOperationBatch(batchDocuments, operationOptions);
-
- TimeSpan pollingInterval = new TimeSpan(1000);
-
- await operation.WaitForCompletionAsync(pollingInterval);
-
- AnalyzeOperationResult resultCollection = operation.Value;
-
- RecognizeEntitiesResultCollection entitiesResult = resultCollection.Tasks.EntityRecognitionTasks[0].Results;
-
- ExtractKeyPhrasesResultCollection keyPhrasesResult = resultCollection.Tasks.KeyPhraseExtractionTasks[0].Results;
-
- RecognizePiiEntitiesResultCollection piiResult = resultCollection.Tasks.EntityRecognitionPiiTasks[0].Results;
-```
-
-## Polling using `UpdateStatusAsync()`
-
-This method is for users who want to have intermittent code paths during the polling process.
-
-```C#
- string document = @"We went to Contoso Steakhouse located at midtown NYC last week for a dinner party,
- and we adore the spot! They provide marvelous food and they have a great menu. The
- chief cook happens to be the owner (I think his name is John Doe) and he is super
- nice, coming out of the kitchen and greeted us all. We enjoyed very much dining in
- the place! The Sirloin steak I ordered was tender and juicy, and the place was impeccably
- clean. You can even pre-order from their online menu at www.contososteakhouse.com,
- call 312-555-0176 or send email to order@contososteakhouse.com! The only complaint
- I have is the food didn't come fast enough. Overall I highly recommend it!";
-
- var batchDocuments = new List { document };
-
- AnalyzeOperationOptions operationOptions = new AnalyzeOperationOptions()
- {
- KeyPhrasesTaskParameters = new KeyPhrasesTaskParameters(),
- EntitiesTaskParameters = new EntitiesTaskParameters(),
- PiiTaskParameters = new PiiTaskParameters(),
- DisplayName = "AnalyzeOperationSample"
- };
-
- AnalyzeOperation operation = client.StartAnalyzeOperationBatch(batchDocuments, operationOptions);
-
- TimeSpan pollingInterval = new TimeSpan(1000);
-
- while (true)
- {
- await healthOperation.UpdateStatusAsync();
- if (healthOperation.HasCompleted)
- {
- // TIP - Add logging, max wait time, or any other intermittent code path.
- break;
- }
-
- await Task.Delay(pollingInterval);
- }
-
- AnalyzeOperationResult resultCollection = operation.Value;
-
- RecognizeEntitiesResultCollection entitiesResult = resultCollection.Tasks.EntityRecognitionTasks[0].Results;
-
- ExtractKeyPhrasesResultCollection keyPhrasesResult = resultCollection.Tasks.KeyPhraseExtractionTasks[0].Results;
-
- RecognizePiiEntitiesResultCollection piiResult = resultCollection.Tasks.EntityRecognitionPiiTasks[0].Results;
+## Manual polling
+
+This method is for users who want to have intermittent code paths during the polling process, or want to stick to a sync behavior.
+
+```C# Snippet:TextAnalyticsAnalyzeHealthcareEntitiesConvenience
+// get input documents
+string document1 = @"RECORD #333582770390100 | MH | 85986313 | | 054351 | 2/14/2001 12:00:00 AM | CORONARY ARTERY DISEASE | Signed | DIS | \
+ Admission Date: 5/22/2001 Report Status: Signed Discharge Date: 4/24/2001 ADMISSION DIAGNOSIS: CORONARY ARTERY DISEASE. \
+ HISTORY OF PRESENT ILLNESS: The patient is a 54-year-old gentleman with a history of progressive angina over the past several months. \
+ The patient had a cardiac catheterization in July of this year revealing total occlusion of the RCA and 50% left main disease ,\
+ with a strong family history of coronary artery disease with a brother dying at the age of 52 from a myocardial infarction and \
+ another brother who is status post coronary artery bypass grafting. The patient had a stress echocardiogram done on July , 2001 , \
+ which showed no wall motion abnormalities , but this was a difficult study due to body habitus. The patient went for six minutes with \
+ minimal ST depressions in the anterior lateral leads , thought due to fatigue and wrist pain , his anginal equivalent. Due to the patient's \
+ increased symptoms and family history and history left main disease with total occasional of his RCA was referred for revascularization with open heart surgery.";
+
+string document2 = "Prescribed 100mg ibuprofen, taken twice daily.";
+
+// prepare analyze operation input
+List batchInput = new List()
+{
+ document1,
+ document2
+};
+
+// start analysis process
+AnalyzeHealthcareEntitiesOperation healthOperation = client.StartAnalyzeHealthcareEntities(batchInput);
+
+// wait for completion with manual polling
+TimeSpan pollingInterval = new TimeSpan(1000);
+
+while (true)
+{
+ Console.WriteLine($"Status: {healthOperation.Status}");
+ healthOperation.UpdateStatus();
+ if (healthOperation.HasCompleted)
+ {
+ break;
+ }
+
+ Thread.Sleep(pollingInterval);
+}
+
+Console.WriteLine($"AnalyzeHealthcareEntities operation was completed");
```
To see the full example source files, see:
-* [Automatic Polling AnalyzeOperation ](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_AnalyzeOperationAsync.cs)
-* [Manual Polling AnalyzeOperation ](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_AnalyzeOperation.cs)
-* [Automatic Polling HealthcareOperation ](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntitiesConvenienceAsync_AutomaticPolling.cs)
-* [Manual Polling HealthcareOperation ](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntitiesConvenience_ManualPolling.cs)
+* [Asynchronous AnalyzeHealthcareEntities Convenience](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntitiesConvenienceAsync.cs)
+* [Synchronous AnalyzeHealthcareEntities Convenience ](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntitiesConvenience.cs)
+[analyze-healthcare-entities]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample7_AnalyzeHealthcareEntities.md
[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/samples/assets/opinion-mining.png b/sdk/textanalytics/Azure.AI.TextAnalytics/samples/assets/opinion-mining.png
deleted file mode 100644
index 026d14cee86e..000000000000
Binary files a/sdk/textanalytics/Azure.AI.TextAnalytics/samples/assets/opinion-mining.png and /dev/null differ
diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsClient.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsClient.cs
index f92df81e1852..ce9d2cd190c4 100644
--- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsClient.cs
+++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsClient.cs
@@ -115,7 +115,7 @@ public TextAnalyticsClient(Uri endpoint, AzureKeyCredential credential, TextAnal
/// language is correct. Scores close to 1 indicate high certainty in
/// the result.
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// The document to analyze.
/// Indicates the country of origin of the
@@ -168,7 +168,7 @@ public virtual async Task> DetectLanguageAsync(string
/// language is correct. Scores close to 1 indicate high certainty in
/// the result.
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// The document to analyze.
/// Indicates the country of origin of the
@@ -220,7 +220,7 @@ public virtual Response DetectLanguage(string document, string
/// the inferred language is correct. Scores close to 1 indicate high
/// certainty in the result.
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// A collection of documents to analyze.
/// Indicates the country of origin of all of
@@ -254,7 +254,7 @@ public virtual async Task> DetectLangua
/// the inferred language is correct. Scores close to 1 indicate high
/// certainty in the result.
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// A collection of documents to analyze.
/// Indicates the country of origin of all of
@@ -288,7 +288,7 @@ public virtual Response DetectLanguageBatch(IEnu
/// the inferred language is correct. Scores close to 1 indicate high
/// certainty in the result.
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// A collection of documents to analyze.
/// used to
@@ -316,7 +316,7 @@ public virtual async Task> DetectLangua
/// the inferred language is correct. Scores close to 1 indicate high
/// certainty in the result.
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// A collection of documents to analyze.
/// used to
@@ -402,7 +402,7 @@ private Response DetectLanguageBatch(LanguageBat
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// The document to analyze.
/// The language that the document is written in.
@@ -460,7 +460,7 @@ public virtual async Task> RecognizeEntiti
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// The document to analyze.
/// The language that the document is written in.
@@ -518,7 +518,7 @@ public virtual Response RecognizeEntities(string do
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// The documents to analyze.
/// The language that all the documents are
@@ -554,7 +554,7 @@ public virtual async Task> Recognize
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// The documents to analyze.
/// The language that all the documents are
@@ -590,7 +590,7 @@ public virtual Response RecognizeEntitiesBatc
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// The documents to analyze.
/// used to
@@ -621,7 +621,7 @@ public virtual async Task> Recognize
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// The documents to analyze.
/// used to
@@ -711,7 +711,7 @@ private Response RecognizeEntitiesBatch(Multi
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
///
/// Method is only available for and up.
@@ -781,7 +781,7 @@ public virtual async Task> RecognizePiiEntitiesAsy
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
///
/// Method is only available for and up.
@@ -851,7 +851,7 @@ public virtual Response RecognizePiiEntities(string documen
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
///
/// Method is only available for and up.
@@ -890,7 +890,7 @@ public virtual async Task> Recogn
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
///
/// Method is only available for and up.
@@ -929,7 +929,7 @@ public virtual Response RecognizePiiEntiti
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
///
/// Method is only available for and up.
@@ -963,7 +963,7 @@ public virtual async Task> Recogn
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
///
/// Method is only available for and up.
@@ -1055,7 +1055,7 @@ private Response RecognizePiiEntitiesBatch
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// The document to analyze.
/// The language that the document is written in.
@@ -1083,7 +1083,7 @@ public virtual async Task> AnalyzeSentimentAsync(str
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// The text to analyze.
/// The language that the document is written in.
@@ -1111,7 +1111,7 @@ public virtual Response AnalyzeSentiment(string document, str
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// The document to analyze.
/// The language that the document is written in.
@@ -1172,7 +1172,7 @@ public virtual async Task> AnalyzeSentimentAsync(str
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// The text to analyze.
/// The language that the document is written in.
@@ -1233,7 +1233,7 @@ public virtual Response AnalyzeSentiment(string document, str
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// The documents to analyze.
/// The language that all of the documents are written in.
@@ -1267,7 +1267,7 @@ public virtual async Task> AnalyzeSen
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// The documents to analyze.
/// The language that all of the documents are written in.
@@ -1301,7 +1301,7 @@ public virtual Response AnalyzeSentimentBatch(
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// The documents to analyze.
/// The language that all of the documents are written in.
@@ -1333,7 +1333,7 @@ public virtual async Task> AnalyzeSen
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// The documents to analyze.
/// The language that all of the documents are written in.
@@ -1365,7 +1365,7 @@ public virtual Response AnalyzeSentimentBatch(
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// The documents to analyze.
/// used to
@@ -1394,7 +1394,7 @@ public virtual async Task> AnalyzeSen
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// The documents to analyze.
/// used to
@@ -1423,7 +1423,7 @@ public virtual Response AnalyzeSentimentBatch(
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// The documents to analyze.
/// The additional configurable that may be passed when
@@ -1450,7 +1450,7 @@ public virtual async Task> AnalyzeSen
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// The documents to analyze.
/// The additional configurable that may be passed when
@@ -1539,7 +1539,7 @@ private Response AnalyzeSentimentBatch(MultiLa
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// The document to analyze.
/// The language that the document is written in.
@@ -1592,7 +1592,7 @@ public virtual async Task> ExtractKeyPhrasesAsync(
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// The document to analyze.
/// The language that the document is written in.
@@ -1645,7 +1645,7 @@ public virtual Response ExtractKeyPhrases(string document,
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// The documents to analyze.
/// The language that all the documents are
@@ -1680,7 +1680,7 @@ public virtual async Task> ExtractKe
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// The documents to analyze.
/// The language that all the documents are
@@ -1715,7 +1715,7 @@ public virtual Response ExtractKeyPhrasesBatc
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// The documents to analyze.
/// used to
@@ -1745,7 +1745,7 @@ public virtual async Task> ExtractKe
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// The documents to analyze.
/// used to
@@ -1829,7 +1829,7 @@ private Response ExtractKeyPhrasesBatch(Multi
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// The document to analyze.
/// The language that the document is written in.
@@ -1885,7 +1885,7 @@ public virtual async Task> RecognizeLinkedEntit
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// The document to analyze.
/// The language that the document is written in.
@@ -1941,7 +1941,7 @@ public virtual Response RecognizeLinkedEntities(string d
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// The documents to analyze.
/// The language that the documents are written in.
@@ -1975,7 +1975,7 @@ public virtual async Task> Rec
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// The documents to analyze.
/// The language that the documents are written in.
@@ -2009,7 +2009,7 @@ public virtual Response RecognizeLinked
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// The documents to analyze.
/// used to
@@ -2038,7 +2038,7 @@ public virtual async Task> Rec
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// The documents to analyze.
/// used to
@@ -2124,7 +2124,7 @@ private Response RecognizeLinkedEntitie
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// Method is only available for and up.
///
@@ -2157,7 +2157,7 @@ public virtual async Task StartAnalyzeHealth
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// Method is only available for and up.
///
@@ -2197,7 +2197,7 @@ public virtual AnalyzeHealthcareEntitiesOperation StartAnalyzeHealthcareEntities
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// Method is only available for and up.
///
@@ -2230,7 +2230,7 @@ public virtual AnalyzeHealthcareEntitiesOperation StartAnalyzeHealthcareEntities
/// For a list of languages supported by this operation, see
/// .
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
/// Method is only available for and up.
///
@@ -2321,7 +2321,7 @@ private async Task StartAnalyzeHealthcareEnt
/// PII entity recognition, linked entity recognition, key phrases extraction, and sentiment analysis.
/// Accepts a list of strings which are analyzed asynchronously.
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
///
/// Method is only available for and up.
@@ -2349,7 +2349,7 @@ public virtual async Task StartAnalyzeActionsAsync(IEnu
/// PII entity recognition, linked entity recognition, key phrases extraction, and sentiment analysis.
/// Accepts a list of strings which are analyzed asynchronously.
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
///
/// Method is only available for and up.
@@ -2377,7 +2377,7 @@ public virtual AnalyzeActionsOperation StartAnalyzeActions(IEnumerable d
/// PII entity recognition, linked entity recognition, key phrases extraction, and sentiment analysis.
/// Accepts a list of strings which are analyzed asynchronously.
/// For document length limits, maximum batch size, and supported text encoding, see
- /// .
+ /// .
///
///
/// Method is only available for and up.
@@ -2404,7 +2404,7 @@ public virtual AnalyzeActionsOperation StartAnalyzeActions(IEnumerable.
+ /// .
///
///
/// Method is only available for and up.
diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample5_RecognizePiiEntitiesWithCategoriesFilter.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample5_RecognizePiiEntitiesWithCategoriesFilter.cs
index bf4cf28c3514..5e4570b4be9a 100644
--- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample5_RecognizePiiEntitiesWithCategoriesFilter.cs
+++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample5_RecognizePiiEntitiesWithCategoriesFilter.cs
@@ -26,7 +26,7 @@ public void RecognizePiiEntitiesWithCategories()
try
{
// For sample purposes we want the service to only return SSN.
- RecognizePiiEntitiesOptions options = new() { CategoriesFilter = { PiiEntityCategory.PhoneNumber } };
+ RecognizePiiEntitiesOptions options = new() { CategoriesFilter = { PiiEntityCategory.USSocialSecurityNumber } };
Response response = client.RecognizePiiEntities(document, options: options);
PiiEntityCollection entities = response.Value;
diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntities.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntities.cs
index ad43537efb9f..dcd694fdd0fd 100644
--- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntities.cs
+++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntities.cs
@@ -3,7 +3,7 @@
using System;
using System.Collections.Generic;
-using System.Threading.Tasks;
+using System.Threading;
using Azure.AI.TextAnalytics.Tests;
using Azure.Core.TestFramework;
using NUnit.Framework;
@@ -14,14 +14,13 @@ namespace Azure.AI.TextAnalytics.Samples
public partial class TextAnalyticsSamples: SamplesBase
{
[Test]
- public async Task Sample7_AnalyzeHealthcareEntities()
+ public void AnalyzeHealthcareEntities()
{
// 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:TextAnalyticsSampleHealthcare
// get input documents
string document1 = @"RECORD #333582770390100 | MH | 85986313 | | 054351 | 2/14/2001 12:00:00 AM | CORONARY ARTERY DISEASE | Signed | DIS | \
Admission Date: 5/22/2001 Report Status: Signed Discharge Date: 4/24/2001 ADMISSION DIAGNOSIS: CORONARY ARTERY DISEASE. \
@@ -56,7 +55,29 @@ with a strong family history of coronary artery disease with a brother dying at
// start analysis process
AnalyzeHealthcareEntitiesOperation healthOperation = client.StartAnalyzeHealthcareEntities(batchInput, options);
- await healthOperation.WaitForCompletionAsync();
+ // wait for completion with manual polling
+ TimeSpan pollingInterval = new TimeSpan(1000);
+
+ while (true)
+ {
+ Console.WriteLine($"Status: {healthOperation.Status}");
+ healthOperation.UpdateStatus();
+ if (healthOperation.HasCompleted)
+ {
+ break;
+ }
+
+ Thread.Sleep(pollingInterval);
+ }
+
+ // view operation status
+ Console.WriteLine($"AnalyzeHealthcareEntities operation was completed");
+
+ Console.WriteLine($"Created On : {healthOperation.CreatedOn}");
+ Console.WriteLine($"Expires On : {healthOperation.ExpiresOn}");
+ Console.WriteLine($"Id : {healthOperation.Id}");
+ Console.WriteLine($"Status : {healthOperation.Status}");
+ Console.WriteLine($"Last Modified: {healthOperation.LastModified}");
// view operation results
foreach (AnalyzeHealthcareEntitiesResultCollection documentsInPage in healthOperation.GetValues())
@@ -66,63 +87,62 @@ with a strong family history of coronary artery disease with a brother dying at
foreach (AnalyzeHealthcareEntitiesResult result in documentsInPage)
{
- Console.WriteLine($" Recognized the following {result.Entities.Count} healthcare entities:");
+ Console.WriteLine($" Recognized the following {result.Entities.Count} healthcare entities:");
// view recognized healthcare entities
foreach (HealthcareEntity entity in result.Entities)
{
- Console.WriteLine($" Entity: {entity.Text}");
- Console.WriteLine($" Category: {entity.Category}");
- Console.WriteLine($" Offset: {entity.Offset}");
- Console.WriteLine($" Length: {entity.Length}");
- Console.WriteLine($" NormalizedText: {entity.NormalizedText}");
- Console.WriteLine($" Links:");
+ Console.WriteLine($" Entity: {entity.Text}");
+ Console.WriteLine($" Category: {entity.Category}");
+ Console.WriteLine($" Offset: {entity.Offset}");
+ Console.WriteLine($" Length: {entity.Length}");
+ Console.WriteLine($" NormalizedText: {entity.NormalizedText}");
+ Console.WriteLine($" Links:");
// view entity data sources
foreach (EntityDataSource entityDataSource in entity.DataSources)
{
- Console.WriteLine($" Entity ID in Data Source: {entityDataSource.EntityId}");
- Console.WriteLine($" DataSource: {entityDataSource.Name}");
+ Console.WriteLine($" Entity ID in Data Source: {entityDataSource.EntityId}");
+ Console.WriteLine($" DataSource: {entityDataSource.Name}");
}
// view assertion
if (entity.Assertion != null)
{
- Console.WriteLine($" Assertions:");
+ Console.WriteLine($" Assertions:");
if (entity.Assertion?.Association != null)
{
- Console.WriteLine($" Association: {entity.Assertion?.Association}");
+ Console.WriteLine($" Association: {entity.Assertion?.Association}");
}
if (entity.Assertion?.Certainty != null)
{
- Console.WriteLine($" Certainty: {entity.Assertion?.Certainty}");
+ Console.WriteLine($" Certainty: {entity.Assertion?.Certainty}");
}
if (entity.Assertion?.Conditionality != null)
{
- Console.WriteLine($" Conditionality: {entity.Assertion?.Conditionality}");
+ Console.WriteLine($" Conditionality: {entity.Assertion?.Conditionality}");
}
}
}
- Console.WriteLine($" We found {result.EntityRelations.Count} relations in the current document:");
+ Console.WriteLine($" We found {result.EntityRelations.Count} relations in the current document:");
Console.WriteLine("");
// view recognized healthcare relations
foreach (HealthcareEntityRelation relations in result.EntityRelations)
{
- Console.WriteLine($" Relation: {relations.RelationType}");
- Console.WriteLine($" For this relation there are {relations.Roles.Count} roles");
+ Console.WriteLine($" Relation: {relations.RelationType}");
+ Console.WriteLine($" For this relation there are {relations.Roles.Count} roles");
// view relation roles
foreach (HealthcareEntityRelationRole role in relations.Roles)
{
- Console.WriteLine($" Role Name: {role.Name}");
-
- Console.WriteLine($" Associated Entity Text: {role.Entity.Text}");
- Console.WriteLine($" Associated Entity Category: {role.Entity.Category}");
+ Console.WriteLine($" Role Name: {role.Name}");
+ Console.WriteLine($" Associated Entity Text: {role.Entity.Text}");
+ Console.WriteLine($" Associated Entity Category: {role.Entity.Category}");
Console.WriteLine("");
}
@@ -130,22 +150,19 @@ with a strong family history of coronary artery disease with a brother dying at
}
// current document statistics
- Console.WriteLine($" Document statistics:");
- Console.WriteLine($" Character count (in Unicode graphemes): {result.Statistics.CharacterCount}");
- Console.WriteLine($" Transaction count: {result.Statistics.TransactionCount}");
+ Console.WriteLine($" Document statistics:");
+ Console.WriteLine($" Character count (in Unicode graphemes): {result.Statistics.CharacterCount}");
+ Console.WriteLine($" Transaction count: {result.Statistics.TransactionCount}");
Console.WriteLine("");
}
// view statistics about documents in current page
Console.WriteLine($"Request statistics:");
- Console.WriteLine($" Document Count: {documentsInPage.Statistics.DocumentCount}");
- Console.WriteLine($" Valid Document Count: {documentsInPage.Statistics.ValidDocumentCount}");
- Console.WriteLine($" Transaction Count: {documentsInPage.Statistics.TransactionCount}");
- Console.WriteLine($" Invalid Document Count: {documentsInPage.Statistics.InvalidDocumentCount}");
- Console.WriteLine("");
+ Console.WriteLine($" Document Count: {documentsInPage.Statistics.DocumentCount}");
+ Console.WriteLine($" Valid Document Count: {documentsInPage.Statistics.ValidDocumentCount}");
+ Console.WriteLine($" Transaction Count: {documentsInPage.Statistics.TransactionCount}");
+ Console.WriteLine($" Invalid Document Count: {documentsInPage.Statistics.InvalidDocumentCount}");
}
}
-
- #endregion
}
}
diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntitiesAsync.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntitiesAsync.cs
index 178a62980676..d0f8e2b0cef1 100644
--- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntitiesAsync.cs
+++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntitiesAsync.cs
@@ -14,14 +14,13 @@ namespace Azure.AI.TextAnalytics.Samples
public partial class TextAnalyticsSamples: SamplesBase
{
[Test]
- public async Task Sample7_AnalyzeHealthcareEntitiesAsync()
+ public async Task AnalyzeHealthcareEntitiesAsync()
{
// 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:TextAnalyticsSampleHealthcareAsync
// get input documents
string document1 = @"RECORD #333582770390100 | MH | 85986313 | | 054351 | 2/14/2001 12:00:00 AM | CORONARY ARTERY DISEASE | Signed | DIS |
Admission Date: 5/22/2001 Report Status: Signed Discharge Date: 4/24/2001 ADMISSION DIAGNOSIS: CORONARY ARTERY DISEASE.
@@ -45,8 +44,7 @@ with a strong family history of coronary artery disease with a brother dying at
new TextDocumentInput("2", document2)
{
Language = "en"
- },
- new TextDocumentInput("3", string.Empty)
+ }
};
AnalyzeHealthcareEntitiesOptions options = new AnalyzeHealthcareEntitiesOptions()
@@ -95,58 +93,57 @@ with a strong family history of coronary artery disease with a brother dying at
// view recognized healthcare entities
foreach (HealthcareEntity entity in result.Entities)
{
- Console.WriteLine($" Entity: {entity.Text}");
- Console.WriteLine($" Category: {entity.Category}");
- Console.WriteLine($" Offset: {entity.Offset}");
- Console.WriteLine($" Length: {entity.Length}");
- Console.WriteLine($" NormalizedText: {entity.NormalizedText}");
- Console.WriteLine($" Links:");
+ Console.WriteLine($" Entity: {entity.Text}");
+ Console.WriteLine($" Category: {entity.Category}");
+ Console.WriteLine($" Offset: {entity.Offset}");
+ Console.WriteLine($" Length: {entity.Length}");
+ Console.WriteLine($" NormalizedText: {entity.NormalizedText}");
+ Console.WriteLine($" Links:");
// view entity data sources
foreach (EntityDataSource entityDataSource in entity.DataSources)
{
- Console.WriteLine($" Entity ID in Data Source: {entityDataSource.EntityId}");
- Console.WriteLine($" DataSource: {entityDataSource.Name}");
+ Console.WriteLine($" Entity ID in Data Source: {entityDataSource.EntityId}");
+ Console.WriteLine($" DataSource: {entityDataSource.Name}");
}
// view assertion
if (entity.Assertion != null)
{
- Console.WriteLine($" Assertions:");
+ Console.WriteLine($" Assertions:");
if (entity.Assertion?.Association != null)
{
- Console.WriteLine($" Association: {entity.Assertion?.Association}");
+ Console.WriteLine($" Association: {entity.Assertion?.Association}");
}
if (entity.Assertion?.Certainty != null)
{
- Console.WriteLine($" Certainty: {entity.Assertion?.Certainty}");
+ Console.WriteLine($" Certainty: {entity.Assertion?.Certainty}");
}
if (entity.Assertion?.Conditionality != null)
{
- Console.WriteLine($" Conditionality: {entity.Assertion?.Conditionality}");
+ Console.WriteLine($" Conditionality: {entity.Assertion?.Conditionality}");
}
}
}
- Console.WriteLine($" We found {result.EntityRelations.Count} relations in the current document:");
+ Console.WriteLine($" We found {result.EntityRelations.Count} relations in the current document:");
Console.WriteLine("");
// view recognized healthcare relations
foreach (HealthcareEntityRelation relations in result.EntityRelations)
{
- Console.WriteLine($" Relation: {relations.RelationType}");
- Console.WriteLine($" For this relation there are {relations.Roles.Count} roles");
+ Console.WriteLine($" Relation: {relations.RelationType}");
+ Console.WriteLine($" For this relation there are {relations.Roles.Count} roles");
// view relation roles
foreach (HealthcareEntityRelationRole role in relations.Roles)
{
- Console.WriteLine($" Role Name: {role.Name}");
-
- Console.WriteLine($" Associated Entity Text: {role.Entity.Text}");
- Console.WriteLine($" Associated Entity Category: {role.Entity.Category}");
+ Console.WriteLine($" Role Name: {role.Name}");
+ Console.WriteLine($" Associated Entity Text: {role.Entity.Text}");
+ Console.WriteLine($" Associated Entity Category: {role.Entity.Category}");
Console.WriteLine("");
}
@@ -157,9 +154,9 @@ with a strong family history of coronary artery disease with a brother dying at
}
// current document statistics
- Console.WriteLine($" Document statistics:");
- Console.WriteLine($" Character count (in Unicode graphemes): {result.Statistics.CharacterCount}");
- Console.WriteLine($" Transaction count: {result.Statistics.TransactionCount}");
+ Console.WriteLine($" Document statistics:");
+ Console.WriteLine($" Character count (in Unicode graphemes): {result.Statistics.CharacterCount}");
+ Console.WriteLine($" Transaction count: {result.Statistics.TransactionCount}");
Console.WriteLine("");
}
@@ -169,10 +166,7 @@ with a strong family history of coronary artery disease with a brother dying at
Console.WriteLine($" Valid document count: {documentsInPage.Statistics.ValidDocumentCount}");
Console.WriteLine($" Invalid document count: {documentsInPage.Statistics.InvalidDocumentCount}");
Console.WriteLine($" Transaction count: {documentsInPage.Statistics.TransactionCount}");
- Console.WriteLine("");
}
}
-
- #endregion
}
}
diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntitiesAsync_AutomaticPolling.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntitiesAsync_AutomaticPolling.cs
deleted file mode 100644
index c046ea8a414f..000000000000
--- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntitiesAsync_AutomaticPolling.cs
+++ /dev/null
@@ -1,154 +0,0 @@
-// 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
-{
- [LiveOnly]
- public partial class TextAnalyticsSamples: SamplesBase
- {
- [Test]
- public async Task Sample7_AnalyzeHealthcareEntitiesAsync_AutomaticPolling()
- {
- // 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:RecognizeHealthcareEntitiesAsyncAutomaticPolling
- // get input documents
- string document1 = @"RECORD #333582770390100 | MH | 85986313 | | 054351 | 2/14/2001 12:00:00 AM | CORONARY ARTERY DISEASE | Signed | DIS | \
- Admission Date: 5/22/2001 Report Status: Signed Discharge Date: 4/24/2001 ADMISSION DIAGNOSIS: CORONARY ARTERY DISEASE. \
- HISTORY OF PRESENT ILLNESS: The patient is a 54-year-old gentleman with a history of progressive angina over the past several months. \
- The patient had a cardiac catheterization in July of this year revealing total occlusion of the RCA and 50% left main disease ,\
- with a strong family history of coronary artery disease with a brother dying at the age of 52 from a myocardial infarction and \
- another brother who is status post coronary artery bypass grafting. The patient had a stress echocardiogram done on July , 2001 , \
- which showed no wall motion abnormalities , but this was a difficult study due to body habitus. The patient went for six minutes with \
- minimal ST depressions in the anterior lateral leads , thought due to fatigue and wrist pain , his anginal equivalent. Due to the patient's \
- increased symptoms and family history and history left main disease with total occasional of his RCA was referred for revascularization with open heart surgery.";
-
- string document2 = "Prescribed 100mg ibuprofen, taken twice daily.";
-
- // prepare analyze operation input
- List batchInput = new List()
- {
- new TextDocumentInput("1", document1)
- {
- Language = "en"
- },
- new TextDocumentInput("2", document2)
- {
- Language = "en"
- }
- };
-
- AnalyzeHealthcareEntitiesOptions options = new AnalyzeHealthcareEntitiesOptions()
- {
- IncludeStatistics = true
- };
-
- // start analysis process
- AnalyzeHealthcareEntitiesOperation healthOperation = await client.StartAnalyzeHealthcareEntitiesAsync(batchInput, options);
-
- // wait for operation completion with automatic polling
- TimeSpan pollingInterval = new TimeSpan(1000);
-
- await healthOperation.WaitForCompletionAsync(pollingInterval);
-
- // view operation results
- await foreach (AnalyzeHealthcareEntitiesResultCollection documentsInPage in healthOperation.Value)
- {
- Console.WriteLine($"Results of Azure Text Analytics \"Healthcare Async\" Model, version: \"{documentsInPage.ModelVersion}\"");
- Console.WriteLine("");
-
- foreach (AnalyzeHealthcareEntitiesResult result in documentsInPage)
- {
- Console.WriteLine($" Recognized the following {result.Entities.Count} healthcare entities:");
-
- // view recognized healthcare entities
- foreach (HealthcareEntity entity in result.Entities)
- {
- Console.WriteLine($" Entity: {entity.Text}");
- Console.WriteLine($" Category: {entity.Category}");
- Console.WriteLine($" Offset: {entity.Offset}");
- Console.WriteLine($" Length: {entity.Length}");
- Console.WriteLine($" NormalizedText: {entity.NormalizedText}");
- Console.WriteLine($" Links:");
-
- // view entity data sources
- foreach (EntityDataSource entityDataSource in entity.DataSources)
- {
- Console.WriteLine($" Entity ID in Data Source: {entityDataSource.EntityId}");
- Console.WriteLine($" DataSource: {entityDataSource.Name}");
- }
-
- // view assertion
- if (entity.Assertion != null)
- {
- Console.WriteLine($" Assertions:");
-
- if (entity.Assertion?.Association != null)
- {
- Console.WriteLine($" Association: {entity.Assertion?.Association}");
- }
-
- if (entity.Assertion?.Certainty != null)
- {
- Console.WriteLine($" Certainty: {entity.Assertion?.Certainty}");
- }
- if (entity.Assertion?.Conditionality != null)
- {
- Console.WriteLine($" Conditionality: {entity.Assertion?.Conditionality}");
- }
- }
- }
-
- Console.WriteLine($" We found {result.EntityRelations.Count} relations in the current document:");
- Console.WriteLine("");
-
- // view recognized healthcare relations
- foreach (HealthcareEntityRelation relations in result.EntityRelations)
- {
- Console.WriteLine($" Relation: {relations.RelationType}");
- Console.WriteLine($" For this relation there are {relations.Roles.Count} roles");
-
- // view relation roles
- foreach (HealthcareEntityRelationRole role in relations.Roles)
- {
- Console.WriteLine($" Role Name: {role.Name}");
-
- Console.WriteLine($" Associated Entity Text: {role.Entity.Text}");
- Console.WriteLine($" Associated Entity Category: {role.Entity.Category}");
-
- Console.WriteLine("");
- }
-
- Console.WriteLine("");
- }
-
- // document statistics
- Console.WriteLine($" Document statistics:");
- Console.WriteLine($" Character count (in Unicode graphemes): {result.Statistics.CharacterCount}");
- Console.WriteLine($" Transaction count: {result.Statistics.TransactionCount}");
- Console.WriteLine("");
- }
-
- // batch operation statistics
- Console.WriteLine($"Batch operation statistics:");
- Console.WriteLine($" Document count: {documentsInPage.Statistics.DocumentCount}");
- Console.WriteLine($" Valid document count: {documentsInPage.Statistics.ValidDocumentCount}");
- Console.WriteLine($" Invalid document count: {documentsInPage.Statistics.InvalidDocumentCount}");
- Console.WriteLine($" Transaction count: {documentsInPage.Statistics.TransactionCount}");
- Console.WriteLine("");
- }
- }
-
- #endregion
- }
-}
diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntitiesAsync_Cancellation.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntitiesAsync_Cancellation.cs
index b49ad2333f03..8352fac90931 100644
--- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntitiesAsync_Cancellation.cs
+++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntitiesAsync_Cancellation.cs
@@ -14,14 +14,13 @@ namespace Azure.AI.TextAnalytics.Samples
public partial class TextAnalyticsSamples: SamplesBase
{
[Test]
- public async Task Sample7_AnalyzeHealthcareEntitiesAsync_Cancellation()
+ public async Task AnalyzeHealthcareEntitiesAsync_Cancellation()
{
string endpoint = TestEnvironment.Endpoint;
string apiKey = TestEnvironment.ApiKey;
var client = new TextAnalyticsClient(new Uri(endpoint), new AzureKeyCredential(apiKey));
- #region Snippet:TextAnalyticsSampleHealthcareAsyncCancellation
string document = @"RECORD #333582770390100 | MH | 85986313 | | 054351 | 2/14/2001 12:00:00 AM | CORONARY ARTERY DISEASE | Signed | DIS | \
Admission Date: 5/22/2001 Report Status: Signed Discharge Date: 4/24/2001 ADMISSION DIAGNOSIS: CORONARY ARTERY DISEASE. \
HISTORY OF PRESENT ILLNESS: The patient is a 54-year-old gentleman with a history of progressive angina over the past several months. \
@@ -43,7 +42,5 @@ with a strong family history of coronary artery disease with a brother dying at
await healthOperation.CancelAsync();
}
-
- #endregion
}
}
diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntitiesConvenience.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntitiesConvenience.cs
index e906b791ae66..a5a3d9ed7176 100644
--- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntitiesConvenience.cs
+++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntitiesConvenience.cs
@@ -3,7 +3,7 @@
using System;
using System.Collections.Generic;
-using System.Threading.Tasks;
+using System.Threading;
using Azure.AI.TextAnalytics.Tests;
using Azure.Core.TestFramework;
using NUnit.Framework;
@@ -14,14 +14,14 @@ namespace Azure.AI.TextAnalytics.Samples
public partial class TextAnalyticsSamples: SamplesBase
{
[Test]
- public async Task Sample7_AnalyzeHealthcareEntitiesConvenience()
+ public void AnalyzeHealthcareEntitiesConvenience()
{
// 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:Sample7_AnalyzeHealthcareEntitiesConvenience
+ #region Snippet:TextAnalyticsAnalyzeHealthcareEntitiesConvenience
// get input documents
string document1 = @"RECORD #333582770390100 | MH | 85986313 | | 054351 | 2/14/2001 12:00:00 AM | CORONARY ARTERY DISEASE | Signed | DIS | \
Admission Date: 5/22/2001 Report Status: Signed Discharge Date: 4/24/2001 ADMISSION DIAGNOSIS: CORONARY ARTERY DISEASE. \
@@ -39,23 +39,36 @@ with a strong family history of coronary artery disease with a brother dying at
List batchInput = new List()
{
document1,
- document2,
- string.Empty
+ document2
};
- var options = new AnalyzeHealthcareEntitiesOptions { };
// start analysis process
- AnalyzeHealthcareEntitiesOperation healthOperation = client.StartAnalyzeHealthcareEntities(batchInput, "en", options);
+ AnalyzeHealthcareEntitiesOperation healthOperation = client.StartAnalyzeHealthcareEntities(batchInput);
- await healthOperation.WaitForCompletionAsync();
+ // wait for completion with manual polling
+ TimeSpan pollingInterval = new TimeSpan(1000);
+
+ while (true)
+ {
+ Console.WriteLine($"Status: {healthOperation.Status}");
+ healthOperation.UpdateStatus();
+ if (healthOperation.HasCompleted)
+ {
+ break;
+ }
+
+ Thread.Sleep(pollingInterval);
+ }
Console.WriteLine($"AnalyzeHealthcareEntities operation was completed");
+ #endregion Snippet:TextAnalyticsAnalyzeHealthcareEntitiesConvenience
+
// view operation status
- Console.WriteLine($"Created On : {healthOperation.CreatedOn}");
- Console.WriteLine($"Expires On : {healthOperation.ExpiresOn}");
- Console.WriteLine($"Status : {healthOperation.Status}");
- Console.WriteLine($"Last Modified: {healthOperation.LastModified}");
+ Console.WriteLine($" Created On : {healthOperation.CreatedOn}");
+ Console.WriteLine($" Expires On : {healthOperation.ExpiresOn}");
+ Console.WriteLine($" Status : {healthOperation.Status}");
+ Console.WriteLine($" Last Modified: {healthOperation.LastModified}");
// view operation results
foreach (AnalyzeHealthcareEntitiesResultCollection documentsInPage in healthOperation.GetValues())
@@ -73,62 +86,61 @@ with a strong family history of coronary artery disease with a brother dying at
}
else
{
- Console.WriteLine($" Recognized the following {result.Entities.Count} healthcare entities:");
+ Console.WriteLine($" Recognized the following {result.Entities.Count} healthcare entities:");
// view recognized healthcare entities
foreach (HealthcareEntity entity in result.Entities)
{
- Console.WriteLine($" Entity: {entity.Text}");
- Console.WriteLine($" Category: {entity.Category}");
- Console.WriteLine($" Offset: {entity.Offset}");
- Console.WriteLine($" Length: {entity.Length}");
- Console.WriteLine($" NormalizedText: {entity.NormalizedText}");
- Console.WriteLine($" Links:");
+ Console.WriteLine($" Entity: {entity.Text}");
+ Console.WriteLine($" Category: {entity.Category}");
+ Console.WriteLine($" Offset: {entity.Offset}");
+ Console.WriteLine($" Length: {entity.Length}");
+ Console.WriteLine($" NormalizedText: {entity.NormalizedText}");
+ Console.WriteLine($" Links:");
// view entity data sources
foreach (EntityDataSource entityDataSource in entity.DataSources)
{
- Console.WriteLine($" Entity ID in Data Source: {entityDataSource.EntityId}");
- Console.WriteLine($" DataSource: {entityDataSource.Name}");
+ Console.WriteLine($" Entity ID in Data Source: {entityDataSource.EntityId}");
+ Console.WriteLine($" DataSource: {entityDataSource.Name}");
}
// view assertion
if (entity.Assertion != null)
{
- Console.WriteLine($" Assertions:");
+ Console.WriteLine($" Assertions:");
if (entity.Assertion?.Association != null)
{
- Console.WriteLine($" Association: {entity.Assertion?.Association}");
+ Console.WriteLine($" Association: {entity.Assertion?.Association}");
}
if (entity.Assertion?.Certainty != null)
{
- Console.WriteLine($" Certainty: {entity.Assertion?.Certainty}");
+ Console.WriteLine($" Certainty: {entity.Assertion?.Certainty}");
}
if (entity.Assertion?.Conditionality != null)
{
- Console.WriteLine($" Conditionality: {entity.Assertion?.Conditionality}");
+ Console.WriteLine($" Conditionality: {entity.Assertion?.Conditionality}");
}
}
- Console.WriteLine($" We found {result.EntityRelations.Count} relations in the current document:");
+ Console.WriteLine($" We found {result.EntityRelations.Count} relations in the current document:");
Console.WriteLine("");
// view recognized healthcare relations
foreach (HealthcareEntityRelation relations in result.EntityRelations)
{
- Console.WriteLine($" Relation: {relations.RelationType}");
- Console.WriteLine($" For this relation there are {relations.Roles.Count} roles");
+ Console.WriteLine($" Relation: {relations.RelationType}");
+ Console.WriteLine($" For this relation there are {relations.Roles.Count} roles");
// view relation roles
foreach (HealthcareEntityRelationRole role in relations.Roles)
{
- Console.WriteLine($" Role Name: {role.Name}");
-
- Console.WriteLine($" Associated Entity Text: {role.Entity.Text}");
- Console.WriteLine($" Associated Entity Category: {role.Entity.Category}");
+ Console.WriteLine($" Role Name: {role.Name}");
+ Console.WriteLine($" Associated Entity Text: {role.Entity.Text}");
+ Console.WriteLine($" Associated Entity Category: {role.Entity.Category}");
Console.WriteLine("");
}
@@ -140,6 +152,5 @@ with a strong family history of coronary artery disease with a brother dying at
}
}
}
- #endregion
}
}
diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntitiesConvenienceAsync.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntitiesConvenienceAsync.cs
index a117d4f4b7b7..1f637d3288ac 100644
--- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntitiesConvenienceAsync.cs
+++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntitiesConvenienceAsync.cs
@@ -14,14 +14,15 @@ namespace Azure.AI.TextAnalytics.Samples
public partial class TextAnalyticsSamples: SamplesBase
{
[Test]
- public async Task Sample7_AnalyzeHealthcareEntitiesConvenienceAsync()
+ public async Task AnalyzeHealthcareEntitiesConvenienceAsync()
{
// 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:TextAnalyticsSampleHealthcareConvenienceAnalyzeDocumentsAsync
+ #region Snippet:TextAnalyticsAnalyzeHealthcareEntitiesConvenienceAsyncAll
+ #region Snippet:TextAnalyticsAnalyzeHealthcareEntitiesConvenienceAsync
// get input documents
string document1 = @"RECORD #333582770390100 | MH | 85986313 | | 054351 | 2/14/2001 12:00:00 AM | CORONARY ARTERY DISEASE | Signed | DIS | \
Admission Date: 5/22/2001 Report Status: Signed Discharge Date: 4/24/2001 ADMISSION DIAGNOSIS: CORONARY ARTERY DISEASE. \
@@ -39,17 +40,13 @@ with a strong family history of coronary artery disease with a brother dying at
List batchInput = new List()
{
document1,
- document2,
- string.Empty
+ document2
};
- var options = new AnalyzeHealthcareEntitiesOptions { };
-
// start analysis process
- AnalyzeHealthcareEntitiesOperation healthOperation = await client.StartAnalyzeHealthcareEntitiesAsync(batchInput, "en", options);
-
+ AnalyzeHealthcareEntitiesOperation healthOperation = await client.StartAnalyzeHealthcareEntitiesAsync(batchInput);
await healthOperation.WaitForCompletionAsync();
- #endregion
+ #endregion Snippet:TextAnalyticsAnalyzeHealthcareEntitiesConvenienceAsync
#region Snippet:TextAnalyticsSampleHealthcareOperationStatus
// view operation status
@@ -57,7 +54,7 @@ with a strong family history of coronary artery disease with a brother dying at
Console.WriteLine($"Expires On : {healthOperation.ExpiresOn}");
Console.WriteLine($"Status : {healthOperation.Status}");
Console.WriteLine($"Last Modified: {healthOperation.LastModified}");
- #endregion
+ #endregion Snippet:TextAnalyticsSampleHealthcareOperationStatus
#region Snippet:TextAnalyticsSampleHealthcareConvenienceAsyncViewResults
// view operation results
@@ -73,58 +70,57 @@ with a strong family history of coronary artery disease with a brother dying at
foreach (var entity in entitiesInDoc.Entities)
{
// view recognized healthcare entities
- Console.WriteLine($" Entity: {entity.Text}");
- Console.WriteLine($" Category: {entity.Category}");
- Console.WriteLine($" Offset: {entity.Offset}");
- Console.WriteLine($" Length: {entity.Length}");
- Console.WriteLine($" NormalizedText: {entity.NormalizedText}");
- Console.WriteLine($" Links:");
+ Console.WriteLine($" Entity: {entity.Text}");
+ Console.WriteLine($" Category: {entity.Category}");
+ Console.WriteLine($" Offset: {entity.Offset}");
+ Console.WriteLine($" Length: {entity.Length}");
+ Console.WriteLine($" NormalizedText: {entity.NormalizedText}");
+ Console.WriteLine($" Links:");
// view entity data sources
foreach (EntityDataSource entityDataSource in entity.DataSources)
{
- Console.WriteLine($" Entity ID in Data Source: {entityDataSource.EntityId}");
- Console.WriteLine($" DataSource: {entityDataSource.Name}");
+ Console.WriteLine($" Entity ID in Data Source: {entityDataSource.EntityId}");
+ Console.WriteLine($" DataSource: {entityDataSource.Name}");
}
// view assertion
if (entity.Assertion != null)
{
- Console.WriteLine($" Assertions:");
+ Console.WriteLine($" Assertions:");
if (entity.Assertion?.Association != null)
{
- Console.WriteLine($" Association: {entity.Assertion?.Association}");
+ Console.WriteLine($" Association: {entity.Assertion?.Association}");
}
if (entity.Assertion?.Certainty != null)
{
- Console.WriteLine($" Certainty: {entity.Assertion?.Certainty}");
+ Console.WriteLine($" Certainty: {entity.Assertion?.Certainty}");
}
if (entity.Assertion?.Conditionality != null)
{
- Console.WriteLine($" Conditionality: {entity.Assertion?.Conditionality}");
+ Console.WriteLine($" Conditionality: {entity.Assertion?.Conditionality}");
}
}
}
- Console.WriteLine($" We found {entitiesInDoc.EntityRelations.Count} relations in the current document:");
+ Console.WriteLine($" We found {entitiesInDoc.EntityRelations.Count} relations in the current document:");
Console.WriteLine("");
// view recognized healthcare relations
foreach (HealthcareEntityRelation relations in entitiesInDoc.EntityRelations)
{
- Console.WriteLine($" Relation: {relations.RelationType}");
- Console.WriteLine($" For this relation there are {relations.Roles.Count} roles");
+ Console.WriteLine($" Relation: {relations.RelationType}");
+ Console.WriteLine($" For this relation there are {relations.Roles.Count} roles");
// view relation roles
foreach (HealthcareEntityRelationRole role in relations.Roles)
{
- Console.WriteLine($" Role Name: {role.Name}");
-
- Console.WriteLine($" Associated Entity Text: {role.Entity.Text}");
- Console.WriteLine($" Associated Entity Category: {role.Entity.Category}");
+ Console.WriteLine($" Role Name: {role.Name}");
+ Console.WriteLine($" Associated Entity Text: {role.Entity.Text}");
+ Console.WriteLine($" Associated Entity Category: {role.Entity.Category}");
Console.WriteLine("");
}
@@ -141,7 +137,9 @@ with a strong family history of coronary artery disease with a brother dying at
Console.WriteLine("");
}
}
- #endregion
+ #endregion Snippet:TextAnalyticsSampleHealthcareConvenienceAsyncViewResults
+
+ #endregion Snippet:TextAnalyticsAnalyzeHealthcareEntitiesConvenienceAsyncAll
}
}
}
diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntitiesConvenienceAsync_AutomaticPolling.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntitiesConvenienceAsync_AutomaticPolling.cs
deleted file mode 100644
index 9edbd24188e1..000000000000
--- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntitiesConvenienceAsync_AutomaticPolling.cs
+++ /dev/null
@@ -1,123 +0,0 @@
-// 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
-{
- [LiveOnly]
- public partial class TextAnalyticsSamples: SamplesBase
- {
- [Test]
- public async Task Sample7_AnalyzeHealthcareEntitiesConvenienceAsync_AutomaticPolling()
- {
- // 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:RecognizeHealthcareEntitiesAsyncAutomaticPolling
- // get input documents
- string document = @"RECORD #333582770390100 | MH | 85986313 | | 054351 | 2/14/2001 12:00:00 AM | CORONARY ARTERY DISEASE | Signed | DIS | \
- Admission Date: 5/22/2001 Report Status: Signed Discharge Date: 4/24/2001 ADMISSION DIAGNOSIS: CORONARY ARTERY DISEASE. \
- HISTORY OF PRESENT ILLNESS: The patient is a 54-year-old gentleman with a history of progressive angina over the past several months. \
- The patient had a cardiac catheterization in July of this year revealing total occlusion of the RCA and 50% left main disease ,\
- with a strong family history of coronary artery disease with a brother dying at the age of 52 from a myocardial infarction and \
- another brother who is status post coronary artery bypass grafting. The patient had a stress echocardiogram done on July , 2001 , \
- which showed no wall motion abnormalities , but this was a difficult study due to body habitus. The patient went for six minutes with \
- minimal ST depressions in the anterior lateral leads , thought due to fatigue and wrist pain , his anginal equivalent. Due to the patient's \
- increased symptoms and family history and history left main disease with total occasional of his RCA was referred for revascularization with open heart surgery.";
-
- // start analysis process
- AnalyzeHealthcareEntitiesOperation healthOperation = await client.StartAnalyzeHealthcareEntitiesAsync(new List() { document });
-
- // wait for operation completion with automatic polling
- TimeSpan pollingInterval = new TimeSpan(1000);
-
- await healthOperation.WaitForCompletionAsync(pollingInterval);
-
- // view operation results
- await foreach (AnalyzeHealthcareEntitiesResultCollection documentsInPage in healthOperation.Value)
- {
- Console.WriteLine($"Results of Azure Text Analytics \"Healthcare Async\" Model, version: \"{documentsInPage.ModelVersion}\"");
- Console.WriteLine("");
-
- foreach (AnalyzeHealthcareEntitiesResult result in documentsInPage)
- {
- Console.WriteLine($" Recognized the following {result.Entities.Count} healthcare entities:");
-
- // view recognized healthcare entities
- foreach (HealthcareEntity entity in result.Entities)
- {
- Console.WriteLine($" Entity: {entity.Text}");
- Console.WriteLine($" Category: {entity.Category}");
- Console.WriteLine($" Offset: {entity.Offset}");
- Console.WriteLine($" Length: {entity.Length}");
- Console.WriteLine($" NormalizedText: {entity.NormalizedText}");
- Console.WriteLine($" Links:");
-
- // view entity data sources
- foreach (EntityDataSource entityDataSource in entity.DataSources)
- {
- Console.WriteLine($" Entity ID in Data Source: {entityDataSource.EntityId}");
- Console.WriteLine($" DataSource: {entityDataSource.Name}");
- }
-
- // view assertion
- if (entity.Assertion != null)
- {
- Console.WriteLine($" Assertions:");
-
- if (entity.Assertion?.Association != null)
- {
- Console.WriteLine($" Association: {entity.Assertion?.Association}");
- }
-
- if (entity.Assertion?.Certainty != null)
- {
- Console.WriteLine($" Certainty: {entity.Assertion?.Certainty}");
- }
- if (entity.Assertion?.Conditionality != null)
- {
- Console.WriteLine($" Conditionality: {entity.Assertion?.Conditionality}");
- }
- }
- }
-
- Console.WriteLine($" We found {result.EntityRelations.Count} relations in the current document:");
- Console.WriteLine("");
-
- // view recognized healthcare relations
- foreach (HealthcareEntityRelation relations in result.EntityRelations)
- {
- Console.WriteLine($" Relation: {relations.RelationType}");
- Console.WriteLine($" For this relation there are {relations.Roles.Count} roles");
-
- // view relation roles
- foreach (HealthcareEntityRelationRole role in relations.Roles)
- {
- Console.WriteLine($" Role Name: {role.Name}");
-
- Console.WriteLine($" Associated Entity Text: {role.Entity.Text}");
- Console.WriteLine($" Associated Entity Category: {role.Entity.Category}");
-
- Console.WriteLine("");
- }
-
- Console.WriteLine("");
- }
-
- Console.WriteLine("");
- Console.WriteLine("");
- }
- }
- }
-
- #endregion
- }
-}
diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntitiesConvenience_ManualPolling.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntitiesConvenience_ManualPolling.cs
deleted file mode 100644
index 7054c8430c49..000000000000
--- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntitiesConvenience_ManualPolling.cs
+++ /dev/null
@@ -1,132 +0,0 @@
-// 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
-{
- [LiveOnly]
- public partial class TextAnalyticsSamples: SamplesBase
- {
- [Test]
- public async Task Sample7_AnalyzeHealthcareEntitiesConvenience_ManualPolling()
- {
- // 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:RecognizeHealthcareEntitiesAsyncManualPolling
- // get input documents
- string document = @"RECORD #333582770390100 | MH | 85986313 | | 054351 | 2/14/2001 12:00:00 AM | CORONARY ARTERY DISEASE | Signed | DIS | \
- Admission Date: 5/22/2001 Report Status: Signed Discharge Date: 4/24/2001 ADMISSION DIAGNOSIS: CORONARY ARTERY DISEASE. \
- HISTORY OF PRESENT ILLNESS: The patient is a 54-year-old gentleman with a history of progressive angina over the past several months. \
- The patient had a cardiac catheterization in July of this year revealing total occlusion of the RCA and 50% left main disease ,\
- with a strong family history of coronary artery disease with a brother dying at the age of 52 from a myocardial infarction and \
- another brother who is status post coronary artery bypass grafting. The patient had a stress echocardiogram done on July , 2001 , \
- which showed no wall motion abnormalities , but this was a difficult study due to body habitus. The patient went for six minutes with \
- minimal ST depressions in the anterior lateral leads , thought due to fatigue and wrist pain , his anginal equivalent. Due to the patient's \
- increased symptoms and family history and history left main disease with total occasional of his RCA was referred for revascularization with open heart surgery.";
-
- // start analysis process
- AnalyzeHealthcareEntitiesOperation healthOperation = await client.StartAnalyzeHealthcareEntitiesAsync(new List() { document });
-
- // wait for completion with manual polling
- TimeSpan pollingInterval = new TimeSpan(1000);
-
- while (true)
- {
- await healthOperation.UpdateStatusAsync();
- if (healthOperation.HasCompleted)
- {
- break;
- }
-
- await Task.Delay(pollingInterval);
- }
-
- // view operation results
- await foreach (AnalyzeHealthcareEntitiesResultCollection documentsInPage in healthOperation.Value)
- {
- Console.WriteLine($"Results of Azure Text Analytics \"Healthcare Async\" Model, version: \"{documentsInPage.ModelVersion}\"");
- Console.WriteLine("");
-
- foreach (AnalyzeHealthcareEntitiesResult result in documentsInPage)
- {
- Console.WriteLine($" Recognized the following {result.Entities.Count} healthcare entities:");
-
- // view recognized healthcare entities
- foreach (HealthcareEntity entity in result.Entities)
- {
- Console.WriteLine($" Entity: {entity.Text}");
- Console.WriteLine($" Category: {entity.Category}");
- Console.WriteLine($" Offset: {entity.Offset}");
- Console.WriteLine($" Length: {entity.Length}");
- Console.WriteLine($" NormalizedText: {entity.NormalizedText}");
- Console.WriteLine($" Links:");
-
- // view entity data sources
- foreach (EntityDataSource entityDataSource in entity.DataSources)
- {
- Console.WriteLine($" Entity ID in Data Source: {entityDataSource.EntityId}");
- Console.WriteLine($" DataSource: {entityDataSource.Name}");
- }
-
- // view assertion
- if (entity.Assertion != null)
- {
- Console.WriteLine($" Assertions:");
-
- if (entity.Assertion?.Association != null)
- {
- Console.WriteLine($" Association: {entity.Assertion?.Association}");
- }
-
- if (entity.Assertion?.Certainty != null)
- {
- Console.WriteLine($" Certainty: {entity.Assertion?.Certainty}");
- }
- if (entity.Assertion?.Conditionality != null)
- {
- Console.WriteLine($" Conditionality: {entity.Assertion?.Conditionality}");
- }
- }
-
- Console.WriteLine($" We found {result.EntityRelations.Count} relations in the current document:");
- Console.WriteLine("");
-
- // view recognized healthcare relations
- foreach (HealthcareEntityRelation relations in result.EntityRelations)
- {
- Console.WriteLine($" Relation: {relations.RelationType}");
- Console.WriteLine($" For this relation there are {relations.Roles.Count} roles");
-
- // view relation roles
- foreach (HealthcareEntityRelationRole role in relations.Roles)
- {
- Console.WriteLine($" Role Name: {role.Name}");
-
- Console.WriteLine($" Associated Entity Text: {role.Entity.Text}");
- Console.WriteLine($" Associated Entity Category: {role.Entity.Category}");
-
- Console.WriteLine("");
- }
-
- Console.WriteLine("");
- }
-
- Console.WriteLine("");
- }
- Console.WriteLine("");
- }
- }
- }
-
- #endregion
- }
-}
diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntities_Cancellation.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntities_Cancellation.cs
index 49018fa836c5..c37384612043 100644
--- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntities_Cancellation.cs
+++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntities_Cancellation.cs
@@ -13,14 +13,13 @@ namespace Azure.AI.TextAnalytics.Samples
public partial class TextAnalyticsSamples: SamplesBase
{
[Test]
- public void Sample7_AnalyzeHealthcareEntities_Cancellation()
+ public void AnalyzeHealthcareEntities_Cancellation()
{
string endpoint = TestEnvironment.Endpoint;
string apiKey = TestEnvironment.ApiKey;
var client = new TextAnalyticsClient(new Uri(endpoint), new AzureKeyCredential(apiKey));
- #region Snippet:TextAnalyticsSampleHealthcareCancellation
string document = @"RECORD #333582770390100 | MH | 85986313 | | 054351 | 2/14/2001 12:00:00 AM | CORONARY ARTERY DISEASE | Signed | DIS | \
Admission Date: 5/22/2001 Report Status: Signed Discharge Date: 4/24/2001 ADMISSION DIAGNOSIS: CORONARY ARTERY DISEASE. \
HISTORY OF PRESENT ILLNESS: The patient is a 54-year-old gentleman with a history of progressive angina over the past several months. \
@@ -42,7 +41,5 @@ with a strong family history of coronary artery disease with a brother dying at
healthOperation.Cancel();
}
-
- #endregion
}
}
diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntities_ManualPolling.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntities_ManualPolling.cs
deleted file mode 100644
index c6bcef31030a..000000000000
--- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample7_AnalyzeHealthcareEntities_ManualPolling.cs
+++ /dev/null
@@ -1,152 +0,0 @@
-// 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
-{
- [LiveOnly]
- public partial class TextAnalyticsSamples: SamplesBase
- {
- [Test]
- public async Task Sample7_AnalyzeHealthcareEntities_ManualPolling()
- {
- // 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:Sample7_AnalyzeHealthcareEntities_ManualPolling
- // get input documents
- string document1 = @"RECORD #333582770390100 | MH | 85986313 | | 054351 | 2/14/2001 12:00:00 AM | CORONARY ARTERY DISEASE | Signed | DIS | \
- Admission Date: 5/22/2001 Report Status: Signed Discharge Date: 4/24/2001 ADMISSION DIAGNOSIS: CORONARY ARTERY DISEASE. \
- HISTORY OF PRESENT ILLNESS: The patient is a 54-year-old gentleman with a history of progressive angina over the past several months. \
- The patient had a cardiac catheterization in July of this year revealing total occlusion of the RCA and 50% left main disease ,\
- with a strong family history of coronary artery disease with a brother dying at the age of 52 from a myocardial infarction and \
- another brother who is status post coronary artery bypass grafting. The patient had a stress echocardiogram done on July , 2001 , \
- which showed no wall motion abnormalities , but this was a difficult study due to body habitus. The patient went for six minutes with \
- minimal ST depressions in the anterior lateral leads , thought due to fatigue and wrist pain , his anginal equivalent. Due to the patient's \
- increased symptoms and family history and history left main disease with total occasional of his RCA was referred for revascularization with open heart surgery.";
-
- string document2 = "Prescribed 100mg ibuprofen, taken twice daily.";
-
- // prepare analyze operation input
- List batchInput = new List()
- {
- new TextDocumentInput("1", document1)
- {
- Language = "en"
- },
- new TextDocumentInput("2", document2)
- {
- Language = "en"
- }
- };
-
- AnalyzeHealthcareEntitiesOptions options = new AnalyzeHealthcareEntitiesOptions()
- {
- IncludeStatistics = true
- };
-
- // start analysis process
- AnalyzeHealthcareEntitiesOperation healthOperation = await client.StartAnalyzeHealthcareEntitiesAsync(batchInput, options);
-
- TimeSpan pollingInterval = new TimeSpan(1000);
-
- // wait for completion with manual polling
- while (true)
- {
- await healthOperation.UpdateStatusAsync();
- if (healthOperation.HasCompleted)
- {
- break;
- }
-
- await Task.Delay(pollingInterval);
- }
-
- // view operation results
- await foreach (AnalyzeHealthcareEntitiesResultCollection documentsInPage in healthOperation.Value)
- {
- Console.WriteLine($"Results of Azure Text Analytics \"Healthcare Async\" Model, version: \"{documentsInPage.ModelVersion}\"");
- Console.WriteLine("");
-
- foreach (AnalyzeHealthcareEntitiesResult result in documentsInPage)
- {
- Console.WriteLine($" Recognized the following {result.Entities.Count} healthcare entities:");
-
- // view recognized healthcare entities
- foreach (HealthcareEntity entity in result.Entities)
- {
- Console.WriteLine($" Entity: {entity.Text}");
- Console.WriteLine($" Category: {entity.Category}");
- Console.WriteLine($" Offset: {entity.Offset}");
- Console.WriteLine($" Length: {entity.Length}");
- Console.WriteLine($" NormalizedText: {entity.NormalizedText}");
- Console.WriteLine($" Links:");
-
- // view entity data sources
- foreach (EntityDataSource entityDataSource in entity.DataSources)
- {
- Console.WriteLine($" Entity ID in Data Source: {entityDataSource.EntityId}");
- Console.WriteLine($" DataSource: {entityDataSource.Name}");
- }
-
- // view assertion
- if (entity.Assertion != null)
- {
- Console.WriteLine($" Assertions:");
-
- if (entity.Assertion?.Association != null)
- {
- Console.WriteLine($" Association: {entity.Assertion?.Association}");
- }
-
- if (entity.Assertion?.Certainty != null)
- {
- Console.WriteLine($" Certainty: {entity.Assertion?.Certainty}");
- }
- if (entity.Assertion?.Conditionality != null)
- {
- Console.WriteLine($" Conditionality: {entity.Assertion?.Conditionality}");
- }
- }
-
- Console.WriteLine($" We found {result.EntityRelations.Count} relations in the current document:");
- Console.WriteLine("");
-
- // view recognized healthcare relations
- foreach (HealthcareEntityRelation relations in result.EntityRelations)
- {
- Console.WriteLine($" Relation: {relations.RelationType}");
- Console.WriteLine($" For this relation there are {relations.Roles.Count} roles");
-
- // view relation roles
- foreach (HealthcareEntityRelationRole role in relations.Roles)
- {
- Console.WriteLine($" Role Name: {role.Name}");
-
- Console.WriteLine($" Associated Entity Text: {role.Entity.Text}");
- Console.WriteLine($" Associated Entity Category: {role.Entity.Category}");
-
- Console.WriteLine("");
- }
-
- Console.WriteLine("");
- }
-
- Console.WriteLine("");
- }
- Console.WriteLine("");
- }
- }
- }
-
- #endregion
- }
-}
diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_AnalyzeOperation.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_AnalyzeOperation.cs
index b6b81f3fa7b1..0836901572e1 100644
--- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_AnalyzeOperation.cs
+++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_AnalyzeOperation.cs
@@ -22,8 +22,6 @@ public void AnalyzeOperation()
var client = new TextAnalyticsClient(new Uri(endpoint), new AzureKeyCredential(apiKey));
- #region Snippet:TextAnalyticsAnalyzeOperation
-
string documentA = @"We love this trail and make the trip every year. The views are breathtaking and well
worth the hike! Yesterday was foggy though, so we missed the spectacular views.
We tried again today and it was amazing. Everyone in my family liked the trail although
@@ -200,7 +198,5 @@ We tried again today and it was amazing. Everyone in my family liked the trail a
}
}
}
-
- #endregion
}
}
diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_AnalyzeOperationAsync.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_AnalyzeOperationAsync.cs
index 5bfd45d63e82..28e3f96d4ac1 100644
--- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_AnalyzeOperationAsync.cs
+++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_AnalyzeOperationAsync.cs
@@ -23,7 +23,6 @@ public async Task AnalyzeOperationAsync()
var client = new TextAnalyticsClient(new Uri(endpoint), new AzureKeyCredential(apiKey));
- #region Snippet:AnalyzeOperationBatchAsync
string documentA = @"We love this trail and make the trip every year. The views are breathtaking and well
worth the hike! Yesterday was foggy though, so we missed the spectacular views.
We tried again today and it was amazing. Everyone in my family liked the trail although
@@ -191,7 +190,5 @@ We tried again today and it was amazing. Everyone in my family liked the trail a
}
}
}
-
- #endregion
}
}
diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_AnalyzeOperationConvenience.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_AnalyzeOperationConvenience.cs
index dc21b590af36..86744a552cd8 100644
--- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_AnalyzeOperationConvenience.cs
+++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_AnalyzeOperationConvenience.cs
@@ -22,7 +22,6 @@ public void AnalyzeOperationConvenience()
var client = new TextAnalyticsClient(new Uri(endpoint), new AzureKeyCredential(apiKey));
- #region Snippet:AnalyzeOperationConvenience
string documentA = @"We love this trail and make the trip every year. The views are breathtaking and well
worth the hike! Yesterday was foggy though, so we missed the spectacular views.
We tried again today and it was amazing. Everyone in my family liked the trail although
@@ -193,7 +192,5 @@ We tried again today and it was amazing. Everyone in my family liked the trail a
}
}
}
-
- #endregion
}
}