Skip to content

Commit f7cd232

Browse files
author
Chris Tufts
committed
updated csharp-sdk quickstart, but also found a bug in the entity linking results
1 parent 170edaa commit f7cd232

File tree

1 file changed

+2
-31
lines changed
  • articles/cognitive-services/text-analytics/includes/quickstarts

1 file changed

+2
-31
lines changed

articles/cognitive-services/text-analytics/includes/quickstarts/csharp-sdk.md

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ Install the client library by right-clicking on the solution in the **Solution E
5858
Open the *program.cs* file and add the following `using` directives:
5959

6060
```csharp
61+
using Azure;
6162
using System;
6263
using System.Globalization;
6364
using Azure.AI.TextAnalytics;
@@ -68,7 +69,7 @@ In the application's `Program` class, create variables for your resource's key a
6869
[!INCLUDE [text-analytics-find-resource-information](../find-azure-resource-info.md)]
6970

7071
```csharp
71-
private static readonly TextAnalyticsApiKeyCredential credentials = new TextAnalyticsApiKeyCredential("<replace-with-your-text-analytics-key-here>");
72+
private static readonly AzureKeyCredential credentials = new AzureKeyCredential("<replace-with-your-text-analytics-key-here>");
7273
private static readonly Uri endpoint = new Uri("<replace-with-your-text-analytics-endpoint-here>");
7374
```
7475

@@ -82,7 +83,6 @@ static void Main(string[] args)
8283
SentimentAnalysisExample(client);
8384
LanguageDetectionExample(client);
8485
EntityRecognitionExample(client);
85-
EntityPIIExample(client);
8686
EntityLinkingExample(client);
8787
KeyPhraseExtractionExample(client);
8888

@@ -123,7 +123,6 @@ If you're using version `3.0-preview`, you can use an optional `TextAnalyticsCli
123123
* [Sentiment analysis](#sentiment-analysis)
124124
* [Language detection](#language-detection)
125125
* [Named Entity Recognition](#named-entity-recognition-ner)
126-
* [Detect personal information](#detect-personal-information)
127126
* [Entity linking](#entity-linking)
128127
* [Key phrase extraction](#key-phrase-extraction)
129128

@@ -259,7 +258,6 @@ Language: English
259258

260259
> [!NOTE]
261260
> New in version `3.0-preview`:
262-
> * Entity recognition now includes the ability to detect personal information in text.
263261
> * Entity linking is now a separated from entity recognition.
264262
265263

@@ -289,33 +287,6 @@ Named Entities:
289287
Length: 9, Score: 0.80
290288
```
291289

292-
## Detect personal information
293-
294-
Create a new function called `EntityPIIExample()` that takes the client that you created earlier, call its `RecognizePiiEntities()` function and iterate through the results. Similar to the previous function the returned `Response<IReadOnlyCollection<CategorizedEntity>>` object will contain the list of detected entities. If there was an error, it will throw a `RequestFailedException`.
295-
296-
```csharp
297-
static void EntityPIIExample(TextAnalyticsClient client)
298-
{
299-
string inputText = "Insurance policy for SSN on file 123-12-1234 is here by approved.";
300-
var response = client.RecognizePiiEntities(inputText);
301-
Console.WriteLine("Personally Identifiable Information Entities:");
302-
foreach (var entity in response.Value)
303-
{
304-
Console.WriteLine($"\tText: {entity.Text},\tCategory: {entity.Category},\tSub-Category: {entity.SubCategory}");
305-
Console.WriteLine($"\t\tLength: {entity.GraphemeLength},\tScore: {entity.ConfidenceScore:F2}\n");
306-
}
307-
}
308-
```
309-
310-
### Output
311-
312-
```console
313-
Personally Identifiable Information Entities:
314-
Text: 123-12-1234, Category: U.S. Social Security Number (SSN), Sub-Category:
315-
Length: 11, Score: 0.85
316-
```
317-
318-
319290
## Entity linking
320291

321292
Create a new function called `EntityLinkingExample()` that takes the client that you created earlier, call its `RecognizeLinkedEntities()` function and iterate through the results. The returned `Response<IReadOnlyCollection<LinkedEntity>>` represents the list of detected entities. If there was an error, it will throw a `RequestFailedException`. Since linked entities are uniquely identified, occurrences of the same entity are grouped under a `LinkedEntity` object as a list of `LinkedEntityMatch` objects.

0 commit comments

Comments
 (0)