Skip to content

Commit a78af03

Browse files
authored
Merge pull request #45 from thediris/patch-1
adjust .NET TextAnalytics quickstart to adhere to sdk changes, and reflect that api v3.0 is not preview anymore
2 parents ff0ac05 + d7fbe75 commit a78af03

File tree

1 file changed

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

1 file changed

+27
-27
lines changed

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

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ ms.reviewer: assafi
1313

1414
<a name="HOLTop"></a>
1515

16-
#### [Version 3.0-preview](#tab/version-3)
16+
#### [Version 3.0](#tab/version-3)
1717

1818
[v3 Reference documentation](https://aka.ms/azsdk-net-textanalytics-ref-docs) | [v3 Library source code](https://github.com/Azure/azure-sdk-for-net/tree/master/sdk/textanalytics) | [v3 Package (NuGet)](https://www.nuget.org/packages/Azure.AI.TextAnalytics) | [v3 Samples](https://github.com/Azure/azure-sdk-for-net/tree/master/sdk/textanalytics/Azure.AI.TextAnalytics/samples)
1919

@@ -37,9 +37,9 @@ ms.reviewer: assafi
3737

3838
Using the Visual Studio IDE, create a new .NET Core console app. This will create a "Hello World" project with a single C# source file: *program.cs*.
3939

40-
#### [Version 3.0-preview](#tab/version-3)
40+
#### [Version 3.0](#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.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).
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.5`, 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.
@@ -53,7 +53,7 @@ Install the client library by right-clicking on the solution in the **Solution E
5353
5454
---
5555

56-
#### [Version 3.0-preview](#tab/version-3)
56+
#### [Version 3.0](#tab/version-3)
5757

5858
Open the *program.cs* file and add the following `using` directives:
5959

@@ -116,7 +116,7 @@ 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` of the service, you can use an optional `TextAnalyticsClientOptions` instance to initialize the client with various default settings (for example default language or country/region hint). You can also authenticate using an Azure Active Directory token.
119+
If you're using version `3.0` of the service, you can use an optional `TextAnalyticsClientOptions` instance to initialize the client with various default settings (for example default language or country/region hint). You can also authenticate using an Azure Active Directory token.
120120

121121
## Code examples
122122

@@ -128,7 +128,7 @@ If you're using version `3.0-preview` of the service, you can use an optional `T
128128

129129
## Authenticate the client
130130

131-
#### [Version 3.0-preview](#tab/version-3)
131+
#### [Version 3.0](#tab/version-3)
132132

133133
Make sure your main method from earlier creates a new client object with your endpoint and credentials.
134134

@@ -150,7 +150,7 @@ Create a method to instantiate the [TextAnalyticsClient](https://docs.microsoft.
150150

151151
## Sentiment analysis
152152

153-
#### [Version 3.0-preview](#tab/version-3)
153+
#### [Version 3.0](#tab/version-3)
154154

155155
Create a new function called `SentimentAnalysisExample()` that takes the client that you created earlier, and call its `AnalyzeSentiment()` function. The returned `Response<DocumentSentiment>` object will contain the sentiment label and score of the entire input document, as well as a sentiment analysis for each sentence if successful. If there was an error, it will throw a `RequestFailedException`.
156156

@@ -164,8 +164,7 @@ static void SentimentAnalysisExample(TextAnalyticsClient client)
164164
var si = new StringInfo(inputText);
165165
foreach (var sentence in documentSentiment.Sentences)
166166
{
167-
Console.WriteLine($"\tSentence [length {sentence.GraphemeLength}]");
168-
Console.WriteLine($"\tText: \"{si.SubstringByTextElements(sentence.GraphemeOffset, sentence.GraphemeLength)}\"");
167+
Console.WriteLine($"\tText: \"{sentence.Text}\"");
169168
Console.WriteLine($"\tSentence sentiment: {sentence.Sentiment}");
170169
Console.WriteLine($"\tPositive score: {sentence.ConfidenceScores.Positive:0.00}");
171170
Console.WriteLine($"\tNegative score: {sentence.ConfidenceScores.Negative:0.00}");
@@ -179,14 +178,12 @@ static void SentimentAnalysisExample(TextAnalyticsClient client)
179178
```console
180179
Document sentiment: Positive
181180

182-
Sentence [length 30]
183181
Text: "I had the best day of my life."
184182
Sentence sentiment: Positive
185183
Positive score: 1.00
186184
Negative score: 0.00
187185
Neutral score: 0.00
188186

189-
Sentence [length 30]
190187
Text: "I wish you were there with me."
191188
Sentence sentiment: Neutral
192189
Positive score: 0.21
@@ -210,7 +207,7 @@ Sentiment Score: 0.87
210207

211208
## Language detection
212209

213-
#### [Version 3.0-preview](#tab/version-3)
210+
#### [Version 3.0](#tab/version-3)
214211

215212

216213
Create a new function called `LanguageDetectionExample()` that takes the client that you created earlier, and call its `DetectLanguage()` function. The returned `Response<DetectedLanguage>` object will contain the detected language along with its name and ISO-6391 code. If there was an error, it will throw a `RequestFailedException`.
@@ -253,11 +250,11 @@ Language: English
253250

254251
## Named Entity Recognition (NER)
255252

256-
#### [Version 3.0-preview](#tab/version-3)
253+
#### [Version 3.0](#tab/version-3)
257254

258255

259256
> [!NOTE]
260-
> New in version `3.0-preview`:
257+
> New in version `3.0`:
261258
> * Entity linking is now a separated from entity recognition.
262259
263260

@@ -271,7 +268,7 @@ static void EntityRecognitionExample(TextAnalyticsClient client)
271268
foreach (var entity in response.Value)
272269
{
273270
Console.WriteLine($"\tText: {entity.Text},\tCategory: {entity.Category},\tSub-Category: {entity.SubCategory}");
274-
Console.WriteLine($"\t\tLength: {entity.GraphemeLength},\tScore: {entity.ConfidenceScore:F2}\n");
271+
Console.WriteLine($"\t\tScore: {entity.ConfidenceScore:F2}\n");
275272
}
276273
}
277274
```
@@ -280,11 +277,14 @@ static void EntityRecognitionExample(TextAnalyticsClient client)
280277

281278
```console
282279
Named Entities:
280+
Text: trip, Category: Event, Sub-Category:
281+
Score: 0.61
282+
283283
Text: Seattle, Category: Location, Sub-Category: GPE
284-
Length: 7, Score: 0.92
284+
Score: 0.82
285285

286286
Text: last week, Category: DateTime, Sub-Category: DateRange
287-
Length: 9, Score: 0.80
287+
Score: 0.80
288288
```
289289

290290
## Entity linking
@@ -308,7 +308,7 @@ static void EntityLinkingExample(TextAnalyticsClient client)
308308
foreach (var match in entity.Matches)
309309
{
310310
Console.WriteLine($"\t\tText: {match.Text}");
311-
Console.WriteLine($"\t\tLength: {match.GraphemeLength},\tScore: {match.ConfidenceScore:F2}\n");
311+
Console.WriteLine($"\t\tScore: {match.ConfidenceScore:F2}\n");
312312
}
313313
}
314314
}
@@ -321,38 +321,38 @@ Linked Entities:
321321
Name: Altair 8800, ID: Altair 8800, URL: https://en.wikipedia.org/wiki/Altair_8800 Data Source: Wikipedia
322322
Matches:
323323
Text: Altair 8800
324-
Length: 11, Score: 0.78
324+
Score: 0.88
325325

326326
Name: Bill Gates, ID: Bill Gates, URL: https://en.wikipedia.org/wiki/Bill_Gates Data Source: Wikipedia
327327
Matches:
328328
Text: Bill Gates
329-
Length: 10, Score: 0.55
329+
Score: 0.63
330330

331331
Text: Gates
332-
Length: 5, Score: 0.55
332+
Score: 0.63
333333

334334
Name: Paul Allen, ID: Paul Allen, URL: https://en.wikipedia.org/wiki/Paul_Allen Data Source: Wikipedia
335335
Matches:
336336
Text: Paul Allen
337-
Length: 10, Score: 0.53
337+
Score: 0.60
338338

339339
Name: Microsoft, ID: Microsoft, URL: https://en.wikipedia.org/wiki/Microsoft Data Source: Wikipedia
340340
Matches:
341341
Text: Microsoft
342-
Length: 9, Score: 0.47
342+
Score: 0.55
343343

344344
Text: Microsoft
345-
Length: 9, Score: 0.47
345+
Score: 0.55
346346

347347
Name: April 4, ID: April 4, URL: https://en.wikipedia.org/wiki/April_4 Data Source: Wikipedia
348348
Matches:
349349
Text: April 4
350-
Length: 7, Score: 0.25
350+
Score: 0.32
351351

352352
Name: BASIC, ID: BASIC, URL: https://en.wikipedia.org/wiki/BASIC Data Source: Wikipedia
353353
Matches:
354354
Text: BASIC
355-
Length: 5, Score: 0.28
355+
Score: 0.33
356356
```
357357

358358
#### [Version 2.1](#tab/version-2)
@@ -369,7 +369,7 @@ Create a new function called `RecognizeEntitiesExample()` that takes the client
369369

370370
## Key phrase extraction
371371

372-
#### [Version 3.0-preview](#tab/version-3)
372+
#### [Version 3.0](#tab/version-3)
373373

374374
Create a new function called `KeyPhraseExtractionExample()` that takes the client that you created earlier, and call its `ExtractKeyPhrases()` function. The returned `<Response<IReadOnlyCollection<string>>` object will contain the list of detected key phrases. If there was an error, it will throw a `RequestFailedException`.
375375

0 commit comments

Comments
 (0)