Skip to content

Commit a5d9990

Browse files
authored
Merge pull request #110906 from thediris/textanalytics_js_quickstart_1.0.0-preview.4
update nodejs quickstart to 1.0.0-preview.4
2 parents 830702b + 27457fb commit a5d9990

File tree

1 file changed

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

1 file changed

+3
-38
lines changed

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

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ npm init
5656
Install the `@azure/ai-text-analytics` NPM packages:
5757

5858
```console
59-
npm install --save @azure/[email protected].3
59+
npm install --save @azure/[email protected].4
6060
```
6161

6262
> [!TIP]
@@ -83,7 +83,7 @@ Create a file named `index.js` and add the following:
8383
```javascript
8484
"use strict";
8585

86-
const { TextAnalyticsClient, TextAnalyticsApiKeyCredential } = require("@azure/ai-text-analytics");
86+
const { TextAnalyticsClient, AzureKeyCredential } = require("@azure/ai-text-analytics");
8787
```
8888

8989
#### [Version 2.1](#tab/version-2)
@@ -128,7 +128,7 @@ The response object is a list containing the analysis information for each docum
128128
Create a new `TextAnalyticsClient` object with your key and endpoint as parameters.
129129

130130
```javascript
131-
const textAnalyticsClient = new TextAnalyticsClient(endpoint, new TextAnalyticsApiKeyCredential(key));
131+
const textAnalyticsClient = new TextAnalyticsClient(endpoint, new AzureKeyCredential(key));
132132
```
133133

134134
#### [Version 2.1](#tab/version-2)
@@ -261,7 +261,6 @@ Document ID: 3 , Language: Chinese_Simplified
261261

262262
> [!NOTE]
263263
> In version `3.0-preview`:
264-
> * NER includes separate methods for detecting personal information.
265264
> * Entity linking is a separate request than NER.
266265
267266
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.
@@ -315,40 +314,6 @@ Document ID: 1
315314
Score: 0.31
316315
```
317316

318-
## Using NER to detect personal information
319-
320-
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.
321-
322-
323-
```javascript
324-
async function entityPiiRecognition(client){
325-
326-
const entityPiiInput = [
327-
"Insurance policy for SSN on file 123-12-1234 is here by approved."
328-
];
329-
const entityPiiResults = await client.recognizePiiEntities(entityPiiInput);
330-
331-
entityPiiResults.forEach(document => {
332-
console.log(`Document ID: ${document.id}`);
333-
document.entities.forEach(entity => {
334-
console.log(`\tName: ${entity.text} \tCategory: ${entity.category} \tSubcategory: ${entity.subCategory ? entity.subCategory : "N/A"}`);
335-
console.log(`\tScore: ${entity.score}`);
336-
});
337-
});
338-
}
339-
entityPiiRecognition(textAnalyticsClient);
340-
```
341-
342-
Run your code with `node index.js` in your console window.
343-
344-
### Output
345-
346-
```console
347-
Document ID: 0
348-
Name: 123-12-1234 Category: U.S. Social Security Number (SSN) Subcategory: N/A
349-
Score: 0.85
350-
```
351-
352317
## Entity Linking
353318

354319
Create an array of strings containing the document you want to analyze. Call the client's `recognizeLinkedEntities()` method and get the `RecognizeLinkedEntitiesResult` object. Iterate through the list of results, and print the entity name, ID, data source, url, and matches. Every object in `matches` array will contain offset, length, and score for that match.

0 commit comments

Comments
 (0)