@@ -156,14 +156,13 @@ async function sentimentAnalysis(client){
156
156
console .log (` ID: ${ document .id } ` );
157
157
console .log (` \t Document Sentiment: ${ document .sentiment } ` );
158
158
console .log (` \t Document Scores:` );
159
- console .log (` \t\t Positive: ${ document .sentimentScores .positive .toFixed (2 )} \t Negative: ${ document .sentimentScores .negative .toFixed (2 )} \t Neutral: ${ document .sentimentScores .neutral .toFixed (2 )} ` );
159
+ console .log (` \t\t Positive: ${ document .confidenceScores .positive .toFixed (2 )} \t Negative: ${ document .confidenceScores .negative .toFixed (2 )} \t Neutral: ${ document .confidenceScores .neutral .toFixed (2 )} ` );
160
160
console .log (` \t Sentences Sentiment(${ document .sentences .length } ):` );
161
161
document .sentences .forEach (sentence => {
162
162
console .log (` \t\t Sentence sentiment: ${ sentence .sentiment } ` )
163
163
console .log (` \t\t Sentences Scores:` );
164
- console .log (` \t\t Positive: ${ sentence .sentimentScores .positive .toFixed (2 )} \t Negative: ${ sentence .sentimentScores .negative .toFixed (2 )} \t Neutral: ${ sentence .sentimentScores .neutral .toFixed (2 )} ` );
165
- console .log (` \t\t Length: ${ sentence .length } , Offset: ${ sentence .offset } ` );
166
- })
164
+ console .log (` \t\t Positive: ${ sentence .confidenceScores .positive .toFixed (2 )} \t Negative: ${ sentence .confidenceScores .negative .toFixed (2 )} \t Neutral: ${ sentence .confidenceScores .neutral .toFixed (2 )} ` );
165
+ });
167
166
});
168
167
}
169
168
sentimentAnalysis (textAnalyticsClient)
@@ -182,11 +181,9 @@ ID: 0
182
181
Sentence sentiment: positive
183
182
Sentences Scores:
184
183
Positive: 1.00 Negative: 0.00 Neutral: 0.00
185
- Length: 30, Offset: 0
186
184
Sentence sentiment: neutral
187
185
Sentences Scores:
188
186
Positive: 0.21 Negative: 0.02 Neutral: 0.77
189
- Length: 30, Offset: 31
190
187
```
191
188
192
189
#### [ Version 2.1] ( #tab/version-2 )
@@ -281,7 +278,7 @@ async function entityRecognition(client){
281
278
console .log (` Document ID: ${ document .id } ` );
282
279
document .entities .forEach (entity => {
283
280
console .log (` \t Name: ${ entity .text } \t Category: ${ entity .category } \t Subcategory: ${ entity .subCategory ? entity .subCategory : " N/A" } ` );
284
- console .log (` \t Offset: ${ entity . offset } , Length: ${ entity . length } \ t Score: ${ entity .score } ` );
281
+ console .log (` \t Score: ${ entity .score } ` );
285
282
});
286
283
});
287
284
}
@@ -295,25 +292,26 @@ Run your code with `node index.js` in your console window.
295
292
``` console
296
293
Document ID: 0
297
294
Name: Microsoft Category: Organization Subcategory: N/A
298
- Offset: 0, Length: 9 Score: 1
295
+ Score: 1
299
296
Name: Bill Gates Category: Person Subcategory: N/A
300
- Offset: 25, Length: 10 Score: 0.67
297
+ Score: 0.67
301
298
Name: Paul Allen Category: Person Subcategory: N/A
302
- Offset: 40, Length: 10 Score: 0.81
299
+ Score: 0.81
303
300
Name: April 4, 1975 Category: DateTime Subcategory: Date
304
- Offset: 54, Length: 13 Score: 0.8
301
+ Score: 0.8
305
302
Name: interpreters Category: PersonType Subcategory: N/A
306
- Offset: 95, Length: 12 Score: 0.6
303
+ Score: 0.6
307
304
Name: 8800 Category: Quantity Subcategory: Number
308
- Offset: 123, Length: 4 Score: 0.8
305
+ Score: 0.8
309
306
Document ID: 1
310
307
Name: Microsoft Category: Organization Subcategory: N/A
311
- Offset: 21, Length: 9 Score: 0.96
308
+ Score: 0.96
312
309
Name: Redmond Category: Location Subcategory: GPE
313
- Offset: 60, Length: 7 Score: 0.09
310
+ Score: 0.09
314
311
Name: 21 Category: Quantity Subcategory: Number
315
- Offset: 71, Length: 2 Score: 0.8
312
+ Score: 0.8
316
313
Name: Seattle Category: Location Subcategory: GPE
314
+ Score: 0.31
317
315
```
318
316
319
317
## Using NER to detect personal information
@@ -333,7 +331,7 @@ async function entityPiiRecognition(client){
333
331
console .log (` Document ID: ${ document .id } ` );
334
332
document .entities .forEach (entity => {
335
333
console .log (` \t Name: ${ entity .text } \t Category: ${ entity .category } \t Subcategory: ${ entity .subCategory ? entity .subCategory : " N/A" } ` );
336
- console .log (` \t Offset: ${ entity . offset } , Length: ${ entity . length } \ t Score: ${ entity .score } ` );
334
+ console .log (` \t Score: ${ entity .score } ` );
337
335
});
338
336
});
339
337
}
@@ -347,7 +345,7 @@ Run your code with `node index.js` in your console window.
347
345
``` console
348
346
Document ID: 0
349
347
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
351
349
```
352
350
353
351
## Entity Linking
@@ -365,11 +363,10 @@ async function linkedEntityRecognition(client){
365
363
entityResults .forEach (document => {
366
364
console .log (` Document ID: ${ document .id } ` );
367
365
document .entities .forEach (entity => {
368
- console .log (` \t Name: ${ entity .name } \t ID: ${ entity .id } \t URL: ${ entity .url } \t Data Source: ${ entity .dataSource } ` );
366
+ console .log (` \t Name: ${ entity .name } \t ID: ${ entity .dataSourceEntityId } \t URL: ${ entity .url } \t Data Source: ${ entity .dataSource } ` );
369
367
console .log (` \t Matches:` )
370
368
entity .matches .forEach (match => {
371
- console .log (` \t\t Text: ${ match .text } ` );
372
- console .log (` \t\t Offset: ${ match .offset } , Length: ${ match .length } \t Score: ${ match .score .toFixed (3 )} ` );
369
+ console .log (` \t\t Text: ${ match .text } \t Score: ${ match .score .toFixed (2 )} ` );
373
370
});
374
371
});
375
372
});
@@ -385,32 +382,24 @@ Run your code with `node index.js` in your console window.
385
382
Document ID: 0
386
383
Name: Altair 8800 ID: Altair 8800 URL: https://en.wikipedia.org/wiki/Altair_8800 Data Source: Wikipedia
387
384
Matches:
388
- Text: Altair 8800
389
- Offset: 116, Length: 11 Score: 0.777
385
+ Text: Altair 8800 Score: 0.78
390
386
Name: Bill Gates ID: Bill Gates URL: https://en.wikipedia.org/wiki/Bill_Gates Data Source: Wikipedia
391
387
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
396
390
Name: Paul Allen ID: Paul Allen URL: https://en.wikipedia.org/wiki/Paul_Allen Data Source: Wikipedia
397
391
Matches:
398
- Text: Paul Allen
399
- Offset: 40, Length: 10 Score: 0.533
392
+ Text: Paul Allen Score: 0.53
400
393
Name: Microsoft ID: Microsoft URL: https://en.wikipedia.org/wiki/Microsoft Data Source: Wikipedia
401
394
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
406
397
Name: April 4 ID: April 4 URL: https://en.wikipedia.org/wiki/April_4 Data Source: Wikipedia
407
398
Matches:
408
- Text: April 4
409
- Offset: 54, Length: 7 Score: 0.248
399
+ Text: April 4 Score: 0.25
410
400
Name: BASIC ID: BASIC URL: https://en.wikipedia.org/wiki/BASIC Data Source: Wikipedia
411
401
Matches:
412
- Text: BASIC
413
- Offset: 89, Length: 5 Score: 0.281
402
+ Text: BASIC Score: 0.28
414
403
```
415
404
416
405
#### [ Version 2.1] ( #tab/version-2 )
0 commit comments