@azure/ai-language-text 1.1.0-beta.1 → 1.1.0-beta.2

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -38,6 +38,15 @@ Key links:
38
38
 
39
39
  Please see the [Migration Guide](https://github.com/azure/azure-sdk-for-js/blob/main/sdk/cognitivelanguage/ai-language-text/MIGRATION_ai_text_analytics.md) for detailed instructions on how to update application code from version 5.x of the AI Text Analytics client library to the new AI Language Text client library.
40
40
 
41
+ ## What's New
42
+ * [Abstractive Summarization](https://github.com/azure/azure-sdk-for-js/blob/main/sdk/cognitivelanguage/ai-language-text/Samples.md#abstractive-summarization)
43
+ * [Dynamic Classification](https://github.com/azure/azure-sdk-for-js/blob/main/sdk/cognitivelanguage/ai-language-text/Samples.md#dynamic-classification)
44
+ * [Script Detection](https://github.com/azure/azure-sdk-for-js/blob/main/sdk/cognitivelanguage/ai-language-text/Samples.md#language-detection)
45
+ * [Automatic Language Detection](https://github.com/azure/azure-sdk-for-js/blob/main/sdk/cognitivelanguage/ai-language-text/Samples.md#automatic-language-detection)
46
+ * [Entity Resolutions](https://github.com/azure/azure-sdk-for-js/blob/main/sdk/cognitivelanguage/ai-language-text/Samples.md#entity-resolutions)
47
+ * [Specifying healthcare document type for better FHIR results](https://github.com/azure/azure-sdk-for-js/blob/main/sdk/cognitivelanguage/ai-language-text/Samples.md#healthcare-analysis)
48
+
49
+
41
50
  ## Getting started
42
51
 
43
52
  ### Currently supported environments
@@ -50,7 +59,7 @@ See our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUP
50
59
  ### Prerequisites
51
60
 
52
61
  - An [Azure subscription][azure_sub].
53
- - An existing [Cognitive Services][cognitive_resource] or Language resource. If you need to create the resource, you can use the [Azure Portal][azure_portal] or [Azure CLI][azure_cli].
62
+ - An existing [Cognitive Services][cognitive_resource] or Language resource. If you need to create the resource, you can use the [Azure Portal][azure_portal] or [Azure CLI][azure_cli] following the steps in [this document][cli_docs].
54
63
 
55
64
  If you use the Azure CLI, replace `<your-resource-group-name>` and `<your-resource-name>` with your own unique names:
56
65
 
@@ -179,635 +188,33 @@ if (result.error !== undefined) {
179
188
  }
180
189
  ```
181
190
 
182
- ## Examples
183
-
184
- ### Sentiment Analysis
185
-
186
- Analyze sentiment of text to determine if it is positive, negative, neutral, or mixed, including per-sentence sentiment analysis and confidence scores.
187
-
188
- ```javascript
189
- const { TextAnalysisClient, AzureKeyCredential } = require("@azure/ai-language-text");
190
-
191
- const client = new TextAnalysisClient("<endpoint>", new AzureKeyCredential("<API key>"));
192
-
193
- const documents = [
194
- "I did not like the restaurant. The food was too spicy.",
195
- "The restaurant was decorated beautifully. The atmosphere was unlike any other restaurant I've been to.",
196
- "The food was yummy. :)",
197
- ];
198
-
199
- async function main() {
200
- const results = await client.analyze("SentimentAnalysis", documents);
201
-
202
- for (const result of results) {
203
- if (result.error === undefined) {
204
- console.log("Overall sentiment:", result.sentiment);
205
- console.log("Scores:", result.confidenceScores);
206
- } else {
207
- console.error("Encountered an error:", result.error);
208
- }
209
- }
210
- }
211
-
212
- main();
213
- ```
214
-
215
- To get more granular information about the opinions related to aspects of a product/service, also known as Aspect-based Sentiment Analysis in Natural Language Processing (NLP), see a sample on sentiment analysis with opinion mining [here][analyze_sentiment_opinion_mining_sample].
216
-
217
- ### Entity Recognition
218
-
219
- Recognize and categorize entities in text as people, places, organizations, dates/times, quantities, currencies, etc.
220
-
221
- The `language` parameter is optional. If it is not specified, the default English model will be used.
222
-
223
- ```javascript
224
- const { TextAnalysisClient, AzureKeyCredential } = require("@azure/ai-language-text");
225
-
226
- const client = new TextAnalysisClient("<endpoint>", new AzureKeyCredential("<API key>"));
227
-
228
- const documents = [
229
- "Microsoft was founded by Bill Gates and Paul Allen.",
230
- "Redmond is a city in King County, Washington, United States, located 15 miles east of Seattle.",
231
- "Jeff bought three dozen eggs because there was a 50% discount.",
232
- ];
233
-
234
- async function main() {
235
- const results = await client.analyze("EntityRecognition", documents, "en");
236
-
237
- for (const result of results) {
238
- if (result.error === undefined) {
239
- console.log(" -- Recognized entities for input", result.id, "--");
240
- for (const entity of result.entities) {
241
- console.log(entity.text, ":", entity.category, "(Score:", entity.confidenceScore, ")");
242
- }
243
- } else {
244
- console.error("Encountered an error:", result.error);
245
- }
246
- }
247
- }
248
-
249
- main();
250
- ```
251
-
252
- ### PII Entity Recognition
253
-
254
- There is a separate action for recognizing Personally Identifiable Information (PII) in text such as Social Security Numbers, bank account information, credit card numbers, etc. Its usage is very similar to the standard entity recognition above:
255
-
256
- ```javascript
257
- const { TextAnalysisClient, AzureKeyCredential } = require("@azure/ai-language-text");
258
- const client = new TextAnalysisClient("<endpoint>", new AzureKeyCredential("<API key>"));
259
- const documents = [
260
- "The employee's SSN is 555-55-5555.",
261
- "The employee's phone number is (555) 555-5555.",
262
- ];
263
- async function main() {
264
- const results = await client.analyze("PiiEntityRecognition", documents, "en");
265
- for (const result of results) {
266
- if (result.error === undefined) {
267
- console.log(" -- Recognized PII entities for input", result.id, "--");
268
- for (const entity of result.entities) {
269
- console.log(entity.text, ":", entity.category, "(Score:", entity.confidenceScore, ")");
270
- }
271
- } else {
272
- console.error("Encountered an error:", result.error);
273
- }
274
- }
275
- }
276
- main();
277
- ```
278
-
279
- ### Entity Linking
280
-
281
- A "Linked" entity is one that exists in a knowledge base (such as Wikipedia). The `EntityLinking` action can disambiguate entities by determining which entry in a knowledge base they likely refer to (for example, in a piece of text, does the word "Mars" refer to the planet, or to the Roman god of war). Linked entities contain associated URLs to the knowledge base that provides the definition of the entity.
282
-
283
- ```javascript
284
- const { TextAnalysisClient, AzureKeyCredential } = require("@azure/ai-language-text");
285
-
286
- const client = new TextAnalysisClient("<endpoint>", new AzureKeyCredential("<API key>"));
287
-
288
- const documents = [
289
- "Microsoft was founded by Bill Gates and Paul Allen.",
290
- "Easter Island, a Chilean territory, is a remote volcanic island in Polynesia.",
291
- "I use Azure Functions to develop my product.",
292
- ];
293
-
294
- async function main() {
295
- const results = await client.analyze("EntityLinking", documents, "en");
296
-
297
- for (const result of results) {
298
- if (result.error === undefined) {
299
- console.log(" -- Recognized linked entities for input", result.id, "--");
300
- for (const entity of result.entities) {
301
- console.log(entity.name, "(URL:", entity.url, ", Source:", entity.dataSource, ")");
302
- for (const match of entity.matches) {
303
- console.log(
304
- " Occurrence:",
305
- '"' + match.text + '"',
306
- "(Score:",
307
- match.confidenceScore,
308
- ")"
309
- );
310
- }
311
- }
312
- } else {
313
- console.error("Encountered an error:", result.error);
314
- }
315
- }
316
- }
317
-
318
- main();
319
- ```
320
-
321
- ### Key Phrase Extraction
322
-
323
- Key Phrase extraction identifies the main talking points in a document. For example, given input text "The food was delicious and there were wonderful staff", the service returns "food" and "wonderful staff".
324
-
325
- ```javascript
326
- const { TextAnalysisClient, AzureKeyCredential } = require("@azure/ai-language-text");
327
-
328
- const client = new TextAnalysisClient("<endpoint>", new AzureKeyCredential("<API key>"));
329
-
330
- const documents = [
331
- "Redmond is a city in King County, Washington, United States, located 15 miles east of Seattle.",
332
- "I need to take my cat to the veterinarian.",
333
- "I will travel to South America in the summer.",
334
- ];
335
-
336
- async function main() {
337
- const results = await client.analyze("KeyPhraseExtraction", documents, "en");
338
-
339
- for (const result of results) {
340
- if (result.error === undefined) {
341
- console.log(" -- Extracted key phrases for input", result.id, "--");
342
- console.log(result.keyPhrases);
343
- } else {
344
- console.error("Encountered an error:", result.error);
345
- }
346
- }
347
- }
348
-
349
- main();
350
- ```
351
-
352
- ### Language Detection
353
-
354
- Determine the language of a piece of text.
355
-
356
- The `countryHint` parameter is optional, but can assist the service in providing correct output if the country of origin is known. If provided, it should be set to an ISO-3166 Alpha-2 two-letter country code (such as "us" for the United States or "jp" for Japan) or to the value `"none"`. If the parameter is not provided, then the default `"us"` (United States) model will be used. If you do not know the country of origin of the document, then the parameter `"none"` should be used, and the Language service will apply a model that is tuned for an unknown country of origin.
357
-
358
- ```javascript
359
- const { TextAnalysisClient, AzureKeyCredential } = require("@azure/ai-language-text");
360
-
361
- const client = new TextAnalysisClient("<endpoint>", new AzureKeyCredential("<API key>"));
362
-
363
- const documents = [
364
- "This is written in English.",
365
- "Il documento scritto in italiano.",
366
- "Dies ist in deutscher Sprache verfasst.",
367
- ];
368
-
369
- async function main() {
370
- const results = await client.analyze("LanguageDetection", documents, "none");
371
-
372
- for (const result of results) {
373
- if (result.error === undefined) {
374
- const { primaryLanguage } = result;
375
- console.log(
376
- "Input #",
377
- result.id,
378
- "identified as",
379
- primaryLanguage.name,
380
- "( ISO6391:",
381
- primaryLanguage.iso6391Name,
382
- ", Score:",
383
- primaryLanguage.confidenceScore,
384
- ")"
385
- );
386
- } else {
387
- console.error("Encountered an error:", result.error);
388
- }
389
- }
390
- }
391
-
392
- main();
393
- ```
394
-
395
- ### Dynamic Classification
396
-
397
- On the fly classification of the input documents into one or multiple categories. Assigns either one or multiple categories per document. This type of classification doesn't require model training.
398
-
399
- ```javascript
400
- const { TextAnalysisClient, AzureKeyCredential } = require("@azure/ai-language-text");
401
-
402
- const client = new TextAnalysisClient("<endpoint>", new AzureKeyCredential("<API key>"));
403
-
404
- const documents = [
405
- "The WHO is issuing a warning about Monkey Pox.",
406
- "Mo Salah plays in Liverpool FC in England.",
407
- ];
408
-
409
- export async function main() {
410
- const results = await client.analyze("DynamicClassification", documents, "en", {
411
- categories: ["Health", "Politics", "Music", "Sports"],
412
- classificationType: "Multi",
413
- });
414
-
415
- for (const result of results) {
416
- console.log(`- Document ${result.id}`);
417
- if (!result.error) {
418
- console.log("\tClassifications:");
419
- for (const category of result.classifications) {
420
- console.log(`\t- ${category.category}`);
421
- }
422
- } else {
423
- console.error(" Error:", result.error);
424
- }
425
- }
426
- }
427
-
428
- main();
429
- ```
430
-
431
- ### Healthcare Analysis
432
-
433
- Healthcare analysis identifies healthcare entities. For example, given input text "Prescribed 100mg ibuprofen, taken twice daily", the service returns "100mg" categorized as Dosage, "ibuprofen" as MedicationName, and "twice daily" as Frequency.
434
-
435
- ```javascript
436
- const { AzureKeyCredential, TextAnalysisClient } = require("@azure/ai-language-text");
437
-
438
- const client = new TextAnalysisClient("<endpoint>", new AzureKeyCredential("<API key>"));
439
-
440
- const documents = [
441
- "Prescribed 100mg ibuprofen, taken twice daily.",
442
- "Patient does not suffer from high blood pressure.",
443
- ];
444
-
445
- async function main() {
446
- const actions = [
447
- {
448
- kind: "Healthcare",
449
- },
450
- ];
451
- const poller = await client.beginAnalyzeBatch(actions, documents, "en");
452
- const results = await poller.pollUntilDone();
453
-
454
- for await (const actionResult of results) {
455
- if (actionResult.kind !== "Healthcare") {
456
- throw new Error(`Expected a healthcare results but got: ${actionResult.kind}`);
457
- }
458
- if (actionResult.error) {
459
- const { code, message } = actionResult.error;
460
- throw new Error(`Unexpected error (${code}): ${message}`);
461
- }
462
- for (const result of actionResult.results) {
463
- console.log(`- Document ${result.id}`);
464
- if (result.error) {
465
- const { code, message } = result.error;
466
- throw new Error(`Unexpected error (${code}): ${message}`);
467
- }
468
- console.log("\tRecognized Entities:");
469
- for (const entity of result.entities) {
470
- console.log(`\t- Entity "${entity.text}" of type ${entity.category}`);
471
- if (entity.dataSources.length > 0) {
472
- console.log("\t and it can be referenced in the following data sources:");
473
- for (const ds of entity.dataSources) {
474
- console.log(`\t\t- ${ds.name} with Entity ID: ${ds.entityId}`);
475
- }
476
- }
477
- }
478
- }
479
- }
480
- }
481
-
482
- main();
483
- ```
484
-
485
- ### Extractive Summarization
486
-
487
- Extractive summarization identifies sentences that summarize the article they belong to.
488
-
489
- ```javascript
490
- const { AzureKeyCredential, TextAnalysisClient } = require("@azure/ai-language-text");
491
- const client = new TextAnalysisClient("<endpoint>", new AzureKeyCredential("<API key>"));
492
- const documents = [
493
- "<long article>"
494
- ];
495
- async function main() {
496
- const actions = [
497
- {
498
- kind: "ExtractiveSummarization",
499
- maxSentenceCount: 2,
500
- },
501
- ];
502
- const poller = await client.beginAnalyzeBatch(actions, documents, "en");
503
- const results = await poller.pollUntilDone();
504
-
505
- for await (const actionResult of results) {
506
- if (actionResult.kind !== "ExtractiveSummarization") {
507
- throw new Error(`Expected extractive summarization results but got: ${actionResult.kind}`);
508
- }
509
- if (actionResult.error) {
510
- const { code, message } = actionResult.error;
511
- throw new Error(`Unexpected error (${code}): ${message}`);
512
- }
513
- for (const result of actionResult.results) {
514
- console.log(`- Document ${result.id}`);
515
- if (result.error) {
516
- const { code, message } = result.error;
517
- throw new Error(`Unexpected error (${code}): ${message}`);
518
- }
519
- console.log("Summary:");
520
- console.log(result.sentences.map((sentence) => sentence.text).join("\n"));
521
- }
522
- }
523
- }
524
- main();
525
- ```
526
-
527
- ### Abstractive Summarization
528
-
529
- Abstractive summarization generates a summary for the input articles. Abstractive summarization is different from extractive summarization in that extractive summarization is the strategy of concatenating extracted sentences from the input document into a summary, while abstractive summarization involves paraphrasing the document using novel sentences.
530
-
531
- ```javascript
532
- const { AzureKeyCredential, TextAnalysisClient } = require("@azure/ai-language-text");
533
- const client = new TextAnalysisClient("<endpoint>", new AzureKeyCredential("<API key>"));
534
- const documents = [
535
- "<long article>"
536
- ];
537
- async function main() {
538
- const actions = [
539
- {
540
- kind: "AbstractiveSummarization",
541
- maxSentenceCount: 2,
542
- },
543
- ];
544
- const poller = await client.beginAnalyzeBatch(actions, documents, "en");
545
- const results = await poller.pollUntilDone();
546
-
547
- for await (const actionResult of results) {
548
- if (actionResult.kind !== "AbstractiveSummarization") {
549
- throw new Error(`Expected abstractive summarization results but got: ${actionResult.kind}`);
550
- }
551
- if (actionResult.error) {
552
- const { code, message } = actionResult.error;
553
- throw new Error(`Unexpected error (${code}): ${message}`);
554
- }
555
- for (const result of actionResult.results) {
556
- console.log(`- Document ${result.id}`);
557
- if (result.error) {
558
- const { code, message } = result.error;
559
- throw new Error(`Unexpected error (${code}): ${message}`);
560
- }
561
- console.log("\t- Summary:");
562
- for (const summary of result.summaries) {
563
- console.log(summary.text);
564
- }
565
- }
566
- }
567
- }
568
- main();
569
- ```
570
-
571
- ### Custom Entity Recognition
572
-
573
- Recognize and categorize entities in text as entities using custom entity detection models built using [Azure Language Studio][lang_studio].
574
-
575
- ```javascript
576
- const { AzureKeyCredential, TextAnalysisClient } = require("@azure/ai-language-text");
577
-
578
- const client = new TextAnalysisClient("<endpoint>", new AzureKeyCredential("<API key>"));
579
-
580
- const documents = [
581
- "We love this trail and make the trip every year. The views are breathtaking and well worth the hike! Yesterday was foggy though, so we missed the spectacular views. We tried again today and it was amazing. Everyone in my family liked the trail although it was too challenging for the less athletic among us.",
582
- "Last week we stayed at Hotel Foo to celebrate our anniversary. The staff knew about our anniversary so they helped me organize a little surprise for my partner. The room was clean and with the decoration I requested. It was perfect!",
583
- ];
584
-
585
- async function main() {
586
- const actions = [
587
- {
588
- kind: "CustomEntityRecognition",
589
- deploymentName,
590
- projectName,
591
- },
592
- ];
593
- const poller = await client.beginAnalyzeBatch(actions, documents, "en");
594
- const results = await poller.pollUntilDone();
595
-
596
- for await (const actionResult of results) {
597
- if (actionResult.kind !== "CustomEntityRecognition") {
598
- throw new Error(`Expected a CustomEntityRecognition results but got: ${actionResult.kind}`);
599
- }
600
- if (actionResult.error) {
601
- const { code, message } = actionResult.error;
602
- throw new Error(`Unexpected error (${code}): ${message}`);
603
- }
604
- for (const result of actionResult.results) {
605
- console.log(`- Document ${result.id}`);
606
- if (result.error) {
607
- const { code, message } = result.error;
608
- throw new Error(`Unexpected error (${code}): ${message}`);
609
- }
610
- console.log("\tRecognized Entities:");
611
- for (const entity of result.entities) {
612
- console.log(`\t- Entity "${entity.text}" of type ${entity.category}`);
613
- }
614
- }
615
- }
616
- }
617
-
618
- main();
619
- ```
620
-
621
- ### Custom Single-label Classification
622
-
623
- Classify documents using custom single-label models built using [Azure Language Studio][lang_studio].
624
-
625
- ```javascript
626
- const { TextAnalysisClient, AzureKeyCredential } = require("@azure/ai-language-text");
627
-
628
- const client = new TextAnalysisClient("<endpoint>", new AzureKeyCredential("<API key>"));
629
-
630
- const documents = [
631
- "The plot begins with a large group of characters where everyone thinks that the two main ones should be together but foolish things keep them apart. Misunderstandings, miscommunication, and confusion cause a series of humorous situations.",
632
- ];
633
-
634
- async function main() {
635
- const actions = [
636
- {
637
- kind: "CustomSingleLabelClassification",
638
- deploymentName,
639
- projectName,
640
- },
641
- ];
642
- const poller = await client.beginAnalyzeBatch(actions, documents, "en");
643
- const results = await poller.pollUntilDone();
644
-
645
- for await (const actionResult of results) {
646
- if (actionResult.kind !== "CustomSingleLabelClassification") {
647
- throw new Error(
648
- `Expected a CustomSingleLabelClassification results but got: ${actionResult.kind}`
649
- );
650
- }
651
- if (actionResult.error) {
652
- const { code, message } = actionResult.error;
653
- throw new Error(`Unexpected error (${code}): ${message}`);
654
- }
655
- for (const result of actionResult.results) {
656
- console.log(`- Document ${result.id}`);
657
- if (result.error) {
658
- const { code, message } = result.error;
659
- throw new Error(`Unexpected error (${code}): ${message}`);
660
- }
661
- console.log(`\tClassification: ${result.classifications[0].category}`);
662
- }
663
- }
664
- }
665
-
666
- main();
667
- ```
668
-
669
- ### Custom Multi-label Classification
670
-
671
- Classify documents using custom multi-label models built using [Azure Language Studio][lang_studio].
672
-
673
- ```javascript
674
- const { AzureKeyCredential, TextAnalysisClient } = require("@azure/ai-language-text");
675
-
676
- const client = new TextAnalysisClient("<endpoint>", new AzureKeyCredential("<API key>"));
677
-
678
- const documents = [
679
- "The plot begins with a large group of characters where everyone thinks that the two main ones should be together but foolish things keep them apart. Misunderstandings, miscommunication, and confusion cause a series of humorous situations.",
680
- ];
681
-
682
- async function main() {
683
- const actions = [
684
- {
685
- kind: "CustomMultiLabelClassification",
686
- deploymentName,
687
- projectName,
688
- },
689
- ];
690
- const poller = await client.beginAnalyzeBatch(actions, documents, "en");
691
- const results = await poller.pollUntilDone();
692
-
693
- for await (const actionResult of results) {
694
- if (actionResult.kind !== "CustomMultiLabelClassification") {
695
- throw new Error(
696
- `Expected a CustomMultiLabelClassification results but got: ${actionResult.kind}`
697
- );
698
- }
699
- if (actionResult.error) {
700
- const { code, message } = actionResult.error;
701
- throw new Error(`Unexpected error (${code}): ${message}`);
702
- }
703
- for (const result of actionResult.results) {
704
- console.log(`- Document ${result.id}`);
705
- if (result.error) {
706
- const { code, message } = result.error;
707
- throw new Error(`Unexpected error (${code}): ${message}`);
708
- }
709
- console.log(`\tClassification:`);
710
- for (const classification of result.classifications) {
711
- console.log(`\t\t-category: ${classification.category}`);
712
- }
713
- }
714
- }
715
- }
716
-
717
- main();
718
- ```
719
-
720
- ### Action Batching
721
-
722
- Applies multiple actions on each input document in one service request.
723
-
724
- ```javascript
725
- const { AzureKeyCredential, TextAnalysisClient } = require("@azure/ai-language-text");
726
-
727
- const client = new TextAnalysisClient("<endpoint>", new AzureKeyCredential("<API key>"));
728
-
729
- const documents = [
730
- "Microsoft was founded by Bill Gates and Paul Allen.",
731
- "The employee's SSN is 555-55-5555.",
732
- "Easter Island, a Chilean territory, is a remote volcanic island in Polynesia.",
733
- "I use Azure Functions to develop my product.",
734
- ];
735
-
736
- async function main() {
737
- const actions = [
738
- {
739
- kind: "EntityRecognition",
740
- modelVersion: "latest",
741
- },
742
- {
743
- kind: "PiiEntityRecognition",
744
- modelVersion: "latest",
745
- },
746
- {
747
- kind: "KeyPhraseExtraction",
748
- modelVersion: "latest",
749
- },
750
- ];
751
- const poller = await client.beginAnalyzeBatch(actions, documents, "en");
752
- const actionResults = await poller.pollUntilDone();
753
-
754
- for await (const actionResult of actionResults) {
755
- if (actionResult.error) {
756
- const { code, message } = actionResult.error;
757
- throw new Error(`Unexpected error (${code}): ${message}`);
758
- }
759
- switch (actionResult.kind) {
760
- case "KeyPhraseExtraction": {
761
- for (const doc of actionResult.results) {
762
- console.log(`- Document ${doc.id}`);
763
- if (!doc.error) {
764
- console.log("\tKey phrases:");
765
- for (const phrase of doc.keyPhrases) {
766
- console.log(`\t- ${phrase}`);
767
- }
768
- } else {
769
- console.error("\tError:", doc.error);
770
- }
771
- }
772
- break;
773
- }
774
- case "EntityRecognition": {
775
- for (const doc of actionResult.results) {
776
- console.log(`- Document ${doc.id}`);
777
- if (!doc.error) {
778
- console.log("\tEntities:");
779
- for (const entity of doc.entities) {
780
- console.log(`\t- Entity ${entity.text} of type ${entity.category}`);
781
- }
782
- } else {
783
- console.error("\tError:", doc.error);
784
- }
785
- }
786
- break;
787
- }
788
- case "PiiEntityRecognition": {
789
- for (const doc of actionResult.results) {
790
- console.log(`- Document ${doc.id}`);
791
- if (!doc.error) {
792
- console.log("\tPii Entities:");
793
- for (const entity of doc.entities) {
794
- console.log(`\t- Entity ${entity.text} of type ${entity.category}`);
795
- }
796
- } else {
797
- console.error("\tError:", doc.error);
798
- }
799
- }
800
- break;
801
- }
802
- default: {
803
- throw new Error(`Unexpected action results: ${actionResult.kind}`);
804
- }
805
- }
806
- }
807
- }
808
-
809
- main();
810
- ```
191
+ ## Samples
192
+
193
+ ### Client Usage
194
+ * [Actions Batching](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitivelanguage/ai-language-text/samples-dev/batching.ts)
195
+ * [Choose Model Version](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitivelanguage/ai-language-text/samples-dev/modelVersion.ts)
196
+ * [Paging](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitivelanguage/ai-language-text/samples-dev/paging.ts)
197
+ * [Rehydrate Polling](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitivelanguage/ai-language-text/samples-dev/rehydratePolling.ts)
198
+ * [Get Statistics](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitivelanguage/ai-language-text/samples-dev/stats.ts)
199
+
200
+ ### Prebuilt Tasks
201
+ * [Abstractive Summarization](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitivelanguage/ai-language-text/samples-dev/abstractiveSummarization.ts)
202
+ * [Dynamic Classification](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitivelanguage/ai-language-text/samples-dev/dynamicClassification.ts)
203
+ * [Language Detection](https://github.com/azure/azure-sdk-for-js/blob/main/sdk/cognitivelanguage/ai-language-text/Samples.md#language-detection)
204
+ * [Entity Linking](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitivelanguage/ai-language-text/samples-dev/entityLinking.ts)
205
+ * [Entity Regconition](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitivelanguage/ai-language-text/samples-dev/entityRecognition.ts)
206
+ * [Extractive Summarization](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitivelanguage/ai-language-text/samples-dev/extractiveSummarization.ts)
207
+ * [Healthcare Analysis](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitivelanguage/ai-language-text/samples-dev/healthcare.ts)
208
+ * [Key Phrase Extraction](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitivelanguage/ai-language-text/samples-dev/keyPhraseExtraction.ts)
209
+ * [Language Detection](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitivelanguage/ai-language-text/samples-dev/languageDetection.ts)
210
+ * [Opinion Mining](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitivelanguage/ai-language-text/samples-dev/opinionMining.ts)
211
+ * [PII Entity Recognition](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitivelanguage/ai-language-text/samples-dev/piiEntityRecognition.ts)
212
+ * [Sentiment Analysis](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitivelanguage/ai-language-text/samples-dev/sentimentAnalysis.ts)
213
+
214
+ ### Custom Tasks
215
+ * [Custom Entity Recognition](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitivelanguage/ai-language-text/samples-dev/customEntityRecognition.ts)
216
+ * [Custom Single-lable Classfication](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitivelanguage/ai-language-text/samples-dev/customSingleLabelClassification.ts)
217
+ * [Custom Multi-lable Classfication](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cognitivelanguage/ai-language-text/samples-dev/customMultiLabelClassification.ts)
811
218
 
812
219
  ## Troubleshooting
813
220
 
@@ -837,6 +244,7 @@ If you'd like to contribute to this library, please read the [contributing guide
837
244
 
838
245
  ![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fcognitivelanguage%2Fai-language-text%2FREADME.png)
839
246
 
247
+ [cli_docs]: https://learn.microsoft.com/azure/cognitive-services/cognitive-services-apis-create-account-cli?tabs=windows#prerequisites
840
248
  [azure_cli]: https://docs.microsoft.com/cli/azure
841
249
  [azure_sub]: https://azure.microsoft.com/free/
842
250
  [cognitive_resource]: https://docs.microsoft.com/azure/cognitive-services/cognitive-services-apis-create-account