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

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- {"version":3,"file":"textAnalysisClient.js","sourceRoot":"","sources":["../../src/textAnalysisClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAmBlC,OAAO,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAkC,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrF,OAAO,EAAiB,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EACL,+BAA+B,EAC/B,0BAA0B,EAC1B,mBAAmB,EACnB,aAAa,GACd,MAAM,QAAQ,CAAC;AAChB,OAAO,EACL,qBAAqB,EACrB,iCAAiC,EACjC,4BAA4B,EAC5B,wBAAwB,EACxB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,qCAAqC,EAAE,MAAM,4BAA4B,CAAC;AAEnF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,OAAO,kBAAkB;IA8D7B,YACE,WAAmB,EACnB,UAA2C,EAC3C,UAAqC,EAAE;QAEvC,MAAM,EACJ,kBAAkB,GAAG,IAAI,EACzB,eAAe,GAAG,IAAI,EACtB,cAAc,KAEZ,OAAO,EADN,eAAe,UAChB,OAAO,EALL,2DAKL,CAAU,CAAC;QACZ,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;QAC7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M;gBACN,SAAS,kCAAO,IAAI,KAAE,iBAAiB,GAAE;gBACzC,KAAK;aACN,CAAC;YACF,WAAW,EAAE,wBAAwB,EAAE;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,4BAA4B,CAAC;YAClC,EAAE;YACF,MAAM,EAAE,IAAI,CAAC,OAAO;YACpB,OAAO;YACP,MAAM;YACN,OAAO,EAAE,IAAI,CAAC,QAAQ;SACvB,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n AnalyzeActionName,\n AnalyzeActionParameters,\n AnalyzeBatchAction,\n AnalyzeBatchPoller,\n AnalyzeResult,\n BeginAnalyzeBatchOptions,\n RestoreAnalyzeBatchPollerOptions,\n TextAnalysisClientOptions,\n TextAnalysisOperationOptions,\n} from \"./models\";\nimport {\n AnalyzeBatchActionUnion,\n GeneratedClientOptionalParams,\n LanguageDetectionInput,\n TextDocumentInput,\n} from \"./generated/models\";\nimport { DEFAULT_COGNITIVE_SCOPE, SDK_VERSION } from \"./constants\";\nimport { KeyCredential, TokenCredential, isTokenCredential } from \"@azure/core-auth\";\nimport { TracingClient, createTracingClient } from \"@azure/core-tracing\";\nimport {\n convertToLanguageDetectionInput,\n convertToTextDocumentInput,\n getOperationOptions,\n isStringArray,\n} from \"./util\";\nimport {\n createAnalyzeBatchLro,\n createCreateAnalyzeBatchPollerLro,\n createPollerWithCancellation,\n createUpdateAnalyzeState,\n getDocIDsFromState,\n processAnalyzeResult,\n} from \"./lro\";\nimport { throwError, transformActionResult } from \"./transforms\";\nimport { GeneratedClient } from \"./generated/generatedClient\";\nimport { bearerTokenAuthenticationPolicy } from \"@azure/core-rest-pipeline\";\nimport { createHttpPoller } from \"@azure/core-lro\";\nimport { logger } from \"./logger\";\nimport { textAnalyticsAzureKeyCredentialPolicy } from \"./azureKeyCredentialPolicy\";\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 * ```js\n * import { TextAnalysisClient, AzureKeyCredential } from \"@azure/ai-language-text\";\n *\n * const endpoint = \"https://<resource name>.cognitiveservices.azure.com\";\n * const credential = new AzureKeyCredential(\"<api key>\");\n *\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 * ```js\n * import { TextAnalysisClient } from \"@azure/ai-language-text\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const endpoint = \"https://<resource name>.cognitiveservices.azure.com\";\n * const credential = new DefaultAzureCredential();\n *\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 * ```js\n * import { TextAnalysisClient, AzureKeyCredential } from \"@azure/ai-language-text\";\n *\n * const endpoint = \"https://<resource name>.cognitiveservices.azure.com\";\n * const credential = new AzureKeyCredential(\"<api key>\");\n *\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 * ```js\n * import { TextAnalysisClient } from \"@azure/ai-language-text\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const endpoint = \"https://<resource name>.cognitiveservices.azure.com\";\n * const credential = new DefaultAzureCredential();\n *\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://docs.microsoft.com//azure/cognitive-services/language-service/concepts/data-limits}\n * for data limits.\n *\n * ### Examples\n *\n * #### Language detection\n *\n * ```js\n * const documents = [<input strings>];\n * const countryHint = \"us\";\n * const results = await client.analyze(\"LanguageDetection\", documents, countryHint);\n *\n * for (let i = 0; i < results.length; i++) {\n * const result = results[i];\n * if (result.error) {\n * // a document has an error instead of results\n * } else {\n * const { name, confidenceScore, iso6391Name } = result.primaryLanguage;\n * }\n * }\n * ```\n *\n * See {@link https://docs.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://docs.microsoft.com//azure/cognitive-services/language-service/concepts/data-limits}\n * for data limits.\n *\n * ### Examples\n *\n * #### Language detection\n *\n * ```js\n * const documents = [<input strings>];\n * const countryHint = \"us\";\n * const results = await client.analyze(\"LanguageDetection\", documents, countryHint);\n *\n * for (const result of results) {\n * if (result.error) {\n * // a document has an error instead of results\n * } else {\n * const { name, confidenceScore, iso6391Name } = result.primaryLanguage;\n * }\n * }\n * ```\n *\n * See {@link https://docs.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://docs.microsoft.com//azure/cognitive-services/language-service/concepts/data-limits}\n * for data limits.\n *\n * ### Examples\n *\n * #### Opinion mining\n *\n * ```js\n * const documents = [{\n * id: \"1\",\n * text: \"The food and service aren't the best\",\n * language: \"en\"\n * }];\n * const results = await client.analyze(\"SentimentAnalysis\", documents, {\n * includeOpinionMining: true,\n * });\n *\n * for (const result of results) {\n * if (result.error) {\n * // a document has an error instead of results\n * } else {\n * const { sentiment, confidenceScores, sentences } = result;\n * for (const { sentiment, confidenceScores, opinions } of sentences) {\n * for (const { target, assessments } of opinions) {\n * const { text, sentiment, confidenceScores } = target;\n * for (const { text, sentiment } of assessments) {\n * // Do something\n * }\n * }\n * }\n * }\n * }\n * ```\n *\n * See {@link https://docs.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 * ```js\n * const documents = [<input documents>];\n * const categoriesFilter = [KnownPiiCategory.USSocialSecurityNumber];\n * const domainFilter = KnownPiiDomain.Phi;\n * const results = await client.analyze(\"PiiEntityRecognition\", documents, {\n * domainFilter, categoriesFilter\n * });\n *\n * for (const result of results) {\n * if (result.error) {\n * // a document has an error instead of results\n * } else {\n * const { entities, redactedText } = result;\n * for (const { text, category, confidenceScore, length, offset } of entities) {\n * // Do something\n * }\n * }\n * }\n * ```\n *\n * See {@link https://docs.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://docs.microsoft.com//azure/cognitive-services/language-service/concepts/data-limits}\n * for data limits.\n *\n * ### Examples\n *\n * #### Opinion mining\n *\n * ```js\n * const documents = [\"The food and service aren't the best\"];\n * const results = await client.analyze(\"SentimentAnalysis\", documents, {\n * includeOpinionMining: true,\n * });\n *\n * for (const result of results) {\n * if (result.error) {\n * // a document has an error instead of results\n * } else {\n * const { sentiment, confidenceScores, sentences } = result;\n * for (const { sentiment, confidenceScores, opinions } of sentences) {\n * for (const { target, assessments } of opinions) {\n * const { text, sentiment, confidenceScores } = target;\n * for (const { text, sentiment } of assessments) {\n * // Do something\n * }\n * }\n * }\n * }\n * }\n * ```\n *\n * See {@link https://docs.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 * ```js\n * const documents = [<input strings>];\n * const languageHint = \"en\";\n * const categoriesFilter = [KnownPiiCategory.USSocialSecurityNumber];\n * const domainFilter = KnownPiiDomain.Phi;\n * const results = await client.analyze(\"PiiEntityRecognition\", documents, languageHint, {\n * domainFilter, categoriesFilter\n * });\n *\n * for (const result of results) {\n * if (result.error) {\n * // a document has an error instead of results\n * } else {\n * const { entities, redactedText } = result;\n * for (const { text, category, confidenceScore, length, offset } of entities) {\n * // Do something\n * }\n * }\n * }\n * ```\n *\n * See {@link https://docs.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://docs.microsoft.com//azure/cognitive-services/language-service/named-entity-recognition/language-support}\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://docs.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 * ```js\n * const poller = await client.beginAnalyzeBatch(\n * [{ kind: \"KeyPhraseExtraction\" }, { kind: \"PiiEntityRecognition\" }],\n * documents\n * );\n * const actionResults = await poller.pollUntilDone();\n *\n * for await (const actionResult of actionResults) {\n * if (actionResult.error) {\n * throw new Error(`Unexpected error`);\n * }\n * switch (actionResult.kind) {\n * case \"KeyPhraseExtraction\": {\n * for (const doc of actionResult.results) {\n * // do something\n * }\n * break;\n * }\n * case \"PiiEntityRecognition\": {\n * for (const doc of actionResult.results) {\n * // do something\n * }\n * break;\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://docs.microsoft.com//azure/cognitive-services/language-service/named-entity-recognition/language-support}\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://docs.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 * ```js\n * const poller = await client.beginAnalyzeBatch(\n * [{ kind: \"KeyPhraseExtraction\" }, { kind: \"PiiEntityRecognition\" }],\n * documents\n * );\n * const actionResults = await poller.pollUntilDone();\n *\n * for await (const actionResult of actionResults) {\n * if (actionResult.error) {\n * throw new Error(`Unexpected error`);\n * }\n * switch (actionResult.kind) {\n * case \"KeyPhraseExtraction\": {\n * for (const doc of actionResult.results) {\n * // do something\n * }\n * break;\n * }\n * case \"PiiEntityRecognition\": {\n * for (const doc of actionResult.results) {\n * // do something\n * }\n * break;\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 languageHint = (languageOrOptions as string) ?? this.defaultLanguage;\n realInputs = convertToTextDocumentInput(documents, languageHint);\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 * # Example\n *\n * `client.beginAnalyzeBatch` returns a promise that will resolve to a poller.\n * The state of the poller can be serialized and used to create another as follows:\n *\n * ```js\n * const serializedState = poller.toString();\n * const rehydratedPoller = await client.createAnalyzeBatchPoller(serializedState);\n * const actionResults = await rehydratedPoller.pollUntilDone();\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,OAAO,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAkC,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrF,OAAO,EAAiB,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EACL,+BAA+B,EAC/B,0BAA0B,EAC1B,mBAAmB,EACnB,aAAa,GACd,MAAM,QAAQ,CAAC;AAChB,OAAO,EACL,qBAAqB,EACrB,iCAAiC,EACjC,4BAA4B,EAC5B,wBAAwB,EACxB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,qCAAqC,EAAE,MAAM,4BAA4B,CAAC;AAEnF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,OAAO,kBAAkB;IA8D7B,YACE,WAAmB,EACnB,UAA2C,EAC3C,UAAqC,EAAE;QAEvC,MAAM,EACJ,kBAAkB,GAAG,IAAI,EACzB,eAAe,GAAG,IAAI,EACtB,cAAc,KAEZ,OAAO,EADN,eAAe,UAChB,OAAO,EALL,2DAKL,CAAU,CAAC;QACZ,IAAI,CAAC,kBAAk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AI,CAAC,QAAQ;gBACtB,MAAM;gBACN,SAAS,kCAAO,IAAI,KAAE,iBAAiB,GAAE;gBACzC,KAAK;aACN,CAAC;YACF,WAAW,EAAE,wBAAwB,EAAE;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,4BAA4B,CAAC;YAClC,EAAE;YACF,MAAM,EAAE,IAAI,CAAC,OAAO;YACpB,OAAO;YACP,MAAM;YACN,OAAO,EAAE,IAAI,CAAC,QAAQ;SACvB,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n AnalyzeActionName,\n AnalyzeActionParameters,\n AnalyzeBatchAction,\n AnalyzeBatchPoller,\n AnalyzeResult,\n BeginAnalyzeBatchOptions,\n RestoreAnalyzeBatchPollerOptions,\n TextAnalysisClientOptions,\n TextAnalysisOperationOptions,\n} from \"./models\";\nimport {\n AnalyzeBatchActionUnion,\n GeneratedClientOptionalParams,\n LanguageDetectionInput,\n TextDocumentInput,\n} from \"./generated/models\";\nimport { DEFAULT_COGNITIVE_SCOPE, SDK_VERSION } from \"./constants\";\nimport { KeyCredential, TokenCredential, isTokenCredential } from \"@azure/core-auth\";\nimport { TracingClient, createTracingClient } from \"@azure/core-tracing\";\nimport {\n convertToLanguageDetectionInput,\n convertToTextDocumentInput,\n getOperationOptions,\n isStringArray,\n} from \"./util\";\nimport {\n createAnalyzeBatchLro,\n createCreateAnalyzeBatchPollerLro,\n createPollerWithCancellation,\n createUpdateAnalyzeState,\n getDocIDsFromState,\n processAnalyzeResult,\n} from \"./lro\";\nimport { throwError, transformActionResult } from \"./transforms\";\nimport { GeneratedClient } from \"./generated/generatedClient\";\nimport { bearerTokenAuthenticationPolicy } from \"@azure/core-rest-pipeline\";\nimport { createHttpPoller } from \"@azure/core-lro\";\nimport { logger } from \"./logger\";\nimport { textAnalyticsAzureKeyCredentialPolicy } from \"./azureKeyCredentialPolicy\";\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 * ```js\n * import { TextAnalysisClient, AzureKeyCredential } from \"@azure/ai-language-text\";\n *\n * const endpoint = \"https://<resource name>.cognitiveservices.azure.com\";\n * const credential = new AzureKeyCredential(\"<api key>\");\n *\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 * ```js\n * import { TextAnalysisClient } from \"@azure/ai-language-text\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const endpoint = \"https://<resource name>.cognitiveservices.azure.com\";\n * const credential = new DefaultAzureCredential();\n *\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 * ```js\n * import { TextAnalysisClient, AzureKeyCredential } from \"@azure/ai-language-text\";\n *\n * const endpoint = \"https://<resource name>.cognitiveservices.azure.com\";\n * const credential = new AzureKeyCredential(\"<api key>\");\n *\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 * ```js\n * import { TextAnalysisClient } from \"@azure/ai-language-text\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const endpoint = \"https://<resource name>.cognitiveservices.azure.com\";\n * const credential = new DefaultAzureCredential();\n *\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://docs.microsoft.com//azure/cognitive-services/language-service/concepts/data-limits}\n * for data limits.\n *\n * ### Examples\n *\n * #### Language detection\n *\n * ```js\n * const documents = [<input strings>];\n * const countryHint = \"us\";\n * const results = await client.analyze(\"LanguageDetection\", documents, countryHint);\n *\n * for (let i = 0; i < results.length; i++) {\n * const result = results[i];\n * if (result.error) {\n * // a document has an error instead of results\n * } else {\n * const { name, confidenceScore, iso6391Name } = result.primaryLanguage;\n * }\n * }\n * ```\n *\n * See {@link https://docs.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://docs.microsoft.com//azure/cognitive-services/language-service/concepts/data-limits}\n * for data limits.\n *\n * ### Examples\n *\n * #### Language detection\n *\n * ```js\n * const documents = [<input strings>];\n * const countryHint = \"us\";\n * const results = await client.analyze(\"LanguageDetection\", documents, countryHint);\n *\n * for (const result of results) {\n * if (result.error) {\n * // a document has an error instead of results\n * } else {\n * const { name, confidenceScore, iso6391Name } = result.primaryLanguage;\n * }\n * }\n * ```\n *\n * See {@link https://docs.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://docs.microsoft.com//azure/cognitive-services/language-service/concepts/data-limits}\n * for data limits.\n *\n * ### Examples\n *\n * #### Opinion mining\n *\n * ```js\n * const documents = [{\n * id: \"1\",\n * text: \"The food and service aren't the best\",\n * language: \"en\"\n * }];\n * const results = await client.analyze(\"SentimentAnalysis\", documents, {\n * includeOpinionMining: true,\n * });\n *\n * for (const result of results) {\n * if (result.error) {\n * // a document has an error instead of results\n * } else {\n * const { sentiment, confidenceScores, sentences } = result;\n * for (const { sentiment, confidenceScores, opinions } of sentences) {\n * for (const { target, assessments } of opinions) {\n * const { text, sentiment, confidenceScores } = target;\n * for (const { text, sentiment } of assessments) {\n * // Do something\n * }\n * }\n * }\n * }\n * }\n * ```\n *\n * See {@link https://docs.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 * ```js\n * const documents = [<input documents>];\n * const categoriesFilter = [KnownPiiCategory.USSocialSecurityNumber];\n * const domainFilter = KnownPiiDomain.Phi;\n * const results = await client.analyze(\"PiiEntityRecognition\", documents, {\n * domainFilter, categoriesFilter\n * });\n *\n * for (const result of results) {\n * if (result.error) {\n * // a document has an error instead of results\n * } else {\n * const { entities, redactedText } = result;\n * for (const { text, category, confidenceScore, length, offset } of entities) {\n * // Do something\n * }\n * }\n * }\n * ```\n *\n * See {@link https://docs.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://docs.microsoft.com//azure/cognitive-services/language-service/concepts/data-limits}\n * for data limits.\n *\n * ### Examples\n *\n * #### Opinion mining\n *\n * ```js\n * const documents = [\"The food and service aren't the best\"];\n * const results = await client.analyze(\"SentimentAnalysis\", documents, {\n * includeOpinionMining: true,\n * });\n *\n * for (const result of results) {\n * if (result.error) {\n * // a document has an error instead of results\n * } else {\n * const { sentiment, confidenceScores, sentences } = result;\n * for (const { sentiment, confidenceScores, opinions } of sentences) {\n * for (const { target, assessments } of opinions) {\n * const { text, sentiment, confidenceScores } = target;\n * for (const { text, sentiment } of assessments) {\n * // Do something\n * }\n * }\n * }\n * }\n * }\n * ```\n *\n * See {@link https://docs.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 * ```js\n * const documents = [<input strings>];\n * const languageHint = \"en\";\n * const categoriesFilter = [KnownPiiCategory.USSocialSecurityNumber];\n * const domainFilter = KnownPiiDomain.Phi;\n * const results = await client.analyze(\"PiiEntityRecognition\", documents, languageHint, {\n * domainFilter, categoriesFilter\n * });\n *\n * for (const result of results) {\n * if (result.error) {\n * // a document has an error instead of results\n * } else {\n * const { entities, redactedText } = result;\n * for (const { text, category, confidenceScore, length, offset } of entities) {\n * // Do something\n * }\n * }\n * }\n * ```\n *\n * See {@link https://docs.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://docs.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. If that process fails, the value in the `defaultLanguage`\n * option will be used.\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://docs.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 * ```js\n * const poller = await client.beginAnalyzeBatch(\n * [{ kind: \"KeyPhraseExtraction\" }, { kind: \"PiiEntityRecognition\" }],\n * documents\n * );\n * const actionResults = await poller.pollUntilDone();\n *\n * for await (const actionResult of actionResults) {\n * if (actionResult.error) {\n * throw new Error(`Unexpected error`);\n * }\n * switch (actionResult.kind) {\n * case \"KeyPhraseExtraction\": {\n * for (const doc of actionResult.results) {\n * // do something\n * }\n * break;\n * }\n * case \"PiiEntityRecognition\": {\n * for (const doc of actionResult.results) {\n * // do something\n * }\n * break;\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://docs.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. If that process fails, the value in the `defaultLanguage`\n * option will be used.\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://docs.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 * ```js\n * const poller = await client.beginAnalyzeBatch(\n * [{ kind: \"KeyPhraseExtraction\" }, { kind: \"PiiEntityRecognition\" }],\n * documents\n * );\n * const actionResults = await poller.pollUntilDone();\n *\n * for await (const actionResult of actionResults) {\n * if (actionResult.error) {\n * throw new Error(`Unexpected error`);\n * }\n * switch (actionResult.kind) {\n * case \"KeyPhraseExtraction\": {\n * for (const doc of actionResult.results) {\n * // do something\n * }\n * break;\n * }\n * case \"PiiEntityRecognition\": {\n * for (const doc of actionResult.results) {\n * // do something\n * }\n * break;\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 languageHint = (languageOrOptions as string) ?? this.defaultLanguage;\n realInputs = convertToTextDocumentInput(documents, languageHint);\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 * # Example\n *\n * `client.beginAnalyzeBatch` returns a promise that will resolve to a poller.\n * The state of the poller can be serialized and used to create another as follows:\n *\n * ```js\n * const serializedState = poller.toString();\n * const rehydratedPoller = await client.createAnalyzeBatchPoller(serializedState);\n * const actionResults = await rehydratedPoller.pollUntilDone();\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"]}
@@ -55,11 +55,7 @@ function toSentimentAnalysisResult(docIds, results) {
55
55
  });
56
56
  }
57
57
  function toDynamicClassificationResult(docIds, results) {
58
- return transformDocumentResults(docIds, results, {
59
- // FIXME: Fixing a service bug, see https://github.com/Azure/azure-sdk-for-js/issues/23617
60
- processSuccess: ({ class: classes, id, warnings, statistics, classifications, }) => (Object.assign({ id,
61
- warnings, classifications: classes ? classes : classifications !== null && classifications !== void 0 ? classifications : [] }, (statistics ? { statistics } : {}))),
62
- });
58
+ return transformDocumentResults(docIds, results);
63
59
  }
64
60
  /**
65
61
  * Converts a sentence sentiment object returned by the service to another that
@@ -198,18 +194,6 @@ export async function throwError(p) {
198
194
  throw transformError(e);
199
195
  }
200
196
  }
201
- export function deserializeDetectedLanguage(input) {
202
- function helper(str) {
203
- try {
204
- return JSON.parse(str);
205
- }
206
- catch (e) {
207
- return undefined;
208
- }
209
- }
210
- const obj = helper(input);
211
- return obj !== undefined ? obj : { iso6391Name: input };
212
- }
213
197
  function toHealthcareResult(docIds, results) {
214
198
  function makeHealthcareEntity(entity) {
215
199
  const { dataSources } = entity, rest = __rest(entity, ["dataSources"]);
@@ -229,17 +213,7 @@ function toHealthcareResult(docIds, results) {
229
213
  processSuccess: (_a) => {
230
214
  var { entities, relations, detectedLanguage } = _a, rest = __rest(_a, ["entities", "relations", "detectedLanguage"]);
231
215
  const newEntities = entities.map(makeHealthcareEntity);
232
- return Object.assign(Object.assign({ entities: newEntities, entityRelations: relations.map(makeHealthcareRelation(newEntities)) }, (detectedLanguage
233
- ? { detectedLanguage: deserializeDetectedLanguage(detectedLanguage) }
234
- : {})), rest);
235
- },
236
- });
237
- }
238
- function toCustomSingleLabelClassificationResult(docIds, results) {
239
- return transformDocumentResults(docIds, results, {
240
- processSuccess: (_a) => {
241
- var { class: classification } = _a, rest = __rest(_a, ["class"]);
242
- return Object.assign({ classifications: classification }, rest);
216
+ return Object.assign(Object.assign({ entities: newEntities, entityRelations: relations.map(makeHealthcareRelation(newEntities)) }, (detectedLanguage ? { detectedLanguage: { iso6391Name: detectedLanguage } } : {})), rest);
243
217
  },
244
218
  });
245
219
  }
@@ -289,13 +263,13 @@ export function transformAnalyzeBatchResults(docIds, response = []) {
289
263
  case "CustomSingleLabelClassificationLROResults": {
290
264
  const { results } = actionData;
291
265
  const { deploymentName, projectName, statistics } = results;
292
- return Object.assign(Object.assign(Object.assign({ kind: "CustomSingleLabelClassification", results: toCustomSingleLabelClassificationResult(docIds, results), completedOn }, (actionName ? { actionName } : {})), (statistics ? { statistics } : {})), { deploymentName,
266
+ return Object.assign(Object.assign(Object.assign({ kind: "CustomSingleLabelClassification", results: transformDocumentResults(docIds, results), completedOn }, (actionName ? { actionName } : {})), (statistics ? { statistics } : {})), { deploymentName,
293
267
  projectName });
294
268
  }
295
269
  case "CustomMultiLabelClassificationLROResults": {
296
270
  const { results } = actionData;
297
271
  const { deploymentName, projectName, statistics } = results;
298
- return Object.assign(Object.assign(Object.assign({ kind: "CustomMultiLabelClassification", results: toCustomSingleLabelClassificationResult(docIds, results), completedOn }, (actionName ? { actionName } : {})), (statistics ? { statistics } : {})), { deploymentName,
272
+ return Object.assign(Object.assign(Object.assign({ kind: "CustomMultiLabelClassification", results: transformDocumentResults(docIds, results), completedOn }, (actionName ? { actionName } : {})), (statistics ? { statistics } : {})), { deploymentName,
299
273
  projectName });
300
274
  }
301
275
  case "ExtractiveSummarizationLROResults": {
@@ -1 +1 @@
1
- {"version":3,"file":"transforms.js","sourceRoot":"","sources":["../../src/transforms.ts"],"names":[],"mapp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AAE,CAAC,CAAC,CAAC,EAAE,CAAC,KACrC,cAAc;oBACd,WAAW,IACX;aACH;YACD,KAAK,mCAAmC,CAAC,CAAC;gBACxC,MAAM,EAAE,OAAO,EAAE,GAAG,UAA8C,CAAC;gBACnE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;gBAC7C,mDACE,IAAI,EAAE,yBAAyB,EAC/B,OAAO,EAAE,wBAAwB,CAC/B,MAAM,EACN,OAAO,CACR,EACD,WAAW,IACR,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GAClC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KACrC,YAAY,IACZ;aACH;YACD,KAAK,oCAAoC,CAAC,CAAC;gBACzC,MAAM,EAAE,OAAO,EAAE,GAAG,UAA+C,CAAC;gBACpE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;gBAC7C,mDACE,IAAI,EAAE,0BAA0B,EAChC,OAAO,EAAE,wBAAwB,CAC/B,MAAM,EACN,OAAO,CACR,EACD,WAAW,IACR,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GAClC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KACrC,YAAY,IACZ;aACH;YACD,OAAO,CAAC,CAAC;gBACP,MAAM,IAAI,KAAK,CAAC,6BAA6B,IAAI,EAAE,CAAC,CAAC;aACtD;SACF;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n AbstractiveSummarizationLROResult,\n AnalyzeResponse,\n AnalyzeTextLROResultUnion,\n AssessmentSentiment,\n ClassificationDocumentResult,\n CustomEntityRecognitionLROResult,\n CustomMultiLabelClassificationLROResult,\n CustomSingleLabelClassificationLROResult,\n DocumentError,\n DynamicClassificationTaskResult,\n EntitiesTaskResult,\n EntityLinkingLROResult,\n EntityLinkingTaskResult,\n EntityRecognitionLROResult,\n ErrorModel,\n ErrorResponse,\n ExtractiveSummarizationLROResult,\n CustomLabelClassificationResult as GeneratedCustomClassificationResult,\n DynamicClassificationResult as GeneratedDynamicClassification,\n EntityLinkingResult as GeneratedEntityLinkingResult,\n EntitiesResult as GeneratedEntityRecognitionResult,\n HealthcareEntity as GeneratedHealthcareEntity,\n HealthcareResult as GeneratedHealthcareResult,\n KeyPhraseResult as GeneratedKeyPhraseExtractionResult,\n LanguageDetectionResult as GeneratedLanguageDetectionResult,\n PiiResult as GeneratedPiiEntityRecognitionResult,\n SentenceSentiment as GeneratedSentenceSentiment,\n SentimentResponse as GeneratedSentimentAnalysisResult,\n HealthcareLROResult,\n HealthcareRelation,\n HealthcareRelationEntity,\n InnerErrorModel,\n KeyPhraseExtractionLROResult,\n KeyPhraseTaskResult,\n KnownAnalyzeTextLROResultsKind,\n LanguageDetectionTaskResult,\n PiiEntityRecognitionLROResult,\n PiiTaskResult,\n SentenceTarget,\n SentimentLROResult,\n SentimentTaskResult,\n TargetRelation,\n DynamicClassificationResultDocumentsItem,\n ClassificationCategory,\n CustomEntitiesResultDocumentsItem,\n ExtractedSummaryDocumentResultWithDetectedLanguage,\n AbstractiveSummaryDocumentResultWithDetectedLanguage,\n HealthcareResultDocumentsItem,\n DetectedLanguage,\n} from \"./generated\";\nimport {\n AnalyzeActionName,\n AnalyzeBatchResult,\n AnalyzeResult,\n CustomSingleLabelClassificationResult,\n CustomSingleLabelClassificationSuccessResult,\n DynamicClassificationResult,\n EntityLinkingResult,\n EntityRecognitionResult,\n HealthcareEntity,\n HealthcareEntityRelation,\n HealthcareEntityRelationRole,\n HealthcareResult,\n HealthcareSuccessResult,\n KeyPhraseExtractionResult,\n LanguageDetectionResult,\n Opinion,\n PiiEntityRecognitionResult,\n SentenceSentiment,\n SentimentAnalysisResult,\n TextAnalysisError,\n TextAnalysisErrorResult,\n TextAnalysisSuccessResult,\n WithDetectedLanguage,\n} from \"./models\";\nimport {\n AssessmentIndex,\n parseAssessmentIndex,\n parseHealthcareEntityIndex,\n sortResponseIdObjects,\n} from \"./util\";\nimport { RestError } from \"@azure/core-rest-pipeline\";\n\n/**\n * Helper function for converting nested service error to the unified\n * TextAnalysisError\n */\nfunction toTextAnalysisError(errorModel: ErrorModel | InnerErrorModel): TextAnalysisError {\n // Return the deepest error.\n if (errorModel.innererror !== undefined) {\n return toTextAnalysisError(errorModel.innererror);\n }\n\n return {\n ...errorModel,\n };\n}\n\nfunction makeTextAnalysisErrorResult(id: string, error: ErrorModel): TextAnalysisErrorResult {\n return {\n id,\n error: toTextAnalysisError(error),\n };\n}\n\n/**\n * combines successful and erroneous results into a single array of results and\n * sort them so that the IDs order match that of the input documents array.\n * @param ids - the array of input document IDs.\n * @param response - the response received from the service.\n * @param options - an options bag that includes functions to process the results.\n */\nfunction transformDocumentResults<\n DocumentSuccess extends TextAnalysisSuccessResult,\n PublicDocumentSuccess extends TextAnalysisSuccessResult = DocumentSuccess,\n TError extends TextAnalysisErrorResult = TextAnalysisErrorResult\n>(\n ids: string[],\n response: {\n documents: DocumentSuccess[];\n errors: DocumentError[];\n },\n options?: {\n processSuccess?: (successResult: DocumentSuccess) => PublicDocumentSuccess;\n processError?: (id: string, error: ErrorModel) => TError;\n }\n): (PublicDocumentSuccess | TextAnalysisErrorResult)[] {\n const { processError = makeTextAnalysisErrorResult, processSuccess } = options || {};\n const successResults = processSuccess\n ? response.documents.map(processSuccess)\n : response.documents;\n const unsortedResults = (\n successResults as (PublicDocumentSuccess | TextAnalysisErrorResult)[]\n ).concat(response.errors.map((error) => processError(error.id, error.error)));\n\n return sortResponseIdObjects(ids, unsortedResults);\n}\n\nfunction toLanguageDetectionResult(\n docIds: string[],\n results: GeneratedLanguageDetectionResult\n): LanguageDetectionResult[] {\n return transformDocumentResults(docIds, results, {\n processSuccess: ({ detectedLanguage, ...rest }) => ({\n primaryLanguage: detectedLanguage,\n ...rest,\n }),\n });\n}\n\nfunction toPiiEntityRecognitionResult(\n docIds: string[],\n results: GeneratedPiiEntityRecognitionResult\n): PiiEntityRecognitionResult[] {\n return transformDocumentResults(docIds, results);\n}\n\nfunction toSentimentAnalysisResult(\n docIds: string[],\n results: GeneratedSentimentAnalysisResult\n): SentimentAnalysisResult[] {\n return transformDocumentResults(docIds, results, {\n processSuccess: ({ sentences, ...rest }) => ({\n ...rest,\n sentences: sentences.map((sentence) =>\n convertGeneratedSentenceSentiment(sentence, sentences)\n ),\n }),\n });\n}\n\nfunction toDynamicClassificationResult(\n docIds: string[],\n results: GeneratedDynamicClassification\n): DynamicClassificationResult[] {\n return transformDocumentResults(docIds, results, {\n // FIXME: Fixing a service bug, see https://github.com/Azure/azure-sdk-for-js/issues/23617\n processSuccess: ({\n class: classes,\n id,\n warnings,\n statistics,\n classifications,\n }: DynamicClassificationResultDocumentsItem & {\n classifications?: ClassificationCategory[];\n }) => ({\n id,\n warnings,\n classifications: classes ? classes : classifications ?? [],\n ...(statistics ? { statistics } : {}),\n }),\n });\n}\n\n/**\n * Converts a sentence sentiment object returned by the service to another that\n * is user-friendly.\n *\n * @param sentence - The sentence sentiment object to be converted.\n * @param response - The entire response returned by the service.\n * @returns The user-friendly sentence sentiment object.\n * @internal\n */\nfunction convertGeneratedSentenceSentiment(\n { targets, assessments: _, ...rest }: GeneratedSentenceSentiment,\n sentences: GeneratedSentenceSentiment[]\n): SentenceSentiment {\n return {\n ...rest,\n opinions:\n targets?.map(\n // eslint-disable-next-line @typescript-eslint/no-shadow\n ({ relations, ...rest }: SentenceTarget): Opinion => ({\n target: rest,\n assessments: relations\n .filter((relation) => relation.relationType === \"assessment\")\n .map((relation) => convertTargetRelationToAssessmentSentiment(relation, sentences)),\n })\n ) ?? [],\n };\n}\n\n/**\n * Converts a target relation object returned by the service to an assessment\n * sentiment object where JSON pointers in the former are realized in the\n * latter.\n *\n * @param targetRelation - The target relation object to be converted.\n * @param response - The entire response returned by the service.\n * @returns The user-friendly assessment sentiment object.\n * @internal\n */\nfunction convertTargetRelationToAssessmentSentiment(\n targetRelation: TargetRelation,\n sentences: GeneratedSentenceSentiment[]\n): AssessmentSentiment {\n const assessmentPtr = targetRelation.ref;\n const assessmentIndex: AssessmentIndex = parseAssessmentIndex(assessmentPtr);\n const assessment =\n sentences?.[assessmentIndex.sentence].assessments?.[assessmentIndex.assessment];\n if (assessment !== undefined) {\n return assessment;\n } else {\n throw new Error(`Pointer \"${assessmentPtr}\" is not a valid Assessment pointer`);\n }\n}\n\nfunction toEntityLinkingResult(\n docIds: string[],\n results: GeneratedEntityLinkingResult\n): EntityLinkingResult[] {\n return transformDocumentResults(docIds, results);\n}\n\nfunction toKeyPhraseExtractionResult(\n docIds: string[],\n results: GeneratedKeyPhraseExtractionResult\n): KeyPhraseExtractionResult[] {\n return transformDocumentResults(docIds, results);\n}\n\nfunction toEntityRecognitionResult(\n docIds: string[],\n results: GeneratedEntityRecognitionResult\n): EntityRecognitionResult[] {\n return transformDocumentResults(docIds, results);\n}\n\n/**\n * @internal\n */\nexport function transformActionResult<ActionName extends AnalyzeActionName>(\n actionName: ActionName,\n docIds: string[],\n response: AnalyzeResponse\n): AnalyzeResult<AnalyzeActionName> {\n switch (response.kind) {\n case \"EntityLinkingResults\": {\n return toEntityLinkingResult(docIds, (response as EntityLinkingTaskResult).results);\n }\n case \"EntityRecognitionResults\": {\n return toEntityRecognitionResult(docIds, (response as EntitiesTaskResult).results);\n }\n case \"KeyPhraseExtractionResults\": {\n return toKeyPhraseExtractionResult(docIds, (response as KeyPhraseTaskResult).results);\n }\n case \"PiiEntityRecognitionResults\": {\n return toPiiEntityRecognitionResult(docIds, (response as PiiTaskResult).results);\n }\n case \"SentimentAnalysisResults\": {\n return toSentimentAnalysisResult(docIds, (response as SentimentTaskResult).results);\n }\n case \"LanguageDetectionResults\": {\n return toLanguageDetectionResult(docIds, (response as LanguageDetectionTaskResult).results);\n }\n case \"DynamicClassificationResults\": {\n return toDynamicClassificationResult(\n docIds,\n (response as DynamicClassificationTaskResult).results\n );\n }\n default: {\n const __exhaust: never = response;\n throw new Error(`Unsupported results kind: ${__exhaust} for an action of type ${actionName}`);\n }\n }\n}\n\nfunction appendReadableErrorMessage(currentMessage: string, innerMessage: string): string {\n let message = currentMessage;\n if (message.slice(-1) !== \".\") {\n message = message + \".\";\n }\n return message + \" \" + innerMessage;\n}\n\n/**\n * @internal\n * parses incoming errors from the service/\n * @param error - the incoming error\n */\nfunction transformError(errorResponse: unknown): any {\n const strongErrorResponse = errorResponse as {\n response: {\n parsedBody?: ErrorResponse;\n };\n statusCode: number;\n };\n if (!strongErrorResponse.response) {\n throw errorResponse;\n }\n const topLevelError = strongErrorResponse.response.parsedBody?.error;\n if (!topLevelError) return errorResponse;\n let errorMessage = topLevelError.message;\n let code = topLevelError.code;\n function unwrap(error: ErrorModel | InnerErrorModel): ErrorModel {\n const innerError = error.innererror;\n if (innerError) {\n if (innerError.message) {\n errorMessage = appendReadableErrorMessage(errorMessage, innerError.message);\n }\n if (innerError.code) {\n code = innerError.code;\n }\n return unwrap(innerError);\n }\n return error as ErrorModel;\n }\n unwrap(topLevelError);\n return new RestError(errorMessage, {\n code,\n statusCode: strongErrorResponse.statusCode,\n });\n}\n\nexport async function throwError<T>(p: Promise<T>): Promise<T> {\n try {\n return await p;\n } catch (e: unknown) {\n throw transformError(e);\n }\n}\n\nexport function deserializeDetectedLanguage(input: string): DetectedLanguage {\n function helper(str: string): undefined {\n try {\n return JSON.parse(str);\n } catch (e) {\n return undefined;\n }\n }\n const obj = helper(input);\n return obj !== undefined ? obj : ({ iso6391Name: input } as any);\n}\n\nfunction toHealthcareResult(\n docIds: string[],\n results: GeneratedHealthcareResult\n): HealthcareResult[] {\n function makeHealthcareEntity(entity: GeneratedHealthcareEntity): HealthcareEntity {\n const { dataSources, ...rest } = entity;\n return {\n dataSources: dataSources ?? [],\n ...rest,\n };\n }\n function makeHealthcareRelation(\n entities: HealthcareEntity[]\n ): (relation: HealthcareRelation) => HealthcareEntityRelation {\n return ({\n entities: generatedEntities,\n relationType,\n confidenceScore,\n }: HealthcareRelation): HealthcareEntityRelation => ({\n relationType: relationType,\n confidenceScore,\n roles: generatedEntities.map(\n (role: HealthcareRelationEntity): HealthcareEntityRelationRole => ({\n entity: entities[parseHealthcareEntityIndex(role.ref)],\n name: role.role,\n })\n ),\n });\n }\n return transformDocumentResults<\n HealthcareResultDocumentsItem,\n WithDetectedLanguage<HealthcareSuccessResult>\n >(docIds, results, {\n processSuccess: ({ entities, relations, detectedLanguage, ...rest }) => {\n const newEntities = entities.map(makeHealthcareEntity);\n return {\n entities: newEntities,\n entityRelations: relations.map(makeHealthcareRelation(newEntities)),\n // FIXME: remove this mitigation when the API fixes the representation on their end\n ...(detectedLanguage\n ? { detectedLanguage: deserializeDetectedLanguage(detectedLanguage) }\n : {}),\n ...rest,\n };\n },\n });\n}\n\nfunction toCustomSingleLabelClassificationResult(\n docIds: string[],\n results: GeneratedCustomClassificationResult\n): CustomSingleLabelClassificationResult[] {\n return transformDocumentResults<\n ClassificationDocumentResult,\n CustomSingleLabelClassificationSuccessResult\n >(docIds, results, {\n processSuccess: ({ class: classification, ...rest }) => {\n return {\n classifications: classification,\n ...rest,\n };\n },\n });\n}\n\n/**\n * @internal\n */\nexport function transformAnalyzeBatchResults(\n docIds: string[],\n response: AnalyzeTextLROResultUnion[] = []\n): AnalyzeBatchResult[] {\n return response.map((actionData) => {\n const { lastUpdateDateTime: completedOn, actionName, kind } = actionData;\n switch (kind as KnownAnalyzeTextLROResultsKind) {\n case \"SentimentAnalysisLROResults\": {\n const { results } = actionData as SentimentLROResult;\n const { modelVersion, statistics } = results;\n return {\n kind: \"SentimentAnalysis\",\n results: toSentimentAnalysisResult(docIds, results),\n completedOn,\n ...(actionName ? { actionName } : {}),\n ...(statistics ? { statistics } : {}),\n modelVersion,\n };\n }\n case \"EntityRecognitionLROResults\": {\n const { results } = actionData as EntityRecognitionLROResult;\n const { modelVersion, statistics } = results;\n return {\n kind: \"EntityRecognition\",\n results: toEntityRecognitionResult(docIds, results),\n completedOn,\n ...(actionName ? { actionName } : {}),\n ...(statistics ? { statistics } : {}),\n modelVersion,\n };\n }\n case \"PiiEntityRecognitionLROResults\": {\n const { results } = actionData as PiiEntityRecognitionLROResult;\n const { modelVersion, statistics } = results;\n return {\n kind: \"PiiEntityRecognition\",\n results: toPiiEntityRecognitionResult(docIds, results),\n completedOn,\n ...(actionName ? { actionName } : {}),\n ...(statistics ? { statistics } : {}),\n modelVersion,\n };\n }\n case \"KeyPhraseExtractionLROResults\": {\n const { results } = actionData as KeyPhraseExtractionLROResult;\n const { modelVersion, statistics } = results;\n return {\n kind: \"KeyPhraseExtraction\",\n results: toKeyPhraseExtractionResult(docIds, results),\n completedOn,\n ...(actionName ? { actionName } : {}),\n ...(statistics ? { statistics } : {}),\n modelVersion,\n };\n }\n case \"EntityLinkingLROResults\": {\n const { results } = actionData as EntityLinkingLROResult;\n const { modelVersion, statistics } = results;\n return {\n kind: \"EntityLinking\",\n results: toEntityLinkingResult(docIds, results),\n completedOn,\n ...(actionName ? { actionName } : {}),\n ...(statistics ? { statistics } : {}),\n modelVersion,\n };\n }\n case \"HealthcareLROResults\": {\n const { results } = actionData as HealthcareLROResult;\n const { modelVersion, statistics } = results;\n return {\n kind: \"Healthcare\",\n results: toHealthcareResult(docIds, results),\n completedOn,\n ...(actionName ? { actionName } : {}),\n ...(statistics ? { statistics } : {}),\n modelVersion,\n };\n }\n case \"CustomEntityRecognitionLROResults\": {\n const { results } = actionData as CustomEntityRecognitionLROResult;\n const { deploymentName, projectName, statistics } = results;\n return {\n kind: \"CustomEntityRecognition\",\n results: transformDocumentResults<CustomEntitiesResultDocumentsItem>(docIds, results),\n completedOn,\n ...(actionName ? { actionName } : {}),\n ...(statistics ? { statistics } : {}),\n deploymentName,\n projectName,\n };\n }\n case \"CustomSingleLabelClassificationLROResults\": {\n const { results } = actionData as CustomSingleLabelClassificationLROResult;\n const { deploymentName, projectName, statistics } = results;\n return {\n kind: \"CustomSingleLabelClassification\",\n results: toCustomSingleLabelClassificationResult(docIds, results),\n completedOn,\n ...(actionName ? { actionName } : {}),\n ...(statistics ? { statistics } : {}),\n deploymentName,\n projectName,\n };\n }\n case \"CustomMultiLabelClassificationLROResults\": {\n const { results } = actionData as CustomMultiLabelClassificationLROResult;\n const { deploymentName, projectName, statistics } = results;\n return {\n kind: \"CustomMultiLabelClassification\",\n results: toCustomSingleLabelClassificationResult(docIds, results),\n completedOn,\n ...(actionName ? { actionName } : {}),\n ...(statistics ? { statistics } : {}),\n deploymentName,\n projectName,\n };\n }\n case \"ExtractiveSummarizationLROResults\": {\n const { results } = actionData as ExtractiveSummarizationLROResult;\n const { modelVersion, statistics } = results;\n return {\n kind: \"ExtractiveSummarization\",\n results: transformDocumentResults<ExtractedSummaryDocumentResultWithDetectedLanguage>(\n docIds,\n results\n ),\n completedOn,\n ...(actionName ? { actionName } : {}),\n ...(statistics ? { statistics } : {}),\n modelVersion,\n };\n }\n case \"AbstractiveSummarizationLROResults\": {\n const { results } = actionData as AbstractiveSummarizationLROResult;\n const { modelVersion, statistics } = results;\n return {\n kind: \"AbstractiveSummarization\",\n results: transformDocumentResults<AbstractiveSummaryDocumentResultWithDetectedLanguage>(\n docIds,\n results\n ),\n completedOn,\n ...(actionName ? { actionName } : {}),\n ...(statistics ? { statistics } : {}),\n modelVersion,\n };\n }\n default: {\n throw new Error(`Unsupported results kind: ${kind}`);\n }\n }\n });\n}\n"]}
1
+ {"version":3,"file":"transforms.js","sourceRoot":"","sources":["../../src/transforms.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAwElC,OAAO,EAEL,oBAAoB,EACpB,0BAA0B,EAC1B,qBAAqB,GACtB,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,C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CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KACrC,cAAc;oBACd,WAAW,IACX;aACH;YACD,KAAK,mCAAmC,CAAC,CAAC;gBACxC,MAAM,EAAE,OAAO,EAAE,GAAG,UAA8C,CAAC;gBACnE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;gBAC7C,mDACE,IAAI,EAAE,yBAAyB,EAC/B,OAAO,EAAE,wBAAwB,CAC/B,MAAM,EACN,OAAO,CACR,EACD,WAAW,IACR,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GAClC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KACrC,YAAY,IACZ;aACH;YACD,KAAK,oCAAoC,CAAC,CAAC;gBACzC,MAAM,EAAE,OAAO,EAAE,GAAG,UAA+C,CAAC;gBACpE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;gBAC7C,mDACE,IAAI,EAAE,0BAA0B,EAChC,OAAO,EAAE,wBAAwB,CAC/B,MAAM,EACN,OAAO,CACR,EACD,WAAW,IACR,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GAClC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KACrC,YAAY,IACZ;aACH;YACD,OAAO,CAAC,CAAC;gBACP,MAAM,IAAI,KAAK,CAAC,6BAA6B,IAAI,EAAE,CAAC,CAAC;aACtD;SACF;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n AbstractiveSummarizationLROResult,\n AnalyzeResponse,\n AnalyzeTextLROResultUnion,\n AssessmentSentiment,\n CustomEntityRecognitionLROResult,\n CustomMultiLabelClassificationLROResult,\n CustomSingleLabelClassificationLROResult,\n DocumentError,\n DynamicClassificationTaskResult,\n EntitiesTaskResult,\n EntityLinkingLROResult,\n EntityLinkingTaskResult,\n EntityRecognitionLROResult,\n ErrorModel,\n ErrorResponse,\n ExtractiveSummarizationLROResult,\n DynamicClassificationResult as GeneratedDynamicClassification,\n EntityLinkingResult as GeneratedEntityLinkingResult,\n EntitiesResult as GeneratedEntityRecognitionResult,\n HealthcareEntity as GeneratedHealthcareEntity,\n HealthcareResult as GeneratedHealthcareResult,\n KeyPhraseResult as GeneratedKeyPhraseExtractionResult,\n LanguageDetectionResult as GeneratedLanguageDetectionResult,\n PiiResult as GeneratedPiiEntityRecognitionResult,\n SentenceSentiment as GeneratedSentenceSentiment,\n SentimentResponse as GeneratedSentimentAnalysisResult,\n HealthcareLROResult,\n HealthcareRelation,\n HealthcareRelationEntity,\n InnerErrorModel,\n KeyPhraseExtractionLROResult,\n KeyPhraseTaskResult,\n KnownAnalyzeTextLROResultsKind,\n LanguageDetectionTaskResult,\n PiiEntityRecognitionLROResult,\n PiiTaskResult,\n SentenceTarget,\n SentimentLROResult,\n SentimentTaskResult,\n TargetRelation,\n CustomEntitiesResultDocumentsItem,\n ExtractedSummaryDocumentResultWithDetectedLanguage,\n AbstractiveSummaryDocumentResultWithDetectedLanguage,\n HealthcareEntitiesDocumentResultWithDocumentDetectedLanguage,\n CustomLabelClassificationResultDocumentsItem,\n} from \"./generated\";\nimport {\n AnalyzeActionName,\n AnalyzeBatchResult,\n AnalyzeResult,\n DynamicClassificationResult,\n EntityLinkingResult,\n EntityRecognitionResult,\n HealthcareEntity,\n HealthcareEntityRelation,\n HealthcareEntityRelationRole,\n HealthcareResult,\n HealthcareSuccessResult,\n KeyPhraseExtractionResult,\n LanguageDetectionResult,\n Opinion,\n PiiEntityRecognitionResult,\n SentenceSentiment,\n SentimentAnalysisResult,\n TextAnalysisError,\n TextAnalysisErrorResult,\n TextAnalysisSuccessResult,\n WithDetectedLanguage,\n} from \"./models\";\nimport {\n AssessmentIndex,\n parseAssessmentIndex,\n parseHealthcareEntityIndex,\n sortResponseIdObjects,\n} from \"./util\";\nimport { RestError } from \"@azure/core-rest-pipeline\";\n\n/**\n * Helper function for converting nested service error to the unified\n * TextAnalysisError\n */\nfunction toTextAnalysisError(errorModel: ErrorModel | InnerErrorModel): TextAnalysisError {\n // Return the deepest error.\n if (errorModel.innererror !== undefined) {\n return toTextAnalysisError(errorModel.innererror);\n }\n\n return {\n ...errorModel,\n };\n}\n\nfunction makeTextAnalysisErrorResult(id: string, error: ErrorModel): TextAnalysisErrorResult {\n return {\n id,\n error: toTextAnalysisError(error),\n };\n}\n\n/**\n * combines successful and erroneous results into a single array of results and\n * sort them so that the IDs order match that of the input documents array.\n * @param ids - the array of input document IDs.\n * @param response - the response received from the service.\n * @param options - an options bag that includes functions to process the results.\n */\nfunction transformDocumentResults<\n DocumentSuccess extends TextAnalysisSuccessResult,\n PublicDocumentSuccess extends TextAnalysisSuccessResult = DocumentSuccess,\n TError extends TextAnalysisErrorResult = TextAnalysisErrorResult\n>(\n ids: string[],\n response: {\n documents: DocumentSuccess[];\n errors: DocumentError[];\n },\n options?: {\n processSuccess?: (successResult: DocumentSuccess) => PublicDocumentSuccess;\n processError?: (id: string, error: ErrorModel) => TError;\n }\n): (PublicDocumentSuccess | TextAnalysisErrorResult)[] {\n const { processError = makeTextAnalysisErrorResult, processSuccess } = options || {};\n const successResults = processSuccess\n ? response.documents.map(processSuccess)\n : response.documents;\n const unsortedResults = (\n successResults as (PublicDocumentSuccess | TextAnalysisErrorResult)[]\n ).concat(response.errors.map((error) => processError(error.id, error.error)));\n\n return sortResponseIdObjects(ids, unsortedResults);\n}\n\nfunction toLanguageDetectionResult(\n docIds: string[],\n results: GeneratedLanguageDetectionResult\n): LanguageDetectionResult[] {\n return transformDocumentResults(docIds, results, {\n processSuccess: ({ detectedLanguage, ...rest }) => ({\n primaryLanguage: detectedLanguage,\n ...rest,\n }),\n });\n}\n\nfunction toPiiEntityRecognitionResult(\n docIds: string[],\n results: GeneratedPiiEntityRecognitionResult\n): PiiEntityRecognitionResult[] {\n return transformDocumentResults(docIds, results);\n}\n\nfunction toSentimentAnalysisResult(\n docIds: string[],\n results: GeneratedSentimentAnalysisResult\n): SentimentAnalysisResult[] {\n return transformDocumentResults(docIds, results, {\n processSuccess: ({ sentences, ...rest }) => ({\n ...rest,\n sentences: sentences.map((sentence) =>\n convertGeneratedSentenceSentiment(sentence, sentences)\n ),\n }),\n });\n}\n\nfunction toDynamicClassificationResult(\n docIds: string[],\n results: GeneratedDynamicClassification\n): DynamicClassificationResult[] {\n return transformDocumentResults(docIds, results);\n}\n\n/**\n * Converts a sentence sentiment object returned by the service to another that\n * is user-friendly.\n *\n * @param sentence - The sentence sentiment object to be converted.\n * @param response - The entire response returned by the service.\n * @returns The user-friendly sentence sentiment object.\n * @internal\n */\nfunction convertGeneratedSentenceSentiment(\n { targets, assessments: _, ...rest }: GeneratedSentenceSentiment,\n sentences: GeneratedSentenceSentiment[]\n): SentenceSentiment {\n return {\n ...rest,\n opinions:\n targets?.map(\n // eslint-disable-next-line @typescript-eslint/no-shadow\n ({ relations, ...rest }: SentenceTarget): Opinion => ({\n target: rest,\n assessments: relations\n .filter((relation) => relation.relationType === \"assessment\")\n .map((relation) => convertTargetRelationToAssessmentSentiment(relation, sentences)),\n })\n ) ?? [],\n };\n}\n\n/**\n * Converts a target relation object returned by the service to an assessment\n * sentiment object where JSON pointers in the former are realized in the\n * latter.\n *\n * @param targetRelation - The target relation object to be converted.\n * @param response - The entire response returned by the service.\n * @returns The user-friendly assessment sentiment object.\n * @internal\n */\nfunction convertTargetRelationToAssessmentSentiment(\n targetRelation: TargetRelation,\n sentences: GeneratedSentenceSentiment[]\n): AssessmentSentiment {\n const assessmentPtr = targetRelation.ref;\n const assessmentIndex: AssessmentIndex = parseAssessmentIndex(assessmentPtr);\n const assessment =\n sentences?.[assessmentIndex.sentence].assessments?.[assessmentIndex.assessment];\n if (assessment !== undefined) {\n return assessment;\n } else {\n throw new Error(`Pointer \"${assessmentPtr}\" is not a valid Assessment pointer`);\n }\n}\n\nfunction toEntityLinkingResult(\n docIds: string[],\n results: GeneratedEntityLinkingResult\n): EntityLinkingResult[] {\n return transformDocumentResults(docIds, results);\n}\n\nfunction toKeyPhraseExtractionResult(\n docIds: string[],\n results: GeneratedKeyPhraseExtractionResult\n): KeyPhraseExtractionResult[] {\n return transformDocumentResults(docIds, results);\n}\n\nfunction toEntityRecognitionResult(\n docIds: string[],\n results: GeneratedEntityRecognitionResult\n): EntityRecognitionResult[] {\n return transformDocumentResults(docIds, results);\n}\n\n/**\n * @internal\n */\nexport function transformActionResult<ActionName extends AnalyzeActionName>(\n actionName: ActionName,\n docIds: string[],\n response: AnalyzeResponse\n): AnalyzeResult<AnalyzeActionName> {\n switch (response.kind) {\n case \"EntityLinkingResults\": {\n return toEntityLinkingResult(docIds, (response as EntityLinkingTaskResult).results);\n }\n case \"EntityRecognitionResults\": {\n return toEntityRecognitionResult(docIds, (response as EntitiesTaskResult).results);\n }\n case \"KeyPhraseExtractionResults\": {\n return toKeyPhraseExtractionResult(docIds, (response as KeyPhraseTaskResult).results);\n }\n case \"PiiEntityRecognitionResults\": {\n return toPiiEntityRecognitionResult(docIds, (response as PiiTaskResult).results);\n }\n case \"SentimentAnalysisResults\": {\n return toSentimentAnalysisResult(docIds, (response as SentimentTaskResult).results);\n }\n case \"LanguageDetectionResults\": {\n return toLanguageDetectionResult(docIds, (response as LanguageDetectionTaskResult).results);\n }\n case \"DynamicClassificationResults\": {\n return toDynamicClassificationResult(\n docIds,\n (response as DynamicClassificationTaskResult).results\n );\n }\n default: {\n const __exhaust: never = response;\n throw new Error(`Unsupported results kind: ${__exhaust} for an action of type ${actionName}`);\n }\n }\n}\n\nfunction appendReadableErrorMessage(currentMessage: string, innerMessage: string): string {\n let message = currentMessage;\n if (message.slice(-1) !== \".\") {\n message = message + \".\";\n }\n return message + \" \" + innerMessage;\n}\n\n/**\n * @internal\n * parses incoming errors from the service/\n * @param error - the incoming error\n */\nfunction transformError(errorResponse: unknown): any {\n const strongErrorResponse = errorResponse as {\n response: {\n parsedBody?: ErrorResponse;\n };\n statusCode: number;\n };\n if (!strongErrorResponse.response) {\n throw errorResponse;\n }\n const topLevelError = strongErrorResponse.response.parsedBody?.error;\n if (!topLevelError) return errorResponse;\n let errorMessage = topLevelError.message;\n let code = topLevelError.code;\n function unwrap(error: ErrorModel | InnerErrorModel): ErrorModel {\n const innerError = error.innererror;\n if (innerError) {\n if (innerError.message) {\n errorMessage = appendReadableErrorMessage(errorMessage, innerError.message);\n }\n if (innerError.code) {\n code = innerError.code;\n }\n return unwrap(innerError);\n }\n return error as ErrorModel;\n }\n unwrap(topLevelError);\n return new RestError(errorMessage, {\n code,\n statusCode: strongErrorResponse.statusCode,\n });\n}\n\nexport async function throwError<T>(p: Promise<T>): Promise<T> {\n try {\n return await p;\n } catch (e: unknown) {\n throw transformError(e);\n }\n}\n\nfunction toHealthcareResult(\n docIds: string[],\n results: GeneratedHealthcareResult\n): HealthcareResult[] {\n function makeHealthcareEntity(entity: GeneratedHealthcareEntity): HealthcareEntity {\n const { dataSources, ...rest } = entity;\n return {\n dataSources: dataSources ?? [],\n ...rest,\n };\n }\n function makeHealthcareRelation(\n entities: HealthcareEntity[]\n ): (relation: HealthcareRelation) => HealthcareEntityRelation {\n return ({\n entities: generatedEntities,\n relationType,\n confidenceScore,\n }: HealthcareRelation): HealthcareEntityRelation => ({\n relationType: relationType,\n confidenceScore,\n roles: generatedEntities.map(\n (role: HealthcareRelationEntity): HealthcareEntityRelationRole => ({\n entity: entities[parseHealthcareEntityIndex(role.ref)],\n name: role.role,\n })\n ),\n });\n }\n return transformDocumentResults<\n HealthcareEntitiesDocumentResultWithDocumentDetectedLanguage,\n WithDetectedLanguage<HealthcareSuccessResult>\n >(docIds, results, {\n processSuccess: ({ entities, relations, detectedLanguage, ...rest }) => {\n const newEntities = entities.map(makeHealthcareEntity);\n return {\n entities: newEntities,\n entityRelations: relations.map(makeHealthcareRelation(newEntities)),\n // FIXME: remove this mitigation when the API fixes the representation on their end\n ...(detectedLanguage ? { detectedLanguage: { iso6391Name: detectedLanguage } as any } : {}),\n ...rest,\n };\n },\n });\n}\n\n/**\n * @internal\n */\nexport function transformAnalyzeBatchResults(\n docIds: string[],\n response: AnalyzeTextLROResultUnion[] = []\n): AnalyzeBatchResult[] {\n return response.map((actionData) => {\n const { lastUpdateDateTime: completedOn, actionName, kind } = actionData;\n switch (kind as KnownAnalyzeTextLROResultsKind) {\n case \"SentimentAnalysisLROResults\": {\n const { results } = actionData as SentimentLROResult;\n const { modelVersion, statistics } = results;\n return {\n kind: \"SentimentAnalysis\",\n results: toSentimentAnalysisResult(docIds, results),\n completedOn,\n ...(actionName ? { actionName } : {}),\n ...(statistics ? { statistics } : {}),\n modelVersion,\n };\n }\n case \"EntityRecognitionLROResults\": {\n const { results } = actionData as EntityRecognitionLROResult;\n const { modelVersion, statistics } = results;\n return {\n kind: \"EntityRecognition\",\n results: toEntityRecognitionResult(docIds, results),\n completedOn,\n ...(actionName ? { actionName } : {}),\n ...(statistics ? { statistics } : {}),\n modelVersion,\n };\n }\n case \"PiiEntityRecognitionLROResults\": {\n const { results } = actionData as PiiEntityRecognitionLROResult;\n const { modelVersion, statistics } = results;\n return {\n kind: \"PiiEntityRecognition\",\n results: toPiiEntityRecognitionResult(docIds, results),\n completedOn,\n ...(actionName ? { actionName } : {}),\n ...(statistics ? { statistics } : {}),\n modelVersion,\n };\n }\n case \"KeyPhraseExtractionLROResults\": {\n const { results } = actionData as KeyPhraseExtractionLROResult;\n const { modelVersion, statistics } = results;\n return {\n kind: \"KeyPhraseExtraction\",\n results: toKeyPhraseExtractionResult(docIds, results),\n completedOn,\n ...(actionName ? { actionName } : {}),\n ...(statistics ? { statistics } : {}),\n modelVersion,\n };\n }\n case \"EntityLinkingLROResults\": {\n const { results } = actionData as EntityLinkingLROResult;\n const { modelVersion, statistics } = results;\n return {\n kind: \"EntityLinking\",\n results: toEntityLinkingResult(docIds, results),\n completedOn,\n ...(actionName ? { actionName } : {}),\n ...(statistics ? { statistics } : {}),\n modelVersion,\n };\n }\n case \"HealthcareLROResults\": {\n const { results } = actionData as HealthcareLROResult;\n const { modelVersion, statistics } = results;\n return {\n kind: \"Healthcare\",\n results: toHealthcareResult(docIds, results),\n completedOn,\n ...(actionName ? { actionName } : {}),\n ...(statistics ? { statistics } : {}),\n modelVersion,\n };\n }\n case \"CustomEntityRecognitionLROResults\": {\n const { results } = actionData as CustomEntityRecognitionLROResult;\n const { deploymentName, projectName, statistics } = results;\n return {\n kind: \"CustomEntityRecognition\",\n results: transformDocumentResults<CustomEntitiesResultDocumentsItem>(docIds, results),\n completedOn,\n ...(actionName ? { actionName } : {}),\n ...(statistics ? { statistics } : {}),\n deploymentName,\n projectName,\n };\n }\n case \"CustomSingleLabelClassificationLROResults\": {\n const { results } = actionData as CustomSingleLabelClassificationLROResult;\n const { deploymentName, projectName, statistics } = results;\n return {\n kind: \"CustomSingleLabelClassification\",\n results: transformDocumentResults<CustomLabelClassificationResultDocumentsItem>(\n docIds,\n results\n ),\n completedOn,\n ...(actionName ? { actionName } : {}),\n ...(statistics ? { statistics } : {}),\n deploymentName,\n projectName,\n };\n }\n case \"CustomMultiLabelClassificationLROResults\": {\n const { results } = actionData as CustomMultiLabelClassificationLROResult;\n const { deploymentName, projectName, statistics } = results;\n return {\n kind: \"CustomMultiLabelClassification\",\n results: transformDocumentResults<CustomLabelClassificationResultDocumentsItem>(\n docIds,\n results\n ),\n completedOn,\n ...(actionName ? { actionName } : {}),\n ...(statistics ? { statistics } : {}),\n deploymentName,\n projectName,\n };\n }\n case \"ExtractiveSummarizationLROResults\": {\n const { results } = actionData as ExtractiveSummarizationLROResult;\n const { modelVersion, statistics } = results;\n return {\n kind: \"ExtractiveSummarization\",\n results: transformDocumentResults<ExtractedSummaryDocumentResultWithDetectedLanguage>(\n docIds,\n results\n ),\n completedOn,\n ...(actionName ? { actionName } : {}),\n ...(statistics ? { statistics } : {}),\n modelVersion,\n };\n }\n case \"AbstractiveSummarizationLROResults\": {\n const { results } = actionData as AbstractiveSummarizationLROResult;\n const { modelVersion, statistics } = results;\n return {\n kind: \"AbstractiveSummarization\",\n results: transformDocumentResults<AbstractiveSummaryDocumentResultWithDetectedLanguage>(\n docIds,\n results\n ),\n completedOn,\n ...(actionName ? { actionName } : {}),\n ...(statistics ? { statistics } : {}),\n modelVersion,\n };\n }\n default: {\n throw new Error(`Unsupported results kind: ${kind}`);\n }\n }\n });\n}\n"]}
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "sdk-type": "client",
4
4
  "author": "Microsoft Corporation",
5
5
  "description": "An isomorphic client library for the text analysis features in the Azure Cognitive Language Service.",
6
- "version": "1.1.0-alpha.20221107.2",
6
+ "version": "1.1.0-beta.1",
7
7
  "keywords": [
8
8
  "node",
9
9
  "azure",
@@ -97,12 +97,12 @@
97
97
  "tslib": "^2.2.0"
98
98
  },
99
99
  "devDependencies": {
100
- "@azure/dev-tool": ">=1.0.0-alpha <1.0.0-alphb",
101
- "@azure/eslint-plugin-azure-sdk": ">=3.0.0-alpha <3.0.0-alphb",
100
+ "@azure/dev-tool": "^1.0.0",
101
+ "@azure/eslint-plugin-azure-sdk": "^3.0.0",
102
102
  "@azure/identity": "^2.0.1",
103
- "@azure/test-utils": ">=1.0.0-alpha <1.0.0-alphb",
103
+ "@azure/test-utils": "^1.0.0",
104
104
  "@azure-tools/test-recorder": "^2.0.0",
105
- "@azure-tools/test-credential": ">=1.0.0-alpha <1.0.0-alphb",
105
+ "@azure-tools/test-credential": "^1.0.0",
106
106
  "@microsoft/api-extractor": "^7.31.1",
107
107
  "@types/chai": "^4.1.6",
108
108
  "@types/chai-as-promised": "^7.1.0",
@@ -1907,32 +1907,32 @@ export declare enum KnownScriptKind {
1907
1907
  export declare enum KnownSpeedUnit {
1908
1908
  /** Unspecified */
1909
1909
  Unspecified = "Unspecified",
1910
- /** MetersPerSecond */
1911
- MetersPerSecond = "MetersPerSecond",
1912
- /** KilometersPerHour */
1913
- KilometersPerHour = "KilometersPerHour",
1914
- /** KilometersPerMinute */
1915
- KilometersPerMinute = "KilometersPerMinute",
1916
- /** KilometersPerSecond */
1917
- KilometersPerSecond = "KilometersPerSecond",
1918
- /** MilesPerHour */
1919
- MilesPerHour = "MilesPerHour",
1910
+ /** MeterPerSecond */
1911
+ MeterPerSecond = "MeterPerSecond",
1912
+ /** KilometerPerHour */
1913
+ KilometerPerHour = "KilometerPerHour",
1914
+ /** KilometerPerMinute */
1915
+ KilometerPerMinute = "KilometerPerMinute",
1916
+ /** KilometerPerSecond */
1917
+ KilometerPerSecond = "KilometerPerSecond",
1918
+ /** MilePerHour */
1919
+ MilePerHour = "MilePerHour",
1920
1920
  /** Knot */
1921
1921
  Knot = "Knot",
1922
1922
  /** FootPerSecond */
1923
1923
  FootPerSecond = "FootPerSecond",
1924
1924
  /** FootPerMinute */
1925
1925
  FootPerMinute = "FootPerMinute",
1926
- /** YardsPerMinute */
1927
- YardsPerMinute = "YardsPerMinute",
1928
- /** YardsPerSecond */
1929
- YardsPerSecond = "YardsPerSecond",
1930
- /** MetersPerMillisecond */
1931
- MetersPerMillisecond = "MetersPerMillisecond",
1932
- /** CentimetersPerMillisecond */
1933
- CentimetersPerMillisecond = "CentimetersPerMillisecond",
1934
- /** KilometersPerMillisecond */
1935
- KilometersPerMillisecond = "KilometersPerMillisecond"
1926
+ /** YardPerMinute */
1927
+ YardPerMinute = "YardPerMinute",
1928
+ /** YardPerSecond */
1929
+ YardPerSecond = "YardPerSecond",
1930
+ /** MeterPerMillisecond */
1931
+ MeterPerMillisecond = "MeterPerMillisecond",
1932
+ /** CentimeterPerMillisecond */
1933
+ CentimeterPerMillisecond = "CentimeterPerMillisecond",
1934
+ /** KilometerPerMillisecond */
1935
+ KilometerPerMillisecond = "KilometerPerMillisecond"
1936
1936
  }
1937
1937
 
1938
1938
  /** Known values of {@link StringIndexType} that the service accepts. */
@@ -2249,7 +2249,7 @@ export declare interface NumberResolution extends BaseResolution {
2249
2249
  /** The type of the extracted number entity. */
2250
2250
  numberKind: NumberKind;
2251
2251
  /** A numeric representation of what the extracted text denotes. */
2252
- value: string;
2252
+ value: number;
2253
2253
  }
2254
2254
 
2255
2255
  /** represents the resolution of numeric intervals. */
@@ -2759,19 +2759,19 @@ export declare interface SpeedResolution extends BaseResolution, QuantityResolut
2759
2759
  * this enum contains the known values that the service supports.
2760
2760
  * ### Known values supported by the service
2761
2761
  * **Unspecified** \
2762
- * **MetersPerSecond** \
2763
- * **KilometersPerHour** \
2764
- * **KilometersPerMinute** \
2765
- * **KilometersPerSecond** \
2766
- * **MilesPerHour** \
2762
+ * **MeterPerSecond** \
2763
+ * **KilometerPerHour** \
2764
+ * **KilometerPerMinute** \
2765
+ * **KilometerPerSecond** \
2766
+ * **MilePerHour** \
2767
2767
  * **Knot** \
2768
2768
  * **FootPerSecond** \
2769
2769
  * **FootPerMinute** \
2770
- * **YardsPerMinute** \
2771
- * **YardsPerSecond** \
2772
- * **MetersPerMillisecond** \
2773
- * **CentimetersPerMillisecond** \
2774
- * **KilometersPerMillisecond**
2770
+ * **YardPerMinute** \
2771
+ * **YardPerSecond** \
2772
+ * **MeterPerMillisecond** \
2773
+ * **CentimeterPerMillisecond** \
2774
+ * **KilometerPerMillisecond**
2775
2775
  */
2776
2776
  export declare type SpeedUnit = string;
2777
2777
 
@@ -3250,7 +3250,10 @@ export declare class TextAnalysisClient {
3250
3250
  * the service will apply a model where the language is explicitly set to
3251
3251
  * "None". Language support varies per action, for example, more information
3252
3252
  * about the languages supported for Entity Recognition actions can be
3253
- * found in {@link https://docs.microsoft.com//azure/cognitive-services/language-service/named-entity-recognition/language-support}
3253
+ * found in {@link https://docs.microsoft.com//azure/cognitive-services/language-service/named-entity-recognition/language-support}.
3254
+ * If set to "auto", the service will automatically infer the language from
3255
+ * the input text. If that process fails, the value in the `defaultLanguage`
3256
+ * option will be used.
3254
3257
  * @param options - optional action parameters and settings for the operation
3255
3258
  *
3256
3259
  * @returns an array of results corresponding to the input documents
@@ -3308,7 +3311,10 @@ export declare class TextAnalysisClient {
3308
3311
  * the service will apply a model where the language is explicitly set to
3309
3312
  * "None". Language support varies per action, for example, more information
3310
3313
  * about the languages supported for Entity Recognition actions can be
3311
- * found in {@link https://docs.microsoft.com//azure/cognitive-services/language-service/named-entity-recognition/language-support}
3314
+ * found in {@link https://docs.microsoft.com//azure/cognitive-services/language-service/named-entity-recognition/language-support}.
3315
+ * If set to "auto", the service will automatically infer the language from
3316
+ * the input text. If that process fails, the value in the `defaultLanguage`
3317
+ * option will be used.
3312
3318
  * @param options - optional settings for the operation
3313
3319
  *
3314
3320
  * @returns an array of results corresponding to the input actions