Skip to content

Commit d950a68

Browse files
authored
Merge pull request #107050 from suhas92/patch-28
[Cog Svcs] Update Text Analytics JS Quickstarts with preview.3
2 parents 0825bb8 + b27e3b6 commit d950a68

File tree

1 file changed

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

1 file changed

+26
-37
lines changed

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

Lines changed: 26 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,13 @@ async function sentimentAnalysis(client){
156156
console.log(`ID: ${document.id}`);
157157
console.log(`\tDocument Sentiment: ${document.sentiment}`);
158158
console.log(`\tDocument Scores:`);
159-
console.log(`\t\tPositive: ${document.sentimentScores.positive.toFixed(2)} \tNegative: ${document.sentimentScores.negative.toFixed(2)} \tNeutral: ${document.sentimentScores.neutral.toFixed(2)}`);
159+
console.log(`\t\tPositive: ${document.confidenceScores.positive.toFixed(2)} \tNegative: ${document.confidenceScores.negative.toFixed(2)} \tNeutral: ${document.confidenceScores.neutral.toFixed(2)}`);
160160
console.log(`\tSentences Sentiment(${document.sentences.length}):`);
161161
document.sentences.forEach(sentence => {
162162
console.log(`\t\tSentence sentiment: ${sentence.sentiment}`)
163163
console.log(`\t\tSentences Scores:`);
164-
console.log(`\t\tPositive: ${sentence.sentimentScores.positive.toFixed(2)} \tNegative: ${sentence.sentimentScores.negative.toFixed(2)} \tNeutral: ${sentence.sentimentScores.neutral.toFixed(2)}`);
165-
console.log(`\t\tLength: ${sentence.length}, Offset: ${sentence.offset}`);
166-
})
164+
console.log(`\t\tPositive: ${sentence.confidenceScores.positive.toFixed(2)} \tNegative: ${sentence.confidenceScores.negative.toFixed(2)} \tNeutral: ${sentence.confidenceScores.neutral.toFixed(2)}`);
165+
});
167166
});
168167
}
169168
sentimentAnalysis(textAnalyticsClient)
@@ -182,11 +181,9 @@ ID: 0
182181
Sentence sentiment: positive
183182
Sentences Scores:
184183
Positive: 1.00 Negative: 0.00 Neutral: 0.00
185-
Length: 30, Offset: 0
186184
Sentence sentiment: neutral
187185
Sentences Scores:
188186
Positive: 0.21 Negative: 0.02 Neutral: 0.77
189-
Length: 30, Offset: 31
190187
```
191188

192189
#### [Version 2.1](#tab/version-2)
@@ -281,7 +278,7 @@ async function entityRecognition(client){
281278
console.log(`Document ID: ${document.id}`);
282279
document.entities.forEach(entity => {
283280
console.log(`\tName: ${entity.text} \tCategory: ${entity.category} \tSubcategory: ${entity.subCategory ? entity.subCategory : "N/A"}`);
284-
console.log(`\tOffset: ${entity.offset}, Length: ${entity.length} \tScore: ${entity.score}`);
281+
console.log(`\tScore: ${entity.score}`);
285282
});
286283
});
287284
}
@@ -295,25 +292,26 @@ Run your code with `node index.js` in your console window.
295292
```console
296293
Document ID: 0
297294
Name: Microsoft Category: Organization Subcategory: N/A
298-
Offset: 0, Length: 9 Score: 1
295+
Score: 1
299296
Name: Bill Gates Category: Person Subcategory: N/A
300-
Offset: 25, Length: 10 Score: 0.67
297+
Score: 0.67
301298
Name: Paul Allen Category: Person Subcategory: N/A
302-
Offset: 40, Length: 10 Score: 0.81
299+
Score: 0.81
303300
Name: April 4, 1975 Category: DateTime Subcategory: Date
304-
Offset: 54, Length: 13 Score: 0.8
301+
Score: 0.8
305302
Name: interpreters Category: PersonType Subcategory: N/A
306-
Offset: 95, Length: 12 Score: 0.6
303+
Score: 0.6
307304
Name: 8800 Category: Quantity Subcategory: Number
308-
Offset: 123, Length: 4 Score: 0.8
305+
Score: 0.8
309306
Document ID: 1
310307
Name: Microsoft Category: Organization Subcategory: N/A
311-
Offset: 21, Length: 9 Score: 0.96
308+
Score: 0.96
312309
Name: Redmond Category: Location Subcategory: GPE
313-
Offset: 60, Length: 7 Score: 0.09
310+
Score: 0.09
314311
Name: 21 Category: Quantity Subcategory: Number
315-
Offset: 71, Length: 2 Score: 0.8
312+
Score: 0.8
316313
Name: Seattle Category: Location Subcategory: GPE
314+
Score: 0.31
317315
```
318316

319317
## Using NER to detect personal information
@@ -333,7 +331,7 @@ async function entityPiiRecognition(client){
333331
console.log(`Document ID: ${document.id}`);
334332
document.entities.forEach(entity => {
335333
console.log(`\tName: ${entity.text} \tCategory: ${entity.category} \tSubcategory: ${entity.subCategory ? entity.subCategory : "N/A"}`);
336-
console.log(`\tOffset: ${entity.offset}, Length: ${entity.length} \tScore: ${entity.score}`);
334+
console.log(`\tScore: ${entity.score}`);
337335
});
338336
});
339337
}
@@ -347,7 +345,7 @@ Run your code with `node index.js` in your console window.
347345
```console
348346
Document ID: 0
349347
Name: 123-12-1234 Category: U.S. Social Security Number (SSN) Subcategory: N/A
350-
Offset: 33, Length: 11 Score: 0.85
348+
Score: 0.85
351349
```
352350

353351
## Entity Linking
@@ -365,11 +363,10 @@ async function linkedEntityRecognition(client){
365363
entityResults.forEach(document => {
366364
console.log(`Document ID: ${document.id}`);
367365
document.entities.forEach(entity => {
368-
console.log(`\tName: ${entity.name} \tID: ${entity.id} \tURL: ${entity.url} \tData Source: ${entity.dataSource}`);
366+
console.log(`\tName: ${entity.name} \tID: ${entity.dataSourceEntityId} \tURL: ${entity.url} \tData Source: ${entity.dataSource}`);
369367
console.log(`\tMatches:`)
370368
entity.matches.forEach(match => {
371-
console.log(`\t\tText: ${match.text}`);
372-
console.log(`\t\tOffset: ${match.offset}, Length: ${match.length} \tScore: ${match.score.toFixed(3)}`);
369+
console.log(`\t\tText: ${match.text} \tScore: ${match.score.toFixed(2)}`);
373370
});
374371
});
375372
});
@@ -385,32 +382,24 @@ Run your code with `node index.js` in your console window.
385382
Document ID: 0
386383
Name: Altair 8800 ID: Altair 8800 URL: https://en.wikipedia.org/wiki/Altair_8800 Data Source: Wikipedia
387384
Matches:
388-
Text: Altair 8800
389-
Offset: 116, Length: 11 Score: 0.777
385+
Text: Altair 8800 Score: 0.78
390386
Name: Bill Gates ID: Bill Gates URL: https://en.wikipedia.org/wiki/Bill_Gates Data Source: Wikipedia
391387
Matches:
392-
Text: Bill Gates
393-
Offset: 25, Length: 10 Score: 0.555
394-
Text: Gates
395-
Offset: 161, Length: 5 Score: 0.555
388+
Text: Bill Gates Score: 0.55
389+
Text: Gates Score: 0.55
396390
Name: Paul Allen ID: Paul Allen URL: https://en.wikipedia.org/wiki/Paul_Allen Data Source: Wikipedia
397391
Matches:
398-
Text: Paul Allen
399-
Offset: 40, Length: 10 Score: 0.533
392+
Text: Paul Allen Score: 0.53
400393
Name: Microsoft ID: Microsoft URL: https://en.wikipedia.org/wiki/Microsoft Data Source: Wikipedia
401394
Matches:
402-
Text: Microsoft
403-
Offset: 0, Length: 9 Score: 0.469
404-
Text: Microsoft
405-
Offset: 150, Length: 9 Score: 0.469
395+
Text: Microsoft Score: 0.47
396+
Text: Microsoft Score: 0.47
406397
Name: April 4 ID: April 4 URL: https://en.wikipedia.org/wiki/April_4 Data Source: Wikipedia
407398
Matches:
408-
Text: April 4
409-
Offset: 54, Length: 7 Score: 0.248
399+
Text: April 4 Score: 0.25
410400
Name: BASIC ID: BASIC URL: https://en.wikipedia.org/wiki/BASIC Data Source: Wikipedia
411401
Matches:
412-
Text: BASIC
413-
Offset: 89, Length: 5 Score: 0.281
402+
Text: BASIC Score: 0.28
414403
```
415404

416405
#### [Version 2.1](#tab/version-2)

0 commit comments

Comments
 (0)