Skip to content

Commit 2683df8

Browse files
authored
Merge pull request #110898 from ctufts/chtufts/dotnetQSUpdate
.NET Quickstart Updated for v1.0.0-preview.4
2 parents a2fe8ab + 21602fd commit 2683df8

File tree

1 file changed

+4
-33
lines changed
  • articles/cognitive-services/text-analytics/includes/quickstarts

1 file changed

+4
-33
lines changed

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

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Using the Visual Studio IDE, create a new .NET Core console app. This will creat
3939

4040
#### [Version 3.0-preview](#tab/version-3)
4141

42-
Install the client library by right-clicking on the solution in the **Solution Explorer** and selecting **Manage NuGet Packages**. In the package manager that opens select **Browse**, check **Include prerelease**, and search for `Azure.AI.TextAnalytics`. Select version `1.0.0-preview.3`, and then **Install**. You can also use the [Package Manager Console](https://docs.microsoft.com/nuget/consume-packages/install-use-packages-powershell#find-and-install-a-package).
42+
Install the client library by right-clicking on the solution in the **Solution Explorer** and selecting **Manage NuGet Packages**. In the package manager that opens select **Browse**, check **Include prerelease**, and search for `Azure.AI.TextAnalytics`. Select version `1.0.0-preview.4`, and then **Install**. You can also use the [Package Manager Console](https://docs.microsoft.com/nuget/consume-packages/install-use-packages-powershell#find-and-install-a-package).
4343

4444
> [!TIP]
4545
> Want to view the whole quickstart code file at once? You can find it [on GitHub](https://github.com/Azure-Samples/cognitive-services-quickstart-code/blob/master/dotnet/TextAnalytics/program.cs), which contains the code examples in this quickstart.
@@ -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

@@ -116,14 +116,13 @@ Replace the application's `Main` method. You will define the methods called here
116116

117117
The Text Analytics client is a `TextAnalyticsClient` object that authenticates to Azure using your key, and provides functions to accept text as single strings or as a batch. You can send text to the API synchronously, or asynchronously. The response object will contain the analysis information for each document you send.
118118

119-
If you're using version `3.0-preview`, you can use an optional `TextAnalyticsClientOptions` instance to initialize the client with various default settings (for example default language or country hint). You can also authenticate using an Azure Active Directory token.
119+
If you're using version `3.0-preview` of the service, you can use an optional `TextAnalyticsClientOptions` instance to initialize the client with various default settings (for example default language or country hint). You can also authenticate using an Azure Active Directory token.
120120

121121
## Code examples
122122

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)