@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
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020 Microsoft
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT license.
|
|
3
|
-
import { makeAnalyzeSentimentResultArray } from "./analyzeSentimentResultArray";
|
|
4
|
-
import { makeMultiCategoryClassifyResultArray } from "./multiCategoryClassifyResultArray";
|
|
5
|
-
import { makeSingleCategoryClassifyResultArray } from "./singleCategoryClassifyResultArray";
|
|
6
|
-
import { makeExtractKeyPhrasesResultArray } from "./extractKeyPhrasesResultArray";
|
|
7
|
-
import { makeExtractSummaryResultArray } from "./extractSummaryResultArray";
|
|
8
|
-
import { makeRecognizeCategorizedEntitiesResultArray } from "./recognizeCategorizedEntitiesResultArray";
|
|
9
|
-
import { makeRecognizeCustomEntitiesResultArray } from "./recognizeCustomEntitiesResultArray";
|
|
10
|
-
import { makeRecognizeLinkedEntitiesResultArray } from "./recognizeLinkedEntitiesResultArray";
|
|
11
|
-
import { makeRecognizePiiEntitiesResultArray } from "./recognizePiiEntitiesResultArray";
|
|
12
|
-
import { intoTextAnalyticsError } from "./textAnalyticsResult";
|
|
13
|
-
/**
|
|
14
|
-
* Converts the service task name (in the JSON pointer in an action error) to an action type name.
|
|
15
|
-
* @param serviceActionType - The task type name the service uses.
|
|
16
|
-
* @returns the action type name that the package uses
|
|
17
|
-
* @internal
|
|
18
|
-
*/
|
|
19
|
-
function convertTaskTypeToActionType(taskType) {
|
|
20
|
-
switch (taskType) {
|
|
21
|
-
case "entityRecognitionTasks": {
|
|
22
|
-
return "RecognizeCategorizedEntities";
|
|
23
|
-
}
|
|
24
|
-
case "entityRecognitionPiiTasks": {
|
|
25
|
-
return "RecognizePiiEntities";
|
|
26
|
-
}
|
|
27
|
-
case "keyPhraseExtractionTasks": {
|
|
28
|
-
return "ExtractKeyPhrases";
|
|
29
|
-
}
|
|
30
|
-
case "entityLinkingTasks": {
|
|
31
|
-
return "RecognizeLinkedEntities";
|
|
32
|
-
}
|
|
33
|
-
case "sentimentAnalysisTasks": {
|
|
34
|
-
return "AnalyzeSentiment";
|
|
35
|
-
}
|
|
36
|
-
case "extractiveSummarizationTasks": {
|
|
37
|
-
return "ExtractSummary";
|
|
38
|
-
}
|
|
39
|
-
case "customEntityRecognitionTasks": {
|
|
40
|
-
return "RecognizeCustomEntities";
|
|
41
|
-
}
|
|
42
|
-
case "customSingleClassificationTasks": {
|
|
43
|
-
return "SingleCategoryClassify";
|
|
44
|
-
}
|
|
45
|
-
case "customMultiClassificationTasks": {
|
|
46
|
-
return "MultiCategoryClassify";
|
|
47
|
-
}
|
|
48
|
-
default: {
|
|
49
|
-
throw new Error(`unexpected action type from the service: ${taskType}`);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Converts a service action error to one with the JSON pointer converted to an action index.
|
|
55
|
-
* @param erredActions - the action error the service sent
|
|
56
|
-
* @returns an action error with an action type and index
|
|
57
|
-
* @internal
|
|
58
|
-
*/
|
|
59
|
-
export function parseActionError(erredActions) {
|
|
60
|
-
if (erredActions.target) {
|
|
61
|
-
const regex = new RegExp(/#\/tasks\/(entityRecognitionTasks|entityRecognitionPiiTasks|keyPhraseExtractionTasks|entityLinkingTasks|sentimentAnalysisTasks|extractiveSummarizationTasks|customEntityRecognitionTasks|customSingleClassificationTasks|customMultiClassificationTasks)\/(\d+)/);
|
|
62
|
-
const result = regex.exec(erredActions.target);
|
|
63
|
-
if (result !== null) {
|
|
64
|
-
return {
|
|
65
|
-
code: erredActions.code,
|
|
66
|
-
message: erredActions.message,
|
|
67
|
-
index: parseInt(result[2]),
|
|
68
|
-
type: convertTaskTypeToActionType(result[1])
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
throw new Error(`Pointer "${erredActions.target}" is not a valid action pointer`);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
throw new Error("expected an error with a target field referencing an action but did not get one");
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Categorize each action error into a bucket according to its action type.
|
|
81
|
-
* @param erredActions - list of action errors
|
|
82
|
-
* @param recognizeEntitiesActionErrors - a list of recognize entities action errors to be filled from the errors list
|
|
83
|
-
* @param recognizePiiEntitiesActionErrors - a list of recognize pii entities action errors to be filled from the errors list
|
|
84
|
-
* @param extractKeyPhrasesActionErrors - a list of extract key phrases action errors to be filled from the errors list
|
|
85
|
-
* @internal
|
|
86
|
-
*/
|
|
87
|
-
function categorizeActionErrors(erredActions, recognizeEntitiesActionErrors, recognizePiiEntitiesActionErrors, extractKeyPhrasesActionErrors, recognizeLinkedEntitiesActionErrors, analyzeSentimentActionErrors, extractSummarySentencesActionErrors, recognizeCustomEntitiesActionErrors, singleCategoryClassifyActionErrors, multiCategoryClassifyActionErrors) {
|
|
88
|
-
for (const error of erredActions) {
|
|
89
|
-
const actionError = parseActionError(error);
|
|
90
|
-
switch (actionError.type) {
|
|
91
|
-
case "RecognizeCategorizedEntities": {
|
|
92
|
-
recognizeEntitiesActionErrors.push(actionError);
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
case "RecognizePiiEntities": {
|
|
96
|
-
recognizePiiEntitiesActionErrors.push(actionError);
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
case "ExtractKeyPhrases": {
|
|
100
|
-
extractKeyPhrasesActionErrors.push(actionError);
|
|
101
|
-
break;
|
|
102
|
-
}
|
|
103
|
-
case "RecognizeLinkedEntities": {
|
|
104
|
-
recognizeLinkedEntitiesActionErrors.push(actionError);
|
|
105
|
-
break;
|
|
106
|
-
}
|
|
107
|
-
case "AnalyzeSentiment": {
|
|
108
|
-
analyzeSentimentActionErrors.push(actionError);
|
|
109
|
-
break;
|
|
110
|
-
}
|
|
111
|
-
case "ExtractSummary": {
|
|
112
|
-
extractSummarySentencesActionErrors.push(actionError);
|
|
113
|
-
break;
|
|
114
|
-
}
|
|
115
|
-
case "RecognizeCustomEntities": {
|
|
116
|
-
recognizeCustomEntitiesActionErrors.push(actionError);
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
case "SingleCategoryClassify": {
|
|
120
|
-
singleCategoryClassifyActionErrors.push(actionError);
|
|
121
|
-
break;
|
|
122
|
-
}
|
|
123
|
-
case "MultiCategoryClassify": {
|
|
124
|
-
multiCategoryClassifyActionErrors.push(actionError);
|
|
125
|
-
break;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* @internal
|
|
132
|
-
* @param error - the error the service sent for a task
|
|
133
|
-
* @param lastUpdateDateTime - the time when this task failed
|
|
134
|
-
*/
|
|
135
|
-
function createErredAction(error, lastUpdateDateTime, taskName) {
|
|
136
|
-
return {
|
|
137
|
-
error: intoTextAnalyticsError(error),
|
|
138
|
-
failedOn: lastUpdateDateTime,
|
|
139
|
-
actionName: taskName
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Creates a list of results for any action.
|
|
144
|
-
* @param documents - list of input documents
|
|
145
|
-
* @param makeResultsArray - a function to convert the results of a service response to the SDK's one
|
|
146
|
-
* @param succeededTasks - list of succeeded action results
|
|
147
|
-
* @param erredActions - list of erred actions
|
|
148
|
-
* @internal
|
|
149
|
-
*/
|
|
150
|
-
function makeActionResult(documents, makeResultsArray, succeededTasks, erredActions) {
|
|
151
|
-
let errorIndex = 0;
|
|
152
|
-
function convertTasksToActions(actions, task) {
|
|
153
|
-
const { results: actionResults, lastUpdateDateTime, taskName } = task;
|
|
154
|
-
if (actionResults !== undefined) {
|
|
155
|
-
const recognizeEntitiesResults = makeResultsArray(documents, actionResults);
|
|
156
|
-
return [
|
|
157
|
-
...actions,
|
|
158
|
-
{
|
|
159
|
-
results: recognizeEntitiesResults,
|
|
160
|
-
completedOn: lastUpdateDateTime,
|
|
161
|
-
actionName: taskName
|
|
162
|
-
}
|
|
163
|
-
];
|
|
164
|
-
}
|
|
165
|
-
else {
|
|
166
|
-
return [
|
|
167
|
-
...actions,
|
|
168
|
-
createErredAction(erredActions[errorIndex++], lastUpdateDateTime, taskName)
|
|
169
|
-
];
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
return succeededTasks.reduce(convertTasksToActions, []);
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Creates the user-friendly action results object for the begin analyze actions operation.
|
|
176
|
-
* @param response - the begin analyze actions operation response
|
|
177
|
-
* @param documents - the list of input documents
|
|
178
|
-
* @returns - the user-friendly action results object
|
|
179
|
-
* @internal
|
|
180
|
-
*/
|
|
181
|
-
export function createAnalyzeActionsResult(response, documents) {
|
|
182
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
183
|
-
const recognizeEntitiesActionErrors = [];
|
|
184
|
-
const recognizePiiEntitiesActionErrors = [];
|
|
185
|
-
const extractKeyPhrasesActionErrors = [];
|
|
186
|
-
const recognizeLinkedEntitiesActionErrors = [];
|
|
187
|
-
const analyzeSentimentActionErrors = [];
|
|
188
|
-
const extractSummarySentencesActionErrors = [];
|
|
189
|
-
const recognizeCustomEntitiesActionErrors = [];
|
|
190
|
-
const singleCategoryClassifyActionErrors = [];
|
|
191
|
-
const multiCategoryClassifyActionErrors = [];
|
|
192
|
-
categorizeActionErrors((_a = response === null || response === void 0 ? void 0 : response.errors) !== null && _a !== void 0 ? _a : [], recognizeEntitiesActionErrors, recognizePiiEntitiesActionErrors, extractKeyPhrasesActionErrors, recognizeLinkedEntitiesActionErrors, analyzeSentimentActionErrors, extractSummarySentencesActionErrors, recognizeCustomEntitiesActionErrors, singleCategoryClassifyActionErrors, multiCategoryClassifyActionErrors);
|
|
193
|
-
return {
|
|
194
|
-
recognizeEntitiesResults: makeActionResult(documents, makeRecognizeCategorizedEntitiesResultArray, (_b = response.tasks.entityRecognitionTasks) !== null && _b !== void 0 ? _b : [], recognizeEntitiesActionErrors),
|
|
195
|
-
recognizePiiEntitiesResults: makeActionResult(documents, makeRecognizePiiEntitiesResultArray, (_c = response.tasks.entityRecognitionPiiTasks) !== null && _c !== void 0 ? _c : [], recognizePiiEntitiesActionErrors),
|
|
196
|
-
extractKeyPhrasesResults: makeActionResult(documents, makeExtractKeyPhrasesResultArray, (_d = response.tasks.keyPhraseExtractionTasks) !== null && _d !== void 0 ? _d : [], extractKeyPhrasesActionErrors),
|
|
197
|
-
recognizeLinkedEntitiesResults: makeActionResult(documents, makeRecognizeLinkedEntitiesResultArray, (_e = response.tasks.entityLinkingTasks) !== null && _e !== void 0 ? _e : [], recognizeLinkedEntitiesActionErrors),
|
|
198
|
-
analyzeSentimentResults: makeActionResult(documents, makeAnalyzeSentimentResultArray, (_f = response.tasks.sentimentAnalysisTasks) !== null && _f !== void 0 ? _f : [], analyzeSentimentActionErrors),
|
|
199
|
-
extractSummaryResults: makeActionResult(documents, makeExtractSummaryResultArray, (_g = response.tasks.extractiveSummarizationTasks) !== null && _g !== void 0 ? _g : [], extractSummarySentencesActionErrors),
|
|
200
|
-
recognizeCustomEntitiesResults: makeActionResult(documents, makeRecognizeCustomEntitiesResultArray, (_h = response.tasks.customEntityRecognitionTasks) !== null && _h !== void 0 ? _h : [], recognizeCustomEntitiesActionErrors),
|
|
201
|
-
singleCategoryClassifyResults: makeActionResult(documents, makeSingleCategoryClassifyResultArray, (_j = response.tasks.customSingleClassificationTasks) !== null && _j !== void 0 ? _j : [], singleCategoryClassifyActionErrors),
|
|
202
|
-
multiCategoryClassifyResults: makeActionResult(documents, makeMultiCategoryClassifyResultArray, (_k = response.tasks.customMultiClassificationTasks) !== null && _k !== void 0 ? _k : [], multiCategoryClassifyActionErrors)
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
//# sourceMappingURL=analyzeActionsResult.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"analyzeActionsResult.js","sourceRoot":"","sources":["../../src/analyzeActionsResult.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAEL,+BAA+B,EAChC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAEL,oCAAoC,EACrC,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAEL,qCAAqC,EACtC,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAEL,gCAAgC,EACjC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAEL,6BAA6B,EAC9B,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,2CAA2C,EAE5C,MAAM,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B,mCAAI,EAAE,EAC7C,6BAA6B,CAC9B;QACD,8BAA8B,EAAE,gBAAgB,CAC9C,SAAS,EACT,sCAAsC,EACtC,MAAA,QAAQ,CAAC,KAAK,CAAC,kBAAkB,mCAAI,EAAE,EACvC,mCAAmC,CACpC;QACD,uBAAuB,EAAE,gBAAgB,CACvC,SAAS,EACT,+BAA+B,EAC/B,MAAA,QAAQ,CAAC,KAAK,CAAC,sBAAsB,mCAAI,EAAE,EAC3C,4BAA4B,CAC7B;QACD,qBAAqB,EAAE,gBAAgB,CACrC,SAAS,EACT,6BAA6B,EAC7B,MAAA,QAAQ,CAAC,KAAK,CAAC,4BAA4B,mCAAI,EAAE,EACjD,mCAAmC,CACpC;QACD,8BAA8B,EAAE,gBAAgB,CAC9C,SAAS,EACT,sCAAsC,EACtC,MAAA,QAAQ,CAAC,KAAK,CAAC,4BAA4B,mCAAI,EAAE,EACjD,mCAAmC,CACpC;QACD,6BAA6B,EAAE,gBAAgB,CAC7C,SAAS,EACT,qCAAqC,EACrC,MAAA,QAAQ,CAAC,KAAK,CAAC,+BAA+B,mCAAI,EAAE,EACpD,kCAAkC,CACnC;QACD,4BAA4B,EAAE,gBAAgB,CAC5C,SAAS,EACT,oCAAoC,EACpC,MAAA,QAAQ,CAAC,KAAK,CAAC,8BAA8B,mCAAI,EAAE,EACnD,iCAAiC,CAClC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { PagedAsyncIterableIterator } from \"@azure/core-paging\";\nimport {\n AnalyzeSentimentResultArray,\n makeAnalyzeSentimentResultArray\n} from \"./analyzeSentimentResultArray\";\nimport {\n MultiCategoryClassifyResultArray,\n makeMultiCategoryClassifyResultArray\n} from \"./multiCategoryClassifyResultArray\";\nimport {\n SingleCategoryClassifyResultArray,\n makeSingleCategoryClassifyResultArray\n} from \"./singleCategoryClassifyResultArray\";\nimport {\n ExtractKeyPhrasesResultArray,\n makeExtractKeyPhrasesResultArray\n} from \"./extractKeyPhrasesResultArray\";\nimport {\n ExtractSummaryResultArray,\n makeExtractSummaryResultArray\n} from \"./extractSummaryResultArray\";\nimport { AnalyzeJobState as GeneratedResponse, TextDocumentInput } from \"./generated/models\";\nimport {\n makeRecognizeCategorizedEntitiesResultArray,\n RecognizeCategorizedEntitiesResultArray\n} from \"./recognizeCategorizedEntitiesResultArray\";\nimport {\n makeRecognizeCustomEntitiesResultArray,\n RecognizeCustomEntitiesResultArray\n} from \"./recognizeCustomEntitiesResultArray\";\nimport {\n makeRecognizeLinkedEntitiesResultArray,\n RecognizeLinkedEntitiesResultArray\n} from \"./recognizeLinkedEntitiesResultArray\";\nimport {\n makeRecognizePiiEntitiesResultArray,\n RecognizePiiEntitiesResultArray\n} from \"./recognizePiiEntitiesResultArray\";\nimport { ErrorCode, intoTextAnalyticsError, TextAnalyticsError } from \"./textAnalyticsResult\";\n\n/**\n * The results of an analyze Actions operation.\n */\nexport interface AnalyzeActionsResult {\n /**\n * Array of the results for each categorized entities recognition action.\n */\n recognizeEntitiesResults: RecognizeCategorizedEntitiesActionResult[];\n /**\n * Array of the results for each Pii entities recognition action.\n */\n recognizePiiEntitiesResults: RecognizePiiEntitiesActionResult[];\n /**\n * Array of the results for each key phrases extraction action.\n */\n extractKeyPhrasesResults: ExtractKeyPhrasesActionResult[];\n /**\n * Array of the results for each linked entities recognition action.\n */\n recognizeLinkedEntitiesResults: RecognizeLinkedEntitiesActionResult[];\n /**\n * Array of the results for each analyze sentiment action.\n */\n analyzeSentimentResults: AnalyzeSentimentActionResult[];\n /**\n * Array of the results for each extract summary action.\n */\n extractSummaryResults: ExtractSummaryActionResult[];\n /**\n * Array of the results for each recognize custom entities action.\n */\n recognizeCustomEntitiesResults: RecognizeCustomEntitiesActionResult[];\n /**\n * Array of the results for each custom classify document single category action.\n */\n singleCategoryClassifyResults: SingleCategoryClassifyActionResult[];\n /**\n * Array of the results for each custom classify document multi category action.\n */\n multiCategoryClassifyResults: MultiCategoryClassifyActionResult[];\n}\n\n/**\n * The state of an action\n */\nexport interface TextAnalyticsActionState {\n /**\n * The name of the action.\n */\n actionName?: string;\n}\n\n/**\n * The state of a succeeded action.\n */\nexport interface TextAnalyticsActionSuccessState extends TextAnalyticsActionState {\n /**\n * When this action was completed by the service.\n */\n readonly completedOn: Date;\n /**\n * Discriminant to determine if that this is an error result.\n */\n readonly error?: undefined;\n}\n\n/**\n * The error of an analyze batch action.\n */\nexport interface TextAnalyticsActionErrorResult extends TextAnalyticsActionState {\n /**\n * When this action was completed by the service.\n */\n readonly failedOn: Date;\n /**\n * The Error for this action result.\n */\n readonly error: TextAnalyticsError;\n}\n\n/**\n * The error of a recognize categorized entities action.\n */\nexport type RecognizeCategorizedEntitiesActionErrorResult = TextAnalyticsActionErrorResult;\n\n/**\n * The results of a succeeded recognize categorized entities action.\n */\nexport interface RecognizeCategorizedEntitiesActionSuccessResult\n extends TextAnalyticsActionSuccessState {\n /**\n * Array of the results for each categorized entities recognition action.\n */\n results: RecognizeCategorizedEntitiesResultArray;\n}\n\n/**\n * The result of a recognize categorized entities action.\n */\nexport type RecognizeCategorizedEntitiesActionResult =\n | RecognizeCategorizedEntitiesActionSuccessResult\n | RecognizeCategorizedEntitiesActionErrorResult;\n\n/**\n * The error of a recognize pii entities action.\n */\nexport type RecognizePiiEntitiesActionErrorResult = TextAnalyticsActionErrorResult;\n\n/**\n * The results of a succeeded recognize pii entities action.\n */\nexport interface RecognizePiiEntitiesActionSuccessResult extends TextAnalyticsActionSuccessState {\n /**\n * Array of the results for each pii entities recognition action.\n */\n results: RecognizePiiEntitiesResultArray;\n}\n\n/**\n * The result of a recognize pii entities action.\n */\nexport type RecognizePiiEntitiesActionResult =\n | RecognizePiiEntitiesActionSuccessResult\n | RecognizePiiEntitiesActionErrorResult;\n\n/**\n * The error of a extract key phrases action.\n */\nexport type ExtractKeyPhrasesActionErrorResult = TextAnalyticsActionErrorResult;\n\n/**\n * The results of a succeeded extract key phrases action.\n */\nexport interface ExtractKeyPhrasesActionSuccessResult extends TextAnalyticsActionSuccessState {\n /**\n * Array of the results for each extract key phrases action.\n */\n results: ExtractKeyPhrasesResultArray;\n}\n\n/**\n * The result of a extract key phrases action.\n */\nexport type ExtractKeyPhrasesActionResult =\n | ExtractKeyPhrasesActionSuccessResult\n | ExtractKeyPhrasesActionErrorResult;\n\n/**\n * The error of a recognize linked entities action.\n */\nexport type RecognizeLinkedEntitiesActionErrorResult = TextAnalyticsActionErrorResult;\n\n/**\n * The results of a succeeded recognize linked entities action.\n */\nexport interface RecognizeLinkedEntitiesActionSuccessResult\n extends TextAnalyticsActionSuccessState {\n /**\n * Array of the results for each linked entities recognition action.\n */\n results: RecognizeLinkedEntitiesResultArray;\n}\n\n/**\n * The result of a recognize linked entities action.\n */\nexport type RecognizeLinkedEntitiesActionResult =\n | RecognizeLinkedEntitiesActionSuccessResult\n | RecognizeLinkedEntitiesActionErrorResult;\n\n/**\n * The error of an analyze sentiment action.\n */\nexport type AnalyzeSentimentActionErrorResult = TextAnalyticsActionErrorResult;\n\n/**\n * The results of a succeeded analyze sentiment action.\n */\nexport interface AnalyzeSentimentActionSuccessResult extends TextAnalyticsActionSuccessState {\n /**\n * Array of the results for each analyze sentiment action.\n */\n results: AnalyzeSentimentResultArray;\n}\n\n/**\n * The result of an analyze sentiment action.\n */\nexport type AnalyzeSentimentActionResult =\n | AnalyzeSentimentActionSuccessResult\n | AnalyzeSentimentActionErrorResult;\n\n/**\n * The error of an extract summary action.\n */\nexport type ExtractSummaryActionErrorResult = TextAnalyticsActionErrorResult;\n\n/**\n * The results of a succeeded extract summary action.\n */\nexport interface ExtractSummaryActionSuccessResult extends TextAnalyticsActionSuccessState {\n /**\n * Array of the results for each extract summary action.\n */\n results: ExtractSummaryResultArray;\n}\n\n/**\n * The result of an extract summary action.\n */\nexport type ExtractSummaryActionResult =\n | ExtractSummaryActionSuccessResult\n | ExtractSummaryActionErrorResult;\n\n/**\n * The error of a custom recognize entities action.\n */\nexport type RecongizeCustomEntitiesActionErrorResult = TextAnalyticsActionErrorResult;\n\n/**\n * The results of a succeeded custom recognize entities action.\n */\nexport interface RecongizeCustomEntitiesActionSuccessResult\n extends TextAnalyticsActionSuccessState {\n /**\n * Array of the results for each custom recognize entities action.\n */\n results: RecognizeCustomEntitiesResultArray;\n}\n\n/**\n * The result of a custom recognize entities action.\n */\nexport type RecognizeCustomEntitiesActionResult =\n | RecongizeCustomEntitiesActionSuccessResult\n | RecongizeCustomEntitiesActionErrorResult;\n\n/**\n * The error of a custom classify document single category action.\n */\nexport type SingleCategoryClassifyActionErrorResult = TextAnalyticsActionErrorResult;\n\n/**\n * The results of a succeeded custom classify document single category action.\n */\nexport interface SingleCategoryClassifyActionSuccessResult extends TextAnalyticsActionSuccessState {\n /**\n * Array of the results for each custom classify document single category action.\n */\n results: SingleCategoryClassifyResultArray;\n}\n\n/**\n * The result of a custom classify document single category action.\n */\nexport type SingleCategoryClassifyActionResult =\n | SingleCategoryClassifyActionSuccessResult\n | SingleCategoryClassifyActionErrorResult;\n\n/**\n * The error of a custom classify document multi category action.\n */\nexport type MultiCategoryClassifyActionErrorResult = TextAnalyticsActionErrorResult;\n\n/**\n * The results of a succeeded custom classify document multi category action.\n */\nexport interface MultiCategoryClassifyActionSuccessResult extends TextAnalyticsActionSuccessState {\n /**\n * Array of the results for each custom classify document multi category action.\n */\n results: MultiCategoryClassifyResultArray;\n}\n\n/**\n * The result of a custom classify document multi category action.\n */\nexport type MultiCategoryClassifyActionResult =\n | MultiCategoryClassifyActionSuccessResult\n | MultiCategoryClassifyActionErrorResult;\n\n/**\n * The results of an analyze Actions operation represented as a paged iterator that\n * iterates over the results of the requested actions.\n */\nexport type PagedAsyncIterableAnalyzeActionsResult = PagedAsyncIterableIterator<\n AnalyzeActionsResult,\n AnalyzeActionsResult\n>;\n\n/**\n * The results of an analyze actions operation represented as a paged iterator that\n * iterates over the results of the requested actions.\n */\nexport interface PagedAnalyzeActionsResult extends PagedAsyncIterableAnalyzeActionsResult {\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\n/**\n * The type of different actions supported by the begin analyze actions operation.\n * @internal\n */\ntype TextAnalyticsActionType =\n | \"RecognizeCategorizedEntities\"\n | \"RecognizePiiEntities\"\n | \"ExtractKeyPhrases\"\n | \"RecognizeLinkedEntities\"\n | \"AnalyzeSentiment\"\n | \"ExtractSummary\"\n | \"RecognizeCustomEntities\"\n | \"SingleCategoryClassify\"\n | \"MultiCategoryClassify\";\n\n/**\n * The type of an action error with the type of the action that erred and its\n * index in the list of input actions.\n * @internal\n */\ninterface TextAnalyticsActionError {\n /**\n * A code describing the kind of error produced\n */\n readonly code: ErrorCode;\n /**\n * A message from the service explaining the error\n */\n readonly message: string;\n /**\n * The type of the action that erred\n */\n readonly type: TextAnalyticsActionType;\n /**\n * The index of the action that erred in the list of input actions\n */\n readonly index: number;\n}\n\n/**\n * Converts the service task name (in the JSON pointer in an action error) to an action type name.\n * @param serviceActionType - The task type name the service uses.\n * @returns the action type name that the package uses\n * @internal\n */\nfunction convertTaskTypeToActionType(taskType: string): TextAnalyticsActionType {\n switch (taskType) {\n case \"entityRecognitionTasks\": {\n return \"RecognizeCategorizedEntities\";\n }\n case \"entityRecognitionPiiTasks\": {\n return \"RecognizePiiEntities\";\n }\n case \"keyPhraseExtractionTasks\": {\n return \"ExtractKeyPhrases\";\n }\n case \"entityLinkingTasks\": {\n return \"RecognizeLinkedEntities\";\n }\n case \"sentimentAnalysisTasks\": {\n return \"AnalyzeSentiment\";\n }\n case \"extractiveSummarizationTasks\": {\n return \"ExtractSummary\";\n }\n case \"customEntityRecognitionTasks\": {\n return \"RecognizeCustomEntities\";\n }\n case \"customSingleClassificationTasks\": {\n return \"SingleCategoryClassify\";\n }\n case \"customMultiClassificationTasks\": {\n return \"MultiCategoryClassify\";\n }\n default: {\n throw new Error(`unexpected action type from the service: ${taskType}`);\n }\n }\n}\n\n/**\n * Converts a service action error to one with the JSON pointer converted to an action index.\n * @param erredActions - the action error the service sent\n * @returns an action error with an action type and index\n * @internal\n */\nexport function parseActionError(erredActions: TextAnalyticsError): TextAnalyticsActionError {\n if (erredActions.target) {\n const regex = new RegExp(\n /#\\/tasks\\/(entityRecognitionTasks|entityRecognitionPiiTasks|keyPhraseExtractionTasks|entityLinkingTasks|sentimentAnalysisTasks|extractiveSummarizationTasks|customEntityRecognitionTasks|customSingleClassificationTasks|customMultiClassificationTasks)\\/(\\d+)/\n );\n const result = regex.exec(erredActions.target);\n if (result !== null) {\n return {\n code: erredActions.code,\n message: erredActions.message,\n index: parseInt(result[2]),\n type: convertTaskTypeToActionType(result[1])\n };\n } else {\n throw new Error(`Pointer \"${erredActions.target}\" is not a valid action pointer`);\n }\n } else {\n throw new Error(\n \"expected an error with a target field referencing an action but did not get one\"\n );\n }\n}\n\n/**\n * Categorize each action error into a bucket according to its action type.\n * @param erredActions - list of action errors\n * @param recognizeEntitiesActionErrors - a list of recognize entities action errors to be filled from the errors list\n * @param recognizePiiEntitiesActionErrors - a list of recognize pii entities action errors to be filled from the errors list\n * @param extractKeyPhrasesActionErrors - a list of extract key phrases action errors to be filled from the errors list\n * @internal\n */\nfunction categorizeActionErrors(\n erredActions: TextAnalyticsError[],\n recognizeEntitiesActionErrors: TextAnalyticsActionError[],\n recognizePiiEntitiesActionErrors: TextAnalyticsActionError[],\n extractKeyPhrasesActionErrors: TextAnalyticsActionError[],\n recognizeLinkedEntitiesActionErrors: TextAnalyticsActionError[],\n analyzeSentimentActionErrors: TextAnalyticsActionError[],\n extractSummarySentencesActionErrors: TextAnalyticsActionError[],\n recognizeCustomEntitiesActionErrors: TextAnalyticsActionError[],\n singleCategoryClassifyActionErrors: TextAnalyticsActionError[],\n multiCategoryClassifyActionErrors: TextAnalyticsActionError[]\n): void {\n for (const error of erredActions) {\n const actionError = parseActionError(error);\n switch (actionError.type) {\n case \"RecognizeCategorizedEntities\": {\n recognizeEntitiesActionErrors.push(actionError);\n break;\n }\n case \"RecognizePiiEntities\": {\n recognizePiiEntitiesActionErrors.push(actionError);\n break;\n }\n case \"ExtractKeyPhrases\": {\n extractKeyPhrasesActionErrors.push(actionError);\n break;\n }\n case \"RecognizeLinkedEntities\": {\n recognizeLinkedEntitiesActionErrors.push(actionError);\n break;\n }\n case \"AnalyzeSentiment\": {\n analyzeSentimentActionErrors.push(actionError);\n break;\n }\n case \"ExtractSummary\": {\n extractSummarySentencesActionErrors.push(actionError);\n break;\n }\n case \"RecognizeCustomEntities\": {\n recognizeCustomEntitiesActionErrors.push(actionError);\n break;\n }\n case \"SingleCategoryClassify\": {\n singleCategoryClassifyActionErrors.push(actionError);\n break;\n }\n case \"MultiCategoryClassify\": {\n multiCategoryClassifyActionErrors.push(actionError);\n break;\n }\n }\n }\n}\n\n/**\n * @internal\n * @param error - the error the service sent for a task\n * @param lastUpdateDateTime - the time when this task failed\n */\nfunction createErredAction(\n error: TextAnalyticsActionError,\n lastUpdateDateTime: Date,\n taskName?: string\n): TextAnalyticsActionErrorResult {\n return {\n error: intoTextAnalyticsError(error),\n failedOn: lastUpdateDateTime,\n actionName: taskName\n };\n}\n\ninterface TaskSuccessResult<T> {\n results?: T;\n taskName?: string;\n lastUpdateDateTime: Date;\n}\n\ntype ActionResult<TSuccess> =\n | {\n results: TSuccess;\n completedOn: Date;\n }\n | TextAnalyticsActionErrorResult;\n\n/**\n * Creates a list of results for any action.\n * @param documents - list of input documents\n * @param makeResultsArray - a function to convert the results of a service response to the SDK's one\n * @param succeededTasks - list of succeeded action results\n * @param erredActions - list of erred actions\n * @internal\n */\nfunction makeActionResult<TTaskResult, TActionResult>(\n documents: TextDocumentInput[],\n makeResultsArray: (docs: TextDocumentInput[], x: TTaskResult) => TActionResult,\n succeededTasks: TaskSuccessResult<TTaskResult>[],\n erredActions: TextAnalyticsActionError[]\n): ActionResult<TActionResult>[] {\n let errorIndex = 0;\n function convertTasksToActions(\n actions: ActionResult<TActionResult>[],\n task: TaskSuccessResult<TTaskResult>\n ): ActionResult<TActionResult>[] {\n const { results: actionResults, lastUpdateDateTime, taskName } = task;\n if (actionResults !== undefined) {\n const recognizeEntitiesResults = makeResultsArray(documents, actionResults);\n return [\n ...actions,\n {\n results: recognizeEntitiesResults,\n completedOn: lastUpdateDateTime,\n actionName: taskName\n }\n ];\n } else {\n return [\n ...actions,\n createErredAction(erredActions[errorIndex++], lastUpdateDateTime, taskName)\n ];\n }\n }\n return succeededTasks.reduce(convertTasksToActions, []);\n}\n\n/**\n * Creates the user-friendly action results object for the begin analyze actions operation.\n * @param response - the begin analyze actions operation response\n * @param documents - the list of input documents\n * @returns - the user-friendly action results object\n * @internal\n */\nexport function createAnalyzeActionsResult(\n response: GeneratedResponse,\n documents: TextDocumentInput[]\n): AnalyzeActionsResult {\n const recognizeEntitiesActionErrors: TextAnalyticsActionError[] = [];\n const recognizePiiEntitiesActionErrors: TextAnalyticsActionError[] = [];\n const extractKeyPhrasesActionErrors: TextAnalyticsActionError[] = [];\n const recognizeLinkedEntitiesActionErrors: TextAnalyticsActionError[] = [];\n const analyzeSentimentActionErrors: TextAnalyticsActionError[] = [];\n const extractSummarySentencesActionErrors: TextAnalyticsActionError[] = [];\n const recognizeCustomEntitiesActionErrors: TextAnalyticsActionError[] = [];\n const singleCategoryClassifyActionErrors: TextAnalyticsActionError[] = [];\n const multiCategoryClassifyActionErrors: TextAnalyticsActionError[] = [];\n categorizeActionErrors(\n response?.errors ?? [],\n recognizeEntitiesActionErrors,\n recognizePiiEntitiesActionErrors,\n extractKeyPhrasesActionErrors,\n recognizeLinkedEntitiesActionErrors,\n analyzeSentimentActionErrors,\n extractSummarySentencesActionErrors,\n recognizeCustomEntitiesActionErrors,\n singleCategoryClassifyActionErrors,\n multiCategoryClassifyActionErrors\n );\n return {\n recognizeEntitiesResults: makeActionResult(\n documents,\n makeRecognizeCategorizedEntitiesResultArray,\n response.tasks.entityRecognitionTasks ?? [],\n recognizeEntitiesActionErrors\n ),\n recognizePiiEntitiesResults: makeActionResult(\n documents,\n makeRecognizePiiEntitiesResultArray,\n response.tasks.entityRecognitionPiiTasks ?? [],\n recognizePiiEntitiesActionErrors\n ),\n extractKeyPhrasesResults: makeActionResult(\n documents,\n makeExtractKeyPhrasesResultArray,\n response.tasks.keyPhraseExtractionTasks ?? [],\n extractKeyPhrasesActionErrors\n ),\n recognizeLinkedEntitiesResults: makeActionResult(\n documents,\n makeRecognizeLinkedEntitiesResultArray,\n response.tasks.entityLinkingTasks ?? [],\n recognizeLinkedEntitiesActionErrors\n ),\n analyzeSentimentResults: makeActionResult(\n documents,\n makeAnalyzeSentimentResultArray,\n response.tasks.sentimentAnalysisTasks ?? [],\n analyzeSentimentActionErrors\n ),\n extractSummaryResults: makeActionResult(\n documents,\n makeExtractSummaryResultArray,\n response.tasks.extractiveSummarizationTasks ?? [],\n extractSummarySentencesActionErrors\n ),\n recognizeCustomEntitiesResults: makeActionResult(\n documents,\n makeRecognizeCustomEntitiesResultArray,\n response.tasks.customEntityRecognitionTasks ?? [],\n recognizeCustomEntitiesActionErrors\n ),\n singleCategoryClassifyResults: makeActionResult(\n documents,\n makeSingleCategoryClassifyResultArray,\n response.tasks.customSingleClassificationTasks ?? [],\n singleCategoryClassifyActionErrors\n ),\n multiCategoryClassifyResults: makeActionResult(\n documents,\n makeMultiCategoryClassifyResultArray,\n response.tasks.customMultiClassificationTasks ?? [],\n multiCategoryClassifyActionErrors\n )\n };\n}\n"]}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT license.
|
|
3
|
-
import { makeTextAnalyticsErrorResult, makeTextAnalyticsSuccessResult } from "./textAnalyticsResult";
|
|
4
|
-
import { parseHealthcareEntityIndex } from "./util";
|
|
5
|
-
/**
|
|
6
|
-
* Creates a user-friendly healthcare entity represented as a node in a graph
|
|
7
|
-
* @param entity - the healthcare entity returned by the service
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
function makeHealthcareEntitiesWithoutNeighbors(entity) {
|
|
11
|
-
var _a;
|
|
12
|
-
const { category, confidenceScore, assertion, offset, text, links, subcategory, length, name } = entity;
|
|
13
|
-
return {
|
|
14
|
-
category,
|
|
15
|
-
confidenceScore,
|
|
16
|
-
assertion,
|
|
17
|
-
offset,
|
|
18
|
-
length,
|
|
19
|
-
text,
|
|
20
|
-
normalizedText: name,
|
|
21
|
-
subCategory: subcategory,
|
|
22
|
-
dataSources: (_a = links === null || links === void 0 ? void 0 : links.map(({ dataSource, id }) => ({ name: dataSource, entityId: id }))) !== null && _a !== void 0 ? _a : []
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* @internal
|
|
27
|
-
*/
|
|
28
|
-
function makeHealthcareRelations(entities, relations) {
|
|
29
|
-
return relations.map((relation) => ({
|
|
30
|
-
relationType: relation.relationType,
|
|
31
|
-
roles: relation.entities.map((role) => ({
|
|
32
|
-
entity: entities[parseHealthcareEntityIndex(role.ref)],
|
|
33
|
-
name: role.role
|
|
34
|
-
}))
|
|
35
|
-
}));
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Creates a healthcare entity in the convenience layer from the one sent by the service.
|
|
39
|
-
* @param document - incoming results sent by the service for a particular document
|
|
40
|
-
* @internal
|
|
41
|
-
*/
|
|
42
|
-
export function makeHealthcareEntitiesResult(document) {
|
|
43
|
-
const { id, entities, relations, warnings, statistics } = document;
|
|
44
|
-
const newEntities = entities.map(makeHealthcareEntitiesWithoutNeighbors);
|
|
45
|
-
return Object.assign(Object.assign({}, makeTextAnalyticsSuccessResult(id, warnings, statistics)), { entities: newEntities, entityRelations: makeHealthcareRelations(newEntities, relations) });
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* @internal
|
|
49
|
-
*/
|
|
50
|
-
export function makeHealthcareEntitiesErrorResult(id, error) {
|
|
51
|
-
return makeTextAnalyticsErrorResult(id, error);
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=analyzeHealthcareEntitiesResult.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"analyzeHealthcareEntitiesResult.js","sourceRoot":"","sources":["../../src/analyzeHealthcareEntitiesResult.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAelC,OAAO,EACL,4BAA4B,EAC5B,8BAA8B,EAG/B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,0BAA0B,EAAE,MAAM,QAAQ,CAAC;AAoKpD;;;;GAIG;AACH,SAAS,sCAAsC,CAC7C,MAAiC;;IAEjC,MAAM,EACJ,QAAQ,EACR,eAAe,EACf,SAAS,EACT,MAAM,EACN,IAAI,EACJ,KAAK,EACL,WAAW,EACX,MAAM,EACN,IAAI,EACL,GAAG,MAAM,CAAC;IACX,OAAO;QACL,QAAQ;QACR,eAAe;QACf,SAAS;QACT,MAAM;QACN,MAAM;QACN,IAAI;QACJ,cAAc,EAAE,IAAI;QACpB,WAAW,EAAE,WAAW;QACxB,WAAW,EACT,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,GAAG,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,EAAoB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC,mCAC1F,EAAE;KACL,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,uBAAuB,CAC9B,QAA4B,EAC5B,SAA+B;IAE/B,OAAO,SAAS,CAAC,GAAG,CAClB,CAAC,QAA4B,EAA4B,EAAE,CAAC,CAAC;QAC3D,YAAY,EAAE,QAAQ,CAAC,YAAY;QACnC,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAC1B,CAAC,IAA8B,EAAgC,EAAE,CAAC,CAAC;YACjE,MAAM,EAAE,QAAQ,CAAC,0BAA0B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACtD,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC,CACH;KACF,CAAC,CACH,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,4BAA4B,CAC1C,QAAoC;IAEpC,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,QAAQ,CAAC;IACnE,MAAM,WAAW,GAAG,QAAQ,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC;IACzE,uCACK,8BAA8B,CAAC,EAAE,EAAE,QAAQ,EAAE,UAAU,CAAC,KAC3D,QAAQ,EAAE,WAAW,EACrB,eAAe,EAAE,uBAAuB,CAAC,WAAW,EAAE,SAAS,CAAC,IAChE;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iCAAiC,CAC/C,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 { PagedAsyncIterableIterator } from \"@azure/core-paging\";\nimport {\n DocumentHealthcareEntities,\n Entity,\n HealthcareRelation,\n TextDocumentBatchStatistics,\n HealthcareEntity as GeneratedHealthcareEntity,\n TextAnalyticsError,\n HealthcareAssertion,\n RelationType,\n HealthcareRelationEntity,\n HealthcareEntityCategory\n} from \"./generated/models\";\nimport {\n makeTextAnalyticsErrorResult,\n makeTextAnalyticsSuccessResult,\n TextAnalyticsErrorResult,\n TextAnalyticsSuccessResult\n} from \"./textAnalyticsResult\";\nimport { parseHealthcareEntityIndex } from \"./util\";\n\n/**\n * A type representing a reference for the healthcare entity into a specific\n * entity catalog.\n */\nexport interface EntityDataSource {\n /**\n * Entity Catalog. Examples include: UMLS, CHV, MSH, etc.\n */\n name: string;\n /**\n * Entity id in the given source catalog.\n */\n entityId: string;\n}\n\n/**\n * A healthcare entity represented as a node in a directed graph where the edges are\n * a particular type of relationship between the source and target nodes.\n */\nexport interface HealthcareEntity extends Entity {\n /**\n * Normalized name for the entity. For example, the normalized text for \"histologically\" is \"histologic\".\n */\n normalizedText?: string;\n /**\n * Whether the entity is negated.\n */\n assertion?: HealthcareAssertion;\n /**\n * Entity references in known data sources.\n */\n dataSources: EntityDataSource[];\n /**\n * Defines values for HealthcareEntityCategory.\n * {@link KnownHealthcareEntityCategory} can be used interchangeably with HealthcareEntityCategory,\n * this enum contains the known values that the service supports.\n * ### Known values supported by the service\n * **BODY_STRUCTURE**\n * **AGE**\n * **GENDER**\n * **EXAMINATION_NAME**\n * **DATE**\n * **DIRECTION**\n * **FREQUENCY**\n * **MEASUREMENT_VALUE**\n * **MEASUREMENT_UNIT**\n * **RELATIONAL_OPERATOR**\n * **TIME**\n * **GENE_OR_PROTEIN**\n * **VARIANT**\n * **ADMINISTRATIVE_EVENT**\n * **CARE_ENVIRONMENT**\n * **HEALTHCARE_PROFESSION**\n * **DIAGNOSIS**\n * **SYMPTOM_OR_SIGN**\n * **CONDITION_QUALIFIER**\n * **MEDICATION_CLASS**\n * **MEDICATION_NAME**\n * **DOSAGE**\n * **MEDICATION_FORM**\n * **MEDICATION_ROUTE**\n * **FAMILY_RELATION**\n * **TREATMENT_NAME**\n */\n category: HealthcareEntityCategory;\n}\n\n/**\n * The type of different roles a healthcare entity can play in a relation.\n */\nexport type HealthcareEntityRelationRoleType = string;\n\n/**\n * A healthcare entity that plays a specific role in a relation.\n */\nexport interface HealthcareEntityRelationRole {\n /**\n * A healthcare entity\n */\n entity: HealthcareEntity;\n /**\n * The role of the healthcare entity in a particular relation.\n */\n name: HealthcareEntityRelationRoleType;\n}\n\n/**\n * A relationship between two or more healthcare entities.\n */\nexport interface HealthcareEntityRelation {\n /**\n * The type of the healthcare relation.\n */\n relationType: RelationType;\n /**\n * The list of healthcare entities and their roles in the healthcare relation.\n */\n roles: HealthcareEntityRelationRole[];\n}\n\n/**\n * The results of a successful healthcare operation for a single document.\n */\nexport interface AnalyzeHealthcareEntitiesSuccessResult extends TextAnalyticsSuccessResult {\n /**\n * Healthcare entities.\n */\n entities: HealthcareEntity[];\n /**\n * Relations between healthcare entities.\n */\n entityRelations: HealthcareEntityRelation[];\n}\n\n/**\n * An error result from the healthcare operation on a single document.\n */\nexport type AnalyzeHealthcareEntitiesErrorResult = TextAnalyticsErrorResult;\n\n/**\n * The result of the healthcare operation on a single document.\n */\nexport type AnalyzeHealthcareEntitiesResult =\n | AnalyzeHealthcareEntitiesSuccessResult\n | AnalyzeHealthcareEntitiesErrorResult;\n\n/**\n * Array of {@link AnalyzeHealthcareEntitiesResult}\n */\nexport interface AnalyzeHealthcareEntitiesResultArray\n extends Array<AnalyzeHealthcareEntitiesResult> {}\n\n/**\n * The results of a healthcare operation represented as a paged iterator that can\n * either iterate over the results on a document-by-document basis or, by\n * byPage(), can iterate over pages of documents.\n */\nexport type PagedAsyncIterableAnalyzeHealthcareEntitiesResult = PagedAsyncIterableIterator<\n AnalyzeHealthcareEntitiesResult,\n AnalyzeHealthcareEntitiesResultArray\n>;\n\n/**\n * The results of a healthcare operation represented as a paged iterator that can\n * either iterate over the results on a document-by-document basis or, by\n * byPage(), can iterate over pages of documents.\n */\nexport interface PagedAnalyzeHealthcareEntitiesResult\n extends PagedAsyncIterableAnalyzeHealthcareEntitiesResult {\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 * Creates a user-friendly healthcare entity represented as a node in a graph\n * @param entity - the healthcare entity returned by the service\n * @internal\n */\nfunction makeHealthcareEntitiesWithoutNeighbors(\n entity: GeneratedHealthcareEntity\n): HealthcareEntity {\n const {\n category,\n confidenceScore,\n assertion,\n offset,\n text,\n links,\n subcategory,\n length,\n name\n } = entity;\n return {\n category,\n confidenceScore,\n assertion,\n offset,\n length,\n text,\n normalizedText: name,\n subCategory: subcategory,\n dataSources:\n links?.map(({ dataSource, id }): EntityDataSource => ({ name: dataSource, entityId: id })) ??\n []\n };\n}\n\n/**\n * @internal\n */\nfunction makeHealthcareRelations(\n entities: HealthcareEntity[],\n relations: HealthcareRelation[]\n): HealthcareEntityRelation[] {\n return relations.map(\n (relation: HealthcareRelation): HealthcareEntityRelation => ({\n relationType: relation.relationType,\n roles: relation.entities.map(\n (role: HealthcareRelationEntity): HealthcareEntityRelationRole => ({\n entity: entities[parseHealthcareEntityIndex(role.ref)],\n name: role.role\n })\n )\n })\n );\n}\n\n/**\n * Creates a healthcare entity in the convenience layer from the one sent by the service.\n * @param document - incoming results sent by the service for a particular document\n * @internal\n */\nexport function makeHealthcareEntitiesResult(\n document: DocumentHealthcareEntities\n): AnalyzeHealthcareEntitiesSuccessResult {\n const { id, entities, relations, warnings, statistics } = document;\n const newEntities = entities.map(makeHealthcareEntitiesWithoutNeighbors);\n return {\n ...makeTextAnalyticsSuccessResult(id, warnings, statistics),\n entities: newEntities,\n entityRelations: makeHealthcareRelations(newEntities, relations)\n };\n}\n\n/**\n * @internal\n */\nexport function makeHealthcareEntitiesErrorResult(\n id: string,\n error: TextAnalyticsError\n): AnalyzeHealthcareEntitiesErrorResult {\n return makeTextAnalyticsErrorResult(id, error);\n}\n"]}
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT license.
|
|
3
|
-
import { SpanStatusCode } from "@azure/core-tracing";
|
|
4
|
-
import { createSerializer } from "@azure/core-client";
|
|
5
|
-
import { createSpan } from "./tracing";
|
|
6
|
-
import { compileError, getRawResponse, sendGetRequest } from "./util";
|
|
7
|
-
import * as Mappers from "./generated/models/mappers";
|
|
8
|
-
import { accept, apiVersion, endpoint, includeStatistics, skip, top } from "./generated/models/parameters";
|
|
9
|
-
import { getPagedAsyncIterator } from "@azure/core-paging";
|
|
10
|
-
import { createAnalyzeActionsResult } from "./analyzeActionsResult";
|
|
11
|
-
const serializer = createSerializer(Mappers, /* isXml */ false);
|
|
12
|
-
// Consider whether the spec can be exported by code gen
|
|
13
|
-
const analyzeStatusOperationSpec = {
|
|
14
|
-
httpMethod: "GET",
|
|
15
|
-
responses: {
|
|
16
|
-
200: {
|
|
17
|
-
bodyMapper: Mappers.AnalyzeJobState
|
|
18
|
-
},
|
|
19
|
-
default: {
|
|
20
|
-
bodyMapper: Mappers.ErrorResponse
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
queryParameters: [includeStatistics, top, skip],
|
|
24
|
-
urlParameters: [endpoint, apiVersion],
|
|
25
|
-
headerParameters: [accept],
|
|
26
|
-
serializer
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* @internal
|
|
30
|
-
*/
|
|
31
|
-
export class AnalyzeLro {
|
|
32
|
-
constructor(
|
|
33
|
-
// eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters
|
|
34
|
-
client, baseOptions, initOptions, pollOptions, documents, tasks) {
|
|
35
|
-
this.client = client;
|
|
36
|
-
this.baseOptions = baseOptions;
|
|
37
|
-
this.initOptions = initOptions;
|
|
38
|
-
this.pollOptions = pollOptions;
|
|
39
|
-
this.documents = documents;
|
|
40
|
-
this.tasks = tasks;
|
|
41
|
-
this.requestMethod = "POST";
|
|
42
|
-
this.requestPath = "/analyze";
|
|
43
|
-
}
|
|
44
|
-
async sendInitialRequest() {
|
|
45
|
-
const { span, updatedOptions: finalOptions } = createSpan("TextAnalyticsClient-beginAnalyze", Object.assign(Object.assign({}, this.baseOptions), this.initOptions));
|
|
46
|
-
try {
|
|
47
|
-
const { flatResponse, rawResponse } = await getRawResponse((paramOptions) => this.client.analyze(Object.assign({ body: {
|
|
48
|
-
analysisInput: { documents: this.documents },
|
|
49
|
-
tasks: this.tasks,
|
|
50
|
-
displayName: this.initOptions.displayName
|
|
51
|
-
} }, paramOptions)), finalOptions);
|
|
52
|
-
return {
|
|
53
|
-
flatResponse: flatResponse,
|
|
54
|
-
rawResponse
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
catch (e) {
|
|
58
|
-
const exception = compileError(e);
|
|
59
|
-
span.setStatus({
|
|
60
|
-
code: SpanStatusCode.ERROR,
|
|
61
|
-
message: exception.message
|
|
62
|
-
});
|
|
63
|
-
throw exception;
|
|
64
|
-
}
|
|
65
|
-
finally {
|
|
66
|
-
span.end();
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
async sendPollRequest(path) {
|
|
70
|
-
return sendGetRequest(this.client, analyzeStatusOperationSpec, "AnalyzeStatus", Object.assign(Object.assign({}, this.baseOptions), this.pollOptions), path);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* @internal
|
|
75
|
-
*/
|
|
76
|
-
export function isAnalyzeDone(response) {
|
|
77
|
-
const castResponse = response;
|
|
78
|
-
switch (castResponse.status) {
|
|
79
|
-
case "notStarted":
|
|
80
|
-
case "running":
|
|
81
|
-
return false;
|
|
82
|
-
default: {
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* @internal
|
|
89
|
-
*/
|
|
90
|
-
export function processAnalyzeResult(
|
|
91
|
-
// eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters
|
|
92
|
-
client, documents, options) {
|
|
93
|
-
return (_result, state) => {
|
|
94
|
-
const pollingURL = state.pollingURL;
|
|
95
|
-
const pagedResult = {
|
|
96
|
-
firstPageLink: pollingURL,
|
|
97
|
-
getPage: async (pageLink, maxPageSize) => {
|
|
98
|
-
const response = await sendGetRequest(client, analyzeStatusOperationSpec, "AnalyzeStatus",
|
|
99
|
-
// if `top` is set to `undefined`, the default value will not be sent
|
|
100
|
-
// as part of the request.
|
|
101
|
-
maxPageSize ? Object.assign(Object.assign({}, options), { top: maxPageSize }) : options, pageLink);
|
|
102
|
-
const flatResponse = response.flatResponse;
|
|
103
|
-
return {
|
|
104
|
-
page: createAnalyzeActionsResult(flatResponse, documents),
|
|
105
|
-
nextPageLink: flatResponse.nextLink
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
const pagedIterator = getPagedAsyncIterator(pagedResult);
|
|
110
|
-
// Attach stats if the service starts to return them
|
|
111
|
-
// https://github.com/Azure/azure-sdk-for-js/issues/14139
|
|
112
|
-
// state.result = Object.assign(pagedIterator, {
|
|
113
|
-
// statistics: operationStatus.statistics
|
|
114
|
-
// });
|
|
115
|
-
return pagedIterator;
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* @internal
|
|
120
|
-
*/
|
|
121
|
-
export function updateAnalyzeState(state, lastResponse) {
|
|
122
|
-
const response = lastResponse.body;
|
|
123
|
-
state.createdOn = response.createdDateTime;
|
|
124
|
-
state.lastModifiedOn = response.lastUpdateDateTime;
|
|
125
|
-
state.expiresOn = response.expirationDateTime;
|
|
126
|
-
state.status = response.status;
|
|
127
|
-
state.actionsSucceededCount = response.tasks.completed;
|
|
128
|
-
state.actionsFailedCount = response.tasks.failed;
|
|
129
|
-
state.actionsInProgressCount = response.tasks.inProgress;
|
|
130
|
-
state.displayName = response.displayName;
|
|
131
|
-
}
|
|
132
|
-
//# sourceMappingURL=analyzeLro.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"analyzeLro.js","sourceRoot":"","sources":["../../src/analyzeLro.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAmC,MAAM,oBAAoB,CAAC;AAQvF,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AACtE,OAAO,KAAK,OAAO,MAAM,4BAA4B,CAAC;AACtD,OA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AAC,SAAS,CAAC;IACvD,KAAK,CAAC,kBAAkB,GAAG,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC;IACjD,KAAK,CAAC,sBAAsB,GAAG,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC;IACzD,KAAK,CAAC,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC;AAC3C,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { LongRunningOperation, LroResponse, PollerLike, RawResponse } from \"@azure/core-lro\";\nimport { SpanStatusCode } from \"@azure/core-tracing\";\nimport { createSerializer, OperationOptions, OperationSpec } from \"@azure/core-client\";\nimport {\n GeneratedClient,\n GeneratedClientAnalyzeStatusOptionalParams,\n GeneratedClientAnalyzeStatusResponse,\n JobManifestTasks,\n TextDocumentInput\n} from \"./generated\";\nimport { createSpan } from \"./tracing\";\nimport { compileError, getRawResponse, sendGetRequest } from \"./util\";\nimport * as Mappers from \"./generated/models/mappers\";\nimport {\n accept,\n apiVersion,\n endpoint,\n includeStatistics,\n skip,\n top\n} from \"./generated/models/parameters\";\nimport { getPagedAsyncIterator, PagedResult } from \"@azure/core-paging\";\nimport { AnalysisPollOperationState, OperationMetadata } from \"./pollerModels\";\nimport {\n AnalyzeActionsResult,\n createAnalyzeActionsResult,\n PagedAnalyzeActionsResult\n} from \"./analyzeActionsResult\";\n\n/**\n * Options for the begin analyze actions operation.\n */\nexport interface BeginAnalyzeActionsOptions extends OperationOptions {\n /**\n * Delay to wait until next poll, in milliseconds.\n */\n updateIntervalInMs?: number;\n /**\n * A serialized poller which can be used to resume an existing paused Long-Running-Operation.\n */\n resumeFrom?: string;\n /**\n * If set to true, response will contain input and document level statistics.\n */\n includeStatistics?: boolean;\n /**\n * The operation's display name.\n */\n displayName?: string;\n}\n\n/**\n * Result type of the Begin Analyze Actions Long-Running-Operation (LRO).\n */\nexport type AnalyzeActionsPollerLike = PollerLike<\n AnalyzeActionsOperationState,\n PagedAnalyzeActionsResult\n>;\n\n/**\n * The metadata for beginAnalyzeActions operations.\n */\nexport interface AnalyzeActionsOperationMetadata extends OperationMetadata {\n /**\n * Number of successfully completed actions.\n */\n actionsSucceededCount: number;\n /**\n * Number of failed actions.\n */\n actionsFailedCount: number;\n /**\n * Number of actions still in progress.\n */\n actionsInProgressCount: number;\n /**\n * The operation's display name.\n */\n displayName?: string;\n}\n\n/**\n * The state of the begin analyze polling operation.\n */\nexport interface AnalyzeActionsOperationState\n extends AnalysisPollOperationState<PagedAnalyzeActionsResult>,\n AnalyzeActionsOperationMetadata {}\n\nconst serializer = createSerializer(Mappers, /* isXml */ false);\n\n// Consider whether the spec can be exported by code gen\nconst analyzeStatusOperationSpec: OperationSpec = {\n httpMethod: \"GET\",\n responses: {\n 200: {\n bodyMapper: Mappers.AnalyzeJobState\n },\n default: {\n bodyMapper: Mappers.ErrorResponse\n }\n },\n queryParameters: [includeStatistics, top, skip],\n urlParameters: [endpoint, apiVersion],\n headerParameters: [accept],\n serializer\n};\n\n/**\n * @internal\n */\nexport class AnalyzeLro implements LongRunningOperation<PagedAnalyzeActionsResult> {\n public requestMethod = \"POST\";\n public requestPath = \"/analyze\";\n constructor(\n // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters\n private client: GeneratedClient,\n private baseOptions: OperationOptions,\n private initOptions: {\n displayName?: string;\n },\n private pollOptions: {\n includeStatistics?: boolean;\n },\n private documents: TextDocumentInput[],\n private tasks: JobManifestTasks\n ) {}\n async sendInitialRequest(): Promise<LroResponse<PagedAnalyzeActionsResult>> {\n const { span, updatedOptions: finalOptions } = createSpan(\"TextAnalyticsClient-beginAnalyze\", {\n ...this.baseOptions,\n ...this.initOptions\n });\n try {\n const { flatResponse, rawResponse } = await getRawResponse(\n (paramOptions) =>\n this.client.analyze({\n body: {\n analysisInput: { documents: this.documents },\n tasks: this.tasks,\n displayName: this.initOptions.displayName\n },\n ...paramOptions\n }),\n finalOptions\n );\n return {\n flatResponse: flatResponse as PagedAnalyzeActionsResult,\n rawResponse\n };\n } catch (e) {\n const exception = compileError(e);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: exception.message\n });\n throw exception;\n } finally {\n span.end();\n }\n }\n async sendPollRequest(path: string): Promise<LroResponse<PagedAnalyzeActionsResult>> {\n return sendGetRequest(\n this.client,\n analyzeStatusOperationSpec,\n \"AnalyzeStatus\",\n { ...this.baseOptions, ...this.pollOptions },\n path\n ) as Promise<LroResponse<PagedAnalyzeActionsResult>>;\n }\n}\n\n/**\n * @internal\n */\nexport function isAnalyzeDone(response: unknown): boolean {\n const castResponse = response as GeneratedClientAnalyzeStatusResponse;\n switch (castResponse.status) {\n case \"notStarted\":\n case \"running\":\n return false;\n default: {\n return true;\n }\n }\n}\n\n/**\n * @internal\n */\nexport function processAnalyzeResult(\n // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters\n client: GeneratedClient,\n documents: TextDocumentInput[],\n options: GeneratedClientAnalyzeStatusOptionalParams\n): (result: unknown, state: AnalyzeActionsOperationState) => PagedAnalyzeActionsResult {\n return (_result: unknown, state: AnalyzeActionsOperationState): PagedAnalyzeActionsResult => {\n const pollingURL = (state as any).pollingURL;\n const pagedResult: PagedResult<AnalyzeActionsResult> = {\n firstPageLink: pollingURL,\n getPage: async (pageLink: string, maxPageSize?: number) => {\n const response = await sendGetRequest(\n client,\n analyzeStatusOperationSpec,\n \"AnalyzeStatus\",\n // if `top` is set to `undefined`, the default value will not be sent\n // as part of the request.\n maxPageSize ? { ...options, top: maxPageSize } : options,\n pageLink\n );\n const flatResponse = response.flatResponse as GeneratedClientAnalyzeStatusResponse;\n return {\n page: createAnalyzeActionsResult(flatResponse, documents),\n nextPageLink: flatResponse.nextLink\n };\n }\n };\n const pagedIterator = getPagedAsyncIterator<AnalyzeActionsResult, AnalyzeActionsResult>(\n pagedResult\n );\n // Attach stats if the service starts to return them\n // https://github.com/Azure/azure-sdk-for-js/issues/14139\n // state.result = Object.assign(pagedIterator, {\n // statistics: operationStatus.statistics\n // });\n return pagedIterator;\n };\n}\n\n/**\n * @internal\n */\nexport function updateAnalyzeState(\n state: AnalyzeActionsOperationState,\n lastResponse: RawResponse\n): void {\n const response = lastResponse.body as GeneratedClientAnalyzeStatusResponse;\n state.createdOn = response.createdDateTime;\n state.lastModifiedOn = response.lastUpdateDateTime;\n state.expiresOn = response.expirationDateTime;\n state.status = response.status;\n state.actionsSucceededCount = response.tasks.completed;\n state.actionsFailedCount = response.tasks.failed;\n state.actionsInProgressCount = response.tasks.inProgress;\n state.displayName = response.displayName;\n}\n"]}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT license.
|
|
3
|
-
import { makeTextAnalyticsSuccessResult, makeTextAnalyticsErrorResult } from "./textAnalyticsResult";
|
|
4
|
-
import { parseAssessmentIndex } from "./util";
|
|
5
|
-
/**
|
|
6
|
-
* @param document - A document result coming from the service.
|
|
7
|
-
* @internal
|
|
8
|
-
*/
|
|
9
|
-
export function makeAnalyzeSentimentResult(result) {
|
|
10
|
-
const { id, sentiment, confidenceScores, sentenceSentiments: sentences, warnings, statistics } = result;
|
|
11
|
-
return Object.assign(Object.assign({}, makeTextAnalyticsSuccessResult(id, warnings, statistics)), { sentiment,
|
|
12
|
-
confidenceScores, sentences: sentences.map((sentence) => convertGeneratedSentenceSentiment(sentence, result)) });
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* @internal
|
|
16
|
-
*/
|
|
17
|
-
export function makeAnalyzeSentimentErrorResult(id, error) {
|
|
18
|
-
return makeTextAnalyticsErrorResult(id, error);
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Converts a sentence sentiment object returned by the service to another that
|
|
22
|
-
* is user-friendly.
|
|
23
|
-
*
|
|
24
|
-
* @param sentence - The sentence sentiment object to be converted.
|
|
25
|
-
* @param response - The entire response returned by the service.
|
|
26
|
-
* @returns The user-friendly sentence sentiment object.
|
|
27
|
-
* @internal
|
|
28
|
-
*/
|
|
29
|
-
function convertGeneratedSentenceSentiment(sentence, result) {
|
|
30
|
-
return {
|
|
31
|
-
confidenceScores: sentence.confidenceScores,
|
|
32
|
-
sentiment: sentence.sentiment,
|
|
33
|
-
text: sentence.text,
|
|
34
|
-
offset: sentence.offset,
|
|
35
|
-
length: sentence.length,
|
|
36
|
-
opinions: sentence.targets
|
|
37
|
-
? sentence.targets.map((target) => ({
|
|
38
|
-
target: {
|
|
39
|
-
confidenceScores: target.confidenceScores,
|
|
40
|
-
sentiment: target.sentiment,
|
|
41
|
-
text: target.text,
|
|
42
|
-
offset: target.offset,
|
|
43
|
-
length: target.length
|
|
44
|
-
},
|
|
45
|
-
assessments: target.relations
|
|
46
|
-
.filter((relation) => relation.relationType === "assessment")
|
|
47
|
-
.map((relation) => convertTargetRelationToAssessmentSentiment(relation, result))
|
|
48
|
-
}))
|
|
49
|
-
: []
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Converts a target relation object returned by the service to an assessment
|
|
54
|
-
* sentiment object where JSON pointers in the former are realized in the
|
|
55
|
-
* latter.
|
|
56
|
-
*
|
|
57
|
-
* @param targetRelation - The target relation object to be converted.
|
|
58
|
-
* @param response - The entire response returned by the service.
|
|
59
|
-
* @returns The user-friendly assessment sentiment object.
|
|
60
|
-
* @internal
|
|
61
|
-
*/
|
|
62
|
-
function convertTargetRelationToAssessmentSentiment(targetRelation, result) {
|
|
63
|
-
var _a, _b;
|
|
64
|
-
const assessmentPtr = targetRelation.ref;
|
|
65
|
-
const assessmentIndex = parseAssessmentIndex(assessmentPtr);
|
|
66
|
-
const assessment = (_b = (_a = result.sentenceSentiments) === null || _a === void 0 ? void 0 : _a[assessmentIndex.sentence].assessments) === null || _b === void 0 ? void 0 : _b[assessmentIndex.assessment];
|
|
67
|
-
if (assessment !== undefined) {
|
|
68
|
-
return assessment;
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
throw new Error(`Pointer "${assessmentPtr}" is not a valid Assessment pointer`);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
//# sourceMappingURL=analyzeSentimentResult.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"analyzeSentimentResult.js","sourceRoot":"","sources":["../../src/analyzeSentimentResult.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EACL,8BAA8B,EAG9B,4BAA4B,EAC7B,MAAM,uBAAuB,CAAC;AAc/B,OAAO,EAAmB,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAuH/D;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CACxC,MAAyB;IAEzB,MAAM,EACJ,EAAE,EACF,SAAS,EACT,gBAAgB,EAChB,kBAAkB,EAAE,SAAS,EAC7B,QAAQ,EACR,UAAU,EACX,GAAG,MAAM,CAAC;IACX,uCACK,8BAA8B,CAAC,EAAE,EAAE,QAAQ,EAAE,UAAU,CAAC,KAC3D,SAAS;QACT,gBAAgB,EAChB,SAAS,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,iCAAiC,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,IAC3F;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,+BAA+B,CAC7C,EAAU,EACV,KAAyB;IAEzB,OAAO,4BAA4B,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;AACjD,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,iCAAiC,CACxC,QAAoC,EACpC,MAAyB;IAEzB,OAAO;QACL,gBAAgB,EAAE,QAAQ,CAAC,gBAAgB;QAC3C,SAAS,EAAE,QAAQ,CAAC,SAAS;QAC7B,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,QAAQ,EAAE,QAAQ,CAAC,OAAO;YACxB,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAClB,CAAC,MAAsB,EAAW,EAAE,CAAC,CAAC;gBACpC,MAAM,EAAE;oBACN,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;oBACzC,SAAS,EAAE,MAAM,CAAC,SAAS;oBAC3B,IAAI,EAAE,MAAM,CAAC,IAAI;oBACjB,MAAM,EAAE,MAAM,CAAC,MAAM;oBACrB,MAAM,EAAE,MAAM,CAAC,MAAM;iBACtB;gBACD,WAAW,EAAE,MAAM,CAAC,SAAS;qBAC1B,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,YAAY,KAAK,YAAY,CAAC;qBAC5D,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,0CAA0C,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;aACnF,CAAC,CACH;YACH,CAAC,CAAC,EAAE;KACP,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,SAAS,0CAA0C,CACjD,cAA8B,EAC9B,MAAyB;;IAEzB,MAAM,aAAa,GAAG,cAAc,CAAC,GAAG,CAAC;IACzC,MAAM,eAAe,GAAoB,oBAAoB,CAAC,aAAa,CAAC,CAAC;IAC7E,MAAM,UAAU,GACd,MAAA,MAAA,MAAM,CAAC,kBAAkB,0CAAG,eAAe,CAAC,QAAQ,EAAE,WAAW,0CAAG,eAAe,CAAC,UAAU,CAAC,CAAC;IAClG,IAAI,UAAU,KAAK,SAAS,EAAE;QAC5B,OAAO,UAAU,CAAC;KACnB;SAAM;QACL,MAAM,IAAI,KAAK,CAAC,YAAY,aAAa,qCAAqC,CAAC,CAAC;KACjF;AACH,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 DocumentSentimentLabel,\n SentimentConfidenceScores,\n SentenceSentiment as GeneratedSentenceSentiment,\n SentenceSentimentLabel,\n DocumentSentiment,\n SentenceTarget,\n TargetRelation,\n SentenceAssessment,\n TokenSentimentValue as SentenceTargetSentiment,\n TargetConfidenceScoreLabel\n} from \"./generated/models\";\nimport { AssessmentIndex, parseAssessmentIndex } from \"./util\";\n\n/**\n * The result of the analyze sentiment operation on a single document.\n */\nexport type AnalyzeSentimentResult = AnalyzeSentimentSuccessResult | AnalyzeSentimentErrorResult;\n\n/**\n * The result of the analyze sentiment operation on a single document,\n * containing the predicted sentiment for each sentence as well as for the full document.\n */\nexport interface AnalyzeSentimentSuccessResult extends TextAnalyticsSuccessResult {\n /**\n * Predicted sentiment for document. Possible values\n * include: 'positive', 'neutral', 'negative', 'mixed'\n */\n sentiment: DocumentSentimentLabel;\n /**\n * Document level sentiment confidence scores between 0 and 1 for each sentiment class.\n */\n confidenceScores: SentimentConfidenceScores;\n /**\n * The predicted sentiment for each sentence in the corresponding document.\n */\n sentences: SentenceSentiment[];\n}\n\n/**\n * The predicted sentiment for a given span of text. For more information regarding text sentiment, see https://docs.microsoft.com/azure/cognitive-services/Text-Analytics/how-tos/text-analytics-how-to-sentiment-analysis.\n */\nexport interface SentenceSentiment {\n /**\n * The sentence text.\n */\n text: string;\n /**\n * The predicted Sentiment for the sentence.\n */\n sentiment: SentenceSentimentLabel;\n /**\n * The sentiment confidence score between 0 and 1 for the sentence for all classes.\n */\n confidenceScores: SentimentConfidenceScores;\n /**\n * The sentence text offset from the start of the document.\n */\n offset: number;\n /**\n * The length of the sentence text.\n */\n length: number;\n /**\n * The list of opinions mined from this sentence. For example in \"The food is\n * good, but the service is bad\", we would mine these two opinions \"food is\n * good\", \"service is bad\". Only returned if `includeOpinionMining` is set to\n * True in the call to `analyzeSentiment`.\n */\n opinions: Opinion[];\n}\n\n/**\n * TargetSentiment contains the predicted sentiment, confidence scores and other\n * information about an target of a product. A target of a product/service is a\n * key component of that product/service. For example in \"The food at Hotel Foo\n * is good\", \"food\" is a target of \"Hotel Foo\".\n */\nexport interface TargetSentiment {\n /**\n * The sentiment confidence score between 0 and 1 for the target for\n * 'positive' and 'negative' labels.\n */\n confidenceScores: TargetConfidenceScoreLabel;\n /**\n * The predicted Sentiment for the Target. Possible values include 'positive',\n * 'mixed', and 'negative'.\n */\n sentiment: SentenceTargetSentiment;\n /**\n * The target text.\n */\n text: string;\n /**\n * The Target text offset from the start of the sentence.\n */\n offset: number;\n /**\n * The length of the Target text.\n */\n length: number;\n}\n\n/**\n * AssessmentSentiment contains the predicted sentiment, confidence scores and\n * other information about an assessment of a target. For example, in the sentence\n * \"The food is good\", the assessment of the target 'food' is 'good'.\n */\nexport interface AssessmentSentiment extends SentenceAssessment {}\n\n/**\n * A mined opinion object represents an opinion we've extracted from a sentence.\n * It consists of both a target that these assessments are about, and the actual\n * assessments themselves.\n */\nexport interface Opinion {\n /**\n * The target of a product/service that this assessment is about.\n */\n target: TargetSentiment;\n /**\n * The actual assessments of the target.\n */\n assessments: AssessmentSentiment[];\n}\n\n/**\n * An error result from the analyze sentiment operation on a single document.\n */\nexport type AnalyzeSentimentErrorResult = TextAnalyticsErrorResult;\n\n/**\n * @param document - A document result coming from the service.\n * @internal\n */\nexport function makeAnalyzeSentimentResult(\n result: DocumentSentiment\n): AnalyzeSentimentSuccessResult {\n const {\n id,\n sentiment,\n confidenceScores,\n sentenceSentiments: sentences,\n warnings,\n statistics\n } = result;\n return {\n ...makeTextAnalyticsSuccessResult(id, warnings, statistics),\n sentiment,\n confidenceScores,\n sentences: sentences.map((sentence) => convertGeneratedSentenceSentiment(sentence, result))\n };\n}\n\n/**\n * @internal\n */\nexport function makeAnalyzeSentimentErrorResult(\n id: string,\n error: TextAnalyticsError\n): AnalyzeSentimentErrorResult {\n return makeTextAnalyticsErrorResult(id, error);\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 sentence: GeneratedSentenceSentiment,\n result: DocumentSentiment\n): SentenceSentiment {\n return {\n confidenceScores: sentence.confidenceScores,\n sentiment: sentence.sentiment,\n text: sentence.text,\n offset: sentence.offset,\n length: sentence.length,\n opinions: sentence.targets\n ? sentence.targets.map(\n (target: SentenceTarget): Opinion => ({\n target: {\n confidenceScores: target.confidenceScores,\n sentiment: target.sentiment,\n text: target.text,\n offset: target.offset,\n length: target.length\n },\n assessments: target.relations\n .filter((relation) => relation.relationType === \"assessment\")\n .map((relation) => convertTargetRelationToAssessmentSentiment(relation, result))\n })\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 result: DocumentSentiment\n): AssessmentSentiment {\n const assessmentPtr = targetRelation.ref;\n const assessmentIndex: AssessmentIndex = parseAssessmentIndex(assessmentPtr);\n const assessment: SentenceAssessment | undefined =\n result.sentenceSentiments?.[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"]}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT license.
|
|
3
|
-
import { makeAnalyzeSentimentErrorResult, makeAnalyzeSentimentResult } from "./analyzeSentimentResult";
|
|
4
|
-
import { combineSuccessfulAndErroneousDocumentsWithStatisticsAndModelVersion } from "./textAnalyticsResult";
|
|
5
|
-
/**
|
|
6
|
-
* @internal
|
|
7
|
-
*/
|
|
8
|
-
export function makeAnalyzeSentimentResultArray(input, response) {
|
|
9
|
-
return combineSuccessfulAndErroneousDocumentsWithStatisticsAndModelVersion(input, response, makeAnalyzeSentimentResult, makeAnalyzeSentimentErrorResult);
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=analyzeSentimentResultArray.js.map
|