You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/cognitive-services/text-analytics/quickstarts/csharp.md
+38-36Lines changed: 38 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
-
title: 'Quickstart: Using C# to call the Text Analytics API'
2
+
title: 'Quickstart: Call the Text Analytics service by using the Azure SDK for .NET and C#'
3
3
titleSuffix: Azure Cognitive Services
4
-
description: Get information and code samples to help you quickly get started with using the Text Analytics API.
4
+
description: Information and code samples to help you start using the Text Analytics service and C#.
5
5
services: cognitive-services
6
6
author: raymondl
7
7
manager: nitinme
@@ -13,35 +13,38 @@ ms.date: 04/29/2019
13
13
ms.author: assafi
14
14
---
15
15
16
-
# Quickstart: Using C# to call the Text Analytics Cognitive Service
16
+
# Quickstart: Use the .NET SDK and C# to call the Text Analytics service
17
17
<aname="HOLTop"></a>
18
18
19
-
Use this quickstart to begin analyzing language with the Text Analytics SDK for C#. While the [Text Analytics](//go.microsoft.com/fwlink/?LinkID=759711) REST API is compatible with most programming languages, the SDK provides an easy way to integrate the service into your applications. The source code for this sample can be found on [GitHub](https://github.com/Azure-Samples/cognitive-services-dotnet-sdk-samples/tree/master/samples/TextAnalytics).
19
+
This quickstart helps you begin using the Azure SDK for .NET and C# to analyze language. Although the [Text Analytics](//go.microsoft.com/fwlink/?LinkID=759711) REST API is compatible with most programming languages, the SDK provides an easy way to integrate the service into your applications.
20
20
21
-
Refer to the [API definitions](https://westus.dev.cognitive.microsoft.com/docs/services/TextAnalytics-v2-1/operations/56f30ceeeda5650db055a3c7) for technical documentation for the APIs.
21
+
> [!NOTE]
22
+
> The source code for this sample is available on [GitHub](https://github.com/Azure-Samples/cognitive-services-dotnet-sdk-samples/tree/master/samples/TextAnalytics).
23
+
24
+
For technical details, refer to the SDK for .NET [Text Analytics reference](https://docs.microsoft.com/dotnet/api/overview/azure/cognitiveservices/client/textanalytics?view=azure-dotnet).
You must also have the [endpoint and access key](../How-tos/text-analytics-how-to-access-key.md) that was generated for you during sign-up.
30
+
You also need the [endpoint and access key](../How-tos/text-analytics-how-to-access-key.md) that was generated for you during sign-up.
28
31
29
32
> [!Tip]
30
-
> While you could call the [HTTP endpoints](https://westus.dev.cognitive.microsoft.com/docs/services/TextAnalytics-v2-1/operations/56f30ceeeda5650db055a3c9) directly from C#, the Microsoft.Azure.CognitiveServices.Language SDK makes it much easier to call the service without having to worry about serializing and deserializing JSON.
33
+
> While you can call the [HTTP endpoints](https://westus.dev.cognitive.microsoft.com/docs/services/TextAnalytics-v2-1/operations/56f30ceeeda5650db055a3c9) directly from C#, the Microsoft.Azure.CognitiveServices.Language SDK makes it much easier to call the service without having to serialize and deserialize JSON.
## Create the Visual Studio solution and install the SDK
37
40
38
-
1. Create a new Console App (.NET Core) project[Visual Studio](https://visualstudio.microsoft.com/vs/).
39
-
1. Rightclick on the solution and click**Manage NuGet Packages for Solution**
40
-
1. Select the **Browse** tab, and Search for **Microsoft.Azure.CognitiveServices.Language.TextAnalytics**
41
+
1. Create a new console app (.NET Core) project. [Access Visual Studio](https://visualstudio.microsoft.com/vs/).
42
+
1. Right-click the solution and select**Manage NuGet Packages for Solution**.
43
+
1. Select the **Browse** tab. Search for **Microsoft.Azure.CognitiveServices.Language.TextAnalytics**.
41
44
42
45
## Authenticate your credentials
43
46
44
-
1. Add the following `using` statements to the main class file (`Program.cs` by default).
47
+
1. Add the following `using` statements to the main class file (which is Program.cs by default).
45
48
46
49
```csharp
47
50
usingSystem;
@@ -59,7 +62,7 @@ You must also have the [endpoint and access key](../How-tos/text-analytics-how-t
59
62
60
63
```csharp
61
64
/// <summary>
62
-
/// Allows authentication to the API using a basic apiKey mechanism
65
+
/// Allows authentication to the API by using a basic apiKey mechanism
63
66
/// </summary>
64
67
class ApiKeyServiceClientCredentials : ServiceClientCredentials
65
68
{
@@ -92,32 +95,32 @@ You must also have the [endpoint and access key](../How-tos/text-analytics-how-t
92
95
}
93
96
```
94
97
95
-
3. Updatethe `Program` classand add a constant member for your Text Analytics subscription key and another for the service endpoint. Remember to use the correct Azure region for your Text Analytics subscription.
98
+
3. Updatethe `Program` class. Add a constant member for your Text Analytics subscription key, and another for the service endpoint. Remember to use the correct Azure region for your Text Analytics subscription.
@@ -150,7 +153,7 @@ Next sections describes how to call each of the API features.
150
153
}
151
154
```
152
155
153
-
3. Inthesamefunction, call `client.SentimentAsync()` andgettheresult. Theniteratethroughtheresults, andprinteachdocument's ID, and sentiment score. A score closer to 0 indicates a negative sentiment, while a score closer to 1 indicates a positive sentiment.
156
+
3. Inthesamefunction, call `client.SentimentAsync()` andgettheresult. Theniteratethroughtheresults. Printeachdocument's ID and sentiment score. A score that'scloseto0indicatesanegativesentiment, whileascorethat's closer to 1 indicates a positive sentiment.
3. Inthesamefunction, call `client.DetectLanguageAsync()` andgettheresult. Theniteratethroughtheresults, andprinteachdocument's ID, and the first returned language.
198
+
3. Inthesamefunction, call `client.DetectLanguageAsync()` andgettheresult. Theniteratethroughtheresults. Printeachdocument's ID and the first returned language.
3. Inthesamefunction, call `client.EntitiesAsync()` andgettheresult. Theniteratethroughtheresults, andprinteachdocument's ID. For each detected entity, print it'swikipedianame, thetypeandsub-types (ifexists) aswellasthelocationsintheoriginaltext.
239
+
3. Inthesamefunction, call `client.EntitiesAsync()` andgettheresult. Theniteratethroughtheresults. Printeachdocument's ID. For each detected entity, print its Wikipedia name and the type and subtypes (if they exist) as well as the locations in the original text.
3. Inthesamefunction, call `client.KeyPhrasesAsync()` andgettheresult. Theniteratethroughtheresults, andprinteachdocument's ID, and any detected key phrases.
312
+
3. Inthesamefunction, call `client.KeyPhrasesAsync()` andgettheresult. Theniteratethroughtheresults. Printeachdocument's ID and any detected key phrases.
0 commit comments