@azure/ai-language-text 1.1.0-alpha.20250113.2 → 1.1.0-alpha.20250114.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,12 +14,12 @@ import type { KeyCredential, TokenCredential } from "@azure/core-auth";
14
14
  *
15
15
  * #### API Key
16
16
  *
17
- * ```js
18
- * import { TextAnalysisClient, AzureKeyCredential } from "@azure/ai-language-text";
17
+ * ```ts snippet:ReadmeSampleCreateClient_Node
18
+ * import { AzureKeyCredential } from "@azure/core-auth";
19
+ * import { TextAnalysisClient } from "@azure/ai-language-text";
19
20
  *
20
21
  * const endpoint = "https://<resource name>.cognitiveservices.azure.com";
21
22
  * const credential = new AzureKeyCredential("<api key>");
22
- *
23
23
  * const client = new TextAnalysisClient(endpoint, credential);
24
24
  * ```
25
25
  *
@@ -28,13 +28,12 @@ import type { KeyCredential, TokenCredential } from "@azure/core-auth";
28
28
  * See the [`@azure/identity`](https://npmjs.com/package/\@azure/identity)
29
29
  * package for more information about authenticating with Azure Active Directory.
30
30
  *
31
- * ```js
32
- * import { TextAnalysisClient } from "@azure/ai-language-text";
31
+ * ```ts snippet:ReadmeSampleCreateClient_ActiveDirectory
33
32
  * import { DefaultAzureCredential } from "@azure/identity";
33
+ * import { TextAnalysisClient } from "@azure/ai-language-text";
34
34
  *
35
35
  * const endpoint = "https://<resource name>.cognitiveservices.azure.com";
36
36
  * const credential = new DefaultAzureCredential();
37
- *
38
37
  * const client = new TextAnalysisClient(endpoint, credential);
39
38
  * ```
40
39
  */
@@ -53,12 +52,12 @@ export declare class TextAnalysisClient {
53
52
  *
54
53
  * ### Example
55
54
  *
56
- * ```js
57
- * import { TextAnalysisClient, AzureKeyCredential } from "@azure/ai-language-text";
55
+ * ```ts snippet:ReadmeSampleCreateClient_Node
56
+ * import { AzureKeyCredential } from "@azure/core-auth";
57
+ * import { TextAnalysisClient } from "@azure/ai-language-text";
58
58
  *
59
59
  * const endpoint = "https://<resource name>.cognitiveservices.azure.com";
60
60
  * const credential = new AzureKeyCredential("<api key>");
61
- *
62
61
  * const client = new TextAnalysisClient(endpoint, credential);
63
62
  * ```
64
63
  *
@@ -80,13 +79,12 @@ export declare class TextAnalysisClient {
80
79
  * See the [`@azure/identity`](https://npmjs.com/package/\@azure/identity)
81
80
  * package for more information about authenticating with Azure Active Directory.
82
81
  *
83
- * ```js
84
- * import { TextAnalysisClient } from "@azure/ai-language-text";
82
+ * ```ts snippet:ReadmeSampleCreateClient_ActiveDirectory
85
83
  * import { DefaultAzureCredential } from "@azure/identity";
84
+ * import { TextAnalysisClient } from "@azure/ai-language-text";
86
85
  *
87
86
  * const endpoint = "https://<resource name>.cognitiveservices.azure.com";
88
87
  * const credential = new DefaultAzureCredential();
89
- *
90
88
  * const client = new TextAnalysisClient(endpoint, credential);
91
89
  * ```
92
90
  *
@@ -109,17 +107,29 @@ export declare class TextAnalysisClient {
109
107
  *
110
108
  * #### Language detection
111
109
  *
112
- * ```js
113
- * const documents = [<input strings>];
114
- * const countryHint = "us";
115
- * const results = await client.analyze("LanguageDetection", documents, countryHint);
110
+ * ```ts snippet:Sample_LanguageDetection
111
+ * import { TextAnalysisClient } from "@azure/ai-language-text";
112
+ * import { AzureKeyCredential } from "@azure/core-auth";
116
113
  *
117
- * for (let i = 0; i < results.length; i++) {
118
- * const result = results[i];
119
- * if (result.error) {
120
- * // a document has an error instead of results
121
- * } else {
122
- * const { name, confidenceScore, iso6391Name } = result.primaryLanguage;
114
+ * const documents = [
115
+ * "This document is written in English.",
116
+ * "Este es un document escrito en Español.",
117
+ * "这是一个用中文写的文件",
118
+ * "Dies ist ein Dokument in deutsche Sprache.",
119
+ * "Detta är ett dokument skrivet engelska.",
120
+ * ];
121
+ *
122
+ * const client = new TextAnalysisClient("<endpoint>", new AzureKeyCredential("<API key>"));
123
+ *
124
+ * const result = await client.analyze("LanguageDetection", documents, "us", {
125
+ * modelVersion: "2022-04-10-preview",
126
+ * });
127
+ *
128
+ * for (const doc of result) {
129
+ * if (!doc.error) {
130
+ * console.log(
131
+ * `Primary language: ${doc.primaryLanguage.name} (iso6391 name: ${doc.primaryLanguage.iso6391Name})`,
132
+ * );
123
133
  * }
124
134
  * }
125
135
  * ```
@@ -150,16 +160,29 @@ export declare class TextAnalysisClient {
150
160
  *
151
161
  * #### Language detection
152
162
  *
153
- * ```js
154
- * const documents = [<input strings>];
155
- * const countryHint = "us";
156
- * const results = await client.analyze("LanguageDetection", documents, countryHint);
163
+ * ```ts snippet:Sample_LanguageDetection
164
+ * import { TextAnalysisClient } from "@azure/ai-language-text";
165
+ * import { AzureKeyCredential } from "@azure/core-auth";
157
166
  *
158
- * for (const result of results) {
159
- * if (result.error) {
160
- * // a document has an error instead of results
161
- * } else {
162
- * const { name, confidenceScore, iso6391Name } = result.primaryLanguage;
167
+ * const documents = [
168
+ * "This document is written in English.",
169
+ * "Este es un document escrito en Español.",
170
+ * "这是一个用中文写的文件",
171
+ * "Dies ist ein Dokument in deutsche Sprache.",
172
+ * "Detta är ett dokument skrivet på engelska.",
173
+ * ];
174
+ *
175
+ * const client = new TextAnalysisClient("<endpoint>", new AzureKeyCredential("<API key>"));
176
+ *
177
+ * const result = await client.analyze("LanguageDetection", documents, "us", {
178
+ * modelVersion: "2022-04-10-preview",
179
+ * });
180
+ *
181
+ * for (const doc of result) {
182
+ * if (!doc.error) {
183
+ * console.log(
184
+ * `Primary language: ${doc.primaryLanguage.name} (iso6391 name: ${doc.primaryLanguage.iso6391Name})`,
185
+ * );
163
186
  * }
164
187
  * }
165
188
  * ```
@@ -201,29 +224,34 @@ export declare class TextAnalysisClient {
201
224
  *
202
225
  * #### Opinion mining
203
226
  *
204
- * ```js
205
- * const documents = [{
206
- * id: "1",
207
- * text: "The food and service aren't the best",
208
- * language: "en"
209
- * }];
210
- * const results = await client.analyze("SentimentAnalysis", documents, {
211
- * includeOpinionMining: true,
212
- * });
227
+ * ```ts snippet:Sample_SentimentAnalysis
228
+ * import { TextAnalysisClient } from "@azure/ai-language-text";
229
+ * import { AzureKeyCredential } from "@azure/core-auth";
213
230
  *
214
- * for (const result of results) {
215
- * if (result.error) {
216
- * // a document has an error instead of results
217
- * } else {
218
- * const { sentiment, confidenceScores, sentences } = result;
219
- * for (const { sentiment, confidenceScores, opinions } of sentences) {
220
- * for (const { target, assessments } of opinions) {
221
- * const { text, sentiment, confidenceScores } = target;
222
- * for (const { text, sentiment } of assessments) {
223
- * // Do something
224
- * }
225
- * }
231
+ * const documents = [
232
+ * "I had the best day of my life.",
233
+ * "This was a waste of my time. The speaker put me to sleep.",
234
+ * ];
235
+ *
236
+ * const client = new TextAnalysisClient("<endpoint>", new AzureKeyCredential("<API key>"));
237
+ *
238
+ * const results = await client.analyze("SentimentAnalysis", documents);
239
+ *
240
+ * for (let i = 0; i < results.length; i++) {
241
+ * const result = results[i];
242
+ * console.log(`- Document ${result.id}`);
243
+ * if (!result.error) {
244
+ * console.log(`\tDocument text: ${documents[i]}`);
245
+ * console.log(`\tOverall Sentiment: ${result.sentiment}`);
246
+ * console.log("\tSentiment confidence scores: ", result.confidenceScores);
247
+ * console.log("\tSentences");
248
+ * for (const { sentiment, confidenceScores, text } of result.sentences) {
249
+ * console.log(`\t- Sentence text: ${text}`);
250
+ * console.log(`\t Sentence sentiment: ${sentiment}`);
251
+ * console.log("\t Confidence scores:", confidenceScores);
226
252
  * }
253
+ * } else {
254
+ * console.error(` Error: ${result.error}`);
227
255
  * }
228
256
  * }
229
257
  * ```
@@ -233,22 +261,27 @@ export declare class TextAnalysisClient {
233
261
  *
234
262
  * #### Personally identifiable information
235
263
  *
236
- * ```js
237
- * const documents = [<input documents>];
238
- * const categoriesFilter = [KnownPiiCategory.USSocialSecurityNumber];
239
- * const domainFilter = KnownPiiDomain.Phi;
240
- * const results = await client.analyze("PiiEntityRecognition", documents, {
241
- * domainFilter, categoriesFilter
264
+ * ```ts snippet:Sample_PIIEntityRecognition
265
+ * import { TextAnalysisClient } from "@azure/ai-language-text";
266
+ * import { AzureKeyCredential } from "@azure/core-auth";
267
+ *
268
+ * const client = new TextAnalysisClient("<endpoint>", new AzureKeyCredential("<API key>"));
269
+ *
270
+ * const documents = ["My phone number is 555-5555"];
271
+ *
272
+ * const [result] = await client.analyze("PiiEntityRecognition", documents, "en", {
273
+ * domainFilter: KnownPiiEntityDomain.Phi,
274
+ * categoriesFilter: [
275
+ * KnownPiiEntityCategory.PhoneNumber,
276
+ * KnownPiiEntityCategory.USSocialSecurityNumber,
277
+ * ],
242
278
  * });
243
279
  *
244
- * for (const result of results) {
245
- * if (result.error) {
246
- * // a document has an error instead of results
247
- * } else {
248
- * const { entities, redactedText } = result;
249
- * for (const { text, category, confidenceScore, length, offset } of entities) {
250
- * // Do something
251
- * }
280
+ * if (!result.error) {
281
+ * console.log(`Redacted text: "${result.redactedText}"`);
282
+ * console.log("Pii Entities: ");
283
+ * for (const entity of result.entities) {
284
+ * console.log(`\t- "${entity.text}" of type ${entity.category}`);
252
285
  * }
253
286
  * }
254
287
  * ```
@@ -282,25 +315,34 @@ export declare class TextAnalysisClient {
282
315
  *
283
316
  * #### Opinion mining
284
317
  *
285
- * ```js
286
- * const documents = ["The food and service aren't the best"];
287
- * const results = await client.analyze("SentimentAnalysis", documents, {
288
- * includeOpinionMining: true,
289
- * });
318
+ * ```ts snippet:Sample_SentimentAnalysis
319
+ * import { TextAnalysisClient } from "@azure/ai-language-text";
320
+ * import { AzureKeyCredential } from "@azure/core-auth";
290
321
  *
291
- * for (const result of results) {
292
- * if (result.error) {
293
- * // a document has an error instead of results
294
- * } else {
295
- * const { sentiment, confidenceScores, sentences } = result;
296
- * for (const { sentiment, confidenceScores, opinions } of sentences) {
297
- * for (const { target, assessments } of opinions) {
298
- * const { text, sentiment, confidenceScores } = target;
299
- * for (const { text, sentiment } of assessments) {
300
- * // Do something
301
- * }
302
- * }
322
+ * const documents = [
323
+ * "I had the best day of my life.",
324
+ * "This was a waste of my time. The speaker put me to sleep.",
325
+ * ];
326
+ *
327
+ * const client = new TextAnalysisClient("<endpoint>", new AzureKeyCredential("<API key>"));
328
+ *
329
+ * const results = await client.analyze("SentimentAnalysis", documents);
330
+ *
331
+ * for (let i = 0; i < results.length; i++) {
332
+ * const result = results[i];
333
+ * console.log(`- Document ${result.id}`);
334
+ * if (!result.error) {
335
+ * console.log(`\tDocument text: ${documents[i]}`);
336
+ * console.log(`\tOverall Sentiment: ${result.sentiment}`);
337
+ * console.log("\tSentiment confidence scores: ", result.confidenceScores);
338
+ * console.log("\tSentences");
339
+ * for (const { sentiment, confidenceScores, text } of result.sentences) {
340
+ * console.log(`\t- Sentence text: ${text}`);
341
+ * console.log(`\t Sentence sentiment: ${sentiment}`);
342
+ * console.log("\t Confidence scores:", confidenceScores);
303
343
  * }
344
+ * } else {
345
+ * console.error(` Error: ${result.error}`);
304
346
  * }
305
347
  * }
306
348
  * ```
@@ -310,23 +352,27 @@ export declare class TextAnalysisClient {
310
352
  *
311
353
  * #### Personally identifiable information
312
354
  *
313
- * ```js
314
- * const documents = [<input strings>];
315
- * const languageCode = "en";
316
- * const categoriesFilter = [KnownPiiCategory.USSocialSecurityNumber];
317
- * const domainFilter = KnownPiiDomain.Phi;
318
- * const results = await client.analyze("PiiEntityRecognition", documents, languageCode, {
319
- * domainFilter, categoriesFilter
355
+ * ```ts snippet:Sample_PIIEntityRecognition
356
+ * import { TextAnalysisClient } from "@azure/ai-language-text";
357
+ * import { AzureKeyCredential } from "@azure/core-auth";
358
+ *
359
+ * const client = new TextAnalysisClient("<endpoint>", new AzureKeyCredential("<API key>"));
360
+ *
361
+ * const documents = ["My phone number is 555-5555"];
362
+ *
363
+ * const [result] = await client.analyze("PiiEntityRecognition", documents, "en", {
364
+ * domainFilter: KnownPiiEntityDomain.Phi,
365
+ * categoriesFilter: [
366
+ * KnownPiiEntityCategory.PhoneNumber,
367
+ * KnownPiiEntityCategory.USSocialSecurityNumber,
368
+ * ],
320
369
  * });
321
370
  *
322
- * for (const result of results) {
323
- * if (result.error) {
324
- * // a document has an error instead of results
325
- * } else {
326
- * const { entities, redactedText } = result;
327
- * for (const { text, category, confidenceScore, length, offset } of entities) {
328
- * // Do something
329
- * }
371
+ * if (!result.error) {
372
+ * console.log(`Redacted text: "${result.redactedText}"`);
373
+ * console.log("Pii Entities: ");
374
+ * for (const entity of result.entities) {
375
+ * console.log(`\t- "${entity.text}" of type ${entity.category}`);
330
376
  * }
331
377
  * }
332
378
  * ```
@@ -367,31 +413,100 @@ export declare class TextAnalysisClient {
367
413
  *
368
414
  * #### Key phrase extraction and Pii entity recognition
369
415
  *
370
- * ```js
371
- * const poller = await client.beginAnalyzeBatch(
372
- * [{ kind: "KeyPhraseExtraction" }, { kind: "PiiEntityRecognition" }],
373
- * documents
374
- * );
416
+ * ```ts snippet:Sample_ActionBatching
417
+ * import { TextAnalysisClient } from "@azure/ai-language-text";
418
+ * import { AzureKeyCredential } from "@azure/core-auth";
419
+ *
420
+ * const documents = [
421
+ * "Microsoft was founded by Bill Gates and Paul Allen.",
422
+ * "Redmond is a city in King County, Washington, United States, located 15 miles east of Seattle.",
423
+ * "I need to take my cat to the veterinarian.",
424
+ * "The employee's SSN is 555-55-5555.",
425
+ * "We went to Contoso Steakhouse located at midtown NYC last week for a dinner party, and we adore the spot! They provide marvelous food and they have a great menu. The chief cook happens to be the owner (I think his name is John Doe) and he is super nice, coming out of the kitchen and greeted us all. We enjoyed very much dining in the place! The Sirloin steak I ordered was tender and juicy, and the place was impeccably clean. You can even pre-order from their online menu at www.contososteakhouse.com, call 312-555-0176 or send email to order@contososteakhouse.com! The only complaint I have is the food didn't come fast enough. Overall I highly recommend it!",
426
+ * ];
427
+ *
428
+ * const client = new TextAnalysisClient("<endpoint>", new AzureKeyCredential("<API key>"));
429
+ *
430
+ * const actions: AnalyzeBatchAction[] = [
431
+ * {
432
+ * kind: "EntityRecognition",
433
+ * modelVersion: "latest",
434
+ * },
435
+ * {
436
+ * kind: "PiiEntityRecognition",
437
+ * modelVersion: "latest",
438
+ * },
439
+ * {
440
+ * kind: "KeyPhraseExtraction",
441
+ * modelVersion: "latest",
442
+ * },
443
+ * ];
444
+ * const poller = await client.beginAnalyzeBatch(actions, documents, "en");
445
+ *
446
+ * poller.onProgress(() => {
447
+ * console.log(
448
+ * `Number of actions still in progress: ${poller.getOperationState().actionInProgressCount}`,
449
+ * );
450
+ * });
451
+ *
452
+ * console.log(`The operation was created on ${poller.getOperationState().createdOn}`);
453
+ *
454
+ * console.log(`The operation results will expire on ${poller.getOperationState().expiresOn}`);
455
+ *
375
456
  * const actionResults = await poller.pollUntilDone();
376
457
  *
377
458
  * for await (const actionResult of actionResults) {
378
- * if (actionResult.error) {
379
- * throw new Error(`Unexpected error`);
380
- * }
381
- * switch (actionResult.kind) {
382
- * case "KeyPhraseExtraction": {
383
- * for (const doc of actionResult.results) {
384
- * // do something
385
- * }
386
- * break;
387
- * }
388
- * case "PiiEntityRecognition": {
389
- * for (const doc of actionResult.results) {
390
- * // do something
391
- * }
392
- * break;
393
- * }
394
- * }
459
+ * if (actionResult.error) {
460
+ * const { code, message } = actionResult.error;
461
+ * throw new Error(`Unexpected error (${code}): ${message}`);
462
+ * }
463
+ * switch (actionResult.kind) {
464
+ * case "KeyPhraseExtraction": {
465
+ * for (const doc of actionResult.results) {
466
+ * console.log(`- Document ${doc.id}`);
467
+ * if (!doc.error) {
468
+ * console.log("\tKey phrases:");
469
+ * for (const phrase of doc.keyPhrases) {
470
+ * console.log(`\t- ${phrase}`);
471
+ * }
472
+ * } else {
473
+ * console.error("\tError:", doc.error);
474
+ * }
475
+ * }
476
+ * break;
477
+ * }
478
+ * case "EntityRecognition": {
479
+ * for (const doc of actionResult.results) {
480
+ * console.log(`- Document ${doc.id}`);
481
+ * if (!doc.error) {
482
+ * console.log("\tEntities:");
483
+ * for (const entity of doc.entities) {
484
+ * console.log(`\t- Entity ${entity.text} of type ${entity.category}`);
485
+ * }
486
+ * } else {
487
+ * console.error("\tError:", doc.error);
488
+ * }
489
+ * }
490
+ * break;
491
+ * }
492
+ * case "PiiEntityRecognition": {
493
+ * for (const doc of actionResult.results) {
494
+ * console.log(`- Document ${doc.id}`);
495
+ * if (!doc.error) {
496
+ * console.log("\tPii Entities:");
497
+ * for (const entity of doc.entities) {
498
+ * console.log(`\t- Entity ${entity.text} of type ${entity.category}`);
499
+ * }
500
+ * } else {
501
+ * console.error("\tError:", doc.error);
502
+ * }
503
+ * }
504
+ * break;
505
+ * }
506
+ * default: {
507
+ * throw new Error(`Unexpected action results: ${actionResult.kind}`);
508
+ * }
509
+ * }
395
510
  * }
396
511
  * ```
397
512
  *
@@ -427,31 +542,100 @@ export declare class TextAnalysisClient {
427
542
  *
428
543
  * #### Keyphrase extraction and Pii entity recognition
429
544
  *
430
- * ```js
431
- * const poller = await client.beginAnalyzeBatch(
432
- * [{ kind: "KeyPhraseExtraction" }, { kind: "PiiEntityRecognition" }],
433
- * documents
434
- * );
545
+ * ```ts snippet:Sample_ActionBatching
546
+ * import { TextAnalysisClient } from "@azure/ai-language-text";
547
+ * import { AzureKeyCredential } from "@azure/core-auth";
548
+ *
549
+ * const documents = [
550
+ * "Microsoft was founded by Bill Gates and Paul Allen.",
551
+ * "Redmond is a city in King County, Washington, United States, located 15 miles east of Seattle.",
552
+ * "I need to take my cat to the veterinarian.",
553
+ * "The employee's SSN is 555-55-5555.",
554
+ * "We went to Contoso Steakhouse located at midtown NYC last week for a dinner party, and we adore the spot! They provide marvelous food and they have a great menu. The chief cook happens to be the owner (I think his name is John Doe) and he is super nice, coming out of the kitchen and greeted us all. We enjoyed very much dining in the place! The Sirloin steak I ordered was tender and juicy, and the place was impeccably clean. You can even pre-order from their online menu at www.contososteakhouse.com, call 312-555-0176 or send email to order@contososteakhouse.com! The only complaint I have is the food didn't come fast enough. Overall I highly recommend it!",
555
+ * ];
556
+ *
557
+ * const client = new TextAnalysisClient("<endpoint>", new AzureKeyCredential("<API key>"));
558
+ *
559
+ * const actions: AnalyzeBatchAction[] = [
560
+ * {
561
+ * kind: "EntityRecognition",
562
+ * modelVersion: "latest",
563
+ * },
564
+ * {
565
+ * kind: "PiiEntityRecognition",
566
+ * modelVersion: "latest",
567
+ * },
568
+ * {
569
+ * kind: "KeyPhraseExtraction",
570
+ * modelVersion: "latest",
571
+ * },
572
+ * ];
573
+ * const poller = await client.beginAnalyzeBatch(actions, documents, "en");
574
+ *
575
+ * poller.onProgress(() => {
576
+ * console.log(
577
+ * `Number of actions still in progress: ${poller.getOperationState().actionInProgressCount}`,
578
+ * );
579
+ * });
580
+ *
581
+ * console.log(`The operation was created on ${poller.getOperationState().createdOn}`);
582
+ *
583
+ * console.log(`The operation results will expire on ${poller.getOperationState().expiresOn}`);
584
+ *
435
585
  * const actionResults = await poller.pollUntilDone();
436
586
  *
437
587
  * for await (const actionResult of actionResults) {
438
- * if (actionResult.error) {
439
- * throw new Error(`Unexpected error`);
440
- * }
441
- * switch (actionResult.kind) {
442
- * case "KeyPhraseExtraction": {
443
- * for (const doc of actionResult.results) {
444
- * // do something
445
- * }
446
- * break;
447
- * }
448
- * case "PiiEntityRecognition": {
449
- * for (const doc of actionResult.results) {
450
- * // do something
451
- * }
452
- * break;
453
- * }
454
- * }
588
+ * if (actionResult.error) {
589
+ * const { code, message } = actionResult.error;
590
+ * throw new Error(`Unexpected error (${code}): ${message}`);
591
+ * }
592
+ * switch (actionResult.kind) {
593
+ * case "KeyPhraseExtraction": {
594
+ * for (const doc of actionResult.results) {
595
+ * console.log(`- Document ${doc.id}`);
596
+ * if (!doc.error) {
597
+ * console.log("\tKey phrases:");
598
+ * for (const phrase of doc.keyPhrases) {
599
+ * console.log(`\t- ${phrase}`);
600
+ * }
601
+ * } else {
602
+ * console.error("\tError:", doc.error);
603
+ * }
604
+ * }
605
+ * break;
606
+ * }
607
+ * case "EntityRecognition": {
608
+ * for (const doc of actionResult.results) {
609
+ * console.log(`- Document ${doc.id}`);
610
+ * if (!doc.error) {
611
+ * console.log("\tEntities:");
612
+ * for (const entity of doc.entities) {
613
+ * console.log(`\t- Entity ${entity.text} of type ${entity.category}`);
614
+ * }
615
+ * } else {
616
+ * console.error("\tError:", doc.error);
617
+ * }
618
+ * }
619
+ * break;
620
+ * }
621
+ * case "PiiEntityRecognition": {
622
+ * for (const doc of actionResult.results) {
623
+ * console.log(`- Document ${doc.id}`);
624
+ * if (!doc.error) {
625
+ * console.log("\tPii Entities:");
626
+ * for (const entity of doc.entities) {
627
+ * console.log(`\t- Entity ${entity.text} of type ${entity.category}`);
628
+ * }
629
+ * } else {
630
+ * console.error("\tError:", doc.error);
631
+ * }
632
+ * }
633
+ * break;
634
+ * }
635
+ * default: {
636
+ * throw new Error(`Unexpected action results: ${actionResult.kind}`);
637
+ * }
638
+ * }
455
639
  * }
456
640
  * ```
457
641
  *
@@ -471,16 +655,6 @@ export declare class TextAnalysisClient {
471
655
  * result of `poller.toString()`
472
656
  * @param options - optional settings for the operation
473
657
  *
474
- * # Example
475
- *
476
- * `client.beginAnalyzeBatch` returns a promise that will resolve to a poller.
477
- * The state of the poller can be serialized and used to create another as follows:
478
- *
479
- * ```js
480
- * const serializedState = poller.toString();
481
- * const rehydratedPoller = await client.createAnalyzeBatchPoller(serializedState);
482
- * const actionResults = await rehydratedPoller.pollUntilDone();
483
- * ```
484
658
  */
485
659
  restoreAnalyzeBatchPoller(serializedState: string, options?: RestoreAnalyzeBatchPollerOptions): Promise<AnalyzeBatchPoller>;
486
660
  }
@@ -1 +1 @@
1
- {"version":3,"file":"textAnalysisClient.d.ts","sourceRoot":"","sources":["../../src/textAnalysisClient.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EACb,wBAAwB,EACxB,gCAAgC,EAChC,yBAAyB,EACzB,4BAA4B,EAC7B,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAGV,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,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ACrB,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,kBAAkB,CAAC;IAC9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAsHG;IACG,iBAAiB,CACrB,OAAO,EAAE,kBAAkB,EAAE,EAC7B,SAAS,EAAE,iBAAiB,EAAE,EAC9B,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,kBAAkB,CAAC;IAuE9B;;;;;;;;;OASG;IACG,yBAAyB,CAC7B,eAAe,EAAE,MAAM,EACvB,OAAO,CAAC,EAAE,gCAAgC,GACzC,OAAO,CAAC,kBAAkB,CAAC;CA0C/B"}
@@ -28,12 +28,12 @@ const azureKeyCredentialPolicy_js_1 = require("./azureKeyCredentialPolicy.js");
28
28
  *
29
29
  * #### API Key
30
30
  *
31
- * ```js
32
- * import { TextAnalysisClient, AzureKeyCredential } from "@azure/ai-language-text";
31
+ * ```ts snippet:ReadmeSampleCreateClient_Node
32
+ * import { AzureKeyCredential } from "@azure/core-auth";
33
+ * import { TextAnalysisClient } from "@azure/ai-language-text";
33
34
  *
34
35
  * const endpoint = "https://<resource name>.cognitiveservices.azure.com";
35
36
  * const credential = new AzureKeyCredential("<api key>");
36
- *
37
37
  * const client = new TextAnalysisClient(endpoint, credential);
38
38
  * ```
39
39
  *
@@ -42,13 +42,12 @@ const azureKeyCredentialPolicy_js_1 = require("./azureKeyCredentialPolicy.js");
42
42
  * See the [`@azure/identity`](https://npmjs.com/package/\@azure/identity)
43
43
  * package for more information about authenticating with Azure Active Directory.
44
44
  *
45
- * ```js
46
- * import { TextAnalysisClient } from "@azure/ai-language-text";
45
+ * ```ts snippet:ReadmeSampleCreateClient_ActiveDirectory
47
46
  * import { DefaultAzureCredential } from "@azure/identity";
47
+ * import { TextAnalysisClient } from "@azure/ai-language-text";
48
48
  *
49
49
  * const endpoint = "https://<resource name>.cognitiveservices.azure.com";
50
50
  * const credential = new DefaultAzureCredential();
51
- *
52
51
  * const client = new TextAnalysisClient(endpoint, credential);
53
52
  * ```
54
53
  */