@azure/ai-language-text 1.1.0-alpha.20250618.1 → 1.1.0-alpha.20250722.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.
Files changed (66) hide show
  1. package/dist/browser/generated/generatedClient.js +10 -3
  2. package/dist/browser/generated/generatedClient.js.map +1 -1
  3. package/dist/browser/generated/models/mappers.js +407 -161
  4. package/dist/browser/generated/models/mappers.js.map +1 -1
  5. package/dist/browser/generated/operations/analyzeText.js +1 -0
  6. package/dist/browser/generated/operations/analyzeText.js.map +1 -1
  7. package/dist/browser/lro.js +22 -11
  8. package/dist/browser/lro.js.map +1 -1
  9. package/dist/browser/models.js +1 -1
  10. package/dist/browser/models.js.map +1 -1
  11. package/dist/browser/textAnalysisClient.js +25 -22
  12. package/dist/browser/textAnalysisClient.js.map +1 -1
  13. package/dist/browser/transforms.js +127 -47
  14. package/dist/browser/transforms.js.map +1 -1
  15. package/dist/browser/util.js +1 -2
  16. package/dist/browser/util.js.map +1 -1
  17. package/dist/commonjs/generated/generatedClient.js +10 -3
  18. package/dist/commonjs/generated/generatedClient.js.map +1 -1
  19. package/dist/commonjs/generated/models/mappers.js +407 -161
  20. package/dist/commonjs/generated/models/mappers.js.map +1 -1
  21. package/dist/commonjs/generated/operations/analyzeText.js +1 -0
  22. package/dist/commonjs/generated/operations/analyzeText.js.map +1 -1
  23. package/dist/commonjs/lro.js +22 -11
  24. package/dist/commonjs/lro.js.map +1 -1
  25. package/dist/commonjs/models.js +1 -1
  26. package/dist/commonjs/models.js.map +1 -1
  27. package/dist/commonjs/textAnalysisClient.js +25 -22
  28. package/dist/commonjs/textAnalysisClient.js.map +1 -1
  29. package/dist/commonjs/transforms.js +127 -47
  30. package/dist/commonjs/transforms.js.map +1 -1
  31. package/dist/commonjs/tsdoc-metadata.json +11 -11
  32. package/dist/commonjs/util.js +1 -2
  33. package/dist/commonjs/util.js.map +1 -1
  34. package/dist/esm/generated/generatedClient.js +10 -3
  35. package/dist/esm/generated/generatedClient.js.map +1 -1
  36. package/dist/esm/generated/models/mappers.js +407 -161
  37. package/dist/esm/generated/models/mappers.js.map +1 -1
  38. package/dist/esm/generated/operations/analyzeText.js +1 -0
  39. package/dist/esm/generated/operations/analyzeText.js.map +1 -1
  40. package/dist/esm/lro.js +22 -11
  41. package/dist/esm/lro.js.map +1 -1
  42. package/dist/esm/models.js +1 -1
  43. package/dist/esm/models.js.map +1 -1
  44. package/dist/esm/textAnalysisClient.js +25 -22
  45. package/dist/esm/textAnalysisClient.js.map +1 -1
  46. package/dist/esm/transforms.js +127 -47
  47. package/dist/esm/transforms.js.map +1 -1
  48. package/dist/esm/util.js +1 -2
  49. package/dist/esm/util.js.map +1 -1
  50. package/dist/react-native/generated/generatedClient.js +10 -3
  51. package/dist/react-native/generated/generatedClient.js.map +1 -1
  52. package/dist/react-native/generated/models/mappers.js +407 -161
  53. package/dist/react-native/generated/models/mappers.js.map +1 -1
  54. package/dist/react-native/generated/operations/analyzeText.js +1 -0
  55. package/dist/react-native/generated/operations/analyzeText.js.map +1 -1
  56. package/dist/react-native/lro.js +22 -11
  57. package/dist/react-native/lro.js.map +1 -1
  58. package/dist/react-native/models.js +1 -1
  59. package/dist/react-native/models.js.map +1 -1
  60. package/dist/react-native/textAnalysisClient.js +25 -22
  61. package/dist/react-native/textAnalysisClient.js.map +1 -1
  62. package/dist/react-native/transforms.js +127 -47
  63. package/dist/react-native/transforms.js.map +1 -1
  64. package/dist/react-native/util.js +1 -2
  65. package/dist/react-native/util.js.map +1 -1
  66. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"textAnalysisClient.js","sourceRoot":"","sources":["../../src/textAnalysisClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;AAmBlC,iDAAsE;AAEtE,gDAAqD;AAErD,sDAA0D;AAC1D,uCAKmB;AACnB,qCAOkB;AAClB,mDAAoE;AACpE,uEAAiE;AACjE,kEAA4E;AAC5E,8CAAm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AK,OAAO,EAA5D,2CAAkD,CAAU,CAAC;QACnE,MAAM,MAAM,GAAG,IAAA,2BAAkB,EAAC,eAAe,CAAC,CAAC;QACnD,MAAM,GAAG,GAAG,IAAA,0CAAiC,EAAC;YAC5C,MAAM,EAAE,IAAI,CAAC,OAAO;YACpB,OAAO,kCAAO,IAAI,KAAE,iBAAiB,GAAE;YACvC,OAAO,EAAE,IAAI,CAAC,QAAQ;SACvB,CAAC,CAAC;QAEH,MAAM,KAAK,GAAG,EAAE,iBAAiB,EAAE,EAAE,EAAE,CAAC;QAExC,MAAM,MAAM,GAAG,MAAM,IAAA,2BAAgB,EAAC,GAAG,EAAE;YACzC,YAAY,EAAE,kBAAkB;YAChC,WAAW,EAAE,eAAe;YAC5B,aAAa,EAAE,IAAA,6BAAoB,EAAC;gBAClC,MAAM,EAAE,IAAI,CAAC,OAAO;gBACpB,OAAO,EAAE,IAAI,CAAC,QAAQ;gBACtB,MAAM;gBACN,SAAS,kCAAO,IAAI,KAAE,iBAAiB,GAAE;gBACzC,KAAK;aACN,CAAC;YACF,WAAW,EAAE,IAAA,iCAAwB,GAAE;YACvC,qBAAqB,CAAC,iBAAyB;gBAC7C,KAAK,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;YAC9C,CAAC;SACF,CAAC,CAAC;QAEH,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,MAAM,EAAE,GAAG,MAAM,CAAC,iBAAiB,EAAE,CAAC,EAAE,CAAC;QACzC,OAAO,IAAA,qCAA4B,EAAC;YAClC,EAAE;YACF,MAAM,EAAE,IAAI,CAAC,OAAO;YACpB,OAAO;YACP,MAAM;YACN,OAAO,EAAE,IAAI,CAAC,QAAQ;SACvB,CAAC,CAAC;IACL,CAAC;CACF;AAj3BD,gDAi3BC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n AnalyzeActionName,\n AnalyzeActionParameters,\n AnalyzeBatchAction,\n AnalyzeBatchPoller,\n AnalyzeResult,\n BeginAnalyzeBatchOptions,\n RestoreAnalyzeBatchPollerOptions,\n TextAnalysisClientOptions,\n TextAnalysisOperationOptions,\n} from \"./models.js\";\nimport type {\n AnalyzeBatchActionUnion,\n GeneratedClientOptionalParams,\n LanguageDetectionInput,\n TextDocumentInput,\n} from \"./generated/models/index.js\";\nimport { DEFAULT_COGNITIVE_SCOPE, SDK_VERSION } from \"./constants.js\";\nimport type { KeyCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isTokenCredential } from \"@azure/core-auth\";\nimport type { TracingClient } from \"@azure/core-tracing\";\nimport { createTracingClient } from \"@azure/core-tracing\";\nimport {\n convertToLanguageDetectionInput,\n convertToTextDocumentInput,\n getOperationOptions,\n isStringArray,\n} from \"./util.js\";\nimport {\n createAnalyzeBatchLro,\n createCreateAnalyzeBatchPollerLro,\n createPollerWithCancellation,\n createUpdateAnalyzeState,\n getDocIDsFromState,\n processAnalyzeResult,\n} from \"./lro.js\";\nimport { throwError, transformActionResult } from \"./transforms.js\";\nimport { GeneratedClient } from \"./generated/generatedClient.js\";\nimport { bearerTokenAuthenticationPolicy } from \"@azure/core-rest-pipeline\";\nimport { createHttpPoller } from \"@azure/core-lro\";\nimport { logger } from \"./logger.js\";\nimport { textAnalyticsAzureKeyCredentialPolicy } from \"./azureKeyCredentialPolicy.js\";\n\n/**\n * A client for interacting with the text analysis features in Azure Cognitive\n * Language Service.\n *\n * The client needs the endpoint of a Language resource and an authentication\n * method such as an API key or AAD. The API key and endpoint can be found in\n * the Language resource page in the Azure portal. They will be located in the\n * resource's Keys and Endpoint page, under Resource Management.\n *\n * ### Examples for authentication:\n *\n * #### API Key\n *\n * ```ts snippet:ReadmeSampleCreateClient_Key\n * import { AzureKeyCredential, TextAnalysisClient } from \"@azure/ai-language-text\";\n *\n * const endpoint = \"https://<resource name>.cognitiveservices.azure.com\";\n * const credential = new AzureKeyCredential(\"<api key>\");\n * const client = new TextAnalysisClient(endpoint, credential);\n * ```\n *\n * #### Azure Active Directory\n *\n * See the [`@azure/identity`](https://npmjs.com/package/\\@azure/identity)\n * package for more information about authenticating with Azure Active Directory.\n *\n * ```ts snippet:ReadmeSampleCreateClient_ActiveDirectory\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import { TextAnalysisClient } from \"@azure/ai-language-text\";\n *\n * const endpoint = \"https://<resource name>.cognitiveservices.azure.com\";\n * const credential = new DefaultAzureCredential();\n * const client = new TextAnalysisClient(endpoint, credential);\n * ```\n */\nexport class TextAnalysisClient {\n private readonly _client: GeneratedClient;\n private readonly _tracing: TracingClient;\n private readonly defaultCountryHint: string;\n private readonly defaultLanguage: string;\n\n /**\n * Creates an instance of TextAnalysisClient with the endpoint of a Language\n * resource and an authentication method such as an API key or AAD.\n *\n * The API key and endpoint can be found in the Language resource page in the\n * Azure portal. They will be located in the resource's Keys and Endpoint page,\n * under Resource Management.\n *\n * ### Example\n *\n * ```ts snippet:ReadmeSampleCreateClient_Key\n * import { AzureKeyCredential, TextAnalysisClient } from \"@azure/ai-language-text\";\n *\n * const endpoint = \"https://<resource name>.cognitiveservices.azure.com\";\n * const credential = new AzureKeyCredential(\"<api key>\");\n * const client = new TextAnalysisClient(endpoint, credential);\n * ```\n *\n * @param endpointUrl - The URL to the endpoint of a Cognitive Language Service resource\n * @param credential - Key credential to be used to authenticate requests to the service.\n * @param options - Used to configure the TextAnalytics client.\n */\n constructor(endpointUrl: string, credential: KeyCredential, options?: TextAnalysisClientOptions);\n /**\n * Creates an instance of TextAnalysisClient with the endpoint of a Language\n * resource and an authentication method such as an API key or AAD.\n *\n * The API key and endpoint can be found in the Language resource page in the\n * Azure portal. They will be located in the resource's Keys and Endpoint page,\n * under Resource Management.\n *\n * ### Example\n *\n * See the [`@azure/identity`](https://npmjs.com/package/\\@azure/identity)\n * package for more information about authenticating with Azure Active Directory.\n *\n * ```ts snippet:ReadmeSampleCreateClient_ActiveDirectory\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import { TextAnalysisClient } from \"@azure/ai-language-text\";\n *\n * const endpoint = \"https://<resource name>.cognitiveservices.azure.com\";\n * const credential = new DefaultAzureCredential();\n * const client = new TextAnalysisClient(endpoint, credential);\n * ```\n *\n * @param endpointUrl - The URL to the endpoint of a Cognitive Language Service resource\n * @param credential - Token credential to be used to authenticate requests to the service.\n * @param options - Used to configure the TextAnalytics client.\n */\n constructor(\n endpointUrl: string,\n credential: TokenCredential,\n options?: TextAnalysisClientOptions,\n );\n constructor(\n endpointUrl: string,\n credential: TokenCredential | KeyCredential,\n options: TextAnalysisClientOptions = {},\n ) {\n const {\n defaultCountryHint = \"us\",\n defaultLanguage = \"en\",\n serviceVersion,\n ...pipelineOptions\n } = options;\n this.defaultCountryHint = defaultCountryHint;\n this.defaultLanguage = defaultLanguage;\n\n const internalPipelineOptions: GeneratedClientOptionalParams = {\n ...pipelineOptions,\n ...{\n loggingOptions: {\n logger: logger.info,\n additionalAllowedHeaderNames: [\"x-ms-correlation-request-id\", \"x-ms-request-id\"],\n },\n },\n apiVersion: serviceVersion,\n };\n\n this._client = new GeneratedClient(endpointUrl, internalPipelineOptions);\n\n const authPolicy = isTokenCredential(credential)\n ? bearerTokenAuthenticationPolicy({ credential, scopes: DEFAULT_COGNITIVE_SCOPE })\n : textAnalyticsAzureKeyCredentialPolicy(credential);\n\n this._client.pipeline.addPolicy(authPolicy);\n this._tracing = createTracingClient({\n packageName: \"@azure/ai-language-text\",\n packageVersion: SDK_VERSION,\n namespace: \"Microsoft.CognitiveServices\",\n });\n }\n\n /**\n * Runs a predictive model to determine the language that the passed-in\n * input strings are written in, and returns, for each one, the detected\n * language as well as a score indicating the model's confidence that the\n * inferred language is correct. Scores close to 1 indicate high certainty in\n * the result. 120 languages are supported.\n *\n * See {@link https://learn.microsoft.com//azure/cognitive-services/language-service/concepts/data-limits}\n * for data limits.\n *\n * ### Examples\n *\n * #### Language detection\n *\n * ```ts snippet:Sample_LanguageDetection\n * import { TextAnalysisClient } from \"@azure/ai-language-text\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const documents = [\n * \"This document is written in English.\",\n * \"Este es un document escrito en Español.\",\n * \"这是一个用中文写的文件\",\n * \"Dies ist ein Dokument in deutsche Sprache.\",\n * \"Detta är ett dokument skrivet på engelska.\",\n * ];\n *\n * const client = new TextAnalysisClient(\"<endpoint>\", new DefaultAzureCredential());\n *\n * const result = await client.analyze(\"LanguageDetection\", documents, \"us\", {\n * modelVersion: \"2022-04-10-preview\",\n * });\n *\n * for (const doc of result) {\n * if (!doc.error) {\n * console.log(\n * `Primary language: ${doc.primaryLanguage.name} (iso6391 name: ${doc.primaryLanguage.iso6391Name})`,\n * );\n * }\n * }\n * ```\n *\n * See {@link https://learn.microsoft.com//azure/cognitive-services/language-service/language-detection/overview}\n * for more information on language detection.\n *\n * @param actionName - the name of the action to be performed on the input\n * documents, see ${@link AnalyzeActionName}\n * @param documents - the input documents to be analyzed\n * @param options - optional action parameters and settings for the operation\n *\n * @returns an array of results where each element contains the primary language\n * for the corresponding input document.\n */\n public async analyze<ActionName extends \"LanguageDetection\">(\n actionName: ActionName,\n documents: LanguageDetectionInput[],\n options?: AnalyzeActionParameters<ActionName> & TextAnalysisOperationOptions,\n ): Promise<AnalyzeResult<ActionName>>;\n /**\n * Runs a predictive model to determine the language that the passed-in\n * input strings are written in, and returns, for each one, the detected\n * language as well as a score indicating the model's confidence that the\n * inferred language is correct. Scores close to 1 indicate high certainty in\n * the result. 120 languages are supported.\n *\n * See {@link https://learn.microsoft.com//azure/cognitive-services/language-service/concepts/data-limits}\n * for data limits.\n *\n * ### Examples\n *\n * #### Language detection\n *\n * ```ts snippet:Sample_LanguageDetection\n * import { TextAnalysisClient } from \"@azure/ai-language-text\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const documents = [\n * \"This document is written in English.\",\n * \"Este es un document escrito en Español.\",\n * \"这是一个用中文写的文件\",\n * \"Dies ist ein Dokument in deutsche Sprache.\",\n * \"Detta är ett dokument skrivet på engelska.\",\n * ];\n *\n * const client = new TextAnalysisClient(\"<endpoint>\", new DefaultAzureCredential());\n *\n * const result = await client.analyze(\"LanguageDetection\", documents, \"us\", {\n * modelVersion: \"2022-04-10-preview\",\n * });\n *\n * for (const doc of result) {\n * if (!doc.error) {\n * console.log(\n * `Primary language: ${doc.primaryLanguage.name} (iso6391 name: ${doc.primaryLanguage.iso6391Name})`,\n * );\n * }\n * }\n * ```\n *\n * See {@link https://learn.microsoft.com//azure/cognitive-services/language-service/language-detection/overview}\n * for more information on language detection.\n *\n * @param actionName - the name of the action to be performed on the input\n * documents, see ${@link AnalyzeActionName}\n * @param documents - the input documents to be analyzed\n * @param countryHint - Indicates the country of origin for all of\n * the input strings to assist the model in predicting the language they are\n * written in. If unspecified, this value will be set to the default\n * country hint in `TextAnalysisClientOptions`. If set to an empty string,\n * or the string \"none\", the service will apply a model where the country is\n * explicitly unset. The same country hint is applied to all strings in the\n * input collection.\n * @param options - optional action parameters and settings for the operation\n *\n * @returns an array of results where each element contains the primary language\n * for the corresponding input document.\n */\n public async analyze<ActionName extends \"LanguageDetection\">(\n actionName: ActionName,\n documents: string[],\n countryHint?: string,\n options?: AnalyzeActionParameters<ActionName> & TextAnalysisOperationOptions,\n ): Promise<AnalyzeResult<ActionName>>;\n /**\n * Runs a predictive model to perform the action of choice on the input\n * documents. See ${@link AnalyzeActionName} for a list of supported\n * actions.\n *\n * The layout of each item in the results array depends on the action chosen.\n * For example, each PIIEntityRecognition document result consists of both\n * `entities` and `redactedText` where the former is a list of all Pii entities\n * in the text and the latter is the original text after all such Pii entities\n * have been redacted from it.\n *\n * See {@link https://learn.microsoft.com//azure/cognitive-services/language-service/concepts/data-limits}\n * for data limits.\n *\n * ### Examples\n *\n * #### Opinion mining\n *\n * ```ts snippet:Sample_SentimentAnalysis\n * import { TextAnalysisClient } from \"@azure/ai-language-text\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const documents = [\n * \"I had the best day of my life.\",\n * \"This was a waste of my time. The speaker put me to sleep.\",\n * ];\n *\n * const client = new TextAnalysisClient(\"<endpoint>\", new DefaultAzureCredential());\n *\n * const results = await client.analyze(\"SentimentAnalysis\", documents);\n *\n * for (let i = 0; i < results.length; i++) {\n * const result = results[i];\n * console.log(`- Document ${result.id}`);\n * if (!result.error) {\n * console.log(`\\tDocument text: ${documents[i]}`);\n * console.log(`\\tOverall Sentiment: ${result.sentiment}`);\n * console.log(\"\\tSentiment confidence scores: \", result.confidenceScores);\n * console.log(\"\\tSentences\");\n * for (const { sentiment, confidenceScores, text } of result.sentences) {\n * console.log(`\\t- Sentence text: ${text}`);\n * console.log(`\\t Sentence sentiment: ${sentiment}`);\n * console.log(\"\\t Confidence scores:\", confidenceScores);\n * }\n * } else {\n * console.error(` Error: ${result.error}`);\n * }\n * }\n * ```\n *\n * See {@link https://learn.microsoft.com//azure/cognitive-services/language-service/sentiment-opinion-mining/overview}\n * for more information on opinion mining.\n *\n * #### Personally identifiable information\n *\n * ```ts snippet:Sample_PIIEntityRecognition\n * import {\n * TextAnalysisClient,\n * KnownPiiEntityDomain,\n * KnownPiiEntityCategory,\n * } from \"@azure/ai-language-text\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const client = new TextAnalysisClient(\"<endpoint>\", new DefaultAzureCredential());\n *\n * const documents = [\"My phone number is 555-5555\"];\n *\n * const [result] = await client.analyze(\"PiiEntityRecognition\", documents, \"en\", {\n * domainFilter: KnownPiiEntityDomain.Phi,\n * categoriesFilter: [\n * KnownPiiEntityCategory.PhoneNumber,\n * KnownPiiEntityCategory.USSocialSecurityNumber,\n * ],\n * });\n *\n * if (!result.error) {\n * console.log(`Redacted text: \"${result.redactedText}\"`);\n * console.log(\"Pii Entities: \");\n * for (const entity of result.entities) {\n * console.log(`\\t- \"${entity.text}\" of type ${entity.category}`);\n * }\n * }\n * ```\n *\n * See {@link https://learn.microsoft.com//azure/cognitive-services/language-service/personally-identifiable-information/overview}\n * for more information on personally identifiable information.\n *\n * @param actionName - the name of the action to be performed on the input\n * documents, see ${@link AnalyzeActionName}\n * @param documents - the input documents to be analyzed\n * @param options - optional action parameters and settings for the operation\n *\n * @returns an array of results corresponding to the input documents\n */\n public async analyze<ActionName extends AnalyzeActionName = AnalyzeActionName>(\n actionName: ActionName,\n documents: TextDocumentInput[],\n options?: AnalyzeActionParameters<ActionName> & TextAnalysisOperationOptions,\n ): Promise<AnalyzeResult<ActionName>>;\n\n /**\n * Runs a predictive model to perform the action of choice on the input\n * strings. See ${@link AnalyzeActionName} for a list of supported\n * actions.\n *\n * The layout of each item in the results array depends on the action chosen.\n * For example, each PIIEntityRecognition document result consists of both\n * `entities` and `redactedText` where the former is a list of all Pii entities\n * in the text and the latter is the original text after all such Pii entities\n * have been redacted from it.\n *\n * See {@link https://learn.microsoft.com//azure/cognitive-services/language-service/concepts/data-limits}\n * for data limits.\n *\n * ### Examples\n *\n * #### Opinion mining\n *\n * ```ts snippet:Sample_SentimentAnalysis\n * import { TextAnalysisClient } from \"@azure/ai-language-text\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const documents = [\n * \"I had the best day of my life.\",\n * \"This was a waste of my time. The speaker put me to sleep.\",\n * ];\n *\n * const client = new TextAnalysisClient(\"<endpoint>\", new DefaultAzureCredential());\n *\n * const results = await client.analyze(\"SentimentAnalysis\", documents);\n *\n * for (let i = 0; i < results.length; i++) {\n * const result = results[i];\n * console.log(`- Document ${result.id}`);\n * if (!result.error) {\n * console.log(`\\tDocument text: ${documents[i]}`);\n * console.log(`\\tOverall Sentiment: ${result.sentiment}`);\n * console.log(\"\\tSentiment confidence scores: \", result.confidenceScores);\n * console.log(\"\\tSentences\");\n * for (const { sentiment, confidenceScores, text } of result.sentences) {\n * console.log(`\\t- Sentence text: ${text}`);\n * console.log(`\\t Sentence sentiment: ${sentiment}`);\n * console.log(\"\\t Confidence scores:\", confidenceScores);\n * }\n * } else {\n * console.error(` Error: ${result.error}`);\n * }\n * }\n * ```\n *\n * See {@link https://learn.microsoft.com//azure/cognitive-services/language-service/sentiment-opinion-mining/overview}\n * for more information on opinion mining.\n *\n * #### Personally identifiable information\n *\n * ```ts snippet:Sample_PIIEntityRecognition\n * import {\n * TextAnalysisClient,\n * KnownPiiEntityDomain,\n * KnownPiiEntityCategory,\n * } from \"@azure/ai-language-text\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const client = new TextAnalysisClient(\"<endpoint>\", new DefaultAzureCredential());\n *\n * const documents = [\"My phone number is 555-5555\"];\n *\n * const [result] = await client.analyze(\"PiiEntityRecognition\", documents, \"en\", {\n * domainFilter: KnownPiiEntityDomain.Phi,\n * categoriesFilter: [\n * KnownPiiEntityCategory.PhoneNumber,\n * KnownPiiEntityCategory.USSocialSecurityNumber,\n * ],\n * });\n *\n * if (!result.error) {\n * console.log(`Redacted text: \"${result.redactedText}\"`);\n * console.log(\"Pii Entities: \");\n * for (const entity of result.entities) {\n * console.log(`\\t- \"${entity.text}\" of type ${entity.category}`);\n * }\n * }\n * ```\n *\n * See {@link https://learn.microsoft.com//azure/cognitive-services/language-service/personally-identifiable-information/overview}\n * for more information on personally identifiable information.\n *\n * @param actionName - the name of the action to be performed on the input\n * documents, see ${@link AnalyzeActionName}\n * @param documents - the input documents to be analyzed\n * @param languageCode - the code of the language that all the input strings are\n * written in. If unspecified, this value will be set to the default\n * language in `TextAnalysisClientOptions`. If set to an empty string,\n * the service will apply a model where the language is explicitly set to\n * \"None\". Language support varies per action, for example, more information\n * about the languages supported for Entity Recognition actions can be\n * found in {@link https://learn.microsoft.com//azure/cognitive-services/language-service/named-entity-recognition/language-support}.\n * If set to \"auto\", the service will automatically infer the language from\n * the input text.\n * @param options - optional action parameters and settings for the operation\n *\n * @returns an array of results corresponding to the input documents\n */\n public async analyze<ActionName extends AnalyzeActionName = AnalyzeActionName>(\n actionName: ActionName,\n documents: string[],\n languageCode?: string,\n options?: AnalyzeActionParameters<ActionName> & TextAnalysisOperationOptions,\n ): Promise<AnalyzeResult<ActionName>>;\n // implementation\n public async analyze<ActionName extends AnalyzeActionName = AnalyzeActionName>(\n actionName: ActionName,\n documents: string[] | LanguageDetectionInput[] | TextDocumentInput[],\n languageOrCountryHintOrOptions?:\n | string\n | (AnalyzeActionParameters<ActionName> & TextAnalysisOperationOptions),\n options?: AnalyzeActionParameters<ActionName> & TextAnalysisOperationOptions,\n ): Promise<AnalyzeResult<ActionName>> {\n let realOptions: AnalyzeActionParameters<ActionName> & TextAnalysisOperationOptions;\n\n if (documents.length === 0) {\n throw new Error(\"'documents' must be a non-empty array\");\n }\n\n let realInputs: LanguageDetectionInput[] | TextDocumentInput[];\n if (isStringArray(documents)) {\n if (actionName === \"LanguageDetection\") {\n realInputs = convertToLanguageDetectionInput(\n documents,\n typeof languageOrCountryHintOrOptions === \"string\"\n ? languageOrCountryHintOrOptions\n : this.defaultCountryHint,\n );\n } else {\n realInputs = convertToTextDocumentInput(\n documents,\n typeof languageOrCountryHintOrOptions === \"string\"\n ? languageOrCountryHintOrOptions\n : this.defaultLanguage,\n );\n }\n realOptions = options || ({} as any);\n } else {\n realInputs = documents;\n realOptions =\n (languageOrCountryHintOrOptions as AnalyzeActionParameters<ActionName> &\n TextAnalysisOperationOptions) || {};\n }\n const { options: operationOptions, rest: action } = getOperationOptions(realOptions);\n return this._tracing.withSpan(\n \"TextAnalysisClient.analyze\",\n operationOptions,\n async (updatedOptions: TextAnalysisOperationOptions) =>\n throwError(\n this._client\n .analyze(\n {\n kind: actionName,\n analysisInput: {\n documents: realInputs,\n },\n parameters: action,\n } as any,\n updatedOptions,\n )\n .then(\n (result) =>\n transformActionResult(\n actionName,\n realInputs.map(({ id }) => id),\n result,\n ) as AnalyzeResult<ActionName>,\n ),\n ),\n );\n }\n\n /**\n * Performs an array (batch) of actions on the input documents. Each action has\n * a `kind` field that specifies the nature of the action. See ${@link AnalyzeBatchActionNames}\n * for a list of supported actions. In addition to `kind`, actions could also\n * have other parameters such as `disableServiceLogs` and `modelVersion`.\n *\n * The results array contains the results for those input actions where each\n * item also has a `kind` field that specifies the type of the results.\n *\n * See {@link https://learn.microsoft.com//azure/cognitive-services/language-service/concepts/data-limits}\n * for data limits.\n *\n * ### Examples\n *\n * #### Key phrase extraction and Pii entity recognition\n *\n * ```ts snippet:Sample_ActionBatching\n * import { TextAnalysisClient, AnalyzeBatchAction } from \"@azure/ai-language-text\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const documents = [\n * \"Microsoft was founded by Bill Gates and Paul Allen.\",\n * \"Redmond is a city in King County, Washington, United States, located 15 miles east of Seattle.\",\n * \"I need to take my cat to the veterinarian.\",\n * \"The employee's SSN is 555-55-5555.\",\n * \"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!\",\n * ];\n *\n * const client = new TextAnalysisClient(\"<endpoint>\", new DefaultAzureCredential());\n *\n * const actions: AnalyzeBatchAction[] = [\n * {\n * kind: \"EntityRecognition\",\n * modelVersion: \"latest\",\n * },\n * {\n * kind: \"PiiEntityRecognition\",\n * modelVersion: \"latest\",\n * },\n * {\n * kind: \"KeyPhraseExtraction\",\n * modelVersion: \"latest\",\n * },\n * ];\n * const poller = await client.beginAnalyzeBatch(actions, documents, \"en\");\n *\n * poller.onProgress(() => {\n * console.log(\n * `Number of actions still in progress: ${poller.getOperationState().actionInProgressCount}`,\n * );\n * });\n *\n * console.log(`The operation was created on ${poller.getOperationState().createdOn}`);\n *\n * console.log(`The operation results will expire on ${poller.getOperationState().expiresOn}`);\n *\n * const actionResults = await poller.pollUntilDone();\n *\n * for await (const actionResult of actionResults) {\n * if (actionResult.error) {\n * const { code, message } = actionResult.error;\n * throw new Error(`Unexpected error (${code}): ${message}`);\n * }\n * switch (actionResult.kind) {\n * case \"KeyPhraseExtraction\": {\n * for (const doc of actionResult.results) {\n * console.log(`- Document ${doc.id}`);\n * if (!doc.error) {\n * console.log(\"\\tKey phrases:\");\n * for (const phrase of doc.keyPhrases) {\n * console.log(`\\t- ${phrase}`);\n * }\n * } else {\n * console.error(\"\\tError:\", doc.error);\n * }\n * }\n * break;\n * }\n * case \"EntityRecognition\": {\n * for (const doc of actionResult.results) {\n * console.log(`- Document ${doc.id}`);\n * if (!doc.error) {\n * console.log(\"\\tEntities:\");\n * for (const entity of doc.entities) {\n * console.log(`\\t- Entity ${entity.text} of type ${entity.category}`);\n * }\n * } else {\n * console.error(\"\\tError:\", doc.error);\n * }\n * }\n * break;\n * }\n * case \"PiiEntityRecognition\": {\n * for (const doc of actionResult.results) {\n * console.log(`- Document ${doc.id}`);\n * if (!doc.error) {\n * console.log(\"\\tPii Entities:\");\n * for (const entity of doc.entities) {\n * console.log(`\\t- Entity ${entity.text} of type ${entity.category}`);\n * }\n * } else {\n * console.error(\"\\tError:\", doc.error);\n * }\n * }\n * break;\n * }\n * default: {\n * throw new Error(`Unexpected action results: ${actionResult.kind}`);\n * }\n * }\n * }\n * ```\n *\n * @param actions - an array of actions that will be run on the input documents\n * @param documents - the input documents to be analyzed\n * @param languageCode - the code of the language that all the input strings are\n * written in. If unspecified, this value will be set to the default\n * language in `TextAnalysisClientOptions`. If set to an empty string,\n * the service will apply a model where the language is explicitly set to\n * \"None\". Language support varies per action, for example, more information\n * about the languages supported for Entity Recognition actions can be\n * found in {@link https://learn.microsoft.com//azure/cognitive-services/language-service/named-entity-recognition/language-support}.\n * If set to \"auto\", the service will automatically infer the language from\n * the input text.\n * @param options - optional settings for the operation\n *\n * @returns an array of results corresponding to the input actions\n */\n async beginAnalyzeBatch(\n actions: AnalyzeBatchAction[],\n documents: string[],\n languageCode?: string,\n options?: BeginAnalyzeBatchOptions,\n ): Promise<AnalyzeBatchPoller>;\n /**\n * Performs an array (batch) of actions on the input documents. Each action has\n * a `kind` field that specifies the nature of the action. See ${@link AnalyzeBatchActionNames}\n * for a list of supported actions. In addition to `kind`, actions could also\n * have other parameters such as `disableServiceLogs` and `modelVersion`.\n *\n * The results array contains the results for those input actions where each\n * item also has a `kind` field that specifies the type of the results.\n *\n * See {@link https://learn.microsoft.com//azure/cognitive-services/language-service/concepts/data-limits}\n * for data limits.\n *\n * ### Examples\n *\n * #### Keyphrase extraction and Pii entity recognition\n *\n * ```ts snippet:Sample_ActionBatching\n * import { TextAnalysisClient, AnalyzeBatchAction } from \"@azure/ai-language-text\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const documents = [\n * \"Microsoft was founded by Bill Gates and Paul Allen.\",\n * \"Redmond is a city in King County, Washington, United States, located 15 miles east of Seattle.\",\n * \"I need to take my cat to the veterinarian.\",\n * \"The employee's SSN is 555-55-5555.\",\n * \"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!\",\n * ];\n *\n * const client = new TextAnalysisClient(\"<endpoint>\", new DefaultAzureCredential());\n *\n * const actions: AnalyzeBatchAction[] = [\n * {\n * kind: \"EntityRecognition\",\n * modelVersion: \"latest\",\n * },\n * {\n * kind: \"PiiEntityRecognition\",\n * modelVersion: \"latest\",\n * },\n * {\n * kind: \"KeyPhraseExtraction\",\n * modelVersion: \"latest\",\n * },\n * ];\n * const poller = await client.beginAnalyzeBatch(actions, documents, \"en\");\n *\n * poller.onProgress(() => {\n * console.log(\n * `Number of actions still in progress: ${poller.getOperationState().actionInProgressCount}`,\n * );\n * });\n *\n * console.log(`The operation was created on ${poller.getOperationState().createdOn}`);\n *\n * console.log(`The operation results will expire on ${poller.getOperationState().expiresOn}`);\n *\n * const actionResults = await poller.pollUntilDone();\n *\n * for await (const actionResult of actionResults) {\n * if (actionResult.error) {\n * const { code, message } = actionResult.error;\n * throw new Error(`Unexpected error (${code}): ${message}`);\n * }\n * switch (actionResult.kind) {\n * case \"KeyPhraseExtraction\": {\n * for (const doc of actionResult.results) {\n * console.log(`- Document ${doc.id}`);\n * if (!doc.error) {\n * console.log(\"\\tKey phrases:\");\n * for (const phrase of doc.keyPhrases) {\n * console.log(`\\t- ${phrase}`);\n * }\n * } else {\n * console.error(\"\\tError:\", doc.error);\n * }\n * }\n * break;\n * }\n * case \"EntityRecognition\": {\n * for (const doc of actionResult.results) {\n * console.log(`- Document ${doc.id}`);\n * if (!doc.error) {\n * console.log(\"\\tEntities:\");\n * for (const entity of doc.entities) {\n * console.log(`\\t- Entity ${entity.text} of type ${entity.category}`);\n * }\n * } else {\n * console.error(\"\\tError:\", doc.error);\n * }\n * }\n * break;\n * }\n * case \"PiiEntityRecognition\": {\n * for (const doc of actionResult.results) {\n * console.log(`- Document ${doc.id}`);\n * if (!doc.error) {\n * console.log(\"\\tPii Entities:\");\n * for (const entity of doc.entities) {\n * console.log(`\\t- Entity ${entity.text} of type ${entity.category}`);\n * }\n * } else {\n * console.error(\"\\tError:\", doc.error);\n * }\n * }\n * break;\n * }\n * default: {\n * throw new Error(`Unexpected action results: ${actionResult.kind}`);\n * }\n * }\n * }\n * ```\n *\n * @param actions - an array of actions that will be run on the input documents\n * @param documents - the input documents to be analyzed\n * @param options - optional settings for the operation\n *\n * @returns an array of results corresponding to the input actions\n */\n async beginAnalyzeBatch(\n actions: AnalyzeBatchAction[],\n documents: TextDocumentInput[],\n options?: BeginAnalyzeBatchOptions,\n ): Promise<AnalyzeBatchPoller>;\n // implementation\n async beginAnalyzeBatch(\n actions: AnalyzeBatchAction[],\n documents: TextDocumentInput[] | string[],\n languageOrOptions?: BeginAnalyzeBatchOptions | string,\n options: BeginAnalyzeBatchOptions = {},\n ): Promise<AnalyzeBatchPoller> {\n let realOptions: BeginAnalyzeBatchOptions;\n let realInputs: TextDocumentInput[];\n\n if (!Array.isArray(documents) || documents.length === 0) {\n throw new Error(\"'documents' must be a non-empty array\");\n }\n\n if (isStringArray(documents)) {\n const languageCode = (languageOrOptions as string) ?? this.defaultLanguage;\n realInputs = convertToTextDocumentInput(documents, languageCode);\n realOptions = options;\n } else {\n realInputs = documents;\n realOptions = languageOrOptions as BeginAnalyzeBatchOptions;\n }\n const realActions = actions.map(\n ({ kind, actionName, ...rest }): AnalyzeBatchActionUnion & { parameters: unknown } => ({\n kind,\n actionName,\n parameters: rest,\n }),\n );\n const { includeStatistics, updateIntervalInMs, displayName, ...rest } = realOptions;\n const lro = createAnalyzeBatchLro({\n client: this._client,\n commonOptions: rest,\n documents: realInputs,\n initialRequestOptions: { displayName },\n pollRequestOptions: { includeStatistics },\n tasks: realActions,\n tracing: this._tracing,\n });\n\n const docIds = realInputs.map(({ id }) => id);\n\n const state = { continuationToken: \"\" };\n\n const poller = await createHttpPoller(lro, {\n intervalInMs: updateIntervalInMs,\n processResult: processAnalyzeResult({\n client: this._client,\n tracing: this._tracing,\n docIds,\n opOptions: { ...rest, includeStatistics },\n state,\n }),\n updateState: createUpdateAnalyzeState(docIds),\n withOperationLocation(operationLocation: string) {\n state.continuationToken = operationLocation;\n },\n });\n\n await poller.poll();\n const id = poller.getOperationState().id;\n return createPollerWithCancellation({\n id,\n client: this._client,\n options,\n poller,\n tracing: this._tracing,\n });\n }\n\n /**\n * Creates a poller from the serialized state of another poller. This can be\n * useful when you want to create pollers on a different host or a poller\n * needs to be constructed after the original one is not in scope.\n *\n * @param serializedState - the serialized state of another poller. It is the\n * result of `poller.toString()`\n * @param options - optional settings for the operation\n *\n */\n async restoreAnalyzeBatchPoller(\n serializedState: string,\n options?: RestoreAnalyzeBatchPollerOptions,\n ): Promise<AnalyzeBatchPoller>;\n // implementation\n async restoreAnalyzeBatchPoller(\n serializedState: string,\n options: RestoreAnalyzeBatchPollerOptions = {},\n ): Promise<AnalyzeBatchPoller> {\n const { includeStatistics, updateIntervalInMs, ...rest } = options;\n const docIds = getDocIDsFromState(serializedState);\n const lro = createCreateAnalyzeBatchPollerLro({\n client: this._client,\n options: { ...rest, includeStatistics },\n tracing: this._tracing,\n });\n\n const state = { continuationToken: \"\" };\n\n const poller = await createHttpPoller(lro, {\n intervalInMs: updateIntervalInMs,\n restoreFrom: serializedState,\n processResult: processAnalyzeResult({\n client: this._client,\n tracing: this._tracing,\n docIds,\n opOptions: { ...rest, includeStatistics },\n state,\n }),\n updateState: createUpdateAnalyzeState(),\n withOperationLocation(operationLocation: string) {\n state.continuationToken = operationLocation;\n },\n });\n\n await poller.poll();\n const id = poller.getOperationState().id;\n return createPollerWithCancellation({\n id,\n client: this._client,\n options,\n poller,\n tracing: this._tracing,\n });\n }\n}\n"]}
1
+ {"version":3,"file":"textAnalysisClient.js","sourceRoot":"","sources":["../../src/textAnalysisClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAmBlC,iDAAsE;AAEtE,gDAAqD;AAErD,sDAA0D;AAC1D,uCAKmB;AACnB,qCAOkB;AAClB,mDAAoE;AACpE,uEAAiE;AACjE,kEAA4E;AAC5E,8CAAmD;AACnD,2CAAqC;AACrC,+EAAsF;AAEtF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAa,kBAAkB;IACZ,OAAO,CAAkB;IACzB,QAAQ,CAAgB;IACxB,kBAAkB,CAAS;IAC3B,eAAe,CAAS;IAwDzC,YACE,WAAmB,EACnB,UAA2C,EAC3C,UAAqC,EAAE;QAEvC,MAAM,EACJ,kBAAkB,GAAG,IAAI,EACzB,eAAe,GAAG,IAAI,EACtB,cAAc,EACd,GAAG,eAAe,EACnB,GAAG,OAAO,CAAC;QACZ,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;QAC7C,IAAI,CAAC,eAAe,G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YAChC,WAAW,EAAE,eAAe;YAC5B,aAAa,EAAE,IAAA,6BAAoB,EAAC;gBAClC,MAAM,EAAE,IAAI,CAAC,OAAO;gBACpB,OAAO,EAAE,IAAI,CAAC,QAAQ;gBACtB,MAAM;gBACN,SAAS,EAAE,EAAE,GAAG,IAAI,EAAE,iBAAiB,EAAE;gBACzC,KAAK;aACN,CAAC;YACF,WAAW,EAAE,IAAA,iCAAwB,GAAE;YACvC,qBAAqB,CAAC,iBAAyB;gBAC7C,KAAK,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;YAC9C,CAAC;SACF,CAAC,CAAC;QAEH,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,MAAM,EAAE,GAAG,MAAM,CAAC,iBAAiB,EAAE,CAAC,EAAE,CAAC;QACzC,OAAO,IAAA,qCAA4B,EAAC;YAClC,EAAE;YACF,MAAM,EAAE,IAAI,CAAC,OAAO;YACpB,OAAO;YACP,MAAM;YACN,OAAO,EAAE,IAAI,CAAC,QAAQ;SACvB,CAAC,CAAC;IACL,CAAC;CACF;AAj3BD,gDAi3BC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n AnalyzeActionName,\n AnalyzeActionParameters,\n AnalyzeBatchAction,\n AnalyzeBatchPoller,\n AnalyzeResult,\n BeginAnalyzeBatchOptions,\n RestoreAnalyzeBatchPollerOptions,\n TextAnalysisClientOptions,\n TextAnalysisOperationOptions,\n} from \"./models.js\";\nimport type {\n AnalyzeBatchActionUnion,\n GeneratedClientOptionalParams,\n LanguageDetectionInput,\n TextDocumentInput,\n} from \"./generated/models/index.js\";\nimport { DEFAULT_COGNITIVE_SCOPE, SDK_VERSION } from \"./constants.js\";\nimport type { KeyCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isTokenCredential } from \"@azure/core-auth\";\nimport type { TracingClient } from \"@azure/core-tracing\";\nimport { createTracingClient } from \"@azure/core-tracing\";\nimport {\n convertToLanguageDetectionInput,\n convertToTextDocumentInput,\n getOperationOptions,\n isStringArray,\n} from \"./util.js\";\nimport {\n createAnalyzeBatchLro,\n createCreateAnalyzeBatchPollerLro,\n createPollerWithCancellation,\n createUpdateAnalyzeState,\n getDocIDsFromState,\n processAnalyzeResult,\n} from \"./lro.js\";\nimport { throwError, transformActionResult } from \"./transforms.js\";\nimport { GeneratedClient } from \"./generated/generatedClient.js\";\nimport { bearerTokenAuthenticationPolicy } from \"@azure/core-rest-pipeline\";\nimport { createHttpPoller } from \"@azure/core-lro\";\nimport { logger } from \"./logger.js\";\nimport { textAnalyticsAzureKeyCredentialPolicy } from \"./azureKeyCredentialPolicy.js\";\n\n/**\n * A client for interacting with the text analysis features in Azure Cognitive\n * Language Service.\n *\n * The client needs the endpoint of a Language resource and an authentication\n * method such as an API key or AAD. The API key and endpoint can be found in\n * the Language resource page in the Azure portal. They will be located in the\n * resource's Keys and Endpoint page, under Resource Management.\n *\n * ### Examples for authentication:\n *\n * #### API Key\n *\n * ```ts snippet:ReadmeSampleCreateClient_Key\n * import { AzureKeyCredential, TextAnalysisClient } from \"@azure/ai-language-text\";\n *\n * const endpoint = \"https://<resource name>.cognitiveservices.azure.com\";\n * const credential = new AzureKeyCredential(\"<api key>\");\n * const client = new TextAnalysisClient(endpoint, credential);\n * ```\n *\n * #### Azure Active Directory\n *\n * See the [`@azure/identity`](https://npmjs.com/package/\\@azure/identity)\n * package for more information about authenticating with Azure Active Directory.\n *\n * ```ts snippet:ReadmeSampleCreateClient_ActiveDirectory\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import { TextAnalysisClient } from \"@azure/ai-language-text\";\n *\n * const endpoint = \"https://<resource name>.cognitiveservices.azure.com\";\n * const credential = new DefaultAzureCredential();\n * const client = new TextAnalysisClient(endpoint, credential);\n * ```\n */\nexport class TextAnalysisClient {\n private readonly _client: GeneratedClient;\n private readonly _tracing: TracingClient;\n private readonly defaultCountryHint: string;\n private readonly defaultLanguage: string;\n\n /**\n * Creates an instance of TextAnalysisClient with the endpoint of a Language\n * resource and an authentication method such as an API key or AAD.\n *\n * The API key and endpoint can be found in the Language resource page in the\n * Azure portal. They will be located in the resource's Keys and Endpoint page,\n * under Resource Management.\n *\n * ### Example\n *\n * ```ts snippet:ReadmeSampleCreateClient_Key\n * import { AzureKeyCredential, TextAnalysisClient } from \"@azure/ai-language-text\";\n *\n * const endpoint = \"https://<resource name>.cognitiveservices.azure.com\";\n * const credential = new AzureKeyCredential(\"<api key>\");\n * const client = new TextAnalysisClient(endpoint, credential);\n * ```\n *\n * @param endpointUrl - The URL to the endpoint of a Cognitive Language Service resource\n * @param credential - Key credential to be used to authenticate requests to the service.\n * @param options - Used to configure the TextAnalytics client.\n */\n constructor(endpointUrl: string, credential: KeyCredential, options?: TextAnalysisClientOptions);\n /**\n * Creates an instance of TextAnalysisClient with the endpoint of a Language\n * resource and an authentication method such as an API key or AAD.\n *\n * The API key and endpoint can be found in the Language resource page in the\n * Azure portal. They will be located in the resource's Keys and Endpoint page,\n * under Resource Management.\n *\n * ### Example\n *\n * See the [`@azure/identity`](https://npmjs.com/package/\\@azure/identity)\n * package for more information about authenticating with Azure Active Directory.\n *\n * ```ts snippet:ReadmeSampleCreateClient_ActiveDirectory\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import { TextAnalysisClient } from \"@azure/ai-language-text\";\n *\n * const endpoint = \"https://<resource name>.cognitiveservices.azure.com\";\n * const credential = new DefaultAzureCredential();\n * const client = new TextAnalysisClient(endpoint, credential);\n * ```\n *\n * @param endpointUrl - The URL to the endpoint of a Cognitive Language Service resource\n * @param credential - Token credential to be used to authenticate requests to the service.\n * @param options - Used to configure the TextAnalytics client.\n */\n constructor(\n endpointUrl: string,\n credential: TokenCredential,\n options?: TextAnalysisClientOptions,\n );\n constructor(\n endpointUrl: string,\n credential: TokenCredential | KeyCredential,\n options: TextAnalysisClientOptions = {},\n ) {\n const {\n defaultCountryHint = \"us\",\n defaultLanguage = \"en\",\n serviceVersion,\n ...pipelineOptions\n } = options;\n this.defaultCountryHint = defaultCountryHint;\n this.defaultLanguage = defaultLanguage;\n\n const internalPipelineOptions: GeneratedClientOptionalParams = {\n ...pipelineOptions,\n ...{\n loggingOptions: {\n logger: logger.info,\n additionalAllowedHeaderNames: [\"x-ms-correlation-request-id\", \"x-ms-request-id\"],\n },\n },\n apiVersion: serviceVersion,\n };\n\n this._client = new GeneratedClient(endpointUrl, internalPipelineOptions);\n\n const authPolicy = isTokenCredential(credential)\n ? bearerTokenAuthenticationPolicy({ credential, scopes: DEFAULT_COGNITIVE_SCOPE })\n : textAnalyticsAzureKeyCredentialPolicy(credential);\n\n this._client.pipeline.addPolicy(authPolicy);\n this._tracing = createTracingClient({\n packageName: \"@azure/ai-language-text\",\n packageVersion: SDK_VERSION,\n namespace: \"Microsoft.CognitiveServices\",\n });\n }\n\n /**\n * Runs a predictive model to determine the language that the passed-in\n * input strings are written in, and returns, for each one, the detected\n * language as well as a score indicating the model's confidence that the\n * inferred language is correct. Scores close to 1 indicate high certainty in\n * the result. 120 languages are supported.\n *\n * See {@link https://learn.microsoft.com//azure/cognitive-services/language-service/concepts/data-limits}\n * for data limits.\n *\n * ### Examples\n *\n * #### Language detection\n *\n * ```ts snippet:Sample_LanguageDetection\n * import { TextAnalysisClient } from \"@azure/ai-language-text\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const documents = [\n * \"This document is written in English.\",\n * \"Este es un document escrito en Español.\",\n * \"这是一个用中文写的文件\",\n * \"Dies ist ein Dokument in deutsche Sprache.\",\n * \"Detta är ett dokument skrivet på engelska.\",\n * ];\n *\n * const client = new TextAnalysisClient(\"<endpoint>\", new DefaultAzureCredential());\n *\n * const result = await client.analyze(\"LanguageDetection\", documents, \"us\", {\n * modelVersion: \"2022-04-10-preview\",\n * });\n *\n * for (const doc of result) {\n * if (!doc.error) {\n * console.log(\n * `Primary language: ${doc.primaryLanguage.name} (iso6391 name: ${doc.primaryLanguage.iso6391Name})`,\n * );\n * }\n * }\n * ```\n *\n * See {@link https://learn.microsoft.com//azure/cognitive-services/language-service/language-detection/overview}\n * for more information on language detection.\n *\n * @param actionName - the name of the action to be performed on the input\n * documents, see ${@link AnalyzeActionName}\n * @param documents - the input documents to be analyzed\n * @param options - optional action parameters and settings for the operation\n *\n * @returns an array of results where each element contains the primary language\n * for the corresponding input document.\n */\n public async analyze<ActionName extends \"LanguageDetection\">(\n actionName: ActionName,\n documents: LanguageDetectionInput[],\n options?: AnalyzeActionParameters<ActionName> & TextAnalysisOperationOptions,\n ): Promise<AnalyzeResult<ActionName>>;\n /**\n * Runs a predictive model to determine the language that the passed-in\n * input strings are written in, and returns, for each one, the detected\n * language as well as a score indicating the model's confidence that the\n * inferred language is correct. Scores close to 1 indicate high certainty in\n * the result. 120 languages are supported.\n *\n * See {@link https://learn.microsoft.com//azure/cognitive-services/language-service/concepts/data-limits}\n * for data limits.\n *\n * ### Examples\n *\n * #### Language detection\n *\n * ```ts snippet:Sample_LanguageDetection\n * import { TextAnalysisClient } from \"@azure/ai-language-text\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const documents = [\n * \"This document is written in English.\",\n * \"Este es un document escrito en Español.\",\n * \"这是一个用中文写的文件\",\n * \"Dies ist ein Dokument in deutsche Sprache.\",\n * \"Detta är ett dokument skrivet på engelska.\",\n * ];\n *\n * const client = new TextAnalysisClient(\"<endpoint>\", new DefaultAzureCredential());\n *\n * const result = await client.analyze(\"LanguageDetection\", documents, \"us\", {\n * modelVersion: \"2022-04-10-preview\",\n * });\n *\n * for (const doc of result) {\n * if (!doc.error) {\n * console.log(\n * `Primary language: ${doc.primaryLanguage.name} (iso6391 name: ${doc.primaryLanguage.iso6391Name})`,\n * );\n * }\n * }\n * ```\n *\n * See {@link https://learn.microsoft.com//azure/cognitive-services/language-service/language-detection/overview}\n * for more information on language detection.\n *\n * @param actionName - the name of the action to be performed on the input\n * documents, see ${@link AnalyzeActionName}\n * @param documents - the input documents to be analyzed\n * @param countryHint - Indicates the country of origin for all of\n * the input strings to assist the model in predicting the language they are\n * written in. If unspecified, this value will be set to the default\n * country hint in `TextAnalysisClientOptions`. If set to an empty string,\n * or the string \"none\", the service will apply a model where the country is\n * explicitly unset. The same country hint is applied to all strings in the\n * input collection.\n * @param options - optional action parameters and settings for the operation\n *\n * @returns an array of results where each element contains the primary language\n * for the corresponding input document.\n */\n public async analyze<ActionName extends \"LanguageDetection\">(\n actionName: ActionName,\n documents: string[],\n countryHint?: string,\n options?: AnalyzeActionParameters<ActionName> & TextAnalysisOperationOptions,\n ): Promise<AnalyzeResult<ActionName>>;\n /**\n * Runs a predictive model to perform the action of choice on the input\n * documents. See ${@link AnalyzeActionName} for a list of supported\n * actions.\n *\n * The layout of each item in the results array depends on the action chosen.\n * For example, each PIIEntityRecognition document result consists of both\n * `entities` and `redactedText` where the former is a list of all Pii entities\n * in the text and the latter is the original text after all such Pii entities\n * have been redacted from it.\n *\n * See {@link https://learn.microsoft.com//azure/cognitive-services/language-service/concepts/data-limits}\n * for data limits.\n *\n * ### Examples\n *\n * #### Opinion mining\n *\n * ```ts snippet:Sample_SentimentAnalysis\n * import { TextAnalysisClient } from \"@azure/ai-language-text\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const documents = [\n * \"I had the best day of my life.\",\n * \"This was a waste of my time. The speaker put me to sleep.\",\n * ];\n *\n * const client = new TextAnalysisClient(\"<endpoint>\", new DefaultAzureCredential());\n *\n * const results = await client.analyze(\"SentimentAnalysis\", documents);\n *\n * for (let i = 0; i < results.length; i++) {\n * const result = results[i];\n * console.log(`- Document ${result.id}`);\n * if (!result.error) {\n * console.log(`\\tDocument text: ${documents[i]}`);\n * console.log(`\\tOverall Sentiment: ${result.sentiment}`);\n * console.log(\"\\tSentiment confidence scores: \", result.confidenceScores);\n * console.log(\"\\tSentences\");\n * for (const { sentiment, confidenceScores, text } of result.sentences) {\n * console.log(`\\t- Sentence text: ${text}`);\n * console.log(`\\t Sentence sentiment: ${sentiment}`);\n * console.log(\"\\t Confidence scores:\", confidenceScores);\n * }\n * } else {\n * console.error(` Error: ${result.error}`);\n * }\n * }\n * ```\n *\n * See {@link https://learn.microsoft.com//azure/cognitive-services/language-service/sentiment-opinion-mining/overview}\n * for more information on opinion mining.\n *\n * #### Personally identifiable information\n *\n * ```ts snippet:Sample_PIIEntityRecognition\n * import {\n * TextAnalysisClient,\n * KnownPiiEntityDomain,\n * KnownPiiEntityCategory,\n * } from \"@azure/ai-language-text\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const client = new TextAnalysisClient(\"<endpoint>\", new DefaultAzureCredential());\n *\n * const documents = [\"My phone number is 555-5555\"];\n *\n * const [result] = await client.analyze(\"PiiEntityRecognition\", documents, \"en\", {\n * domainFilter: KnownPiiEntityDomain.Phi,\n * categoriesFilter: [\n * KnownPiiEntityCategory.PhoneNumber,\n * KnownPiiEntityCategory.USSocialSecurityNumber,\n * ],\n * });\n *\n * if (!result.error) {\n * console.log(`Redacted text: \"${result.redactedText}\"`);\n * console.log(\"Pii Entities: \");\n * for (const entity of result.entities) {\n * console.log(`\\t- \"${entity.text}\" of type ${entity.category}`);\n * }\n * }\n * ```\n *\n * See {@link https://learn.microsoft.com//azure/cognitive-services/language-service/personally-identifiable-information/overview}\n * for more information on personally identifiable information.\n *\n * @param actionName - the name of the action to be performed on the input\n * documents, see ${@link AnalyzeActionName}\n * @param documents - the input documents to be analyzed\n * @param options - optional action parameters and settings for the operation\n *\n * @returns an array of results corresponding to the input documents\n */\n public async analyze<ActionName extends AnalyzeActionName = AnalyzeActionName>(\n actionName: ActionName,\n documents: TextDocumentInput[],\n options?: AnalyzeActionParameters<ActionName> & TextAnalysisOperationOptions,\n ): Promise<AnalyzeResult<ActionName>>;\n\n /**\n * Runs a predictive model to perform the action of choice on the input\n * strings. See ${@link AnalyzeActionName} for a list of supported\n * actions.\n *\n * The layout of each item in the results array depends on the action chosen.\n * For example, each PIIEntityRecognition document result consists of both\n * `entities` and `redactedText` where the former is a list of all Pii entities\n * in the text and the latter is the original text after all such Pii entities\n * have been redacted from it.\n *\n * See {@link https://learn.microsoft.com//azure/cognitive-services/language-service/concepts/data-limits}\n * for data limits.\n *\n * ### Examples\n *\n * #### Opinion mining\n *\n * ```ts snippet:Sample_SentimentAnalysis\n * import { TextAnalysisClient } from \"@azure/ai-language-text\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const documents = [\n * \"I had the best day of my life.\",\n * \"This was a waste of my time. The speaker put me to sleep.\",\n * ];\n *\n * const client = new TextAnalysisClient(\"<endpoint>\", new DefaultAzureCredential());\n *\n * const results = await client.analyze(\"SentimentAnalysis\", documents);\n *\n * for (let i = 0; i < results.length; i++) {\n * const result = results[i];\n * console.log(`- Document ${result.id}`);\n * if (!result.error) {\n * console.log(`\\tDocument text: ${documents[i]}`);\n * console.log(`\\tOverall Sentiment: ${result.sentiment}`);\n * console.log(\"\\tSentiment confidence scores: \", result.confidenceScores);\n * console.log(\"\\tSentences\");\n * for (const { sentiment, confidenceScores, text } of result.sentences) {\n * console.log(`\\t- Sentence text: ${text}`);\n * console.log(`\\t Sentence sentiment: ${sentiment}`);\n * console.log(\"\\t Confidence scores:\", confidenceScores);\n * }\n * } else {\n * console.error(` Error: ${result.error}`);\n * }\n * }\n * ```\n *\n * See {@link https://learn.microsoft.com//azure/cognitive-services/language-service/sentiment-opinion-mining/overview}\n * for more information on opinion mining.\n *\n * #### Personally identifiable information\n *\n * ```ts snippet:Sample_PIIEntityRecognition\n * import {\n * TextAnalysisClient,\n * KnownPiiEntityDomain,\n * KnownPiiEntityCategory,\n * } from \"@azure/ai-language-text\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const client = new TextAnalysisClient(\"<endpoint>\", new DefaultAzureCredential());\n *\n * const documents = [\"My phone number is 555-5555\"];\n *\n * const [result] = await client.analyze(\"PiiEntityRecognition\", documents, \"en\", {\n * domainFilter: KnownPiiEntityDomain.Phi,\n * categoriesFilter: [\n * KnownPiiEntityCategory.PhoneNumber,\n * KnownPiiEntityCategory.USSocialSecurityNumber,\n * ],\n * });\n *\n * if (!result.error) {\n * console.log(`Redacted text: \"${result.redactedText}\"`);\n * console.log(\"Pii Entities: \");\n * for (const entity of result.entities) {\n * console.log(`\\t- \"${entity.text}\" of type ${entity.category}`);\n * }\n * }\n * ```\n *\n * See {@link https://learn.microsoft.com//azure/cognitive-services/language-service/personally-identifiable-information/overview}\n * for more information on personally identifiable information.\n *\n * @param actionName - the name of the action to be performed on the input\n * documents, see ${@link AnalyzeActionName}\n * @param documents - the input documents to be analyzed\n * @param languageCode - the code of the language that all the input strings are\n * written in. If unspecified, this value will be set to the default\n * language in `TextAnalysisClientOptions`. If set to an empty string,\n * the service will apply a model where the language is explicitly set to\n * \"None\". Language support varies per action, for example, more information\n * about the languages supported for Entity Recognition actions can be\n * found in {@link https://learn.microsoft.com//azure/cognitive-services/language-service/named-entity-recognition/language-support}.\n * If set to \"auto\", the service will automatically infer the language from\n * the input text.\n * @param options - optional action parameters and settings for the operation\n *\n * @returns an array of results corresponding to the input documents\n */\n public async analyze<ActionName extends AnalyzeActionName = AnalyzeActionName>(\n actionName: ActionName,\n documents: string[],\n languageCode?: string,\n options?: AnalyzeActionParameters<ActionName> & TextAnalysisOperationOptions,\n ): Promise<AnalyzeResult<ActionName>>;\n // implementation\n public async analyze<ActionName extends AnalyzeActionName = AnalyzeActionName>(\n actionName: ActionName,\n documents: string[] | LanguageDetectionInput[] | TextDocumentInput[],\n languageOrCountryHintOrOptions?:\n | string\n | (AnalyzeActionParameters<ActionName> & TextAnalysisOperationOptions),\n options?: AnalyzeActionParameters<ActionName> & TextAnalysisOperationOptions,\n ): Promise<AnalyzeResult<ActionName>> {\n let realOptions: AnalyzeActionParameters<ActionName> & TextAnalysisOperationOptions;\n\n if (documents.length === 0) {\n throw new Error(\"'documents' must be a non-empty array\");\n }\n\n let realInputs: LanguageDetectionInput[] | TextDocumentInput[];\n if (isStringArray(documents)) {\n if (actionName === \"LanguageDetection\") {\n realInputs = convertToLanguageDetectionInput(\n documents,\n typeof languageOrCountryHintOrOptions === \"string\"\n ? languageOrCountryHintOrOptions\n : this.defaultCountryHint,\n );\n } else {\n realInputs = convertToTextDocumentInput(\n documents,\n typeof languageOrCountryHintOrOptions === \"string\"\n ? languageOrCountryHintOrOptions\n : this.defaultLanguage,\n );\n }\n realOptions = options || ({} as any);\n } else {\n realInputs = documents;\n realOptions =\n (languageOrCountryHintOrOptions as AnalyzeActionParameters<ActionName> &\n TextAnalysisOperationOptions) || {};\n }\n const { options: operationOptions, rest: action } = getOperationOptions(realOptions);\n return this._tracing.withSpan(\n \"TextAnalysisClient.analyze\",\n operationOptions,\n async (updatedOptions: TextAnalysisOperationOptions) =>\n throwError(\n this._client\n .analyze(\n {\n kind: actionName,\n analysisInput: {\n documents: realInputs,\n },\n parameters: action,\n } as any,\n updatedOptions,\n )\n .then(\n (result) =>\n transformActionResult(\n actionName,\n realInputs.map(({ id }) => id),\n result,\n ) as AnalyzeResult<ActionName>,\n ),\n ),\n );\n }\n\n /**\n * Performs an array (batch) of actions on the input documents. Each action has\n * a `kind` field that specifies the nature of the action. See ${@link AnalyzeBatchActionNames}\n * for a list of supported actions. In addition to `kind`, actions could also\n * have other parameters such as `disableServiceLogs` and `modelVersion`.\n *\n * The results array contains the results for those input actions where each\n * item also has a `kind` field that specifies the type of the results.\n *\n * See {@link https://learn.microsoft.com//azure/cognitive-services/language-service/concepts/data-limits}\n * for data limits.\n *\n * ### Examples\n *\n * #### Key phrase extraction and Pii entity recognition\n *\n * ```ts snippet:Sample_ActionBatching\n * import { TextAnalysisClient, AnalyzeBatchAction } from \"@azure/ai-language-text\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const documents = [\n * \"Microsoft was founded by Bill Gates and Paul Allen.\",\n * \"Redmond is a city in King County, Washington, United States, located 15 miles east of Seattle.\",\n * \"I need to take my cat to the veterinarian.\",\n * \"The employee's SSN is 555-55-5555.\",\n * \"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!\",\n * ];\n *\n * const client = new TextAnalysisClient(\"<endpoint>\", new DefaultAzureCredential());\n *\n * const actions: AnalyzeBatchAction[] = [\n * {\n * kind: \"EntityRecognition\",\n * modelVersion: \"latest\",\n * },\n * {\n * kind: \"PiiEntityRecognition\",\n * modelVersion: \"latest\",\n * },\n * {\n * kind: \"KeyPhraseExtraction\",\n * modelVersion: \"latest\",\n * },\n * ];\n * const poller = await client.beginAnalyzeBatch(actions, documents, \"en\");\n *\n * poller.onProgress(() => {\n * console.log(\n * `Number of actions still in progress: ${poller.getOperationState().actionInProgressCount}`,\n * );\n * });\n *\n * console.log(`The operation was created on ${poller.getOperationState().createdOn}`);\n *\n * console.log(`The operation results will expire on ${poller.getOperationState().expiresOn}`);\n *\n * const actionResults = await poller.pollUntilDone();\n *\n * for await (const actionResult of actionResults) {\n * if (actionResult.error) {\n * const { code, message } = actionResult.error;\n * throw new Error(`Unexpected error (${code}): ${message}`);\n * }\n * switch (actionResult.kind) {\n * case \"KeyPhraseExtraction\": {\n * for (const doc of actionResult.results) {\n * console.log(`- Document ${doc.id}`);\n * if (!doc.error) {\n * console.log(\"\\tKey phrases:\");\n * for (const phrase of doc.keyPhrases) {\n * console.log(`\\t- ${phrase}`);\n * }\n * } else {\n * console.error(\"\\tError:\", doc.error);\n * }\n * }\n * break;\n * }\n * case \"EntityRecognition\": {\n * for (const doc of actionResult.results) {\n * console.log(`- Document ${doc.id}`);\n * if (!doc.error) {\n * console.log(\"\\tEntities:\");\n * for (const entity of doc.entities) {\n * console.log(`\\t- Entity ${entity.text} of type ${entity.category}`);\n * }\n * } else {\n * console.error(\"\\tError:\", doc.error);\n * }\n * }\n * break;\n * }\n * case \"PiiEntityRecognition\": {\n * for (const doc of actionResult.results) {\n * console.log(`- Document ${doc.id}`);\n * if (!doc.error) {\n * console.log(\"\\tPii Entities:\");\n * for (const entity of doc.entities) {\n * console.log(`\\t- Entity ${entity.text} of type ${entity.category}`);\n * }\n * } else {\n * console.error(\"\\tError:\", doc.error);\n * }\n * }\n * break;\n * }\n * default: {\n * throw new Error(`Unexpected action results: ${actionResult.kind}`);\n * }\n * }\n * }\n * ```\n *\n * @param actions - an array of actions that will be run on the input documents\n * @param documents - the input documents to be analyzed\n * @param languageCode - the code of the language that all the input strings are\n * written in. If unspecified, this value will be set to the default\n * language in `TextAnalysisClientOptions`. If set to an empty string,\n * the service will apply a model where the language is explicitly set to\n * \"None\". Language support varies per action, for example, more information\n * about the languages supported for Entity Recognition actions can be\n * found in {@link https://learn.microsoft.com//azure/cognitive-services/language-service/named-entity-recognition/language-support}.\n * If set to \"auto\", the service will automatically infer the language from\n * the input text.\n * @param options - optional settings for the operation\n *\n * @returns an array of results corresponding to the input actions\n */\n async beginAnalyzeBatch(\n actions: AnalyzeBatchAction[],\n documents: string[],\n languageCode?: string,\n options?: BeginAnalyzeBatchOptions,\n ): Promise<AnalyzeBatchPoller>;\n /**\n * Performs an array (batch) of actions on the input documents. Each action has\n * a `kind` field that specifies the nature of the action. See ${@link AnalyzeBatchActionNames}\n * for a list of supported actions. In addition to `kind`, actions could also\n * have other parameters such as `disableServiceLogs` and `modelVersion`.\n *\n * The results array contains the results for those input actions where each\n * item also has a `kind` field that specifies the type of the results.\n *\n * See {@link https://learn.microsoft.com//azure/cognitive-services/language-service/concepts/data-limits}\n * for data limits.\n *\n * ### Examples\n *\n * #### Keyphrase extraction and Pii entity recognition\n *\n * ```ts snippet:Sample_ActionBatching\n * import { TextAnalysisClient, AnalyzeBatchAction } from \"@azure/ai-language-text\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const documents = [\n * \"Microsoft was founded by Bill Gates and Paul Allen.\",\n * \"Redmond is a city in King County, Washington, United States, located 15 miles east of Seattle.\",\n * \"I need to take my cat to the veterinarian.\",\n * \"The employee's SSN is 555-55-5555.\",\n * \"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!\",\n * ];\n *\n * const client = new TextAnalysisClient(\"<endpoint>\", new DefaultAzureCredential());\n *\n * const actions: AnalyzeBatchAction[] = [\n * {\n * kind: \"EntityRecognition\",\n * modelVersion: \"latest\",\n * },\n * {\n * kind: \"PiiEntityRecognition\",\n * modelVersion: \"latest\",\n * },\n * {\n * kind: \"KeyPhraseExtraction\",\n * modelVersion: \"latest\",\n * },\n * ];\n * const poller = await client.beginAnalyzeBatch(actions, documents, \"en\");\n *\n * poller.onProgress(() => {\n * console.log(\n * `Number of actions still in progress: ${poller.getOperationState().actionInProgressCount}`,\n * );\n * });\n *\n * console.log(`The operation was created on ${poller.getOperationState().createdOn}`);\n *\n * console.log(`The operation results will expire on ${poller.getOperationState().expiresOn}`);\n *\n * const actionResults = await poller.pollUntilDone();\n *\n * for await (const actionResult of actionResults) {\n * if (actionResult.error) {\n * const { code, message } = actionResult.error;\n * throw new Error(`Unexpected error (${code}): ${message}`);\n * }\n * switch (actionResult.kind) {\n * case \"KeyPhraseExtraction\": {\n * for (const doc of actionResult.results) {\n * console.log(`- Document ${doc.id}`);\n * if (!doc.error) {\n * console.log(\"\\tKey phrases:\");\n * for (const phrase of doc.keyPhrases) {\n * console.log(`\\t- ${phrase}`);\n * }\n * } else {\n * console.error(\"\\tError:\", doc.error);\n * }\n * }\n * break;\n * }\n * case \"EntityRecognition\": {\n * for (const doc of actionResult.results) {\n * console.log(`- Document ${doc.id}`);\n * if (!doc.error) {\n * console.log(\"\\tEntities:\");\n * for (const entity of doc.entities) {\n * console.log(`\\t- Entity ${entity.text} of type ${entity.category}`);\n * }\n * } else {\n * console.error(\"\\tError:\", doc.error);\n * }\n * }\n * break;\n * }\n * case \"PiiEntityRecognition\": {\n * for (const doc of actionResult.results) {\n * console.log(`- Document ${doc.id}`);\n * if (!doc.error) {\n * console.log(\"\\tPii Entities:\");\n * for (const entity of doc.entities) {\n * console.log(`\\t- Entity ${entity.text} of type ${entity.category}`);\n * }\n * } else {\n * console.error(\"\\tError:\", doc.error);\n * }\n * }\n * break;\n * }\n * default: {\n * throw new Error(`Unexpected action results: ${actionResult.kind}`);\n * }\n * }\n * }\n * ```\n *\n * @param actions - an array of actions that will be run on the input documents\n * @param documents - the input documents to be analyzed\n * @param options - optional settings for the operation\n *\n * @returns an array of results corresponding to the input actions\n */\n async beginAnalyzeBatch(\n actions: AnalyzeBatchAction[],\n documents: TextDocumentInput[],\n options?: BeginAnalyzeBatchOptions,\n ): Promise<AnalyzeBatchPoller>;\n // implementation\n async beginAnalyzeBatch(\n actions: AnalyzeBatchAction[],\n documents: TextDocumentInput[] | string[],\n languageOrOptions?: BeginAnalyzeBatchOptions | string,\n options: BeginAnalyzeBatchOptions = {},\n ): Promise<AnalyzeBatchPoller> {\n let realOptions: BeginAnalyzeBatchOptions;\n let realInputs: TextDocumentInput[];\n\n if (!Array.isArray(documents) || documents.length === 0) {\n throw new Error(\"'documents' must be a non-empty array\");\n }\n\n if (isStringArray(documents)) {\n const languageCode = (languageOrOptions as string) ?? this.defaultLanguage;\n realInputs = convertToTextDocumentInput(documents, languageCode);\n realOptions = options;\n } else {\n realInputs = documents;\n realOptions = languageOrOptions as BeginAnalyzeBatchOptions;\n }\n const realActions = actions.map(\n ({ kind, actionName, ...rest }): AnalyzeBatchActionUnion & { parameters: unknown } => ({\n kind,\n actionName,\n parameters: rest,\n }),\n );\n const { includeStatistics, updateIntervalInMs, displayName, ...rest } = realOptions;\n const lro = createAnalyzeBatchLro({\n client: this._client,\n commonOptions: rest,\n documents: realInputs,\n initialRequestOptions: { displayName },\n pollRequestOptions: { includeStatistics },\n tasks: realActions,\n tracing: this._tracing,\n });\n\n const docIds = realInputs.map(({ id }) => id);\n\n const state = { continuationToken: \"\" };\n\n const poller = await createHttpPoller(lro, {\n intervalInMs: updateIntervalInMs,\n processResult: processAnalyzeResult({\n client: this._client,\n tracing: this._tracing,\n docIds,\n opOptions: { ...rest, includeStatistics },\n state,\n }),\n updateState: createUpdateAnalyzeState(docIds),\n withOperationLocation(operationLocation: string) {\n state.continuationToken = operationLocation;\n },\n });\n\n await poller.poll();\n const id = poller.getOperationState().id;\n return createPollerWithCancellation({\n id,\n client: this._client,\n options,\n poller,\n tracing: this._tracing,\n });\n }\n\n /**\n * Creates a poller from the serialized state of another poller. This can be\n * useful when you want to create pollers on a different host or a poller\n * needs to be constructed after the original one is not in scope.\n *\n * @param serializedState - the serialized state of another poller. It is the\n * result of `poller.toString()`\n * @param options - optional settings for the operation\n *\n */\n async restoreAnalyzeBatchPoller(\n serializedState: string,\n options?: RestoreAnalyzeBatchPollerOptions,\n ): Promise<AnalyzeBatchPoller>;\n // implementation\n async restoreAnalyzeBatchPoller(\n serializedState: string,\n options: RestoreAnalyzeBatchPollerOptions = {},\n ): Promise<AnalyzeBatchPoller> {\n const { includeStatistics, updateIntervalInMs, ...rest } = options;\n const docIds = getDocIDsFromState(serializedState);\n const lro = createCreateAnalyzeBatchPollerLro({\n client: this._client,\n options: { ...rest, includeStatistics },\n tracing: this._tracing,\n });\n\n const state = { continuationToken: \"\" };\n\n const poller = await createHttpPoller(lro, {\n intervalInMs: updateIntervalInMs,\n restoreFrom: serializedState,\n processResult: processAnalyzeResult({\n client: this._client,\n tracing: this._tracing,\n docIds,\n opOptions: { ...rest, includeStatistics },\n state,\n }),\n updateState: createUpdateAnalyzeState(),\n withOperationLocation(operationLocation: string) {\n state.continuationToken = operationLocation;\n },\n });\n\n await poller.poll();\n const id = poller.getOperationState().id;\n return createPollerWithCancellation({\n id,\n client: this._client,\n options,\n poller,\n tracing: this._tracing,\n });\n }\n}\n"]}
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.transformActionResult = transformActionResult;
6
6
  exports.throwError = throwError;
7
7
  exports.transformAnalyzeBatchResults = transformAnalyzeBatchResults;
8
- const tslib_1 = require("tslib");
9
8
  const util_js_1 = require("./util.js");
10
9
  const core_rest_pipeline_1 = require("@azure/core-rest-pipeline");
11
10
  /**
@@ -17,7 +16,9 @@ function toTextAnalysisError(errorModel) {
17
16
  if (errorModel.innererror !== undefined) {
18
17
  return toTextAnalysisError(errorModel.innererror);
19
18
  }
20
- return Object.assign({}, errorModel);
19
+ return {
20
+ ...errorModel,
21
+ };
21
22
  }
22
23
  function makeTextAnalysisErrorResult(id, error) {
23
24
  return {
@@ -42,10 +43,10 @@ function transformDocumentResults(ids, response, options) {
42
43
  }
43
44
  function toLanguageDetectionResult(docIds, results) {
44
45
  return transformDocumentResults(docIds, results, {
45
- processSuccess: (_a) => {
46
- var { detectedLanguage } = _a, rest = tslib_1.__rest(_a, ["detectedLanguage"]);
47
- return (Object.assign({ primaryLanguage: detectedLanguage }, rest));
48
- },
46
+ processSuccess: ({ detectedLanguage, ...rest }) => ({
47
+ primaryLanguage: detectedLanguage,
48
+ ...rest,
49
+ }),
49
50
  });
50
51
  }
51
52
  function toPiiEntityRecognitionResult(docIds, results) {
@@ -53,10 +54,10 @@ function toPiiEntityRecognitionResult(docIds, results) {
53
54
  }
54
55
  function toSentimentAnalysisResult(docIds, results) {
55
56
  return transformDocumentResults(docIds, results, {
56
- processSuccess: (_a) => {
57
- var { sentences } = _a, rest = tslib_1.__rest(_a, ["sentences"]);
58
- return (Object.assign(Object.assign({}, rest), { sentences: sentences.map((sentence) => convertGeneratedSentenceSentiment(sentence, sentences)) }));
59
- },
57
+ processSuccess: ({ sentences, ...rest }) => ({
58
+ ...rest,
59
+ sentences: sentences.map((sentence) => convertGeneratedSentenceSentiment(sentence, sentences)),
60
+ }),
60
61
  });
61
62
  }
62
63
  /**
@@ -68,20 +69,18 @@ function toSentimentAnalysisResult(docIds, results) {
68
69
  * @returns The user-friendly sentence sentiment object.
69
70
  * @internal
70
71
  */
71
- function convertGeneratedSentenceSentiment(_a, sentences) {
72
- var _b;
73
- var { targets, assessments: _ } = _a, rest = tslib_1.__rest(_a, ["targets", "assessments"]);
74
- return Object.assign(Object.assign({}, rest), { opinions: (_b = targets === null || targets === void 0 ? void 0 : targets.map(
72
+ function convertGeneratedSentenceSentiment({ targets, assessments: _, ...rest }, sentences) {
73
+ return {
74
+ ...rest,
75
+ opinions: targets?.map(
75
76
  // eslint-disable-next-line @typescript-eslint/no-shadow
76
- (_a) => {
77
- var { relations } = _a, rest = tslib_1.__rest(_a, ["relations"]);
78
- return ({
79
- target: rest,
80
- assessments: relations
81
- .filter((relation) => relation.relationType === "assessment")
82
- .map((relation) => convertTargetRelationToAssessmentSentiment(relation, sentences)),
83
- });
84
- })) !== null && _b !== void 0 ? _b : [] });
77
+ ({ relations, ...rest }) => ({
78
+ target: rest,
79
+ assessments: relations
80
+ .filter((relation) => relation.relationType === "assessment")
81
+ .map((relation) => convertTargetRelationToAssessmentSentiment(relation, sentences)),
82
+ })) ?? [],
83
+ };
85
84
  }
86
85
  /**
87
86
  * Converts a target relation object returned by the service to an assessment
@@ -94,10 +93,9 @@ function convertGeneratedSentenceSentiment(_a, sentences) {
94
93
  * @internal
95
94
  */
96
95
  function convertTargetRelationToAssessmentSentiment(targetRelation, sentences) {
97
- var _a;
98
96
  const assessmentPtr = targetRelation.ref;
99
97
  const assessmentIndex = (0, util_js_1.parseAssessmentIndex)(assessmentPtr);
100
- const assessment = (_a = sentences === null || sentences === void 0 ? void 0 : sentences[assessmentIndex.sentence].assessments) === null || _a === void 0 ? void 0 : _a[assessmentIndex.assessment];
98
+ const assessment = sentences?.[assessmentIndex.sentence].assessments?.[assessmentIndex.assessment];
101
99
  if (assessment !== undefined) {
102
100
  return assessment;
103
101
  }
@@ -156,12 +154,11 @@ function appendReadableErrorMessage(currentMessage, innerMessage) {
156
154
  * @param error - the incoming error
157
155
  */
158
156
  function transformError(errorResponse) {
159
- var _a;
160
157
  const strongErrorResponse = errorResponse;
161
158
  if (!strongErrorResponse.response) {
162
159
  throw errorResponse;
163
160
  }
164
- const topLevelError = (_a = strongErrorResponse.response.parsedBody) === null || _a === void 0 ? void 0 : _a.error;
161
+ const topLevelError = strongErrorResponse.response.parsedBody?.error;
165
162
  if (!topLevelError)
166
163
  return errorResponse;
167
164
  let errorMessage = topLevelError.message;
@@ -195,8 +192,11 @@ async function throwError(p) {
195
192
  }
196
193
  function toHealthcareResult(docIds, results) {
197
194
  function makeHealthcareEntity(entity) {
198
- const { dataSources } = entity, rest = tslib_1.__rest(entity, ["dataSources"]);
199
- return Object.assign({ dataSources: dataSources !== null && dataSources !== void 0 ? dataSources : [] }, rest);
195
+ const { dataSources, ...rest } = entity;
196
+ return {
197
+ dataSources: dataSources ?? [],
198
+ ...rest,
199
+ };
200
200
  }
201
201
  function makeHealthcareRelation(entities) {
202
202
  return ({ entities: generatedEntities, relationType, confidenceScore, }) => ({
@@ -209,10 +209,13 @@ function toHealthcareResult(docIds, results) {
209
209
  });
210
210
  }
211
211
  return transformDocumentResults(docIds, results, {
212
- processSuccess: (_a) => {
213
- var { entities, relations } = _a, rest = tslib_1.__rest(_a, ["entities", "relations"]);
212
+ processSuccess: ({ entities, relations, ...rest }) => {
214
213
  const newEntities = entities.map(makeHealthcareEntity);
215
- return Object.assign({ entities: newEntities, entityRelations: relations.map(makeHealthcareRelation(newEntities)) }, rest);
214
+ return {
215
+ entities: newEntities,
216
+ entityRelations: relations.map(makeHealthcareRelation(newEntities)),
217
+ ...rest,
218
+ };
216
219
  },
217
220
  });
218
221
  }
@@ -232,7 +235,14 @@ function transformAnalyzeBatchResults(docIds, response = [], errors = []) {
232
235
  }
233
236
  const { results } = actionData;
234
237
  const { modelVersion, statistics } = results;
235
- return Object.assign(Object.assign(Object.assign({ kind, results: toSentimentAnalysisResult(docIds, results), completedOn }, (actionName ? { actionName } : {})), (statistics ? { statistics } : {})), { modelVersion });
238
+ return {
239
+ kind,
240
+ results: toSentimentAnalysisResult(docIds, results),
241
+ completedOn,
242
+ ...(actionName ? { actionName } : {}),
243
+ ...(statistics ? { statistics } : {}),
244
+ modelVersion,
245
+ };
236
246
  }
237
247
  case "EntityRecognitionLROResults": {
238
248
  const kind = "EntityRecognition";
@@ -241,7 +251,14 @@ function transformAnalyzeBatchResults(docIds, response = [], errors = []) {
241
251
  }
242
252
  const { results } = actionData;
243
253
  const { modelVersion, statistics } = results;
244
- return Object.assign(Object.assign(Object.assign({ kind: "EntityRecognition", results: toEntityRecognitionResult(docIds, results), completedOn }, (actionName ? { actionName } : {})), (statistics ? { statistics } : {})), { modelVersion });
254
+ return {
255
+ kind: "EntityRecognition",
256
+ results: toEntityRecognitionResult(docIds, results),
257
+ completedOn,
258
+ ...(actionName ? { actionName } : {}),
259
+ ...(statistics ? { statistics } : {}),
260
+ modelVersion,
261
+ };
245
262
  }
246
263
  case "PiiEntityRecognitionLROResults": {
247
264
  const kind = "PiiEntityRecognition";
@@ -250,7 +267,14 @@ function transformAnalyzeBatchResults(docIds, response = [], errors = []) {
250
267
  }
251
268
  const { results } = actionData;
252
269
  const { modelVersion, statistics } = results;
253
- return Object.assign(Object.assign(Object.assign({ kind, results: toPiiEntityRecognitionResult(docIds, results), completedOn }, (actionName ? { actionName } : {})), (statistics ? { statistics } : {})), { modelVersion });
270
+ return {
271
+ kind,
272
+ results: toPiiEntityRecognitionResult(docIds, results),
273
+ completedOn,
274
+ ...(actionName ? { actionName } : {}),
275
+ ...(statistics ? { statistics } : {}),
276
+ modelVersion,
277
+ };
254
278
  }
255
279
  case "KeyPhraseExtractionLROResults": {
256
280
  const kind = "KeyPhraseExtraction";
@@ -259,7 +283,14 @@ function transformAnalyzeBatchResults(docIds, response = [], errors = []) {
259
283
  }
260
284
  const { results } = actionData;
261
285
  const { modelVersion, statistics } = results;
262
- return Object.assign(Object.assign(Object.assign({ kind, results: toKeyPhraseExtractionResult(docIds, results), completedOn }, (actionName ? { actionName } : {})), (statistics ? { statistics } : {})), { modelVersion });
286
+ return {
287
+ kind,
288
+ results: toKeyPhraseExtractionResult(docIds, results),
289
+ completedOn,
290
+ ...(actionName ? { actionName } : {}),
291
+ ...(statistics ? { statistics } : {}),
292
+ modelVersion,
293
+ };
263
294
  }
264
295
  case "EntityLinkingLROResults": {
265
296
  const kind = "EntityLinking";
@@ -268,7 +299,14 @@ function transformAnalyzeBatchResults(docIds, response = [], errors = []) {
268
299
  }
269
300
  const { results } = actionData;
270
301
  const { modelVersion, statistics } = results;
271
- return Object.assign(Object.assign(Object.assign({ kind, results: toEntityLinkingResult(docIds, results), completedOn }, (actionName ? { actionName } : {})), (statistics ? { statistics } : {})), { modelVersion });
302
+ return {
303
+ kind,
304
+ results: toEntityLinkingResult(docIds, results),
305
+ completedOn,
306
+ ...(actionName ? { actionName } : {}),
307
+ ...(statistics ? { statistics } : {}),
308
+ modelVersion,
309
+ };
272
310
  }
273
311
  case "HealthcareLROResults": {
274
312
  const kind = "Healthcare";
@@ -277,7 +315,14 @@ function transformAnalyzeBatchResults(docIds, response = [], errors = []) {
277
315
  }
278
316
  const { results } = actionData;
279
317
  const { modelVersion, statistics } = results;
280
- return Object.assign(Object.assign(Object.assign({ kind, results: toHealthcareResult(docIds, results), completedOn }, (actionName ? { actionName } : {})), (statistics ? { statistics } : {})), { modelVersion });
318
+ return {
319
+ kind,
320
+ results: toHealthcareResult(docIds, results),
321
+ completedOn,
322
+ ...(actionName ? { actionName } : {}),
323
+ ...(statistics ? { statistics } : {}),
324
+ modelVersion,
325
+ };
281
326
  }
282
327
  case "CustomEntityRecognitionLROResults": {
283
328
  const kind = "CustomEntityRecognition";
@@ -286,8 +331,15 @@ function transformAnalyzeBatchResults(docIds, response = [], errors = []) {
286
331
  }
287
332
  const { results } = actionData;
288
333
  const { deploymentName, projectName, statistics } = results;
289
- return Object.assign(Object.assign(Object.assign({ kind, results: transformDocumentResults(docIds, results), completedOn }, (actionName ? { actionName } : {})), (statistics ? { statistics } : {})), { deploymentName,
290
- projectName });
334
+ return {
335
+ kind,
336
+ results: transformDocumentResults(docIds, results),
337
+ completedOn,
338
+ ...(actionName ? { actionName } : {}),
339
+ ...(statistics ? { statistics } : {}),
340
+ deploymentName,
341
+ projectName,
342
+ };
291
343
  }
292
344
  case "CustomSingleLabelClassificationLROResults": {
293
345
  const kind = "CustomSingleLabelClassification";
@@ -296,8 +348,15 @@ function transformAnalyzeBatchResults(docIds, response = [], errors = []) {
296
348
  }
297
349
  const { results } = actionData;
298
350
  const { deploymentName, projectName, statistics } = results;
299
- return Object.assign(Object.assign(Object.assign({ kind, results: transformDocumentResults(docIds, results), completedOn }, (actionName ? { actionName } : {})), (statistics ? { statistics } : {})), { deploymentName,
300
- projectName });
351
+ return {
352
+ kind,
353
+ results: transformDocumentResults(docIds, results),
354
+ completedOn,
355
+ ...(actionName ? { actionName } : {}),
356
+ ...(statistics ? { statistics } : {}),
357
+ deploymentName,
358
+ projectName,
359
+ };
301
360
  }
302
361
  case "CustomMultiLabelClassificationLROResults": {
303
362
  const kind = "CustomMultiLabelClassification";
@@ -306,8 +365,15 @@ function transformAnalyzeBatchResults(docIds, response = [], errors = []) {
306
365
  }
307
366
  const { results } = actionData;
308
367
  const { deploymentName, projectName, statistics } = results;
309
- return Object.assign(Object.assign(Object.assign({ kind, results: transformDocumentResults(docIds, results), completedOn }, (actionName ? { actionName } : {})), (statistics ? { statistics } : {})), { deploymentName,
310
- projectName });
368
+ return {
369
+ kind,
370
+ results: transformDocumentResults(docIds, results),
371
+ completedOn,
372
+ ...(actionName ? { actionName } : {}),
373
+ ...(statistics ? { statistics } : {}),
374
+ deploymentName,
375
+ projectName,
376
+ };
311
377
  }
312
378
  case "ExtractiveSummarizationLROResults": {
313
379
  const kind = "ExtractiveSummarization";
@@ -316,7 +382,14 @@ function transformAnalyzeBatchResults(docIds, response = [], errors = []) {
316
382
  }
317
383
  const { results } = actionData;
318
384
  const { modelVersion, statistics } = results;
319
- return Object.assign(Object.assign(Object.assign({ kind: "ExtractiveSummarization", results: transformDocumentResults(docIds, results), completedOn }, (actionName ? { actionName } : {})), (statistics ? { statistics } : {})), { modelVersion });
385
+ return {
386
+ kind: "ExtractiveSummarization",
387
+ results: transformDocumentResults(docIds, results),
388
+ completedOn,
389
+ ...(actionName ? { actionName } : {}),
390
+ ...(statistics ? { statistics } : {}),
391
+ modelVersion,
392
+ };
320
393
  }
321
394
  case "AbstractiveSummarizationLROResults": {
322
395
  const kind = "AbstractiveSummarization";
@@ -325,7 +398,14 @@ function transformAnalyzeBatchResults(docIds, response = [], errors = []) {
325
398
  }
326
399
  const { results } = actionData;
327
400
  const { modelVersion, statistics } = results;
328
- return Object.assign(Object.assign(Object.assign({ kind: "AbstractiveSummarization", results: transformDocumentResults(docIds, results), completedOn }, (actionName ? { actionName } : {})), (statistics ? { statistics } : {})), { modelVersion });
401
+ return {
402
+ kind: "AbstractiveSummarization",
403
+ results: transformDocumentResults(docIds, results),
404
+ completedOn,
405
+ ...(actionName ? { actionName } : {}),
406
+ ...(statistics ? { statistics } : {}),
407
+ modelVersion,
408
+ };
329
409
  }
330
410
  default: {
331
411
  throw new Error(`Unsupported results kind: ${resultKind}`);
@@ -341,7 +421,7 @@ function toIndexErrorMap(errors) {
341
421
  const errorMap = new Map();
342
422
  for (const error of errors) {
343
423
  const position = (0, util_js_1.extractErrorPointerIndex)(error);
344
- const { target } = error, errorWithoutTarget = tslib_1.__rest(error, ["target"]);
424
+ const { target, ...errorWithoutTarget } = error;
345
425
  errorMap.set(position, toTextAnalysisError(errorWithoutTarget));
346
426
  }
347
427
  return errorMap;