@azure/ai-text-analytics 5.2.0-beta.1 → 6.0.0-alpha.20220517.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +376 -132
- package/dist/index.js +2803 -3497
- 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 +1607 -1464
- package/dist-esm/src/generated/models/mappers.js.map +1 -1
- package/dist-esm/src/generated/models/parameters.js +18 -104
- 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 +36 -158
- package/dist-esm/src/util.js.map +1 -1
- package/package.json +28 -38
- package/types/ai-text-analytics.d.ts +1432 -1143
- package/CHANGELOG.md +0 -143
- package/LICENSE +0 -21
- package/dist-esm/src/analyzeActionsResult.js +0 -167
- 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 -130
- 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 -131
- package/dist-esm/src/healthLro.js.map +0 -1
- package/dist-esm/src/paging.js +0 -83
- package/dist-esm/src/paging.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/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/textAnalyticsAction.js +0 -4
- package/dist-esm/src/textAnalyticsAction.js.map +0 -1
- package/dist-esm/src/textAnalyticsClient.js +0 -523
- 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 -78
- 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/dist-esm/src/utils/url.browser.js +0 -6
- package/dist-esm/src/utils/url.browser.js.map +0 -1
- package/dist-esm/src/utils/url.js +0 -4
- package/dist-esm/src/utils/url.js.map +0 -1
package/CHANGELOG.md
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
# Release History
|
|
2
|
-
|
|
3
|
-
## 5.2.0-beta.1 (2021-08-09)
|
|
4
|
-
|
|
5
|
-
### Features Added
|
|
6
|
-
|
|
7
|
-
- We are now targeting the service's v3.2-preview.1 API as the default instead of v3.1.
|
|
8
|
-
- `beginAnalyzeActions` now supports extract summary actions.
|
|
9
|
-
|
|
10
|
-
## 5.1.0 (2021-07-07)
|
|
11
|
-
|
|
12
|
-
### New Features
|
|
13
|
-
|
|
14
|
-
- We are now targeting the service's v3.1 API as the default instead of v3.1-preview.5.
|
|
15
|
-
- `beginAnalyzeHealthcareEntities` now works with Azure Active Directory credentials.
|
|
16
|
-
- `categoriesFilter` support was added to `RecognizePiiEntitiesAction`.
|
|
17
|
-
- Updated our internal core package dependencies to their latest versions in order to add support for Opentelemetry 1.0.0 which is compatible with the latest versions of our other client libraries.
|
|
18
|
-
- Changed TS compilation target to ES2017 in order to produce smaller bundles and use more native platform features
|
|
19
|
-
|
|
20
|
-
### Breaking Changes
|
|
21
|
-
|
|
22
|
-
- `PiiEntityDomainType` was renamed to `PiiEntityDomain`.
|
|
23
|
-
- `domain` property of `RecognizePiiEntitiesAction` was renamed to `domainFilter`.
|
|
24
|
-
- `beginAnalyzeActions` is now limited to accept up to one action only per type.
|
|
25
|
-
|
|
26
|
-
## 5.1.0-beta.6 (2021-05-18)
|
|
27
|
-
|
|
28
|
-
### New Features
|
|
29
|
-
|
|
30
|
-
- With the dropping of support for Node.js versions that are no longer in LTS, the dependency on `@types/node` has been updated to version 12. Read our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details.
|
|
31
|
-
- We are now targeting the service's v3.1-preview.5 API as the default instead of v3.1-preview.4.
|
|
32
|
-
- `beginAnalyzeActions` adds support for analyze sentiment actions.
|
|
33
|
-
- `disableServiceLogs` parameter is added to most actions in `beginAnalyzeActions` that controls service-side logging.
|
|
34
|
-
|
|
35
|
-
### Breaking Changes
|
|
36
|
-
|
|
37
|
-
- `beginAnalyzeBatchActions` was renamed to `beginAnalyzeActions`.
|
|
38
|
-
- `TextElements_v8` is renamed to `TextElement_v8` in model `StringIndexType`.
|
|
39
|
-
|
|
40
|
-
### Key Bug Fixes
|
|
41
|
-
|
|
42
|
-
- Results of entity linking actions were not returned correctly by `beginAnalyzeActions` and that is now fixed.
|
|
43
|
-
|
|
44
|
-
## 5.1.0-beta.5 (2021-03-11)
|
|
45
|
-
|
|
46
|
-
- We are now targeting the service's v3.1-preview.4 API as the default instead of v3.1-preview.3.
|
|
47
|
-
- [Breaking] Aspects in opinions mining are now called targets and each individual opinion is now called an assessment. The new naming simplifies the naming of different parts of the response.
|
|
48
|
-
- `beginAnalyzeBatchActions` can now process recognize linked entities actions.
|
|
49
|
-
- `beginAnalyzeHealthcareEntities` returns `entityRelations` per document, a list of relations between healthcare entities.
|
|
50
|
-
- `beginAnalyzeHealthcareEntities` entities now include `assertions` instead of `isNegated` which gives more context about the respective entity.
|
|
51
|
-
- [Breaking] `beginAnalyzeHealthcareEntities` no longer returns `relatedEntities`.
|
|
52
|
-
- `recognizePiiEntities` takes a new option, `categoriesFilter`, that specifies a list of Pii categories to return.
|
|
53
|
-
- [Breaking] `statistics` is no longer part of `PagedAnalyzeBatchActionsResult`.
|
|
54
|
-
|
|
55
|
-
## 5.1.0-beta.4 (2021-02-10)
|
|
56
|
-
|
|
57
|
-
- [Breaking] `beginAnalyzeHealthcare` is renamed to `beginAnalyzeHealthcareEntities`.
|
|
58
|
-
- [Breaking] `beginAnalyze` is renamed to `beginAnalyzeBatchActions`.
|
|
59
|
-
- A new option to control how the offset is calculated by the service, `stringIndexType`, is added to `analyzeSentiment`, `recognizeEntities`, `recognizePiiEntities`, and `beginAnalyzeHealthcareEntities`. Furthermore, `stringIndexType` is added to task types `RecognizeEntitiesAction` and `RecognizePiiEntitiesAction`, which are the types of input actions to the `beginAnalyzeBatchActions` method. For more information, see [the Text Analytics documentation](https://docs.microsoft.com/azure/cognitive-services/text-analytics/concepts/text-offsets#offsets-in-api-version-31-preview).
|
|
60
|
-
- [Breaking] The healthcare entities returned by `beginAnalyzeHealthcare` are now organized as a directed graph where the edges represent a certain type of healthcare relationship between the source and target entities. Edges are stored in the `relatedEntities` property.
|
|
61
|
-
- [Breaking] The `links` property of `HealthcareEntity` is renamed to `dataSources`, a list of objects representing medical databases, where each object has `name` and `entityId` properties.
|
|
62
|
-
- The poller for the `beginAnalyzeBatchActions` long-running operation gained the ability to return certain metadata information about the currently running operation (e.g., when the operation was created, will be expired, and last time it was updated, and also how many actions completed and failed so far). Also, the poller for `beginAnalyzeHealthcareEntities` gained a similar ability.
|
|
63
|
-
- [Breaking] the words "operation" and "action" are used consistently in our names and documentation instead of "job" and "task" respectively.
|
|
64
|
-
|
|
65
|
-
## 5.1.0-beta.3 (2020-11-23)
|
|
66
|
-
|
|
67
|
-
- We are now targeting the service's v3.1-preview.3 API as the default instead of v3.1-preview.2.
|
|
68
|
-
- We introduced the `beginAnalyze` API which supports long-running batch process of Named Entity Recognition, Personally identifiable Information, and Key Phrase Extraction.
|
|
69
|
-
- We now have added support for the recognition of healthcare entities with the introduction of the `beginAnalyzeHealthcare` API. Since the Health API is currently only available in a gated preview, you need to have your subscription on the service's allow list. Note that since this is a gated preview, AAD is not supported. For more information, see [the Text Analytics for Health documentation](https://docs.microsoft.com/azure/cognitive-services/text-analytics/how-tos/text-analytics-for-health?tabs=ner#request-access-to-the-public-preview).
|
|
70
|
-
|
|
71
|
-
## 5.1.0-beta.2 (2020-10-06)
|
|
72
|
-
|
|
73
|
-
- [Breaking] The `length` property is removed from `SentenceSentiment`, `Entity`, `Match`, `PiiEntity`, and `CategorizedEntity` because the length information can be accessed from the text property itself using the string's length property.
|
|
74
|
-
|
|
75
|
-
## 5.1.0-beta.1 (2020-09-17)
|
|
76
|
-
|
|
77
|
-
- We are now targeting the service's v3.1-preview.2 API as the default instead of v3.0.
|
|
78
|
-
- We now have added support for opinion mining feature of Sentiment Analysis. To get this support, pass `includeOpinionMining` as True when calling the `analyzeSentiment` endpoint.
|
|
79
|
-
- We have added the `recognizePiiEntities` API which returns entities containing personal information for a batch of documents and also returns the redacted text.
|
|
80
|
-
- The `length` and `offset` properties are added to the `SentenceSentiment`, `Entity`, `Match`, `PiiEntity` and `CategorizedEntity` interfaces to represent the length of the sentence's text and its offset from the start of the document. The unit of distance used is UTF-16 code points.
|
|
81
|
-
- The `text` property of the `SentenceSentiment` interface is no longer marked as optional because the service has always returned it. This interface is used exclusively as an output type so this change does not break existing code.
|
|
82
|
-
- `bingEntitySearchApiId` property is now returned for entities returned by `recognizeLinkedEntities` API and is added to the `LinkedEntity` interface. This property is to be used in conjunction with the Bing Entity Search API to fetch additional relevant information about the returned entity.
|
|
83
|
-
|
|
84
|
-
## 5.0.1 (2020-08-18)
|
|
85
|
-
|
|
86
|
-
- Handles REST exceptions with code InvalidDocumentBatch in a way that maintains backward compatibility.
|
|
87
|
-
|
|
88
|
-
## 5.0.0 (2020-07-27)
|
|
89
|
-
|
|
90
|
-
- Updated the package version to be 5.0.0 instead of 1.0.0 in order to reduce confusion with older versions of the Azure Text Analytics SDKs.
|
|
91
|
-
|
|
92
|
-
## 1.0.0 (2020-06-09)
|
|
93
|
-
|
|
94
|
-
- This release marks the general availability of the `@azure/ai-text-analytics` package.
|
|
95
|
-
|
|
96
|
-
## 1.0.0-preview.5 (2020-05-26)
|
|
97
|
-
|
|
98
|
-
- [Breaking] Renamed all result array types that extend JavaScript's base `Array` class to end with the word `Array` instead of `Collection` (e.g. `AnalyzeSentimentResultCollection` is now `AnalyzeSentimentResultArray`)
|
|
99
|
-
- [Breaking] Renamed `score` to `confidenceScore` in the `Match`, `Entity`, and `DetectedLanguage` types.
|
|
100
|
-
- [Breaking] Removed the `graphemeOffset` and `graphemeLength` properties of the `Match`, `Entity`, and `SentenceSentiment` types.
|
|
101
|
-
- [Breaking] Renamed the `graphemeCount` property of `TextDocumentStatistics` back to `characterCount`
|
|
102
|
-
- Added a `text` property to `SentenceSentiment` that contains the sentence text
|
|
103
|
-
- [Breaking] Removed the `warnings` property of `SentenceSentiment`.
|
|
104
|
-
- Added `warnings` property to every document response object containing a list of `TextAnalyticsWarning` objects relevant to the corresponding document.
|
|
105
|
-
- Migrated to using the Text Analytics v3.0 (General Availability) service endpoint.
|
|
106
|
-
|
|
107
|
-
## 1.0.0-preview.4 (2020-04-07)
|
|
108
|
-
|
|
109
|
-
- Renamed the first parameter of all operation methods from `inputs` to `documents`
|
|
110
|
-
- [Breaking] Removed PII entity detection methods from `TextAnalyticsClient` as well as all associated samples and documentation
|
|
111
|
-
- [Breaking] Replaced `TextAnalyticsApiKeyCredential` with `AzureKeyCredential` (re-exported through this package from `@azure/core-auth`).
|
|
112
|
-
- `TextAnalyticsClient` methods now throw an error when the `documents` parameter is not an array or empty before sending a request to the Text Analytics service.
|
|
113
|
-
|
|
114
|
-
## 1.0.0-preview.3 (2020-03-10)
|
|
115
|
-
|
|
116
|
-
- [Breaking] Renamed `id` to `dataSourceEntityId` in the `LinkedEntity` type.
|
|
117
|
-
- Added special handling for the string `"none"` as the `countryHint` parameter of the `TextAnalyticsClient.detectLanguage`. `"none"` is now treated the same as the empty string, and indicates that the default language detection model should be used.
|
|
118
|
-
- [Breaking] Renamed `offset` to `graphemeOffset` and `length` to `graphemeLength` in fields of response objects as appropriate in order to make it clear that the offsets and lengths are in units of Unicode graphemes.
|
|
119
|
-
- [Breaking] Renamed `sentimentScores` on both `DocumentSentiment` and `SentenceSentiment` to `confidenceScores`, and renamed the type `SentimentScorePerLabel` to `SentimentConfidenceScores`.
|
|
120
|
-
- [Breaking] Renamed `characterCount` to `graphemeCount` in the `DocumentStatistics` interface, to align with the change to using `grapheme` in the lengths/offsets of response objects.
|
|
121
|
-
|
|
122
|
-
## 1.0.0-preview.2 (2020-02-11)
|
|
123
|
-
|
|
124
|
-
- Added support for rotating API keys via the `TextAnalyticsApiKeyCredential.updateKey` method.
|
|
125
|
-
- Added a discriminant type for `TextAnalyticsResult.error` to allow for easy differentiation between success and error types using `if (result.error) { ... }` in both TypeScript and JavaScript.
|
|
126
|
-
- [Breaking] Removed the `Entity` type and added new return types `CategorizedEntity` and `PiiEntity` for the `recognizeEntities` and `recognizePiiEntities` methods respectively. These types are equivalent to the previous `Entity` type.
|
|
127
|
-
- [Breaking] Removed the `detectedLanguages` property from `DetectLanguageResult`, as the service currently only returns one language.
|
|
128
|
-
- [Breaking] Renamed the `detectLanguages` method to `detectLanguage`, as the `detectedLanguages` property was removed from the `DetectLanguageResult` return type.
|
|
129
|
-
- [Breaking] Renamed `documentScores` and `sentenceScores` on the `DocumentSentiment` and `SentenceSentiment` types both to `sentimentScores`.
|
|
130
|
-
- [Breaking] Renamed `type` and `subtype` to `category` and `subcategory` respectively in the `CategorizedEntity` and `PiiEntity` types.
|
|
131
|
-
- [Breaking] Renamed `DocumentSentimentValue` and `SentenceSentimentValue` to `DocumentSentimentLabel` and `SentenceSentimentLabel` respectively.
|
|
132
|
-
- [Breaking] Renamed `SentimentConfidenceScorePerLabel` to `SentimentScorePerLabel`.
|
|
133
|
-
- [Breaking] Refactored `TextAnalyticsError` to flatten the error hierarchy and remove `innerError`. The new error model has properties for `code`, `message`, and an optional `target` only. The `code` property of `TextAnalyticsError` can now contain all of the codes from the previous `InnerErrorCodeValue` as well as those from the top-level `ErrorCodeValue`.
|
|
134
|
-
|
|
135
|
-
## 1.0.0-preview.1 (2020-01-09)
|
|
136
|
-
|
|
137
|
-
- This release is a preview of our efforts to create a client library that is user friendly and
|
|
138
|
-
idiomatic to the JavaScript ecosystem. The reasons for most of the changes in this update can be found in the
|
|
139
|
-
[Azure SDK Design Guidelines for TypeScript](https://azure.github.io/azure-sdk/typescript_introduction.html).
|
|
140
|
-
- Differences from previous public package `@azure/cognitiveservices-textanalytics`
|
|
141
|
-
- Package name changed from `@azure/cognitiveservices-textanalytics` to `@azure/ai-text-analytics`.
|
|
142
|
-
- Package targets version `3.0` of the service API.
|
|
143
|
-
- Supports authentication via `@azure/identity`.
|
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,167 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT license.
|
|
3
|
-
import { makeAnalyzeSentimentResultArray } from "./analyzeSentimentResultArray";
|
|
4
|
-
import { makeExtractKeyPhrasesResultArray } from "./extractKeyPhrasesResultArray";
|
|
5
|
-
import { makeExtractSummaryResultArray } from "./extractSummaryResultArray";
|
|
6
|
-
import { makeRecognizeCategorizedEntitiesResultArray } from "./recognizeCategorizedEntitiesResultArray";
|
|
7
|
-
import { makeRecognizeLinkedEntitiesResultArray } from "./recognizeLinkedEntitiesResultArray";
|
|
8
|
-
import { makeRecognizePiiEntitiesResultArray } from "./recognizePiiEntitiesResultArray";
|
|
9
|
-
import { intoTextAnalyticsError } from "./textAnalyticsResult";
|
|
10
|
-
/**
|
|
11
|
-
* Converts the service task name (in the JSON pointer in an action error) to an action type name.
|
|
12
|
-
* @param serviceActionType - The task type name the service uses.
|
|
13
|
-
* @returns the action type name that the package uses
|
|
14
|
-
* @internal
|
|
15
|
-
*/
|
|
16
|
-
function convertTaskTypeToActionType(taskType) {
|
|
17
|
-
switch (taskType) {
|
|
18
|
-
case "entityRecognitionTasks": {
|
|
19
|
-
return "RecognizeCategorizedEntities";
|
|
20
|
-
}
|
|
21
|
-
case "entityRecognitionPiiTasks": {
|
|
22
|
-
return "RecognizePiiEntities";
|
|
23
|
-
}
|
|
24
|
-
case "keyPhraseExtractionTasks": {
|
|
25
|
-
return "ExtractKeyPhrases";
|
|
26
|
-
}
|
|
27
|
-
case "entityLinkingTasks": {
|
|
28
|
-
return "RecognizeLinkedEntities";
|
|
29
|
-
}
|
|
30
|
-
case "sentimentAnalysisTasks": {
|
|
31
|
-
return "AnalyzeSentiment";
|
|
32
|
-
}
|
|
33
|
-
case "extractiveSummarizationTasks": {
|
|
34
|
-
return "ExtractSummary";
|
|
35
|
-
}
|
|
36
|
-
default: {
|
|
37
|
-
throw new Error(`unexpected action type from the service: ${taskType}`);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Converts a service action error to one with the JSON pointer converted to an action index.
|
|
43
|
-
* @param erredActions - the action error the service sent
|
|
44
|
-
* @returns an action error with an action type and index
|
|
45
|
-
* @internal
|
|
46
|
-
*/
|
|
47
|
-
export function parseActionError(erredActions) {
|
|
48
|
-
if (erredActions.target) {
|
|
49
|
-
const regex = new RegExp(/#\/tasks\/(entityRecognitionTasks|entityRecognitionPiiTasks|keyPhraseExtractionTasks|entityLinkingTasks|sentimentAnalysisTasks|extractiveSummarizationTasks)\/(\d+)/);
|
|
50
|
-
const result = regex.exec(erredActions.target);
|
|
51
|
-
if (result !== null) {
|
|
52
|
-
return {
|
|
53
|
-
code: erredActions.code,
|
|
54
|
-
message: erredActions.message,
|
|
55
|
-
index: parseInt(result[2]),
|
|
56
|
-
type: convertTaskTypeToActionType(result[1])
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
throw new Error(`Pointer "${erredActions.target}" is not a valid action pointer`);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
throw new Error("expected an error with a target field referencing an action but did not get one");
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Categorize each action error into a bucket according to its action type.
|
|
69
|
-
* @param erredActions - list of action errors
|
|
70
|
-
* @param recognizeEntitiesActionErrors - a list of recognize entities action errors to be filled from the errors list
|
|
71
|
-
* @param recognizePiiEntitiesActionErrors - a list of recognize pii entities action errors to be filled from the errors list
|
|
72
|
-
* @param extractKeyPhrasesActionErrors - a list of extract key phrases action errors to be filled from the errors list
|
|
73
|
-
* @internal
|
|
74
|
-
*/
|
|
75
|
-
function categorizeActionErrors(erredActions, recognizeEntitiesActionErrors, recognizePiiEntitiesActionErrors, extractKeyPhrasesActionErrors, recognizeLinkedEntitiesActionErrors, analyzeSentimentActionErrors, extractSummarySentencesActionErrors) {
|
|
76
|
-
for (const error of erredActions) {
|
|
77
|
-
const actionError = parseActionError(error);
|
|
78
|
-
switch (actionError.type) {
|
|
79
|
-
case "RecognizeCategorizedEntities": {
|
|
80
|
-
recognizeEntitiesActionErrors.push(actionError);
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
case "RecognizePiiEntities": {
|
|
84
|
-
recognizePiiEntitiesActionErrors.push(actionError);
|
|
85
|
-
break;
|
|
86
|
-
}
|
|
87
|
-
case "ExtractKeyPhrases": {
|
|
88
|
-
extractKeyPhrasesActionErrors.push(actionError);
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
case "RecognizeLinkedEntities": {
|
|
92
|
-
recognizeLinkedEntitiesActionErrors.push(actionError);
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
case "AnalyzeSentiment": {
|
|
96
|
-
analyzeSentimentActionErrors.push(actionError);
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
case "ExtractSummary": {
|
|
100
|
-
extractSummarySentencesActionErrors.push(actionError);
|
|
101
|
-
break;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* @internal
|
|
108
|
-
* @param error - the error the service sent for a task
|
|
109
|
-
* @param lastUpdateDateTime - the time when this task failed
|
|
110
|
-
*/
|
|
111
|
-
function createErredAction(error, lastUpdateDateTime) {
|
|
112
|
-
return { error: intoTextAnalyticsError(error), failedOn: lastUpdateDateTime };
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Creates a list of results for any action.
|
|
116
|
-
* @param documents - list of input documents
|
|
117
|
-
* @param makeResultsArray - a function to convert the results of a service response to the SDK's one
|
|
118
|
-
* @param succeededTasks - list of succeeded action results
|
|
119
|
-
* @param erredActions - list of erred actions
|
|
120
|
-
* @internal
|
|
121
|
-
*/
|
|
122
|
-
function makeActionResult(documents, makeResultsArray, succeededTasks, erredActions) {
|
|
123
|
-
let errorIndex = 0;
|
|
124
|
-
function convertTasksToActions(actions, task) {
|
|
125
|
-
const { results: actionResults, lastUpdateDateTime } = task;
|
|
126
|
-
if (actionResults !== undefined) {
|
|
127
|
-
const recognizeEntitiesResults = makeResultsArray(documents, actionResults);
|
|
128
|
-
return [
|
|
129
|
-
...actions,
|
|
130
|
-
{
|
|
131
|
-
results: recognizeEntitiesResults,
|
|
132
|
-
completedOn: lastUpdateDateTime
|
|
133
|
-
}
|
|
134
|
-
];
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
return [...actions, createErredAction(erredActions[errorIndex++], lastUpdateDateTime)];
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
return succeededTasks.reduce(convertTasksToActions, []);
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Creates the user-friendly action results object for the begin analyze actions operation.
|
|
144
|
-
* @param response - the begin analyze actions operation response
|
|
145
|
-
* @param documents - the list of input documents
|
|
146
|
-
* @returns - the user-friendly action results object
|
|
147
|
-
* @internal
|
|
148
|
-
*/
|
|
149
|
-
export function createAnalyzeActionsResult(response, documents) {
|
|
150
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
151
|
-
const recognizeEntitiesActionErrors = [];
|
|
152
|
-
const recognizePiiEntitiesActionErrors = [];
|
|
153
|
-
const extractKeyPhrasesActionErrors = [];
|
|
154
|
-
const recognizeLinkedEntitiesActionErrors = [];
|
|
155
|
-
const analyzeSentimentActionErrors = [];
|
|
156
|
-
const extractSummarySentencesActionErrors = [];
|
|
157
|
-
categorizeActionErrors((_a = response === null || response === void 0 ? void 0 : response.errors) !== null && _a !== void 0 ? _a : [], recognizeEntitiesActionErrors, recognizePiiEntitiesActionErrors, extractKeyPhrasesActionErrors, recognizeLinkedEntitiesActionErrors, analyzeSentimentActionErrors, extractSummarySentencesActionErrors);
|
|
158
|
-
return {
|
|
159
|
-
recognizeEntitiesResults: makeActionResult(documents, makeRecognizeCategorizedEntitiesResultArray, (_b = response.tasks.entityRecognitionTasks) !== null && _b !== void 0 ? _b : [], recognizeEntitiesActionErrors),
|
|
160
|
-
recognizePiiEntitiesResults: makeActionResult(documents, makeRecognizePiiEntitiesResultArray, (_c = response.tasks.entityRecognitionPiiTasks) !== null && _c !== void 0 ? _c : [], recognizePiiEntitiesActionErrors),
|
|
161
|
-
extractKeyPhrasesResults: makeActionResult(documents, makeExtractKeyPhrasesResultArray, (_d = response.tasks.keyPhraseExtractionTasks) !== null && _d !== void 0 ? _d : [], extractKeyPhrasesActionErrors),
|
|
162
|
-
recognizeLinkedEntitiesResults: makeActionResult(documents, makeRecognizeLinkedEntitiesResultArray, (_e = response.tasks.entityLinkingTasks) !== null && _e !== void 0 ? _e : [], recognizeLinkedEntitiesActionErrors),
|
|
163
|
-
analyzeSentimentResults: makeActionResult(documents, makeAnalyzeSentimentResultArray, (_f = response.tasks.sentimentAnalysisTasks) !== null && _f !== void 0 ? _f : [], analyzeSentimentActionErrors),
|
|
164
|
-
extractSummaryResults: makeActionResult(documents, makeExtractSummaryResultArray, (_g = response.tasks.extractiveSummarizationTasks) !== null && _g !== void 0 ? _g : [], extractSummarySentencesActionErrors)
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
//# 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,gCAAgC,EACjC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAEL,6BAA6B,EAC9B,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,2CAA2C,EAE5C,MAAM,2CAA2C,CAAC;AACnD,OAAO,EACL,sCAAsC,EAEvC,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,mCAAmC,EAEpC,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAa,sBAAsB,EAAsB,MAAM,uBAAuB,CAAC;AA4P9F;;;;;GAKG;AACH,SAAS,2BAA2B,CAAC,QAAgB;IACnD,QAAQ,QAAQ,EAAE;QAChB,KAAK,wBAAwB,CAAC,CAAC;YAC7B,OAAO,8BAA8B,CAAC;SACvC;QACD,KAAK,2BAA2B,CAAC,CAAC;YAChC,OAAO,sBAAsB,CAAC;SAC/B;QACD,KAAK,0BAA0B,CAAC,CAAC;YAC/B,OAAO,mBAAmB,CAAC;SAC5B;QACD,KAAK,oBAAoB,CAAC,CAAC;YACzB,OAAO,yBAAyB,CAAC;SAClC;QACD,KAAK,wBAAwB,CAAC,CAAC;YAC7B,OAAO,kBAAkB,CAAC;SAC3B;QACD,KAAK,8BAA8B,CAAC,CAAC;YACnC,OAAO,gBAAgB,CAAC;SACzB;QACD,OAAO,CAAC,CAAC;YACP,MAAM,IAAI,KAAK,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B,EAAE,gBAAgB,CACrC,SAAS,EACT,6BAA6B,EAC7B,MAAA,QAAQ,CAAC,KAAK,CAAC,4BAA4B,mCAAI,EAAE,EACjD,mCAAmC,CACpC;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 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 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\n/**\n * The state of a succeeded action.\n */\nexport interface TextAnalyticsActionSuccessState {\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 {\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 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\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 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)\\/(\\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): 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 }\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): TextAnalyticsActionErrorResult {\n return { error: intoTextAnalyticsError(error), failedOn: lastUpdateDateTime };\n}\n\ninterface TaskSuccessResult<T> {\n results?: T;\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 } = task;\n if (actionResults !== undefined) {\n const recognizeEntitiesResults = makeResultsArray(documents, actionResults);\n return [\n ...actions,\n {\n results: recognizeEntitiesResults,\n completedOn: lastUpdateDateTime\n }\n ];\n } else {\n return [...actions, createErredAction(erredActions[errorIndex++], lastUpdateDateTime)];\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 categorizeActionErrors(\n response?.errors ?? [],\n recognizeEntitiesActionErrors,\n recognizePiiEntitiesActionErrors,\n extractKeyPhrasesActionErrors,\n recognizeLinkedEntitiesActionErrors,\n analyzeSentimentActionErrors,\n extractSummarySentencesActionErrors\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 };\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,130 +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 { getRawResponse, handleInvalidDocumentBatch, 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 "./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
|
-
path: "/analyze/jobs/{jobId}",
|
|
15
|
-
httpMethod: "GET",
|
|
16
|
-
responses: {
|
|
17
|
-
200: {
|
|
18
|
-
bodyMapper: Mappers.AnalyzeJobState
|
|
19
|
-
},
|
|
20
|
-
default: {
|
|
21
|
-
bodyMapper: Mappers.ErrorResponse
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
queryParameters: [includeStatistics, top, skip],
|
|
25
|
-
urlParameters: [endpoint, apiVersion],
|
|
26
|
-
headerParameters: [accept],
|
|
27
|
-
serializer
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* @internal
|
|
31
|
-
*/
|
|
32
|
-
export class AnalyzeLro {
|
|
33
|
-
constructor(
|
|
34
|
-
// eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters
|
|
35
|
-
client, baseOptions, initOptions, pollOptions, documents, tasks) {
|
|
36
|
-
this.client = client;
|
|
37
|
-
this.baseOptions = baseOptions;
|
|
38
|
-
this.initOptions = initOptions;
|
|
39
|
-
this.pollOptions = pollOptions;
|
|
40
|
-
this.documents = documents;
|
|
41
|
-
this.tasks = tasks;
|
|
42
|
-
this.requestMethod = "POST";
|
|
43
|
-
this.requestPath = "/analyze";
|
|
44
|
-
}
|
|
45
|
-
async sendInitialRequest() {
|
|
46
|
-
const { span, updatedOptions: finalOptions } = createSpan("TextAnalyticsClient-beginAnalyze", Object.assign(Object.assign({}, this.baseOptions), this.initOptions));
|
|
47
|
-
try {
|
|
48
|
-
const { flatResponse, rawResponse } = await getRawResponse((paramOptions) => this.client.analyze(Object.assign({ body: {
|
|
49
|
-
analysisInput: { documents: this.documents },
|
|
50
|
-
tasks: this.tasks,
|
|
51
|
-
displayName: this.initOptions.displayName
|
|
52
|
-
} }, paramOptions)), finalOptions);
|
|
53
|
-
return {
|
|
54
|
-
flatResponse: flatResponse,
|
|
55
|
-
rawResponse
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
catch (e) {
|
|
59
|
-
const exception = handleInvalidDocumentBatch(e);
|
|
60
|
-
span.setStatus({
|
|
61
|
-
code: SpanStatusCode.ERROR,
|
|
62
|
-
message: exception.message
|
|
63
|
-
});
|
|
64
|
-
throw exception;
|
|
65
|
-
}
|
|
66
|
-
finally {
|
|
67
|
-
span.end();
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
async sendPollRequest(path) {
|
|
71
|
-
return sendGetRequest(this.client, analyzeStatusOperationSpec, "AnalyzeStatus", Object.assign(Object.assign({}, this.baseOptions), this.pollOptions), path);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* @internal
|
|
76
|
-
*/
|
|
77
|
-
export function isAnalyzeDone(response) {
|
|
78
|
-
const castResponse = response;
|
|
79
|
-
switch (castResponse.status) {
|
|
80
|
-
case "notStarted":
|
|
81
|
-
case "running":
|
|
82
|
-
return false;
|
|
83
|
-
default: {
|
|
84
|
-
return true;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* @internal
|
|
90
|
-
*/
|
|
91
|
-
export function processAnalyzeResult(
|
|
92
|
-
// eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters
|
|
93
|
-
client, documents, options) {
|
|
94
|
-
const pagedResult = {
|
|
95
|
-
sendGetRequest: (path, optionsParam) => sendGetRequest(client, analyzeStatusOperationSpec, "AnalyzeStatus", optionsParam, path).then((response) => response.flatResponse),
|
|
96
|
-
buildPage: (flatResponse) => {
|
|
97
|
-
if (flatResponse) {
|
|
98
|
-
return createAnalyzeActionsResult(flatResponse, documents);
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
throw new Error("Analyze action has succeeded but there are no results!");
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
return (_result, state) => {
|
|
106
|
-
const pollingURL = state.pollingURL;
|
|
107
|
-
const pagedIterator = getPagedAsyncIterator(pagedResult, pollingURL, options);
|
|
108
|
-
// Attach stats if the service starts to return them
|
|
109
|
-
// https://github.com/Azure/azure-sdk-for-js/issues/14139
|
|
110
|
-
// state.result = Object.assign(pagedIterator, {
|
|
111
|
-
// statistics: operationStatus.statistics
|
|
112
|
-
// });
|
|
113
|
-
return pagedIterator;
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* @internal
|
|
118
|
-
*/
|
|
119
|
-
export function updateAnalyzeState(state, lastResponse) {
|
|
120
|
-
const response = lastResponse.body;
|
|
121
|
-
state.createdOn = response.createdDateTime;
|
|
122
|
-
state.lastModifiedOn = response.lastUpdateDateTime;
|
|
123
|
-
state.expiresOn = response.expirationDateTime;
|
|
124
|
-
state.status = response.status;
|
|
125
|
-
state.actionsSucceededCount = response.tasks.completed;
|
|
126
|
-
state.actionsFailedCount = response.tasks.failed;
|
|
127
|
-
state.actionsInProgressCount = response.tasks.inProgress;
|
|
128
|
-
state.displayName = response.displayName;
|
|
129
|
-
}
|
|
130
|
-
//# 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,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kBAAkB,CAAC;IACnD,KAAK,CAAC,SAAS,GAAG,QAAQ,CAAC,kBAAkB,CAAC;IAC9C,KAAK,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;IAC/B,KAAK,CAAC,qBAAqB,GAAG,QAAQ,CAAC,KAAK,CAAC,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 GeneratedClientAnalyzeStatusResponse,\n JobManifestTasks,\n TextDocumentInput\n} from \"./generated\";\nimport { createSpan } from \"./tracing\";\nimport { getRawResponse, handleInvalidDocumentBatch, 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 \"./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 path: \"/analyze/jobs/{jobId}\",\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 = handleInvalidDocumentBatch(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<TOptions extends OperationOptions>(\n // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters\n client: GeneratedClient,\n documents: TextDocumentInput[],\n options: TOptions\n): (result: unknown, state: AnalyzeActionsOperationState) => PagedAnalyzeActionsResult {\n const pagedResult: PagedResult<\n TOptions,\n GeneratedClientAnalyzeStatusResponse,\n AnalyzeActionsResult\n > = {\n sendGetRequest: (path: string, optionsParam: TOptions) =>\n sendGetRequest(client, analyzeStatusOperationSpec, \"AnalyzeStatus\", optionsParam, path).then(\n (response) => response.flatResponse as GeneratedClientAnalyzeStatusResponse\n ),\n buildPage: (flatResponse: GeneratedClientAnalyzeStatusResponse) => {\n if (flatResponse) {\n return createAnalyzeActionsResult(flatResponse, documents);\n } else {\n throw new Error(\"Analyze action has succeeded but there are no results!\");\n }\n }\n };\n return (_result: unknown, state: AnalyzeActionsOperationState): PagedAnalyzeActionsResult => {\n const pollingURL = (state as any).pollingURL;\n const pagedIterator = getPagedAsyncIterator<\n TOptions,\n GeneratedClientAnalyzeStatusResponse,\n AnalyzeActionsResult,\n AnalyzeActionsResult\n >(pagedResult, pollingURL, options);\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"]}
|