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/includes/find-azure-resource-info.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,6 @@ ms.author: aahi
12
12
---
13
13
14
14
> [!IMPORTANT]
15
-
> Go to the resource you created to find your key and endpoint. They'll be located on the resource's **Quick start** page, under **resource management**.
15
+
> Go to the Azure portal and find the key and endpoint for the Text Analytics resource you created in the prerequisites. They will be located on the resource's **Quick start** page, under **resource management**. Then replace the strings in the code below with your key and endpoint.
16
16
>
17
17
> Remember to remove the key from your code when you're done, and never post it publicly. For production, consider using a secure way of storing and accessing your credentials. For example, [Azure key vault](https://docs.microsoft.com/azure/key-vault/key-vault-overview).
> * This quickstart uses version `3.0-preview` of the Text Analytics client library, which includes a public preview for improved [Sentiment Analysis](../../../how-tos/text-analytics-how-to-sentiment-analysis.md#sentiment-analysis-versions-and-features) and [Named Entity Recognition (NER)](../../../how-tos/text-analytics-how-to-entity-linking.md#named-entity-recognition-versions-and-features).
20
-
> * The code in this article uses synchronous methods and un-secured credentials storage for simplicity reasons. For production scenarios, we recommend using the batched asynchronous methods for performance and scalability. For example, calling `SentimentBatchAsync()` instead of `Sentiment()`.
21
-
22
18
## Prerequisites
23
19
24
20
* Azure subscription - [Create one for free](https://azure.microsoft.com/free/)
25
21
*[Java Development Kit](https://www.oracle.com/technetwork/java/javase/downloads/index.html) (JDK) with version 8 or above
@@ -123,9 +117,6 @@ In your program's `main()` method, call the authentication method to instantiate
123
117
124
118
## Sentiment analysis
125
119
126
-
> [!NOTE]
127
-
> The below code is for sentiment analysis v3, which is in public preview.
128
-
129
120
Create a new function called `sentimentAnalysisExample()` that takes the client that you created earlier, and call its `analyzeSentiment()` function. The returned `AnalyzeSentimentResult` object will contain `documentSentiment` and `sentenceSentiments` if successful, or an `errorMessage` if not.
> The below code is for Named Entity Recognition v3, which is in public preview.
186
+
> In version `3.0-preview`:
187
+
> * NER includes separate methods for detecting personal information.
188
+
> * Entity linking is a separate request than NER.
196
189
197
190
Create a new function called `recognizeEntitiesExample()` that takes the client that you created earlier, and call its `recognizeEntities()` function. The returned `RecognizeEntitiesResult` object will contain a list of `NamedEntity` if successful, or an `errorMessage` if not.
## Named Entity Recognition - personal information (public preview)
228
-
229
-
> [!NOTE]
230
-
> The below code is for detecting personal information using Named Entity Recognition v3, which is in public preview.
220
+
## Using NER to detect personal information
231
221
232
222
Create a new function called `recognizePIIEntitiesExample()` that takes the client that you created earlier, and call its `recognizePiiEntities()` function. The returned `RecognizePiiEntitiesResult` object will contain a list of `NamedEntity` if successful, or an `errorMessage` if not.
> * This quickstart uses version `3.0-preview` of the Text Analytics client library, which includes a public preview for improved [Sentiment Analysis](../../../how-tos/text-analytics-how-to-sentiment-analysis.md#sentiment-analysis-versions-and-features) and [Named Entity Recognition (NER)](../../../how-tos/text-analytics-how-to-entity-linking.md#named-entity-recognition-versions-and-features).
20
-
>
21
-
> * The code in this article uses un-secured credentials storage for simplicity reasons. For production scenarios, we recommend sending strings in batches for performance and scalability. For example, calling `SentimentBatchAsync()` instead of `Sentiment()`.
> The below code is for sentiment analysis v3, which is in public preview.
108
+
Create a new [TextAnalyticsClient](https://docs.microsoft.com/javascript/api/@azure/cognitiveservices-textanalytics/textanalyticsclient) object with `credentials` and `endpoint` as a parameter.
109
+
110
+
[!code-javascript[Authentication and client creation](~/cognitive-services-node-sdk-samples/Samples/textAnalytics.js?name=authentication)]
111
+
112
+
---
113
+
114
+
## Sentiment analysis
115
+
116
+
#### [Version 3.0-preview](#tab/version-3)
107
117
108
118
Create an array of strings containing the document you want to analyze. Call the client's `analyzeSentiment()` method and get the returned `SentimentBatchResult` object. Iterate through the list of results, and print each document's ID, document level sentiment with confidence scores. For each document, result contains sentence level sentiment along with offsets, length, and confidence scores.
109
119
@@ -152,8 +162,29 @@ ID: 0
152
162
Length: 30, Offset: 31
153
163
```
154
164
165
+
#### [Version 2.1](#tab/version-2)
166
+
167
+
Create a list of dictionary objects, containing the documents you want to analyze. Call the client's [sentiment()](https://docs.microsoft.com/javascript/api/@azure/cognitiveservices-textanalytics/textanalyticsclient#sentiment-models-textanalyticsclientsentimentoptionalparams-) method and get the returned [SentimentBatchResult](https://docs.microsoft.com/javascript/api/@azure/cognitiveservices-textanalytics/sentimentbatchresult). Iterate through the list of results, and print each document's ID and sentiment score. A score closer to 0 indicates a negative sentiment, while a score closer to 1 indicates a positive sentiment.
Run your code with `node index.js` in your console window.
172
+
173
+
### Output
174
+
175
+
```console
176
+
[ { id: '1', score: 0.87 } ]
177
+
[ { id: '2', score: 0.11 } ]
178
+
[ { id: '3', score: 0.44 } ]
179
+
[ { id: '4', score: 1.00 } ]
180
+
```
181
+
182
+
---
183
+
155
184
## Language detection
156
185
186
+
#### [Version 3.0-preview](#tab/version-3)
187
+
157
188
Create an array of strings containing the document you want to analyze. Call the client's `detectLanguages()` method and get the returned `DetectLanguageResult`. Then iterate through the results, and print each document's ID, with respective primary and detected language.
158
189
159
190
```javascript
@@ -186,10 +217,32 @@ ID: 0
186
217
Primary Language French
187
218
```
188
219
189
-
## Named Entity Recognition
220
+
#### [Version 2.1](#tab/version-2)
221
+
222
+
Create a list of dictionary objects containing your documents. Call the client's [detectLanguage()](https://docs.microsoft.com/javascript/api/@azure/cognitiveservices-textanalytics/textanalyticsclient#detectlanguage-models-textanalyticsclientdetectlanguageoptionalparams-) method and get the returned [LanguageBatchResult](https://docs.microsoft.com/javascript/api/@azure/cognitiveservices-textanalytics/languagebatchresult). Then iterate through the results, and print each document's ID, and language.
Run your code with `node index.js` in your console window.
227
+
228
+
### Output
229
+
230
+
```console
231
+
Document ID: 1 , Language: English
232
+
Document ID: 2 , Language: Spanish
233
+
Document ID: 3 , Language: Chinese_Simplified
234
+
```
235
+
236
+
---
237
+
238
+
## Named Entity Recognition (NER)
239
+
240
+
#### [Version 3.0-preview](#tab/version-3)
190
241
191
242
> [!NOTE]
192
-
> The below code is for Named Entity Recognition v3, which is in public preview.
243
+
> In version `3.0-preview`:
244
+
> * NER includes separate methods for detecting personal information.
245
+
> * Entity linking is a separate request than NER.
193
246
194
247
Create an array of strings containing the document you want to analyze. Call the client's `recognizeEntities()` method and get the `RecognizeEntitiesResult` object. Iterate through the list of results, and print the entity name, type, subtype, offset, length, and score.
195
248
@@ -239,10 +292,7 @@ Document ID: 1
239
292
Offset: 71, Length: 2 Score: 0.8
240
293
```
241
294
242
-
## Named Entity Recognition - personal information (public preview)
243
-
244
-
> [!NOTE]
245
-
> The below code is for detecting personal information using Named Entity Recognition v3, which is in public preview.
295
+
## Using NER to detect personal information
246
296
247
297
Create an array of strings containing the document you want to analyze. Call the client's `recognizePiiEntities()` method and get the `EntitiesBatchResult` object. Iterate through the list of results, and print the entity name, type, subtype, offset, length, and score.
248
298
@@ -339,8 +389,53 @@ Document ID: 0
339
389
Offset: 89, Length: 5 Score: 0.052
340
390
```
341
391
392
+
#### [Version 2.1](#tab/version-2)
393
+
394
+
> [!NOTE]
395
+
> In version 2.1, entity linking is included in the NER response.
396
+
397
+
Create a list of objects, containing your documents. Call the client's [entities()](https://docs.microsoft.com/javascript/api/@azure/cognitiveservices-textanalytics/textanalyticsclient#entities-models-textanalyticscliententitiesoptionalparams-) method and get the [EntitiesBatchResult](https://docs.microsoft.com/javascript/api/@azure/cognitiveservices-textanalytics/entitiesbatchresult) object. Iterate through the list of results, and print each document's ID. For each detected entity, print its wikipedia name, the type and sub-types (if exists) as well as the locations in the original text.
Create an array of strings containing the document you want to analyze. Call the client's `extractKeyPhrases()` method and get the returned `ExtractKeyPhrasesResult` object. Iterate through the results and print each document's ID, and any detected key phrases.
345
440
346
441
```javascript
@@ -370,6 +465,27 @@ ID: 0
370
465
Document Key Phrases: cat,veterinarian
371
466
```
372
467
468
+
#### [Version 2.1](#tab/version-2)
469
+
470
+
Create a list of objects, containing your documents. Call the client's [keyPhrases()](https://docs.microsoft.com/javascript/api/@azure/cognitiveservices-textanalytics/textanalyticsclient#keyphrases-models-textanalyticsclientkeyphrasesoptionalparams-) method and get the returned [KeyPhraseBatchResult](https://docs.microsoft.com/javascript/api/@azure/cognitiveservices-textanalytics/keyphrasebatchresult) object. Iterate through the results and print each document's ID, and any detected key phrases.
0 commit comments