@azure/ai-text-analytics 5.2.0-beta.2 → 6.0.0-alpha.20220516.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/README.md +375 -133
- package/dist/index.js +2797 -4176
- package/dist/index.js.map +1 -1
- package/dist-esm/src/azureKeyCredentialPolicy.js +2 -2
- package/dist-esm/src/azureKeyCredentialPolicy.js.map +1 -1
- package/dist-esm/src/constants.js +16 -0
- package/dist-esm/src/constants.js.map +1 -0
- package/dist-esm/src/generated/generatedClient.js +80 -334
- package/dist-esm/src/generated/generatedClient.js.map +1 -1
- package/dist-esm/src/generated/index.js +1 -1
- package/dist-esm/src/generated/index.js.map +1 -1
- package/dist-esm/src/generated/models/index.js +106 -35
- package/dist-esm/src/generated/models/index.js.map +1 -1
- package/dist-esm/src/generated/models/mappers.js +1625 -2101
- package/dist-esm/src/generated/models/mappers.js.map +1 -1
- package/dist-esm/src/generated/models/parameters.js +18 -105
- package/dist-esm/src/generated/models/parameters.js.map +1 -1
- package/dist-esm/src/generated/operations/analyzeText.js +105 -0
- package/dist-esm/src/generated/operations/analyzeText.js.map +1 -0
- package/dist-esm/src/generated/operations/index.js +9 -0
- package/dist-esm/src/generated/operations/index.js.map +1 -0
- package/dist-esm/src/generated/operationsInterfaces/analyzeText.js +9 -0
- package/dist-esm/src/generated/operationsInterfaces/analyzeText.js.map +1 -0
- package/dist-esm/src/generated/operationsInterfaces/index.js +9 -0
- package/dist-esm/src/generated/operationsInterfaces/index.js.map +1 -0
- package/dist-esm/src/index.js +14 -5
- package/dist-esm/src/index.js.map +1 -1
- package/dist-esm/src/lro.js +195 -0
- package/dist-esm/src/lro.js.map +1 -0
- package/dist-esm/src/models.js +42 -0
- package/dist-esm/src/models.js.map +1 -0
- package/dist-esm/src/textAnalysisClient.js +197 -0
- package/dist-esm/src/textAnalysisClient.js.map +1 -0
- package/dist-esm/src/transforms.js +279 -0
- package/dist-esm/src/transforms.js.map +1 -0
- package/dist-esm/src/util.js +35 -141
- package/dist-esm/src/util.js.map +1 -1
- package/package.json +24 -32
- package/types/ai-text-analytics.d.ts +1402 -1421
- package/LICENSE +0 -21
- package/dist-esm/src/analyzeActionsResult.js +0 -205
- package/dist-esm/src/analyzeActionsResult.js.map +0 -1
- package/dist-esm/src/analyzeHealthcareEntitiesResult.js +0 -53
- package/dist-esm/src/analyzeHealthcareEntitiesResult.js.map +0 -1
- package/dist-esm/src/analyzeLro.js +0 -132
- package/dist-esm/src/analyzeLro.js.map +0 -1
- package/dist-esm/src/analyzeSentimentResult.js +0 -74
- package/dist-esm/src/analyzeSentimentResult.js.map +0 -1
- package/dist-esm/src/analyzeSentimentResultArray.js +0 -11
- package/dist-esm/src/analyzeSentimentResultArray.js.map +0 -1
- package/dist-esm/src/detectLanguageResult.js +0 -17
- package/dist-esm/src/detectLanguageResult.js.map +0 -1
- package/dist-esm/src/detectLanguageResultArray.js +0 -11
- package/dist-esm/src/detectLanguageResultArray.js.map +0 -1
- package/dist-esm/src/extractKeyPhrasesResult.js +0 -17
- package/dist-esm/src/extractKeyPhrasesResult.js.map +0 -1
- package/dist-esm/src/extractKeyPhrasesResultArray.js +0 -11
- package/dist-esm/src/extractKeyPhrasesResultArray.js.map +0 -1
- package/dist-esm/src/extractSummaryResult.js +0 -17
- package/dist-esm/src/extractSummaryResult.js.map +0 -1
- package/dist-esm/src/extractSummaryResultArray.js +0 -11
- package/dist-esm/src/extractSummaryResultArray.js.map +0 -1
- package/dist-esm/src/generated/generatedClientContext.js +0 -42
- package/dist-esm/src/generated/generatedClientContext.js.map +0 -1
- package/dist-esm/src/healthLro.js +0 -139
- package/dist-esm/src/healthLro.js.map +0 -1
- package/dist-esm/src/multiCategoryClassifyResult.js +0 -17
- package/dist-esm/src/multiCategoryClassifyResult.js.map +0 -1
- package/dist-esm/src/multiCategoryClassifyResultArray.js +0 -11
- package/dist-esm/src/multiCategoryClassifyResultArray.js.map +0 -1
- package/dist-esm/src/pollerModels.js +0 -4
- package/dist-esm/src/pollerModels.js.map +0 -1
- package/dist-esm/src/recognizeCategorizedEntitiesResult.js +0 -17
- package/dist-esm/src/recognizeCategorizedEntitiesResult.js.map +0 -1
- package/dist-esm/src/recognizeCategorizedEntitiesResultArray.js +0 -11
- package/dist-esm/src/recognizeCategorizedEntitiesResultArray.js.map +0 -1
- package/dist-esm/src/recognizeCustomEntitiesResult.js +0 -17
- package/dist-esm/src/recognizeCustomEntitiesResult.js.map +0 -1
- package/dist-esm/src/recognizeCustomEntitiesResultArray.js +0 -11
- package/dist-esm/src/recognizeCustomEntitiesResultArray.js.map +0 -1
- package/dist-esm/src/recognizeLinkedEntitiesResult.js +0 -17
- package/dist-esm/src/recognizeLinkedEntitiesResult.js.map +0 -1
- package/dist-esm/src/recognizeLinkedEntitiesResultArray.js +0 -11
- package/dist-esm/src/recognizeLinkedEntitiesResultArray.js.map +0 -1
- package/dist-esm/src/recognizePiiEntitiesResult.js +0 -18
- package/dist-esm/src/recognizePiiEntitiesResult.js.map +0 -1
- package/dist-esm/src/recognizePiiEntitiesResultArray.js +0 -11
- package/dist-esm/src/recognizePiiEntitiesResultArray.js.map +0 -1
- package/dist-esm/src/singleCategoryClassifyResult.js +0 -17
- package/dist-esm/src/singleCategoryClassifyResult.js.map +0 -1
- package/dist-esm/src/singleCategoryClassifyResultArray.js +0 -11
- package/dist-esm/src/singleCategoryClassifyResultArray.js.map +0 -1
- package/dist-esm/src/textAnalyticsAction.js +0 -4
- package/dist-esm/src/textAnalyticsAction.js.map +0 -1
- package/dist-esm/src/textAnalyticsClient.js +0 -511
- package/dist-esm/src/textAnalyticsClient.js.map +0 -1
- package/dist-esm/src/textAnalyticsOperationOptions.js +0 -4
- package/dist-esm/src/textAnalyticsOperationOptions.js.map +0 -1
- package/dist-esm/src/textAnalyticsResult.js +0 -94
- package/dist-esm/src/textAnalyticsResult.js.map +0 -1
- package/dist-esm/src/tracing.js +0 -12
- package/dist-esm/src/tracing.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"recognizePiiEntitiesResultArray.js","sourceRoot":"","sources":["../../src/recognizePiiEntitiesResultArray.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAEL,8BAA8B,EAC9B,mCAAmC,EACpC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,mEAAmE,EAAE,MAAM,uBAAuB,CAAC;AAoB5G;;GAEG;AACH,MAAM,UAAU,mCAAmC,CACjD,KAA0B,EAC1B,QAAmB;IAEnB,OAAO,mEAAmE,CACxE,KAAK,EACL,QAAQ,EACR,8BAA8B,EAC9B,mCAAmC,CACpC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { TextDocumentBatchStatistics, TextDocumentInput, PiiResult } from \"./generated/models\";\nimport {\n RecognizePiiEntitiesResult,\n makeRecognizePiiEntitiesResult,\n makeRecognizePiiEntitiesErrorResult\n} from \"./recognizePiiEntitiesResult\";\nimport { combineSuccessfulAndErroneousDocumentsWithStatisticsAndModelVersion } from \"./textAnalyticsResult\";\n\n/**\n * Collection of `RecognizePiiEntitiesResult` objects corresponding to a batch of input documents, and\n * annotated with information about the batch operation.\n */\nexport interface RecognizePiiEntitiesResultArray extends Array<RecognizePiiEntitiesResult> {\n /**\n * Statistics about the input document batch and how it was processed\n * by the service. This property will have a value when includeStatistics is set to true\n * in the client call.\n */\n statistics?: TextDocumentBatchStatistics;\n /**\n * The version of the text analytics model used by this operation on this\n * batch of input documents.\n */\n modelVersion: string;\n}\n\n/**\n * @internal\n */\nexport function makeRecognizePiiEntitiesResultArray(\n input: TextDocumentInput[],\n response: PiiResult\n): RecognizePiiEntitiesResultArray {\n return combineSuccessfulAndErroneousDocumentsWithStatisticsAndModelVersion(\n input,\n response,\n makeRecognizePiiEntitiesResult,\n makeRecognizePiiEntitiesErrorResult\n );\n}\n"]}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT license.
|
|
3
|
-
import { makeTextAnalyticsSuccessResult, makeTextAnalyticsErrorResult } from "./textAnalyticsResult";
|
|
4
|
-
/**
|
|
5
|
-
* @internal
|
|
6
|
-
*/
|
|
7
|
-
export function makeSingleCategoryClassifyResult(result) {
|
|
8
|
-
const { id, warnings, statistics, classification } = result;
|
|
9
|
-
return Object.assign(Object.assign({}, makeTextAnalyticsSuccessResult(id, warnings, statistics)), { classification });
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* @internal
|
|
13
|
-
*/
|
|
14
|
-
export function makeSingleCategoryClassifyErrorResult(id, error) {
|
|
15
|
-
return makeTextAnalyticsErrorResult(id, error);
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=singleCategoryClassifyResult.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"singleCategoryClassifyResult.js","sourceRoot":"","sources":["../../src/singleCategoryClassifyResult.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EACL,8BAA8B,EAG9B,4BAA4B,EAC7B,MAAM,uBAAuB,CAAC;AAmC/B;;GAEG;AACH,MAAM,UAAU,gCAAgC,CAC9C,MAAoC;IAEpC,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,cAAc,EAAE,GAAG,MAAM,CAAC;IAC5D,uCACK,8BAA8B,CAAC,EAAE,EAAE,QAAQ,EAAE,UAAU,CAAC,KAC3D,cAAc,IACd;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qCAAqC,CACnD,EAAU,EACV,KAAyB;IAEzB,OAAO,4BAA4B,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;AACjD,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n makeTextAnalyticsSuccessResult,\n TextAnalyticsSuccessResult,\n TextAnalyticsErrorResult,\n makeTextAnalyticsErrorResult\n} from \"./textAnalyticsResult\";\nimport {\n TextAnalyticsError,\n ClassificationResult,\n SingleClassificationDocument\n} from \"./generated/models\";\n\n/**\n * The result of the custom classify document single category operation on a single document.\n */\nexport type SingleCategoryClassifyResult =\n | SingleCategoryClassifySuccessResult\n | SingleCategoryClassifyErrorResult;\n\n/**\n * The result of the custom classify document single category operation on a single document,\n * containing the result of the classification.\n */\nexport interface SingleCategoryClassifySuccessResult extends TextAnalyticsSuccessResult {\n /**\n * The classification result of the input document.\n */\n classification: ClassificationCategory;\n}\n\n/**\n * A classification result from a custom classify document single category action\n */\nexport interface ClassificationCategory extends ClassificationResult {}\n\n/**\n * An error result from the custom classify document single category operation on a single document.\n */\nexport type SingleCategoryClassifyErrorResult = TextAnalyticsErrorResult;\n\n/**\n * @internal\n */\nexport function makeSingleCategoryClassifyResult(\n result: SingleClassificationDocument\n): SingleCategoryClassifySuccessResult {\n const { id, warnings, statistics, classification } = result;\n return {\n ...makeTextAnalyticsSuccessResult(id, warnings, statistics),\n classification\n };\n}\n\n/**\n * @internal\n */\nexport function makeSingleCategoryClassifyErrorResult(\n id: string,\n error: TextAnalyticsError\n): SingleCategoryClassifyErrorResult {\n return makeTextAnalyticsErrorResult(id, error);\n}\n"]}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT license.
|
|
3
|
-
import { makeSingleCategoryClassifyResult, makeSingleCategoryClassifyErrorResult } from "./singleCategoryClassifyResult";
|
|
4
|
-
import { combineSuccessfulAndErroneousDocumentsWithStatisticsAndCustomProjectInfo } from "./textAnalyticsResult";
|
|
5
|
-
/**
|
|
6
|
-
* @internal
|
|
7
|
-
*/
|
|
8
|
-
export function makeSingleCategoryClassifyResultArray(input, response) {
|
|
9
|
-
return combineSuccessfulAndErroneousDocumentsWithStatisticsAndCustomProjectInfo(input, response, makeSingleCategoryClassifyResult, makeSingleCategoryClassifyErrorResult);
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=singleCategoryClassifyResultArray.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"singleCategoryClassifyResultArray.js","sourceRoot":"","sources":["../../src/singleCategoryClassifyResultArray.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAOlC,OAAO,EAEL,gCAAgC,EAChC,qCAAqC,EACtC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,wEAAwE,EAAE,MAAM,uBAAuB,CAAC;AAyBjH;;GAEG;AACH,MAAM,UAAU,qCAAqC,CACnD,KAA0B,EAC1B,QAA0C;IAE1C,OAAO,wEAAwE,CAC7E,KAAK,EACL,QAAQ,EACR,gCAAgC,EAChC,qCAAqC,CACtC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n TextDocumentBatchStatistics,\n TextDocumentInput,\n CustomSingleClassificationResult\n} from \"./generated/models\";\nimport {\n SingleCategoryClassifyResult,\n makeSingleCategoryClassifyResult,\n makeSingleCategoryClassifyErrorResult\n} from \"./singleCategoryClassifyResult\";\nimport { combineSuccessfulAndErroneousDocumentsWithStatisticsAndCustomProjectInfo } from \"./textAnalyticsResult\";\n\n/**\n * Array of `SingleCategoryClassifyResult` objects corresponding to a batch of input documents, and\n * annotated with information about the batch operation.\n */\nexport interface SingleCategoryClassifyResultArray extends Array<SingleCategoryClassifyResult> {\n /**\n * Statistics about the input document batch and how it was processed\n * by the service. This property will have a value when includeStatistics is set to true\n * in the client call.\n */\n statistics?: TextDocumentBatchStatistics;\n /**\n * The version of the text analytics custom project used by this operation on this\n * batch of input documents.\n */\n projectName: string;\n /**\n * The version of the text analytics custom deployment used by this operation on this\n * batch of input documents.\n */\n deploymentName: string;\n}\n\n/**\n * @internal\n */\nexport function makeSingleCategoryClassifyResultArray(\n input: TextDocumentInput[],\n response: CustomSingleClassificationResult\n): SingleCategoryClassifyResultArray {\n return combineSuccessfulAndErroneousDocumentsWithStatisticsAndCustomProjectInfo(\n input,\n response,\n makeSingleCategoryClassifyResult,\n makeSingleCategoryClassifyErrorResult\n );\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"textAnalyticsAction.js","sourceRoot":"","sources":["../../src/textAnalyticsAction.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * The type of a standard text analytics action.\n */\nexport interface TextAnalyticsAction {\n /**\n * The version of the text analytics model used by this operation on this\n * batch of input documents.\n */\n modelVersion?: string;\n /**\n * The preferred name for this action.\n */\n actionName?: string;\n}\n\n/**\n * The type of a custom text analytics action.\n */\nexport interface CustomTextAnalyticsAction {\n /**\n * The project name for the text analytics model used by this operation on this\n * batch of input documents.\n */\n projectName: string;\n /**\n * The deployment name for the text analytics model used by this operation on this\n * batch of input documents.\n */\n deploymentName: string;\n /**\n * The preferred name for this action.\n */\n actionName?: string;\n}\n"]}
|
|
@@ -1,511 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT license.
|
|
3
|
-
import { __rest } from "tslib";
|
|
4
|
-
import { bearerTokenAuthenticationPolicy } from "@azure/core-rest-pipeline";
|
|
5
|
-
import { isTokenCredential } from "@azure/core-auth";
|
|
6
|
-
import { GeneratedClient } from "./generated/generatedClient";
|
|
7
|
-
import { logger } from "./logger";
|
|
8
|
-
import { makeDetectLanguageResultArray } from "./detectLanguageResultArray";
|
|
9
|
-
import { makeRecognizeCategorizedEntitiesResultArray } from "./recognizeCategorizedEntitiesResultArray";
|
|
10
|
-
import { makeAnalyzeSentimentResultArray } from "./analyzeSentimentResultArray";
|
|
11
|
-
import { makeExtractKeyPhrasesResultArray } from "./extractKeyPhrasesResultArray";
|
|
12
|
-
import { makeRecognizePiiEntitiesResultArray } from "./recognizePiiEntitiesResultArray";
|
|
13
|
-
import { makeRecognizeLinkedEntitiesResultArray } from "./recognizeLinkedEntitiesResultArray";
|
|
14
|
-
import { createSpan } from "./tracing";
|
|
15
|
-
import { SpanStatusCode } from "@azure/core-tracing";
|
|
16
|
-
import { textAnalyticsAzureKeyCredentialPolicy } from "./azureKeyCredentialPolicy";
|
|
17
|
-
import { addParamsToTask, compose, compileError, setCategoriesFilter, setOpinionMining, setOrderBy, setSentenceCount, setStrEncodingParam, setStrEncodingParamValue } from "./util";
|
|
18
|
-
import { HealthLro, isHealthDone, processHealthResult, updateHealthState } from "./healthLro";
|
|
19
|
-
import { LroEngine } from "@azure/core-lro";
|
|
20
|
-
import { AnalyzeLro, isAnalyzeDone, processAnalyzeResult, updateAnalyzeState } from "./analyzeLro";
|
|
21
|
-
const DEFAULT_COGNITIVE_SCOPE = "https://cognitiveservices.azure.com/.default";
|
|
22
|
-
/**
|
|
23
|
-
* The types of PII domains the user can choose from.
|
|
24
|
-
*/
|
|
25
|
-
export var PiiEntityDomain;
|
|
26
|
-
(function (PiiEntityDomain) {
|
|
27
|
-
/**
|
|
28
|
-
* @see {@link https://aka.ms/tanerpii} for more information.
|
|
29
|
-
*/
|
|
30
|
-
PiiEntityDomain["PROTECTED_HEALTH_INFORMATION"] = "PHI";
|
|
31
|
-
})(PiiEntityDomain || (PiiEntityDomain = {}));
|
|
32
|
-
/**
|
|
33
|
-
* Client class for interacting with Azure Text Analytics.
|
|
34
|
-
*/
|
|
35
|
-
export class TextAnalyticsClient {
|
|
36
|
-
/**
|
|
37
|
-
* Creates an instance of TextAnalyticsClient.
|
|
38
|
-
*
|
|
39
|
-
* Example usage:
|
|
40
|
-
* ```ts
|
|
41
|
-
* import { TextAnalyticsClient, AzureKeyCredential } from "@azure/ai-text-analytics";
|
|
42
|
-
*
|
|
43
|
-
* const client = new TextAnalyticsClient(
|
|
44
|
-
* "<service endpoint>",
|
|
45
|
-
* new AzureKeyCredential("<api key>")
|
|
46
|
-
* );
|
|
47
|
-
* ```
|
|
48
|
-
* @param endpointUrl - The URL to the TextAnalytics endpoint
|
|
49
|
-
* @param credential - Used to authenticate requests to the service.
|
|
50
|
-
* @param options - Used to configure the TextAnalytics client.
|
|
51
|
-
*/
|
|
52
|
-
constructor(endpointUrl, credential, options = {}) {
|
|
53
|
-
this.endpointUrl = endpointUrl;
|
|
54
|
-
const { defaultCountryHint = "us", defaultLanguage = "en" } = options, pipelineOptions = __rest(options, ["defaultCountryHint", "defaultLanguage"]);
|
|
55
|
-
this.defaultCountryHint = defaultCountryHint;
|
|
56
|
-
this.defaultLanguage = defaultLanguage;
|
|
57
|
-
const internalPipelineOptions = Object.assign(Object.assign({}, pipelineOptions), {
|
|
58
|
-
loggingOptions: {
|
|
59
|
-
logger: logger.info,
|
|
60
|
-
additionalAllowedHeaderNames: ["x-ms-correlation-request-id", "x-ms-request-id"]
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
this.client = new GeneratedClient(this.endpointUrl, internalPipelineOptions);
|
|
64
|
-
const authPolicy = isTokenCredential(credential)
|
|
65
|
-
? bearerTokenAuthenticationPolicy({ credential, scopes: DEFAULT_COGNITIVE_SCOPE })
|
|
66
|
-
: textAnalyticsAzureKeyCredentialPolicy(credential);
|
|
67
|
-
this.client.pipeline.addPolicy(authPolicy);
|
|
68
|
-
}
|
|
69
|
-
async detectLanguage(documents, countryHintOrOptions, options) {
|
|
70
|
-
let realOptions;
|
|
71
|
-
let realInputs;
|
|
72
|
-
if (!Array.isArray(documents) || documents.length === 0) {
|
|
73
|
-
throw new Error("'documents' must be a non-empty array");
|
|
74
|
-
}
|
|
75
|
-
if (isStringArray(documents)) {
|
|
76
|
-
const countryHint = countryHintOrOptions || this.defaultCountryHint;
|
|
77
|
-
realInputs = convertToDetectLanguageInput(documents, countryHint);
|
|
78
|
-
realOptions = options || {};
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
// Replace "none" hints with ""
|
|
82
|
-
realInputs = documents.map((input) => (Object.assign(Object.assign({}, input), { countryHint: input.countryHint === "none" ? "" : input.countryHint })));
|
|
83
|
-
realOptions = countryHintOrOptions || {};
|
|
84
|
-
}
|
|
85
|
-
const { span, updatedOptions: finalOptions } = createSpan("TextAnalyticsClient-detectLanguages", makeGeneratedDetectLanguageOptions(realOptions));
|
|
86
|
-
try {
|
|
87
|
-
const result = await this.client.languages({
|
|
88
|
-
documents: realInputs
|
|
89
|
-
}, finalOptions);
|
|
90
|
-
return makeDetectLanguageResultArray(realInputs, result);
|
|
91
|
-
}
|
|
92
|
-
catch (e) {
|
|
93
|
-
span.setStatus({
|
|
94
|
-
code: SpanStatusCode.ERROR,
|
|
95
|
-
message: e.message
|
|
96
|
-
});
|
|
97
|
-
throw e;
|
|
98
|
-
}
|
|
99
|
-
finally {
|
|
100
|
-
span.end();
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
async recognizeEntities(documents, languageOrOptions,
|
|
104
|
-
// eslint-disable-next-line @azure/azure-sdk/ts-naming-options
|
|
105
|
-
options) {
|
|
106
|
-
let realOptions;
|
|
107
|
-
let realInputs;
|
|
108
|
-
if (!Array.isArray(documents) || documents.length === 0) {
|
|
109
|
-
throw new Error("'documents' must be a non-empty array");
|
|
110
|
-
}
|
|
111
|
-
if (isStringArray(documents)) {
|
|
112
|
-
const language = languageOrOptions || this.defaultLanguage;
|
|
113
|
-
realInputs = convertToTextDocumentInput(documents, language);
|
|
114
|
-
realOptions = options || {};
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
realInputs = documents;
|
|
118
|
-
realOptions = languageOrOptions || {};
|
|
119
|
-
}
|
|
120
|
-
const { span, updatedOptions: finalOptions } = createSpan("TextAnalyticsClient-recognizeEntities", makeGeneratedRecognizeCategorizedEntitiesOptions(realOptions));
|
|
121
|
-
try {
|
|
122
|
-
const result = await this.client.entitiesRecognitionGeneral({
|
|
123
|
-
documents: realInputs
|
|
124
|
-
}, finalOptions);
|
|
125
|
-
return makeRecognizeCategorizedEntitiesResultArray(realInputs, result);
|
|
126
|
-
}
|
|
127
|
-
catch (e) {
|
|
128
|
-
/**
|
|
129
|
-
* This special logic handles REST exception with code
|
|
130
|
-
* InvalidDocumentBatch and is needed to maintain backward compatability
|
|
131
|
-
* with sdk v5.0.0 and earlier. In general, REST exceptions are thrown as
|
|
132
|
-
* is and include both outer and inner exception codes. However, the
|
|
133
|
-
* earlier versions were throwing an exception that included the inner
|
|
134
|
-
* code only.
|
|
135
|
-
*/
|
|
136
|
-
const backwardCompatibleException = compileError(e);
|
|
137
|
-
span.setStatus({
|
|
138
|
-
code: SpanStatusCode.ERROR,
|
|
139
|
-
message: backwardCompatibleException.message
|
|
140
|
-
});
|
|
141
|
-
throw backwardCompatibleException;
|
|
142
|
-
}
|
|
143
|
-
finally {
|
|
144
|
-
span.end();
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
async analyzeSentiment(documents, languageOrOptions, options) {
|
|
148
|
-
let realOptions;
|
|
149
|
-
let realInputs;
|
|
150
|
-
if (!Array.isArray(documents) || documents.length === 0) {
|
|
151
|
-
throw new Error("'documents' must be a non-empty array");
|
|
152
|
-
}
|
|
153
|
-
if (isStringArray(documents)) {
|
|
154
|
-
const language = languageOrOptions || this.defaultLanguage;
|
|
155
|
-
realInputs = convertToTextDocumentInput(documents, language);
|
|
156
|
-
realOptions = options || {};
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
realInputs = documents;
|
|
160
|
-
realOptions = languageOrOptions || {};
|
|
161
|
-
}
|
|
162
|
-
const { span, updatedOptions: finalOptions } = createSpan("TextAnalyticsClient-analyzeSentiment", makeGeneratedAnalyzeSentimentOptions(realOptions));
|
|
163
|
-
try {
|
|
164
|
-
const result = await this.client.sentiment({
|
|
165
|
-
documents: realInputs
|
|
166
|
-
}, finalOptions);
|
|
167
|
-
return makeAnalyzeSentimentResultArray(realInputs, result);
|
|
168
|
-
}
|
|
169
|
-
catch (e) {
|
|
170
|
-
span.setStatus({
|
|
171
|
-
code: SpanStatusCode.ERROR,
|
|
172
|
-
message: e.message
|
|
173
|
-
});
|
|
174
|
-
throw e;
|
|
175
|
-
}
|
|
176
|
-
finally {
|
|
177
|
-
span.end();
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
async extractKeyPhrases(documents, languageOrOptions, options) {
|
|
181
|
-
let realOptions;
|
|
182
|
-
let realInputs;
|
|
183
|
-
if (!Array.isArray(documents) || documents.length === 0) {
|
|
184
|
-
throw new Error("'documents' must be a non-empty array");
|
|
185
|
-
}
|
|
186
|
-
if (isStringArray(documents)) {
|
|
187
|
-
const language = languageOrOptions || this.defaultLanguage;
|
|
188
|
-
realInputs = convertToTextDocumentInput(documents, language);
|
|
189
|
-
realOptions = options || {};
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
192
|
-
realInputs = documents;
|
|
193
|
-
realOptions = languageOrOptions || {};
|
|
194
|
-
}
|
|
195
|
-
const { span, updatedOptions: finalOptions } = createSpan("TextAnalyticsClient-extractKeyPhrases", makeGeneratedExtractKeyPhrasesOptions(realOptions));
|
|
196
|
-
try {
|
|
197
|
-
const result = await this.client.keyPhrases({
|
|
198
|
-
documents: realInputs
|
|
199
|
-
}, finalOptions);
|
|
200
|
-
return makeExtractKeyPhrasesResultArray(realInputs, result);
|
|
201
|
-
}
|
|
202
|
-
catch (e) {
|
|
203
|
-
span.setStatus({
|
|
204
|
-
code: SpanStatusCode.ERROR,
|
|
205
|
-
message: e.message
|
|
206
|
-
});
|
|
207
|
-
throw e;
|
|
208
|
-
}
|
|
209
|
-
finally {
|
|
210
|
-
span.end();
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
async recognizePiiEntities(inputs, languageOrOptions, options) {
|
|
214
|
-
let realOptions;
|
|
215
|
-
let realInputs;
|
|
216
|
-
if (isStringArray(inputs)) {
|
|
217
|
-
const language = languageOrOptions || this.defaultLanguage;
|
|
218
|
-
realInputs = convertToTextDocumentInput(inputs, language);
|
|
219
|
-
realOptions = options || {};
|
|
220
|
-
}
|
|
221
|
-
else {
|
|
222
|
-
realInputs = inputs;
|
|
223
|
-
realOptions = languageOrOptions || {};
|
|
224
|
-
}
|
|
225
|
-
const { span, updatedOptions: finalOptions } = createSpan("TextAnalyticsClient-recognizePiiEntities", makeGeneratedRecognizePiiEntitiesOptions(realOptions));
|
|
226
|
-
try {
|
|
227
|
-
const result = await this.client.entitiesRecognitionPii({
|
|
228
|
-
documents: realInputs
|
|
229
|
-
}, finalOptions);
|
|
230
|
-
return makeRecognizePiiEntitiesResultArray(realInputs, result);
|
|
231
|
-
}
|
|
232
|
-
catch (e) {
|
|
233
|
-
span.setStatus({
|
|
234
|
-
code: SpanStatusCode.ERROR,
|
|
235
|
-
message: e.message
|
|
236
|
-
});
|
|
237
|
-
throw e;
|
|
238
|
-
}
|
|
239
|
-
finally {
|
|
240
|
-
span.end();
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
async recognizeLinkedEntities(documents, languageOrOptions, options) {
|
|
244
|
-
let realOptions;
|
|
245
|
-
let realInputs;
|
|
246
|
-
if (!Array.isArray(documents) || documents.length === 0) {
|
|
247
|
-
throw new Error("'documents' must be a non-empty array");
|
|
248
|
-
}
|
|
249
|
-
if (isStringArray(documents)) {
|
|
250
|
-
const language = languageOrOptions || this.defaultLanguage;
|
|
251
|
-
realInputs = convertToTextDocumentInput(documents, language);
|
|
252
|
-
realOptions = options || {};
|
|
253
|
-
}
|
|
254
|
-
else {
|
|
255
|
-
realInputs = documents;
|
|
256
|
-
realOptions = languageOrOptions || {};
|
|
257
|
-
}
|
|
258
|
-
const { span, updatedOptions: finalOptions } = createSpan("TextAnalyticsClient-recognizeLinkedEntities", makeGeneratedRecognizeLinkingEntitiesOptions(realOptions));
|
|
259
|
-
try {
|
|
260
|
-
const result = await this.client.entitiesLinking({
|
|
261
|
-
documents: realInputs
|
|
262
|
-
}, finalOptions);
|
|
263
|
-
return makeRecognizeLinkedEntitiesResultArray(realInputs, result);
|
|
264
|
-
}
|
|
265
|
-
catch (e) {
|
|
266
|
-
span.setStatus({
|
|
267
|
-
code: SpanStatusCode.ERROR,
|
|
268
|
-
message: e.message
|
|
269
|
-
});
|
|
270
|
-
throw e;
|
|
271
|
-
}
|
|
272
|
-
finally {
|
|
273
|
-
span.end();
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
async beginAnalyzeHealthcareEntities(documents, languageOrOptions, options) {
|
|
277
|
-
let realOptions;
|
|
278
|
-
let realInputs;
|
|
279
|
-
if (isStringArray(documents)) {
|
|
280
|
-
const language = languageOrOptions || this.defaultLanguage;
|
|
281
|
-
realInputs = convertToTextDocumentInput(documents, language);
|
|
282
|
-
realOptions = options || {};
|
|
283
|
-
}
|
|
284
|
-
else {
|
|
285
|
-
realInputs = documents;
|
|
286
|
-
realOptions = languageOrOptions || {};
|
|
287
|
-
}
|
|
288
|
-
const { updateIntervalInMs, resumeFrom, onResponse, disableServiceLogs, modelVersion, requestOptions, serializerOptions, abortSignal, stringIndexType, includeStatistics, tracingOptions } = realOptions;
|
|
289
|
-
const lro = new HealthLro(this.client, {
|
|
290
|
-
onResponse,
|
|
291
|
-
requestOptions,
|
|
292
|
-
serializerOptions,
|
|
293
|
-
abortSignal,
|
|
294
|
-
tracingOptions
|
|
295
|
-
}, { loggingOptOut: disableServiceLogs, stringIndexType, modelVersion }, { includeStatistics }, realInputs);
|
|
296
|
-
const poller = new LroEngine(lro, {
|
|
297
|
-
intervalInMs: updateIntervalInMs,
|
|
298
|
-
resumeFrom: resumeFrom,
|
|
299
|
-
processResult: processHealthResult(this.client, realInputs, {
|
|
300
|
-
onResponse,
|
|
301
|
-
requestOptions,
|
|
302
|
-
serializerOptions,
|
|
303
|
-
abortSignal,
|
|
304
|
-
tracingOptions,
|
|
305
|
-
includeStatistics
|
|
306
|
-
}),
|
|
307
|
-
isDone: isHealthDone,
|
|
308
|
-
updateState: updateHealthState
|
|
309
|
-
});
|
|
310
|
-
await poller.poll();
|
|
311
|
-
return poller;
|
|
312
|
-
}
|
|
313
|
-
async beginAnalyzeActions(documents, actions, languageOrOptions, options) {
|
|
314
|
-
let realOptions;
|
|
315
|
-
let realInputs;
|
|
316
|
-
if (!Array.isArray(documents) || documents.length === 0) {
|
|
317
|
-
throw new Error("'documents' must be a non-empty array");
|
|
318
|
-
}
|
|
319
|
-
if (isStringArray(documents)) {
|
|
320
|
-
const language = languageOrOptions || this.defaultLanguage;
|
|
321
|
-
realInputs = convertToTextDocumentInput(documents, language);
|
|
322
|
-
realOptions = options || {};
|
|
323
|
-
}
|
|
324
|
-
else {
|
|
325
|
-
realInputs = documents;
|
|
326
|
-
realOptions = languageOrOptions || {};
|
|
327
|
-
}
|
|
328
|
-
const compiledActions = compileAnalyzeInput(actions);
|
|
329
|
-
const { updateIntervalInMs, resumeFrom, displayName, includeStatistics, onResponse, requestOptions, serializerOptions, abortSignal, tracingOptions } = realOptions;
|
|
330
|
-
const lro = new AnalyzeLro(this.client, {
|
|
331
|
-
onResponse,
|
|
332
|
-
requestOptions,
|
|
333
|
-
serializerOptions,
|
|
334
|
-
abortSignal,
|
|
335
|
-
tracingOptions
|
|
336
|
-
}, { displayName }, { includeStatistics }, realInputs, compiledActions);
|
|
337
|
-
const poller = new LroEngine(lro, {
|
|
338
|
-
intervalInMs: updateIntervalInMs,
|
|
339
|
-
resumeFrom: resumeFrom,
|
|
340
|
-
processResult: processAnalyzeResult(this.client, realInputs, {
|
|
341
|
-
onResponse,
|
|
342
|
-
requestOptions,
|
|
343
|
-
serializerOptions,
|
|
344
|
-
abortSignal,
|
|
345
|
-
tracingOptions,
|
|
346
|
-
includeStatistics
|
|
347
|
-
}),
|
|
348
|
-
isDone: isAnalyzeDone,
|
|
349
|
-
updateState: updateAnalyzeState
|
|
350
|
-
});
|
|
351
|
-
await poller.poll();
|
|
352
|
-
return poller;
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
/**
|
|
356
|
-
* @internal
|
|
357
|
-
*/
|
|
358
|
-
function compileAnalyzeInput(actions) {
|
|
359
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
360
|
-
return {
|
|
361
|
-
entityRecognitionPiiTasks: (_a = actions.recognizePiiEntitiesActions) === null || _a === void 0 ? void 0 : _a.map(compose(setStrEncodingParam, compose(setCategoriesFilter, addParamsToTask))),
|
|
362
|
-
entityRecognitionTasks: (_b = actions.recognizeEntitiesActions) === null || _b === void 0 ? void 0 : _b.map(compose(setStrEncodingParam, addParamsToTask)),
|
|
363
|
-
keyPhraseExtractionTasks: (_c = actions.extractKeyPhrasesActions) === null || _c === void 0 ? void 0 : _c.map(addParamsToTask),
|
|
364
|
-
entityLinkingTasks: (_d = actions.recognizeLinkedEntitiesActions) === null || _d === void 0 ? void 0 : _d.map(compose(setStrEncodingParam, addParamsToTask)),
|
|
365
|
-
sentimentAnalysisTasks: (_e = actions.analyzeSentimentActions) === null || _e === void 0 ? void 0 : _e.map(compose(setStrEncodingParam, compose(setOpinionMining, addParamsToTask))),
|
|
366
|
-
extractiveSummarizationTasks: (_f = actions.extractSummaryActions) === null || _f === void 0 ? void 0 : _f.map(compose(setStrEncodingParam, compose(setSentenceCount, compose(setOrderBy, addParamsToTask)))),
|
|
367
|
-
customEntityRecognitionTasks: (_g = actions.recognizeCustomEntitiesActions) === null || _g === void 0 ? void 0 : _g.map(compose(setStrEncodingParam, addParamsToTask)),
|
|
368
|
-
customSingleClassificationTasks: (_h = actions.singleCategoryClassifyActions) === null || _h === void 0 ? void 0 : _h.map(addParamsToTask),
|
|
369
|
-
customMultiClassificationTasks: (_j = actions.multiCategoryClassifyActions) === null || _j === void 0 ? void 0 : _j.map(addParamsToTask)
|
|
370
|
-
};
|
|
371
|
-
}
|
|
372
|
-
function isStringArray(documents) {
|
|
373
|
-
return typeof documents[0] === "string";
|
|
374
|
-
}
|
|
375
|
-
/**
|
|
376
|
-
* @internal
|
|
377
|
-
*/
|
|
378
|
-
function convertToDetectLanguageInput(inputs, countryHint) {
|
|
379
|
-
if (countryHint === "none") {
|
|
380
|
-
countryHint = "";
|
|
381
|
-
}
|
|
382
|
-
return inputs.map((text, index) => {
|
|
383
|
-
return {
|
|
384
|
-
id: String(index),
|
|
385
|
-
countryHint,
|
|
386
|
-
text
|
|
387
|
-
};
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
/**
|
|
391
|
-
* @internal
|
|
392
|
-
*/
|
|
393
|
-
function convertToTextDocumentInput(inputs, language) {
|
|
394
|
-
return inputs.map((text, index) => {
|
|
395
|
-
return {
|
|
396
|
-
id: String(index),
|
|
397
|
-
language,
|
|
398
|
-
text
|
|
399
|
-
};
|
|
400
|
-
});
|
|
401
|
-
}
|
|
402
|
-
/**
|
|
403
|
-
* Creates the options the service expects for the analyze sentiment API from the user friendly ones.
|
|
404
|
-
* @param params - the user friendly parameters
|
|
405
|
-
* @internal
|
|
406
|
-
*/
|
|
407
|
-
function makeGeneratedAnalyzeSentimentOptions(params) {
|
|
408
|
-
return {
|
|
409
|
-
abortSignal: params.abortSignal,
|
|
410
|
-
opinionMining: params.includeOpinionMining,
|
|
411
|
-
includeStatistics: params.includeStatistics,
|
|
412
|
-
modelVersion: params.modelVersion,
|
|
413
|
-
requestOptions: params.requestOptions,
|
|
414
|
-
stringIndexType: setStrEncodingParamValue(params.stringIndexType),
|
|
415
|
-
tracingOptions: params.tracingOptions,
|
|
416
|
-
onResponse: params.onResponse,
|
|
417
|
-
serializerOptions: params.serializerOptions,
|
|
418
|
-
loggingOptOut: params.disableServiceLogs
|
|
419
|
-
};
|
|
420
|
-
}
|
|
421
|
-
/**
|
|
422
|
-
* Creates the options the service expects for the recognize pii entities API from the user friendly ones.
|
|
423
|
-
* @param params - the user friendly parameters
|
|
424
|
-
* @internal
|
|
425
|
-
*/
|
|
426
|
-
function makeGeneratedRecognizePiiEntitiesOptions(params) {
|
|
427
|
-
return {
|
|
428
|
-
abortSignal: params.abortSignal,
|
|
429
|
-
domain: params.domainFilter,
|
|
430
|
-
includeStatistics: params.includeStatistics,
|
|
431
|
-
modelVersion: params.modelVersion,
|
|
432
|
-
requestOptions: params.requestOptions,
|
|
433
|
-
stringIndexType: setStrEncodingParamValue(params.stringIndexType),
|
|
434
|
-
tracingOptions: params.tracingOptions,
|
|
435
|
-
piiCategories: params.categoriesFilter,
|
|
436
|
-
onResponse: params.onResponse,
|
|
437
|
-
serializerOptions: params.serializerOptions,
|
|
438
|
-
loggingOptOut: params.disableServiceLogs
|
|
439
|
-
};
|
|
440
|
-
}
|
|
441
|
-
/**
|
|
442
|
-
* Creates the options the service expects for the recognize entities API from the user friendly ones.
|
|
443
|
-
* @param params - the user friendly parameters
|
|
444
|
-
* @internal
|
|
445
|
-
*/
|
|
446
|
-
function makeGeneratedRecognizeCategorizedEntitiesOptions(params) {
|
|
447
|
-
return {
|
|
448
|
-
abortSignal: params.abortSignal,
|
|
449
|
-
includeStatistics: params.includeStatistics,
|
|
450
|
-
modelVersion: params.modelVersion,
|
|
451
|
-
requestOptions: params.requestOptions,
|
|
452
|
-
stringIndexType: setStrEncodingParamValue(params.stringIndexType),
|
|
453
|
-
tracingOptions: params.tracingOptions,
|
|
454
|
-
onResponse: params.onResponse,
|
|
455
|
-
serializerOptions: params.serializerOptions,
|
|
456
|
-
loggingOptOut: params.disableServiceLogs
|
|
457
|
-
};
|
|
458
|
-
}
|
|
459
|
-
/**
|
|
460
|
-
* Creates the options the service expects for the detect language API from the user friendly ones.
|
|
461
|
-
* @param params - the user friendly parameters
|
|
462
|
-
* @internal
|
|
463
|
-
*/
|
|
464
|
-
function makeGeneratedDetectLanguageOptions(params) {
|
|
465
|
-
return {
|
|
466
|
-
abortSignal: params.abortSignal,
|
|
467
|
-
includeStatistics: params.includeStatistics,
|
|
468
|
-
modelVersion: params.modelVersion,
|
|
469
|
-
requestOptions: params.requestOptions,
|
|
470
|
-
tracingOptions: params.tracingOptions,
|
|
471
|
-
onResponse: params.onResponse,
|
|
472
|
-
serializerOptions: params.serializerOptions,
|
|
473
|
-
loggingOptOut: params.disableServiceLogs
|
|
474
|
-
};
|
|
475
|
-
}
|
|
476
|
-
/**
|
|
477
|
-
* Creates the options the service expects for the extract key phrases API from the user friendly ones.
|
|
478
|
-
* @param params - the user friendly parameters
|
|
479
|
-
* @internal
|
|
480
|
-
*/
|
|
481
|
-
function makeGeneratedExtractKeyPhrasesOptions(params) {
|
|
482
|
-
return {
|
|
483
|
-
abortSignal: params.abortSignal,
|
|
484
|
-
includeStatistics: params.includeStatistics,
|
|
485
|
-
modelVersion: params.modelVersion,
|
|
486
|
-
requestOptions: params.requestOptions,
|
|
487
|
-
tracingOptions: params.tracingOptions,
|
|
488
|
-
onResponse: params.onResponse,
|
|
489
|
-
serializerOptions: params.serializerOptions,
|
|
490
|
-
loggingOptOut: params.disableServiceLogs
|
|
491
|
-
};
|
|
492
|
-
}
|
|
493
|
-
/**
|
|
494
|
-
* Creates the options the service expects for the recognize linked entities API from the user friendly ones.
|
|
495
|
-
* @param params - the user friendly parameters
|
|
496
|
-
* @internal
|
|
497
|
-
*/
|
|
498
|
-
function makeGeneratedRecognizeLinkingEntitiesOptions(params) {
|
|
499
|
-
return {
|
|
500
|
-
abortSignal: params.abortSignal,
|
|
501
|
-
includeStatistics: params.includeStatistics,
|
|
502
|
-
modelVersion: params.modelVersion,
|
|
503
|
-
requestOptions: params.requestOptions,
|
|
504
|
-
tracingOptions: params.tracingOptions,
|
|
505
|
-
onResponse: params.onResponse,
|
|
506
|
-
serializerOptions: params.serializerOptions,
|
|
507
|
-
loggingOptOut: params.disableServiceLogs,
|
|
508
|
-
stringIndexType: setStrEncodingParamValue(params.stringIndexType)
|
|
509
|
-
};
|
|
510
|
-
}
|
|
511
|
-
//# sourceMappingURL=textAnalyticsClient.js.map
|