azure-ai-textanalytics 5.3.0b1__py3-none-any.whl → 6.0.0b1__py3-none-any.whl

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.

Potentially problematic release.


This version of azure-ai-textanalytics might be problematic. Click here for more details.

Files changed (128) hide show
  1. azure/ai/textanalytics/__init__.py +26 -197
  2. azure/ai/textanalytics/_client.py +111 -0
  3. azure/ai/textanalytics/_configuration.py +73 -0
  4. azure/ai/textanalytics/{_generated/v2022_05_01/operations → _operations}/__init__.py +13 -8
  5. azure/ai/textanalytics/_operations/_operations.py +716 -0
  6. azure/ai/textanalytics/{_generated/v2022_05_01/models → _operations}/_patch.py +8 -6
  7. azure/ai/textanalytics/_patch.py +350 -0
  8. azure/ai/textanalytics/{_generated/aio → _utils}/__init__.py +1 -5
  9. azure/ai/textanalytics/_utils/model_base.py +1237 -0
  10. azure/ai/textanalytics/{_generated/_serialization.py → _utils/serialization.py} +640 -616
  11. azure/ai/textanalytics/{_generated/v2022_05_01/aio/_vendor.py → _utils/utils.py} +10 -12
  12. azure/ai/textanalytics/_version.py +8 -7
  13. azure/ai/textanalytics/aio/__init__.py +25 -14
  14. azure/ai/textanalytics/aio/_client.py +115 -0
  15. azure/ai/textanalytics/aio/_configuration.py +75 -0
  16. azure/ai/textanalytics/{_generated/v2022_10_01_preview/aio/operations → aio/_operations}/__init__.py +13 -8
  17. azure/ai/textanalytics/aio/_operations/_operations.py +623 -0
  18. azure/ai/textanalytics/{_generated/v2022_05_01 → aio/_operations}/_patch.py +8 -6
  19. azure/ai/textanalytics/aio/_patch.py +344 -0
  20. azure/ai/textanalytics/models/__init__.py +402 -0
  21. azure/ai/textanalytics/models/_enums.py +1979 -0
  22. azure/ai/textanalytics/models/_models.py +6641 -0
  23. azure/ai/textanalytics/{_generated/v2022_05_01/aio → models}/_patch.py +8 -6
  24. azure/ai/textanalytics/py.typed +1 -0
  25. {azure_ai_textanalytics-5.3.0b1.dist-info → azure_ai_textanalytics-6.0.0b1.dist-info}/METADATA +755 -319
  26. azure_ai_textanalytics-6.0.0b1.dist-info/RECORD +29 -0
  27. {azure_ai_textanalytics-5.3.0b1.dist-info → azure_ai_textanalytics-6.0.0b1.dist-info}/WHEEL +1 -1
  28. azure/ai/textanalytics/_base_client.py +0 -111
  29. azure/ai/textanalytics/_check.py +0 -22
  30. azure/ai/textanalytics/_dict_mixin.py +0 -54
  31. azure/ai/textanalytics/_generated/__init__.py +0 -16
  32. azure/ai/textanalytics/_generated/_configuration.py +0 -70
  33. azure/ai/textanalytics/_generated/_operations_mixin.py +0 -795
  34. azure/ai/textanalytics/_generated/_text_analytics_client.py +0 -126
  35. azure/ai/textanalytics/_generated/_version.py +0 -8
  36. azure/ai/textanalytics/_generated/aio/_configuration.py +0 -66
  37. azure/ai/textanalytics/_generated/aio/_operations_mixin.py +0 -776
  38. azure/ai/textanalytics/_generated/aio/_text_analytics_client.py +0 -124
  39. azure/ai/textanalytics/_generated/models.py +0 -8
  40. azure/ai/textanalytics/_generated/v2022_05_01/__init__.py +0 -20
  41. azure/ai/textanalytics/_generated/v2022_05_01/_configuration.py +0 -72
  42. azure/ai/textanalytics/_generated/v2022_05_01/_text_analytics_client.py +0 -100
  43. azure/ai/textanalytics/_generated/v2022_05_01/_vendor.py +0 -45
  44. azure/ai/textanalytics/_generated/v2022_05_01/aio/__init__.py +0 -20
  45. azure/ai/textanalytics/_generated/v2022_05_01/aio/_configuration.py +0 -71
  46. azure/ai/textanalytics/_generated/v2022_05_01/aio/_text_analytics_client.py +0 -97
  47. azure/ai/textanalytics/_generated/v2022_05_01/aio/operations/__init__.py +0 -18
  48. azure/ai/textanalytics/_generated/v2022_05_01/aio/operations/_patch.py +0 -121
  49. azure/ai/textanalytics/_generated/v2022_05_01/aio/operations/_text_analytics_client_operations.py +0 -603
  50. azure/ai/textanalytics/_generated/v2022_05_01/models/__init__.py +0 -281
  51. azure/ai/textanalytics/_generated/v2022_05_01/models/_models_py3.py +0 -5722
  52. azure/ai/textanalytics/_generated/v2022_05_01/models/_text_analytics_client_enums.py +0 -439
  53. azure/ai/textanalytics/_generated/v2022_05_01/operations/_patch.py +0 -120
  54. azure/ai/textanalytics/_generated/v2022_05_01/operations/_text_analytics_client_operations.py +0 -744
  55. azure/ai/textanalytics/_generated/v2022_10_01_preview/__init__.py +0 -20
  56. azure/ai/textanalytics/_generated/v2022_10_01_preview/_configuration.py +0 -72
  57. azure/ai/textanalytics/_generated/v2022_10_01_preview/_patch.py +0 -19
  58. azure/ai/textanalytics/_generated/v2022_10_01_preview/_text_analytics_client.py +0 -100
  59. azure/ai/textanalytics/_generated/v2022_10_01_preview/_vendor.py +0 -45
  60. azure/ai/textanalytics/_generated/v2022_10_01_preview/aio/__init__.py +0 -20
  61. azure/ai/textanalytics/_generated/v2022_10_01_preview/aio/_configuration.py +0 -71
  62. azure/ai/textanalytics/_generated/v2022_10_01_preview/aio/_patch.py +0 -19
  63. azure/ai/textanalytics/_generated/v2022_10_01_preview/aio/_text_analytics_client.py +0 -97
  64. azure/ai/textanalytics/_generated/v2022_10_01_preview/aio/_vendor.py +0 -27
  65. azure/ai/textanalytics/_generated/v2022_10_01_preview/aio/operations/_patch.py +0 -121
  66. azure/ai/textanalytics/_generated/v2022_10_01_preview/aio/operations/_text_analytics_client_operations.py +0 -603
  67. azure/ai/textanalytics/_generated/v2022_10_01_preview/models/__init__.py +0 -407
  68. azure/ai/textanalytics/_generated/v2022_10_01_preview/models/_models_py3.py +0 -8462
  69. azure/ai/textanalytics/_generated/v2022_10_01_preview/models/_patch.py +0 -72
  70. azure/ai/textanalytics/_generated/v2022_10_01_preview/models/_text_analytics_client_enums.py +0 -730
  71. azure/ai/textanalytics/_generated/v2022_10_01_preview/operations/__init__.py +0 -18
  72. azure/ai/textanalytics/_generated/v2022_10_01_preview/operations/_patch.py +0 -120
  73. azure/ai/textanalytics/_generated/v2022_10_01_preview/operations/_text_analytics_client_operations.py +0 -744
  74. azure/ai/textanalytics/_generated/v3_0/__init__.py +0 -20
  75. azure/ai/textanalytics/_generated/v3_0/_configuration.py +0 -66
  76. azure/ai/textanalytics/_generated/v3_0/_patch.py +0 -31
  77. azure/ai/textanalytics/_generated/v3_0/_text_analytics_client.py +0 -96
  78. azure/ai/textanalytics/_generated/v3_0/_vendor.py +0 -33
  79. azure/ai/textanalytics/_generated/v3_0/aio/__init__.py +0 -20
  80. azure/ai/textanalytics/_generated/v3_0/aio/_configuration.py +0 -65
  81. azure/ai/textanalytics/_generated/v3_0/aio/_patch.py +0 -31
  82. azure/ai/textanalytics/_generated/v3_0/aio/_text_analytics_client.py +0 -93
  83. azure/ai/textanalytics/_generated/v3_0/aio/_vendor.py +0 -27
  84. azure/ai/textanalytics/_generated/v3_0/aio/operations/__init__.py +0 -18
  85. azure/ai/textanalytics/_generated/v3_0/aio/operations/_patch.py +0 -19
  86. azure/ai/textanalytics/_generated/v3_0/aio/operations/_text_analytics_client_operations.py +0 -428
  87. azure/ai/textanalytics/_generated/v3_0/models/__init__.py +0 -81
  88. azure/ai/textanalytics/_generated/v3_0/models/_models_py3.py +0 -1467
  89. azure/ai/textanalytics/_generated/v3_0/models/_patch.py +0 -19
  90. azure/ai/textanalytics/_generated/v3_0/models/_text_analytics_client_enums.py +0 -58
  91. azure/ai/textanalytics/_generated/v3_0/operations/__init__.py +0 -18
  92. azure/ai/textanalytics/_generated/v3_0/operations/_patch.py +0 -19
  93. azure/ai/textanalytics/_generated/v3_0/operations/_text_analytics_client_operations.py +0 -604
  94. azure/ai/textanalytics/_generated/v3_1/__init__.py +0 -20
  95. azure/ai/textanalytics/_generated/v3_1/_configuration.py +0 -66
  96. azure/ai/textanalytics/_generated/v3_1/_patch.py +0 -31
  97. azure/ai/textanalytics/_generated/v3_1/_text_analytics_client.py +0 -98
  98. azure/ai/textanalytics/_generated/v3_1/_vendor.py +0 -45
  99. azure/ai/textanalytics/_generated/v3_1/aio/__init__.py +0 -20
  100. azure/ai/textanalytics/_generated/v3_1/aio/_configuration.py +0 -65
  101. azure/ai/textanalytics/_generated/v3_1/aio/_patch.py +0 -31
  102. azure/ai/textanalytics/_generated/v3_1/aio/_text_analytics_client.py +0 -95
  103. azure/ai/textanalytics/_generated/v3_1/aio/_vendor.py +0 -27
  104. azure/ai/textanalytics/_generated/v3_1/aio/operations/__init__.py +0 -18
  105. azure/ai/textanalytics/_generated/v3_1/aio/operations/_patch.py +0 -19
  106. azure/ai/textanalytics/_generated/v3_1/aio/operations/_text_analytics_client_operations.py +0 -1291
  107. azure/ai/textanalytics/_generated/v3_1/models/__init__.py +0 -205
  108. azure/ai/textanalytics/_generated/v3_1/models/_models_py3.py +0 -3976
  109. azure/ai/textanalytics/_generated/v3_1/models/_patch.py +0 -19
  110. azure/ai/textanalytics/_generated/v3_1/models/_text_analytics_client_enums.py +0 -367
  111. azure/ai/textanalytics/_generated/v3_1/operations/__init__.py +0 -18
  112. azure/ai/textanalytics/_generated/v3_1/operations/_patch.py +0 -19
  113. azure/ai/textanalytics/_generated/v3_1/operations/_text_analytics_client_operations.py +0 -1709
  114. azure/ai/textanalytics/_lro.py +0 -552
  115. azure/ai/textanalytics/_models.py +0 -3142
  116. azure/ai/textanalytics/_policies.py +0 -66
  117. azure/ai/textanalytics/_request_handlers.py +0 -104
  118. azure/ai/textanalytics/_response_handlers.py +0 -580
  119. azure/ai/textanalytics/_text_analytics_client.py +0 -1802
  120. azure/ai/textanalytics/_user_agent.py +0 -8
  121. azure/ai/textanalytics/_validate.py +0 -113
  122. azure/ai/textanalytics/aio/_base_client_async.py +0 -95
  123. azure/ai/textanalytics/aio/_lro_async.py +0 -501
  124. azure/ai/textanalytics/aio/_response_handlers_async.py +0 -94
  125. azure/ai/textanalytics/aio/_text_analytics_client_async.py +0 -1800
  126. azure_ai_textanalytics-5.3.0b1.dist-info/RECORD +0 -115
  127. {azure_ai_textanalytics-5.3.0b1.dist-info → azure_ai_textanalytics-6.0.0b1.dist-info/licenses}/LICENSE +0 -0
  128. {azure_ai_textanalytics-5.3.0b1.dist-info → azure_ai_textanalytics-6.0.0b1.dist-info}/top_level.txt +0 -0
@@ -1,1802 +0,0 @@
1
- # ------------------------------------
2
- # Copyright (c) Microsoft Corporation.
3
- # Licensed under the MIT License.
4
- # ------------------------------------
5
- # pylint: disable=too-many-lines
6
-
7
- from typing import (
8
- Union,
9
- Any,
10
- List,
11
- Dict,
12
- cast,
13
- )
14
- from azure.core.paging import ItemPaged
15
- from azure.core.tracing.decorator import distributed_trace
16
- from azure.core.exceptions import HttpResponseError
17
- from azure.core.credentials import AzureKeyCredential
18
- from azure.core.credentials import TokenCredential
19
- from ._base_client import TextAnalyticsClientBase
20
- from ._lro import AnalyzeActionsLROPoller, AnalyzeHealthcareEntitiesLROPoller, TextAnalysisLROPoller
21
- from ._request_handlers import (
22
- _validate_input,
23
- _determine_action_type,
24
- )
25
- from ._validate import validate_multiapi_args, check_for_unsupported_actions_types
26
- from ._response_handlers import (
27
- process_http_response_error,
28
- entities_result,
29
- linked_entities_result,
30
- key_phrases_result,
31
- sentiment_result,
32
- language_result,
33
- pii_entities_result,
34
- healthcare_paged_result,
35
- analyze_paged_result,
36
- _get_result_from_continuation_token,
37
- dynamic_classification_result,
38
- )
39
-
40
- from ._lro import (
41
- TextAnalyticsOperationResourcePolling,
42
- AnalyzeActionsLROPollingMethod,
43
- AnalyzeHealthcareEntitiesLROPollingMethod,
44
- )
45
- from ._models import (
46
- DetectLanguageInput,
47
- TextDocumentInput,
48
- DetectLanguageResult,
49
- RecognizeEntitiesResult,
50
- RecognizeLinkedEntitiesResult,
51
- ExtractKeyPhrasesResult,
52
- AnalyzeSentimentResult,
53
- DocumentError,
54
- RecognizePiiEntitiesResult,
55
- RecognizeEntitiesAction,
56
- RecognizePiiEntitiesAction,
57
- RecognizeLinkedEntitiesAction,
58
- ExtractKeyPhrasesAction,
59
- AnalyzeSentimentAction,
60
- AnalyzeHealthcareEntitiesResult,
61
- RecognizeCustomEntitiesAction,
62
- RecognizeCustomEntitiesResult,
63
- SingleLabelClassifyAction,
64
- MultiLabelClassifyAction,
65
- ClassifyDocumentResult,
66
- AnalyzeHealthcareEntitiesAction,
67
- _AnalyzeActionsType,
68
- ExtractSummaryAction,
69
- ExtractSummaryResult,
70
- AbstractSummaryAction,
71
- AbstractSummaryResult,
72
- DynamicClassificationResult,
73
- )
74
- from ._check import is_language_api, string_index_type_compatibility
75
-
76
-
77
- AnalyzeActionsResponse = TextAnalysisLROPoller[
78
- ItemPaged[
79
- List[
80
- Union[
81
- RecognizeEntitiesResult,
82
- RecognizeLinkedEntitiesResult,
83
- RecognizePiiEntitiesResult,
84
- ExtractKeyPhrasesResult,
85
- AnalyzeSentimentResult,
86
- RecognizeCustomEntitiesResult,
87
- ClassifyDocumentResult,
88
- AnalyzeHealthcareEntitiesResult,
89
- ExtractSummaryResult,
90
- AbstractSummaryResult,
91
- DocumentError,
92
- ]
93
- ]
94
- ]
95
- ]
96
-
97
-
98
- class TextAnalyticsClient(TextAnalyticsClientBase):
99
- """The Language service API is a suite of natural language processing (NLP) skills built with the best-in-class
100
- Microsoft machine learning algorithms. The API can be used to analyze unstructured text for
101
- tasks such as sentiment analysis, key phrase extraction, entities recognition,
102
- and language detection, and more.
103
-
104
- Further documentation can be found in
105
- https://docs.microsoft.com/azure/cognitive-services/language-service/overview
106
-
107
- :param str endpoint: Supported Cognitive Services or Language resource
108
- endpoints (protocol and hostname, for example: 'https://<resource-name>.cognitiveservices.azure.com').
109
- :param credential: Credentials needed for the client to connect to Azure.
110
- This can be the an instance of AzureKeyCredential if using a Cognitive Services/Language API key
111
- or a token credential from :mod:`azure.identity`.
112
- :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials.TokenCredential
113
- :keyword str default_country_hint: Sets the default country_hint to use for all operations.
114
- Defaults to "US". If you don't want to use a country hint, pass the string "none".
115
- :keyword str default_language: Sets the default language to use for all operations.
116
- Defaults to "en".
117
- :keyword api_version: The API version of the service to use for requests. It defaults to the
118
- latest service version. Setting to an older version may result in reduced feature compatibility.
119
- :paramtype api_version: str or ~azure.ai.textanalytics.TextAnalyticsApiVersion
120
-
121
- .. admonition:: Example:
122
-
123
- .. literalinclude:: ../samples/sample_authentication.py
124
- :start-after: [START create_ta_client_with_key]
125
- :end-before: [END create_ta_client_with_key]
126
- :language: python
127
- :dedent: 4
128
- :caption: Creating the TextAnalyticsClient with endpoint and API key.
129
-
130
- .. literalinclude:: ../samples/sample_authentication.py
131
- :start-after: [START create_ta_client_with_aad]
132
- :end-before: [END create_ta_client_with_aad]
133
- :language: python
134
- :dedent: 4
135
- :caption: Creating the TextAnalyticsClient with endpoint and token credential from Azure Active Directory.
136
- """
137
-
138
- def __init__(
139
- self,
140
- endpoint: str,
141
- credential: Union[AzureKeyCredential, TokenCredential],
142
- **kwargs: Any
143
- ) -> None:
144
- super().__init__(
145
- endpoint=endpoint, credential=credential, **kwargs
146
- )
147
- self._default_language = kwargs.pop("default_language", "en")
148
- self._default_country_hint = kwargs.pop("default_country_hint", "US")
149
- self._string_index_type_default = (
150
- None if kwargs.get("api_version") == "v3.0" else "UnicodeCodePoint"
151
- )
152
-
153
- @distributed_trace
154
- @validate_multiapi_args(
155
- version_method_added="v3.0",
156
- args_mapping={"v3.1": ["disable_service_logs"]}
157
- )
158
- def detect_language(
159
- self,
160
- documents: Union[List[str], List[DetectLanguageInput], List[Dict[str, str]]],
161
- **kwargs: Any,
162
- ) -> List[Union[DetectLanguageResult, DocumentError]]:
163
- """Detect language for a batch of documents.
164
-
165
- Returns the detected language and a numeric score between zero and
166
- one. Scores close to one indicate 100% certainty that the identified
167
- language is true. See https://aka.ms/talangs for the list of enabled languages.
168
-
169
- See https://aka.ms/azsdk/textanalytics/data-limits for service data limits.
170
-
171
- :param documents: The set of documents to process as part of this batch.
172
- If you wish to specify the ID and country_hint on a per-item basis you must
173
- use as input a list[:class:`~azure.ai.textanalytics.DetectLanguageInput`] or a list of
174
- dict representations of :class:`~azure.ai.textanalytics.DetectLanguageInput`, like
175
- `{"id": "1", "country_hint": "us", "text": "hello world"}`.
176
- :type documents:
177
- list[str] or list[~azure.ai.textanalytics.DetectLanguageInput] or list[dict[str, str]]
178
- :keyword str country_hint: Country of origin hint for the entire batch. Accepts two
179
- letter country codes specified by ISO 3166-1 alpha-2. Per-document
180
- country hints will take precedence over whole batch hints. Defaults to
181
- "US". If you don't want to use a country hint, pass the string "none".
182
- :keyword str model_version: Version of the model used on the service side for scoring,
183
- e.g. "latest", "2019-10-01". If a model version
184
- is not specified, the API will default to the latest, non-preview version.
185
- See here for more info: https://aka.ms/text-analytics-model-versioning
186
- :keyword bool show_stats: If set to true, response will contain document
187
- level statistics in the `statistics` field of the document-level response.
188
- :keyword bool disable_service_logs: If set to true, you opt-out of having your text input
189
- logged on the service side for troubleshooting. By default, the Language service logs your
190
- input text for 48 hours, solely to allow for troubleshooting issues in providing you with
191
- the service's natural language processing functions. Setting this parameter to true,
192
- disables input logging and may limit our ability to remediate issues that occur. Please see
193
- Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
194
- additional details, and Microsoft Responsible AI principles at
195
- https://www.microsoft.com/ai/responsible-ai.
196
- :return: The combined list of :class:`~azure.ai.textanalytics.DetectLanguageResult` and
197
- :class:`~azure.ai.textanalytics.DocumentError` in the order the original documents were
198
- passed in.
199
- :rtype: list[~azure.ai.textanalytics.DetectLanguageResult or ~azure.ai.textanalytics.DocumentError]
200
- :raises ~azure.core.exceptions.HttpResponseError or TypeError or ValueError:
201
-
202
- .. versionadded:: v3.1
203
- The *disable_service_logs* keyword argument.
204
-
205
- .. admonition:: Example:
206
-
207
- .. literalinclude:: ../samples/sample_detect_language.py
208
- :start-after: [START detect_language]
209
- :end-before: [END detect_language]
210
- :language: python
211
- :dedent: 4
212
- :caption: Detecting language in a batch of documents.
213
- """
214
- country_hint_arg = kwargs.pop("country_hint", None)
215
- country_hint = (
216
- country_hint_arg
217
- if country_hint_arg is not None
218
- else self._default_country_hint
219
- )
220
- docs = _validate_input(documents, "country_hint", country_hint)
221
- model_version = kwargs.pop("model_version", None)
222
- show_stats = kwargs.pop("show_stats", None)
223
- disable_service_logs = kwargs.pop("disable_service_logs", None)
224
-
225
- try:
226
- if is_language_api(self._api_version):
227
- models = self._client.models(api_version=self._api_version)
228
- return cast(
229
- List[Union[DetectLanguageResult, DocumentError]],
230
- self._client.analyze_text(
231
- body=models.AnalyzeTextLanguageDetectionInput(
232
- analysis_input={"documents": docs},
233
- parameters=models.LanguageDetectionTaskParameters(
234
- logging_opt_out=disable_service_logs,
235
- model_version=model_version
236
- )
237
- ),
238
- show_stats=show_stats,
239
- cls=kwargs.pop("cls", language_result),
240
- **kwargs
241
- )
242
- )
243
-
244
- # api_versions 3.0, 3.1
245
- return cast(
246
- List[Union[DetectLanguageResult, DocumentError]],
247
- self._client.languages(
248
- documents=docs,
249
- model_version=model_version,
250
- show_stats=show_stats,
251
- logging_opt_out=disable_service_logs,
252
- cls=kwargs.pop("cls", language_result),
253
- **kwargs
254
- )
255
- )
256
- except HttpResponseError as error:
257
- return process_http_response_error(error)
258
-
259
- @distributed_trace
260
- @validate_multiapi_args(
261
- version_method_added="v3.0",
262
- args_mapping={"v3.1": ["string_index_type", "disable_service_logs"]}
263
- )
264
- def recognize_entities(
265
- self,
266
- documents: Union[List[str], List[TextDocumentInput], List[Dict[str, str]]],
267
- **kwargs: Any,
268
- ) -> List[Union[RecognizeEntitiesResult, DocumentError]]:
269
- """Recognize entities for a batch of documents.
270
-
271
- Identifies and categorizes entities in your text as people, places,
272
- organizations, date/time, quantities, percentages, currencies, and more.
273
- For the list of supported entity types, check: https://aka.ms/taner
274
-
275
- See https://aka.ms/azsdk/textanalytics/data-limits for service data limits.
276
-
277
- :param documents: The set of documents to process as part of this batch.
278
- If you wish to specify the ID and language on a per-item basis you must
279
- use as input a list[:class:`~azure.ai.textanalytics.TextDocumentInput`] or a list
280
- of dict representations of :class:`~azure.ai.textanalytics.TextDocumentInput`,
281
- like `{"id": "1", "language": "en", "text": "hello world"}`.
282
- :type documents:
283
- list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or list[dict[str, str]]
284
- :keyword str language: The 2 letter ISO 639-1 representation of language for the
285
- entire batch. For example, use "en" for English; "es" for Spanish etc.
286
- If not set, uses "en" for English as default. Per-document language will
287
- take precedence over whole batch language. See https://aka.ms/talangs for
288
- supported languages in Language API.
289
- :keyword str model_version: This value indicates which model will
290
- be used for scoring, e.g. "latest", "2019-10-01". If a model-version
291
- is not specified, the API will default to the latest, non-preview version.
292
- See here for more info: https://aka.ms/text-analytics-model-versioning
293
- :keyword bool show_stats: If set to true, response will contain document
294
- level statistics in the `statistics` field of the document-level response.
295
- :keyword str string_index_type: Specifies the method used to interpret string offsets.
296
- `UnicodeCodePoint`, the Python encoding, is the default. To override the Python default,
297
- you can also pass in `Utf16CodeUnit` or `TextElement_v8`. For additional information
298
- see https://aka.ms/text-analytics-offsets
299
- :keyword bool disable_service_logs: If set to true, you opt-out of having your text input
300
- logged on the service side for troubleshooting. By default, the Language service logs your
301
- input text for 48 hours, solely to allow for troubleshooting issues in providing you with
302
- the service's natural language processing functions. Setting this parameter to true,
303
- disables input logging and may limit our ability to remediate issues that occur. Please see
304
- Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
305
- additional details, and Microsoft Responsible AI principles at
306
- https://www.microsoft.com/ai/responsible-ai.
307
- :return: The combined list of :class:`~azure.ai.textanalytics.RecognizeEntitiesResult` and
308
- :class:`~azure.ai.textanalytics.DocumentError` in the order the original documents
309
- were passed in.
310
- :rtype: list[~azure.ai.textanalytics.RecognizeEntitiesResult or ~azure.ai.textanalytics.DocumentError]
311
- :raises ~azure.core.exceptions.HttpResponseError or TypeError or ValueError:
312
-
313
- .. versionadded:: v3.1
314
- The *disable_service_logs* and *string_index_type* keyword arguments.
315
-
316
- .. admonition:: Example:
317
-
318
- .. literalinclude:: ../samples/sample_recognize_entities.py
319
- :start-after: [START recognize_entities]
320
- :end-before: [END recognize_entities]
321
- :language: python
322
- :dedent: 4
323
- :caption: Recognize entities in a batch of documents.
324
- """
325
- language_arg = kwargs.pop("language", None)
326
- language = language_arg if language_arg is not None else self._default_language
327
- docs = _validate_input(documents, "language", language)
328
- model_version = kwargs.pop("model_version", None)
329
- show_stats = kwargs.pop("show_stats", None)
330
- string_index_type = kwargs.pop("string_index_type", self._string_index_type_default)
331
- disable_service_logs = kwargs.pop("disable_service_logs", None)
332
-
333
- try:
334
- if is_language_api(self._api_version):
335
- models = self._client.models(api_version=self._api_version)
336
- return cast(
337
- List[Union[RecognizeEntitiesResult, DocumentError]],
338
- self._client.analyze_text(
339
- body=models.AnalyzeTextEntityRecognitionInput(
340
- analysis_input={"documents": docs},
341
- parameters=models.EntitiesTaskParameters(
342
- logging_opt_out=disable_service_logs,
343
- model_version=model_version,
344
- string_index_type=string_index_type_compatibility(string_index_type)
345
- )
346
- ),
347
- show_stats=show_stats,
348
- cls=kwargs.pop("cls", entities_result),
349
- **kwargs
350
- )
351
- )
352
-
353
- # api_versions 3.0, 3.1
354
- return cast(
355
- List[Union[RecognizeEntitiesResult, DocumentError]],
356
- self._client.entities_recognition_general(
357
- documents=docs,
358
- model_version=model_version,
359
- show_stats=show_stats,
360
- string_index_type=string_index_type,
361
- logging_opt_out=disable_service_logs,
362
- cls=kwargs.pop("cls", entities_result),
363
- **kwargs,
364
- )
365
- )
366
- except HttpResponseError as error:
367
- return process_http_response_error(error)
368
-
369
- @distributed_trace
370
- @validate_multiapi_args(
371
- version_method_added="v3.1"
372
- )
373
- def recognize_pii_entities(
374
- self,
375
- documents: Union[List[str], List[TextDocumentInput], List[Dict[str, str]]],
376
- **kwargs: Any,
377
- ) -> List[Union[RecognizePiiEntitiesResult, DocumentError]]:
378
- """Recognize entities containing personal information for a batch of documents.
379
-
380
- Returns a list of personal information entities ("SSN",
381
- "Bank Account", etc) in the document. For the list of supported entity types,
382
- check https://aka.ms/tanerpii
383
-
384
- See https://aka.ms/azsdk/textanalytics/data-limits for service data limits.
385
-
386
- :param documents: The set of documents to process as part of this batch.
387
- If you wish to specify the ID and language on a per-item basis you must
388
- use as input a list[:class:`~azure.ai.textanalytics.TextDocumentInput`] or a list of
389
- dict representations of :class:`~azure.ai.textanalytics.TextDocumentInput`, like
390
- `{"id": "1", "language": "en", "text": "hello world"}`.
391
- :type documents:
392
- list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or list[dict[str, str]]
393
- :keyword str language: The 2 letter ISO 639-1 representation of language for the
394
- entire batch. For example, use "en" for English; "es" for Spanish etc.
395
- If not set, uses "en" for English as default. Per-document language will
396
- take precedence over whole batch language. See https://aka.ms/talangs for
397
- supported languages in Language API.
398
- :keyword str model_version: This value indicates which model will
399
- be used for scoring, e.g. "latest", "2019-10-01". If a model-version
400
- is not specified, the API will default to the latest, non-preview version.
401
- See here for more info: https://aka.ms/text-analytics-model-versioning
402
- :keyword bool show_stats: If set to true, response will contain document
403
- level statistics in the `statistics` field of the document-level response.
404
- :keyword domain_filter: Filters the response entities to ones only included in the specified domain.
405
- I.e., if set to 'phi', will only return entities in the Protected Healthcare Information domain.
406
- See https://aka.ms/tanerpii for more information.
407
- :paramtype domain_filter: str or ~azure.ai.textanalytics.PiiEntityDomain
408
- :keyword categories_filter: Instead of filtering over all PII entity categories, you can pass in a list of
409
- the specific PII entity categories you want to filter out. For example, if you only want to filter out
410
- U.S. social security numbers in a document, you can pass in
411
- `[PiiEntityCategory.US_SOCIAL_SECURITY_NUMBER]` for this kwarg.
412
- :paramtype categories_filter: list[str or ~azure.ai.textanalytics.PiiEntityCategory]
413
- :keyword str string_index_type: Specifies the method used to interpret string offsets.
414
- `UnicodeCodePoint`, the Python encoding, is the default. To override the Python default,
415
- you can also pass in `Utf16CodeUnit` or `TextElement_v8`. For additional information
416
- see https://aka.ms/text-analytics-offsets
417
- :keyword bool disable_service_logs: Defaults to true, meaning that the Language service will not log your
418
- input text on the service side for troubleshooting. If set to False, the Language service logs your
419
- input text for 48 hours, solely to allow for troubleshooting issues in providing you with
420
- the service's natural language processing functions. Please see
421
- Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
422
- additional details, and Microsoft Responsible AI principles at
423
- https://www.microsoft.com/ai/responsible-ai.
424
- :return: The combined list of :class:`~azure.ai.textanalytics.RecognizePiiEntitiesResult`
425
- and :class:`~azure.ai.textanalytics.DocumentError` in the order the original documents
426
- were passed in.
427
- :rtype: list[~azure.ai.textanalytics.RecognizePiiEntitiesResult or ~azure.ai.textanalytics.DocumentError]
428
- :raises ~azure.core.exceptions.HttpResponseError or TypeError or ValueError:
429
-
430
- .. versionadded:: v3.1
431
- The *recognize_pii_entities* client method.
432
-
433
- .. admonition:: Example:
434
-
435
- .. literalinclude:: ../samples/sample_recognize_pii_entities.py
436
- :start-after: [START recognize_pii_entities]
437
- :end-before: [END recognize_pii_entities]
438
- :language: python
439
- :dedent: 4
440
- :caption: Recognize personally identifiable information entities in a batch of documents.
441
- """
442
- language_arg = kwargs.pop("language", None)
443
- language = language_arg if language_arg is not None else self._default_language
444
- docs = _validate_input(documents, "language", language)
445
- model_version = kwargs.pop("model_version", None)
446
- show_stats = kwargs.pop("show_stats", None)
447
- domain_filter = kwargs.pop("domain_filter", None)
448
- categories_filter = kwargs.pop("categories_filter", None)
449
- string_index_type = kwargs.pop("string_index_type", self._string_index_type_default)
450
- disable_service_logs = kwargs.pop("disable_service_logs", None)
451
-
452
- try:
453
- if is_language_api(self._api_version):
454
- models = self._client.models(api_version=self._api_version)
455
- return cast(
456
- List[Union[RecognizePiiEntitiesResult, DocumentError]],
457
- self._client.analyze_text(
458
- body=models.AnalyzeTextPiiEntitiesRecognitionInput(
459
- analysis_input={"documents": docs},
460
- parameters=models.PiiTaskParameters(
461
- logging_opt_out=disable_service_logs,
462
- model_version=model_version,
463
- domain=domain_filter,
464
- pii_categories=categories_filter,
465
- string_index_type=string_index_type_compatibility(string_index_type)
466
- )
467
- ),
468
- show_stats=show_stats,
469
- cls=kwargs.pop("cls", pii_entities_result),
470
- **kwargs
471
- )
472
- )
473
-
474
- # api_versions 3.0, 3.1
475
- return cast(
476
- List[Union[RecognizePiiEntitiesResult, DocumentError]],
477
- self._client.entities_recognition_pii(
478
- documents=docs,
479
- model_version=model_version,
480
- show_stats=show_stats,
481
- domain=domain_filter,
482
- pii_categories=categories_filter,
483
- logging_opt_out=disable_service_logs,
484
- string_index_type=string_index_type,
485
- cls=kwargs.pop("cls", pii_entities_result),
486
- **kwargs
487
- )
488
- )
489
- except HttpResponseError as error:
490
- return process_http_response_error(error)
491
-
492
- @distributed_trace
493
- @validate_multiapi_args(
494
- version_method_added="v3.0",
495
- args_mapping={"v3.1": ["string_index_type", "disable_service_logs"]}
496
- )
497
- def recognize_linked_entities(
498
- self,
499
- documents: Union[List[str], List[TextDocumentInput], List[Dict[str, str]]],
500
- **kwargs: Any,
501
- ) -> List[Union[RecognizeLinkedEntitiesResult, DocumentError]]:
502
- """Recognize linked entities from a well-known knowledge base for a batch of documents.
503
-
504
- Identifies and disambiguates the identity of each entity found in text (for example,
505
- determining whether an occurrence of the word Mars refers to the planet, or to the
506
- Roman god of war). Recognized entities are associated with URLs to a well-known
507
- knowledge base, like Wikipedia.
508
-
509
- See https://aka.ms/azsdk/textanalytics/data-limits for service data limits.
510
-
511
- :param documents: The set of documents to process as part of this batch.
512
- If you wish to specify the ID and language on a per-item basis you must
513
- use as input a list[:class:`~azure.ai.textanalytics.TextDocumentInput`] or a list of
514
- dict representations of :class:`~azure.ai.textanalytics.TextDocumentInput`, like
515
- `{"id": "1", "language": "en", "text": "hello world"}`.
516
- :type documents:
517
- list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or list[dict[str, str]]
518
- :keyword str language: The 2 letter ISO 639-1 representation of language for the
519
- entire batch. For example, use "en" for English; "es" for Spanish etc.
520
- If not set, uses "en" for English as default. Per-document language will
521
- take precedence over whole batch language. See https://aka.ms/talangs for
522
- supported languages in Language API.
523
- :keyword str model_version: This value indicates which model will
524
- be used for scoring, e.g. "latest", "2019-10-01". If a model-version
525
- is not specified, the API will default to the latest, non-preview version.
526
- See here for more info: https://aka.ms/text-analytics-model-versioning
527
- :keyword bool show_stats: If set to true, response will contain document
528
- level statistics in the `statistics` field of the document-level response.
529
- :keyword str string_index_type: Specifies the method used to interpret string offsets.
530
- `UnicodeCodePoint`, the Python encoding, is the default. To override the Python default,
531
- you can also pass in `Utf16CodeUnit` or `TextElement_v8`. For additional information
532
- see https://aka.ms/text-analytics-offsets
533
- :keyword bool disable_service_logs: If set to true, you opt-out of having your text input
534
- logged on the service side for troubleshooting. By default, the Language service logs your
535
- input text for 48 hours, solely to allow for troubleshooting issues in providing you with
536
- the service's natural language processing functions. Setting this parameter to true,
537
- disables input logging and may limit our ability to remediate issues that occur. Please see
538
- Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
539
- additional details, and Microsoft Responsible AI principles at
540
- https://www.microsoft.com/ai/responsible-ai.
541
- :return: The combined list of :class:`~azure.ai.textanalytics.RecognizeLinkedEntitiesResult`
542
- and :class:`~azure.ai.textanalytics.DocumentError` in the order the original documents
543
- were passed in.
544
- :rtype: list[~azure.ai.textanalytics.RecognizeLinkedEntitiesResult or ~azure.ai.textanalytics.DocumentError]
545
- :raises ~azure.core.exceptions.HttpResponseError or TypeError or ValueError:
546
-
547
- .. versionadded:: v3.1
548
- The *disable_service_logs* and *string_index_type* keyword arguments.
549
-
550
- .. admonition:: Example:
551
-
552
- .. literalinclude:: ../samples/sample_recognize_linked_entities.py
553
- :start-after: [START recognize_linked_entities]
554
- :end-before: [END recognize_linked_entities]
555
- :language: python
556
- :dedent: 4
557
- :caption: Recognize linked entities in a batch of documents.
558
- """
559
- language_arg = kwargs.pop("language", None)
560
- language = language_arg if language_arg is not None else self._default_language
561
- docs = _validate_input(documents, "language", language)
562
- model_version = kwargs.pop("model_version", None)
563
- show_stats = kwargs.pop("show_stats", None)
564
- disable_service_logs = kwargs.pop("disable_service_logs", None)
565
- string_index_type = kwargs.pop("string_index_type", self._string_index_type_default)
566
-
567
- try:
568
- if is_language_api(self._api_version):
569
- models = self._client.models(api_version=self._api_version)
570
- return cast(
571
- List[Union[RecognizeLinkedEntitiesResult, DocumentError]],
572
- self._client.analyze_text(
573
- body=models.AnalyzeTextEntityLinkingInput(
574
- analysis_input={"documents": docs},
575
- parameters=models.EntityLinkingTaskParameters(
576
- logging_opt_out=disable_service_logs,
577
- model_version=model_version,
578
- string_index_type=string_index_type_compatibility(string_index_type)
579
- )
580
- ),
581
- show_stats=show_stats,
582
- cls=kwargs.pop("cls", linked_entities_result),
583
- **kwargs
584
- )
585
- )
586
-
587
- # api_versions 3.0, 3.1
588
- return cast(
589
- List[Union[RecognizeLinkedEntitiesResult, DocumentError]],
590
- self._client.entities_linking(
591
- documents=docs,
592
- logging_opt_out=disable_service_logs,
593
- model_version=model_version,
594
- string_index_type=string_index_type,
595
- show_stats=show_stats,
596
- cls=kwargs.pop("cls", linked_entities_result),
597
- **kwargs
598
- )
599
- )
600
- except HttpResponseError as error:
601
- return process_http_response_error(error)
602
-
603
- # pylint: disable=unused-argument
604
- def _healthcare_result_callback(
605
- self, raw_response, deserialized, doc_id_order, task_id_order=None, show_stats=False, bespoke=False
606
- ):
607
- if deserialized is None:
608
- models = self._client.models(api_version=self._api_version)
609
- response_cls = \
610
- models.AnalyzeTextJobState if is_language_api(self._api_version) else models.HealthcareJobState
611
- deserialized = response_cls.deserialize(raw_response)
612
- return healthcare_paged_result(
613
- doc_id_order,
614
- self._client.analyze_text_job_status if is_language_api(self._api_version) else self._client.health_status,
615
- raw_response,
616
- deserialized,
617
- show_stats=show_stats,
618
- )
619
-
620
- @distributed_trace
621
- @validate_multiapi_args(
622
- version_method_added="v3.1",
623
- args_mapping={
624
- "2022-10-01-preview": ["fhir_version", "document_type", "autodetect_default_language"],
625
- "2022-05-01": ["display_name"]
626
- }
627
- )
628
- def begin_analyze_healthcare_entities(
629
- self,
630
- documents: Union[List[str], List[TextDocumentInput], List[Dict[str, str]]],
631
- **kwargs: Any,
632
- ) -> AnalyzeHealthcareEntitiesLROPoller[ItemPaged[Union[AnalyzeHealthcareEntitiesResult, DocumentError]]]:
633
- """Analyze healthcare entities and identify relationships between these entities in a batch of documents.
634
-
635
- Entities are associated with references that can be found in existing knowledge bases,
636
- such as UMLS, CHV, MSH, etc.
637
-
638
- We also extract the relations found between entities, for example in "The subject took 100 mg of ibuprofen",
639
- we would extract the relationship between the "100 mg" dosage and the "ibuprofen" medication.
640
-
641
- :param documents: The set of documents to process as part of this batch.
642
- If you wish to specify the ID and language on a per-item basis you must
643
- use as input a list[:class:`~azure.ai.textanalytics.TextDocumentInput`] or a list of
644
- dict representations of :class:`~azure.ai.textanalytics.TextDocumentInput`, like
645
- `{"id": "1", "language": "en", "text": "hello world"}`.
646
- :type documents:
647
- list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or list[dict[str, str]]
648
- :keyword str model_version: This value indicates which model will
649
- be used for scoring, e.g. "latest", "2019-10-01". If a model-version
650
- is not specified, the API will default to the latest, non-preview version.
651
- See here for more info: https://aka.ms/text-analytics-model-versioning
652
- :keyword bool show_stats: If set to true, response will contain document level statistics.
653
- :keyword str language: The 2 letter ISO 639-1 representation of language for the
654
- entire batch. For example, use "en" for English; "es" for Spanish etc.
655
- For automatic language detection, use "auto" (Only supported by API version
656
- 2022-10-01-preview and newer). If not set, uses "en" for English as default.
657
- Per-document language will take precedence over whole batch language.
658
- See https://aka.ms/talangs for supported languages in Language API.
659
- :keyword str autodetect_default_language: Default/fallback language to use for documents requesting
660
- automatic language detection.
661
- :keyword str display_name: An optional display name to set for the requested analysis.
662
- :keyword str string_index_type: Specifies the method used to interpret string offsets.
663
- `UnicodeCodePoint`, the Python encoding, is the default. To override the Python default,
664
- you can also pass in `Utf16CodeUnit` or `TextElement_v8`. For additional information
665
- see https://aka.ms/text-analytics-offsets
666
- :keyword int polling_interval: Waiting time between two polls for LRO operations
667
- if no Retry-After header is present. Defaults to 5 seconds.
668
- :keyword str continuation_token:
669
- Call `continuation_token()` on the poller object to save the long-running operation (LRO)
670
- state into an opaque token. Pass the value as the `continuation_token` keyword argument
671
- to restart the LRO from a saved state.
672
- :keyword bool disable_service_logs: Defaults to true, meaning that the Language service will not log your
673
- input text on the service side for troubleshooting. If set to False, the Language service logs your
674
- input text for 48 hours, solely to allow for troubleshooting issues in providing you with
675
- the service's natural language processing functions. Please see
676
- Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
677
- additional details, and Microsoft Responsible AI principles at
678
- https://www.microsoft.com/ai/responsible-ai.
679
- :keyword str fhir_version: The FHIR Spec version that the result will use to format the fhir_bundle
680
- on the result object. For additional information see https://www.hl7.org/fhir/overview.html.
681
- The only acceptable values to pass in are None and "4.0.1". The default value is None.
682
- :keyword document_type: Document type that can be provided as input for Fhir Documents. Expect to
683
- have fhir_version provided when used. Behavior of using None enum is the same as not using the
684
- document_type parameter. Known values are: "None", "ClinicalTrial", "DischargeSummary",
685
- "ProgressNote", "HistoryAndPhysical", "Consult", "Imaging", "Pathology", and "ProcedureNote".
686
- :paramtype document_type: str or ~azure.ai.textanalytics.HealthcareDocumentType
687
- :return: An instance of an AnalyzeHealthcareEntitiesLROPoller. Call `result()` on the this
688
- object to return a heterogeneous pageable of
689
- :class:`~azure.ai.textanalytics.AnalyzeHealthcareEntitiesResult` and
690
- :class:`~azure.ai.textanalytics.DocumentError`.
691
- :rtype:
692
- ~azure.ai.textanalytics.AnalyzeHealthcareEntitiesLROPoller[~azure.core.paging.ItemPaged[
693
- ~azure.ai.textanalytics.AnalyzeHealthcareEntitiesResult or ~azure.ai.textanalytics.DocumentError]]
694
- :raises ~azure.core.exceptions.HttpResponseError or TypeError or ValueError:
695
-
696
- .. versionadded:: v3.1
697
- The *begin_analyze_healthcare_entities* client method.
698
- .. versionadded:: 2022-05-01
699
- The *display_name* keyword argument.
700
- .. versionadded:: 2022-10-01-preview
701
- The *fhir_version*, *document_type*, and *autodetect_default_language* keyword arguments.
702
-
703
- .. admonition:: Example:
704
-
705
- .. literalinclude:: ../samples/sample_analyze_healthcare_entities.py
706
- :start-after: [START analyze_healthcare_entities]
707
- :end-before: [END analyze_healthcare_entities]
708
- :language: python
709
- :dedent: 4
710
- :caption: Recognize healthcare entities in a batch of documents.
711
- """
712
- language_arg = kwargs.pop("language", None)
713
- language = language_arg if language_arg is not None else self._default_language
714
- model_version = kwargs.pop("model_version", None)
715
- show_stats = kwargs.pop("show_stats", None)
716
- polling_interval = kwargs.pop("polling_interval", 5)
717
- continuation_token = kwargs.pop("continuation_token", None)
718
- string_index_type = kwargs.pop("string_index_type", self._string_index_type_default)
719
- disable_service_logs = kwargs.pop("disable_service_logs", None)
720
- display_name = kwargs.pop("display_name", None)
721
- fhir_version = kwargs.pop("fhir_version", None)
722
- document_type = kwargs.pop("document_type", None)
723
- autodetect_default_language = kwargs.pop("autodetect_default_language", None)
724
-
725
- if continuation_token:
726
- return cast(
727
- AnalyzeHealthcareEntitiesLROPoller[
728
- ItemPaged[Union[AnalyzeHealthcareEntitiesResult, DocumentError]]
729
- ],
730
- _get_result_from_continuation_token(
731
- self._client._client, # pylint: disable=protected-access
732
- continuation_token,
733
- AnalyzeHealthcareEntitiesLROPoller,
734
- AnalyzeHealthcareEntitiesLROPollingMethod(
735
- text_analytics_client=self._client,
736
- timeout=polling_interval,
737
- **kwargs
738
- ),
739
- self._healthcare_result_callback
740
- )
741
- )
742
-
743
- docs = _validate_input(documents, "language", language)
744
- doc_id_order = [doc.get("id") for doc in docs]
745
- my_cls = kwargs.pop(
746
- "cls",
747
- lambda pipeline_response, deserialized, _: self._healthcare_result_callback(
748
- pipeline_response, deserialized, doc_id_order, show_stats=show_stats
749
- ),
750
- )
751
- models = self._client.models(api_version=self._api_version)
752
-
753
- try:
754
- if is_language_api(self._api_version):
755
- docs = models.MultiLanguageAnalysisInput(
756
- documents=_validate_input(documents, "language", language)
757
- )
758
- return cast(
759
- AnalyzeHealthcareEntitiesLROPoller[
760
- ItemPaged[Union[AnalyzeHealthcareEntitiesResult, DocumentError]]
761
- ],
762
- self._client.begin_analyze_text_submit_job( # type: ignore
763
- body=models.AnalyzeTextJobsInput(
764
- analysis_input=docs,
765
- display_name=display_name,
766
- default_language=autodetect_default_language,
767
- tasks=[
768
- models.HealthcareLROTask(
769
- task_name="0",
770
- parameters=models.HealthcareTaskParameters(
771
- model_version=model_version,
772
- logging_opt_out=disable_service_logs,
773
- string_index_type=string_index_type_compatibility(string_index_type),
774
- fhir_version=fhir_version,
775
- document_type=document_type,
776
- )
777
- )
778
- ]
779
- ),
780
- cls=my_cls,
781
- polling=AnalyzeHealthcareEntitiesLROPollingMethod(
782
- text_analytics_client=self._client,
783
- timeout=polling_interval,
784
- show_stats=show_stats,
785
- doc_id_order=doc_id_order,
786
- lro_algorithms=[
787
- TextAnalyticsOperationResourcePolling(
788
- show_stats=show_stats,
789
- )
790
- ],
791
- **kwargs
792
- ),
793
- continuation_token=continuation_token,
794
- poller_cls=AnalyzeHealthcareEntitiesLROPoller,
795
- **kwargs
796
- )
797
- )
798
-
799
- # v3.1
800
- return cast(
801
- AnalyzeHealthcareEntitiesLROPoller[
802
- ItemPaged[Union[AnalyzeHealthcareEntitiesResult, DocumentError]]
803
- ],
804
- self._client.begin_health(
805
- docs,
806
- model_version=model_version,
807
- string_index_type=string_index_type,
808
- logging_opt_out=disable_service_logs,
809
- cls=my_cls,
810
- polling=AnalyzeHealthcareEntitiesLROPollingMethod(
811
- text_analytics_client=self._client,
812
- timeout=polling_interval,
813
- doc_id_order=doc_id_order,
814
- show_stats=show_stats,
815
- lro_algorithms=[
816
- TextAnalyticsOperationResourcePolling(
817
- show_stats=show_stats,
818
- )
819
- ],
820
- **kwargs
821
- ),
822
- continuation_token=continuation_token,
823
- **kwargs
824
- )
825
- )
826
- except HttpResponseError as error:
827
- return process_http_response_error(error)
828
-
829
- @distributed_trace
830
- @validate_multiapi_args(
831
- version_method_added="v3.0",
832
- args_mapping={"v3.1": ["disable_service_logs"]}
833
- )
834
- def extract_key_phrases(
835
- self,
836
- documents: Union[List[str], List[TextDocumentInput], List[Dict[str, str]]],
837
- **kwargs: Any,
838
- ) -> List[Union[ExtractKeyPhrasesResult, DocumentError]]:
839
- """Extract key phrases from a batch of documents.
840
-
841
- Returns a list of strings denoting the key phrases in the input
842
- text. For example, for the input text "The food was delicious and there
843
- were wonderful staff", the API returns the main talking points: "food"
844
- and "wonderful staff"
845
-
846
- See https://aka.ms/azsdk/textanalytics/data-limits for service data limits.
847
-
848
- :param documents: The set of documents to process as part of this batch.
849
- If you wish to specify the ID and language on a per-item basis you must
850
- use as input a list[:class:`~azure.ai.textanalytics.TextDocumentInput`] or a list of
851
- dict representations of :class:`~azure.ai.textanalytics.TextDocumentInput`, like
852
- `{"id": "1", "language": "en", "text": "hello world"}`.
853
- :type documents:
854
- list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or list[dict[str, str]]
855
- :keyword str language: The 2 letter ISO 639-1 representation of language for the
856
- entire batch. For example, use "en" for English; "es" for Spanish etc.
857
- If not set, uses "en" for English as default. Per-document language will
858
- take precedence over whole batch language. See https://aka.ms/talangs for
859
- supported languages in Language API.
860
- :keyword str model_version: This value indicates which model will
861
- be used for scoring, e.g. "latest", "2019-10-01". If a model-version
862
- is not specified, the API will default to the latest, non-preview version.
863
- See here for more info: https://aka.ms/text-analytics-model-versioning
864
- :keyword bool show_stats: If set to true, response will contain document
865
- level statistics in the `statistics` field of the document-level response.
866
- :keyword bool disable_service_logs: If set to true, you opt-out of having your text input
867
- logged on the service side for troubleshooting. By default, the Language service logs your
868
- input text for 48 hours, solely to allow for troubleshooting issues in providing you with
869
- the service's natural language processing functions. Setting this parameter to true,
870
- disables input logging and may limit our ability to remediate issues that occur. Please see
871
- Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
872
- additional details, and Microsoft Responsible AI principles at
873
- https://www.microsoft.com/ai/responsible-ai.
874
- :return: The combined list of :class:`~azure.ai.textanalytics.ExtractKeyPhrasesResult` and
875
- :class:`~azure.ai.textanalytics.DocumentError` in the order the original documents were
876
- passed in.
877
- :rtype: list[~azure.ai.textanalytics.ExtractKeyPhrasesResult or ~azure.ai.textanalytics.DocumentError]
878
- :raises ~azure.core.exceptions.HttpResponseError or TypeError or ValueError:
879
-
880
- .. versionadded:: v3.1
881
- The *disable_service_logs* keyword argument.
882
-
883
- .. admonition:: Example:
884
-
885
- .. literalinclude:: ../samples/sample_extract_key_phrases.py
886
- :start-after: [START extract_key_phrases]
887
- :end-before: [END extract_key_phrases]
888
- :language: python
889
- :dedent: 4
890
- :caption: Extract the key phrases in a batch of documents.
891
- """
892
- language_arg = kwargs.pop("language", None)
893
- language = language_arg if language_arg is not None else self._default_language
894
- docs = _validate_input(documents, "language", language)
895
- model_version = kwargs.pop("model_version", None)
896
- show_stats = kwargs.pop("show_stats", None)
897
- disable_service_logs = kwargs.pop("disable_service_logs", None)
898
-
899
- try:
900
- if is_language_api(self._api_version):
901
- models = self._client.models(api_version=self._api_version)
902
- return cast(
903
- List[Union[ExtractKeyPhrasesResult, DocumentError]],
904
- self._client.analyze_text(
905
- body=models.AnalyzeTextKeyPhraseExtractionInput(
906
- analysis_input={"documents": docs},
907
- parameters=models.KeyPhraseTaskParameters(
908
- logging_opt_out=disable_service_logs,
909
- model_version=model_version,
910
- )
911
- ),
912
- show_stats=show_stats,
913
- cls=kwargs.pop("cls", key_phrases_result),
914
- **kwargs
915
- )
916
- )
917
-
918
- # api_versions 3.0, 3.1
919
- return cast(
920
- List[Union[ExtractKeyPhrasesResult, DocumentError]],
921
- self._client.key_phrases(
922
- documents=docs,
923
- model_version=model_version,
924
- show_stats=show_stats,
925
- logging_opt_out=disable_service_logs,
926
- cls=kwargs.pop("cls", key_phrases_result),
927
- **kwargs
928
- )
929
- )
930
- except HttpResponseError as error:
931
- return process_http_response_error(error)
932
-
933
- @distributed_trace
934
- @validate_multiapi_args(
935
- version_method_added="v3.0",
936
- args_mapping={"v3.1": ["show_opinion_mining", "disable_service_logs", "string_index_type"]}
937
- )
938
- def analyze_sentiment(
939
- self,
940
- documents: Union[List[str], List[TextDocumentInput], List[Dict[str, str]]],
941
- **kwargs: Any,
942
- ) -> List[Union[AnalyzeSentimentResult, DocumentError]]:
943
- """Analyze sentiment for a batch of documents. Turn on opinion mining with `show_opinion_mining`.
944
-
945
- Returns a sentiment prediction, as well as sentiment scores for
946
- each sentiment class (Positive, Negative, and Neutral) for the document
947
- and each sentence within it.
948
-
949
- See https://aka.ms/azsdk/textanalytics/data-limits for service data limits.
950
-
951
- :param documents: The set of documents to process as part of this batch.
952
- If you wish to specify the ID and language on a per-item basis you must
953
- use as input a list[:class:`~azure.ai.textanalytics.TextDocumentInput`] or a list of
954
- dict representations of :class:`~azure.ai.textanalytics.TextDocumentInput`, like
955
- `{"id": "1", "language": "en", "text": "hello world"}`.
956
- :type documents:
957
- list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or list[dict[str, str]]
958
- :keyword bool show_opinion_mining: Whether to mine the opinions of a sentence and conduct more
959
- granular analysis around the aspects of a product or service (also known as
960
- aspect-based sentiment analysis). If set to true, the returned
961
- :class:`~azure.ai.textanalytics.SentenceSentiment` objects
962
- will have property `mined_opinions` containing the result of this analysis. Only available for
963
- API version v3.1 and up.
964
- :keyword str language: The 2 letter ISO 639-1 representation of language for the
965
- entire batch. For example, use "en" for English; "es" for Spanish etc.
966
- If not set, uses "en" for English as default. Per-document language will
967
- take precedence over whole batch language. See https://aka.ms/talangs for
968
- supported languages in Language API.
969
- :keyword str model_version: This value indicates which model will
970
- be used for scoring, e.g. "latest", "2019-10-01". If a model-version
971
- is not specified, the API will default to the latest, non-preview version.
972
- See here for more info: https://aka.ms/text-analytics-model-versioning
973
- :keyword bool show_stats: If set to true, response will contain document
974
- level statistics in the `statistics` field of the document-level response.
975
- :keyword str string_index_type: Specifies the method used to interpret string offsets.
976
- `UnicodeCodePoint`, the Python encoding, is the default. To override the Python default,
977
- you can also pass in `Utf16CodeUnit` or `TextElement_v8`. For additional information
978
- see https://aka.ms/text-analytics-offsets
979
- :keyword bool disable_service_logs: If set to true, you opt-out of having your text input
980
- logged on the service side for troubleshooting. By default, the Language service logs your
981
- input text for 48 hours, solely to allow for troubleshooting issues in providing you with
982
- the service's natural language processing functions. Setting this parameter to true,
983
- disables input logging and may limit our ability to remediate issues that occur. Please see
984
- Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
985
- additional details, and Microsoft Responsible AI principles at
986
- https://www.microsoft.com/ai/responsible-ai.
987
- :return: The combined list of :class:`~azure.ai.textanalytics.AnalyzeSentimentResult` and
988
- :class:`~azure.ai.textanalytics.DocumentError` in the order the original documents were
989
- passed in.
990
- :rtype: list[~azure.ai.textanalytics.AnalyzeSentimentResult or ~azure.ai.textanalytics.DocumentError]
991
- :raises ~azure.core.exceptions.HttpResponseError or TypeError or ValueError:
992
-
993
- .. versionadded:: v3.1
994
- The *show_opinion_mining*, *disable_service_logs*, and *string_index_type* keyword arguments.
995
-
996
- .. admonition:: Example:
997
-
998
- .. literalinclude:: ../samples/sample_analyze_sentiment.py
999
- :start-after: [START analyze_sentiment]
1000
- :end-before: [END analyze_sentiment]
1001
- :language: python
1002
- :dedent: 4
1003
- :caption: Analyze sentiment in a batch of documents.
1004
- """
1005
- language_arg = kwargs.pop("language", None)
1006
- language = language_arg if language_arg is not None else self._default_language
1007
- docs = _validate_input(documents, "language", language)
1008
- model_version = kwargs.pop("model_version", None)
1009
- show_stats = kwargs.pop("show_stats", None)
1010
- show_opinion_mining = kwargs.pop("show_opinion_mining", None)
1011
- disable_service_logs = kwargs.pop("disable_service_logs", None)
1012
- string_index_type = kwargs.pop("string_index_type", self._string_index_type_default)
1013
-
1014
- try:
1015
- if is_language_api(self._api_version):
1016
- models = self._client.models(api_version=self._api_version)
1017
- return cast(
1018
- List[Union[AnalyzeSentimentResult, DocumentError]],
1019
- self._client.analyze_text(
1020
- body=models.AnalyzeTextSentimentAnalysisInput(
1021
- analysis_input={"documents": docs},
1022
- parameters=models.SentimentAnalysisTaskParameters(
1023
- logging_opt_out=disable_service_logs,
1024
- model_version=model_version,
1025
- string_index_type=string_index_type_compatibility(string_index_type),
1026
- opinion_mining=show_opinion_mining,
1027
- )
1028
- ),
1029
- show_stats=show_stats,
1030
- cls=kwargs.pop("cls", sentiment_result),
1031
- **kwargs
1032
- )
1033
- )
1034
-
1035
- # api_versions 3.0, 3.1
1036
- return cast(
1037
- List[Union[AnalyzeSentimentResult, DocumentError]],
1038
- self._client.sentiment(
1039
- documents=docs,
1040
- logging_opt_out=disable_service_logs,
1041
- model_version=model_version,
1042
- string_index_type=string_index_type,
1043
- opinion_mining=show_opinion_mining,
1044
- show_stats=show_stats,
1045
- cls=kwargs.pop("cls", sentiment_result),
1046
- **kwargs
1047
- )
1048
- )
1049
- except HttpResponseError as error:
1050
- return process_http_response_error(error)
1051
-
1052
- def _analyze_result_callback(
1053
- self, raw_response, deserialized, doc_id_order, task_id_order=None, show_stats=False, bespoke=False
1054
- ):
1055
-
1056
- if deserialized is None:
1057
- models = self._client.models(api_version=self._api_version)
1058
- response_cls = models.AnalyzeTextJobState if is_language_api(self._api_version) else models.AnalyzeJobState
1059
- deserialized = response_cls.deserialize(raw_response)
1060
- return analyze_paged_result(
1061
- doc_id_order,
1062
- task_id_order,
1063
- self._client.analyze_text_job_status if is_language_api(self._api_version) else self._client.analyze_status,
1064
- raw_response,
1065
- deserialized,
1066
- show_stats=show_stats,
1067
- bespoke=bespoke
1068
- )
1069
-
1070
- @distributed_trace
1071
- @validate_multiapi_args(
1072
- version_method_added="v3.1",
1073
- custom_wrapper=check_for_unsupported_actions_types,
1074
- args_mapping={
1075
- "2022-10-01-preview": ["autodetect_default_language"],
1076
- }
1077
- )
1078
- def begin_analyze_actions(
1079
- self,
1080
- documents: Union[List[str], List[TextDocumentInput], List[Dict[str, str]]],
1081
- actions: List[
1082
- Union[
1083
- RecognizeEntitiesAction,
1084
- RecognizeLinkedEntitiesAction,
1085
- RecognizePiiEntitiesAction,
1086
- ExtractKeyPhrasesAction,
1087
- AnalyzeSentimentAction,
1088
- RecognizeCustomEntitiesAction,
1089
- SingleLabelClassifyAction,
1090
- MultiLabelClassifyAction,
1091
- AnalyzeHealthcareEntitiesAction,
1092
- ExtractSummaryAction,
1093
- AbstractSummaryAction,
1094
- ]
1095
- ],
1096
- **kwargs: Any,
1097
- ) -> TextAnalysisLROPoller[
1098
- ItemPaged[
1099
- List[
1100
- Union[
1101
- RecognizeEntitiesResult,
1102
- RecognizeLinkedEntitiesResult,
1103
- RecognizePiiEntitiesResult,
1104
- ExtractKeyPhrasesResult,
1105
- AnalyzeSentimentResult,
1106
- RecognizeCustomEntitiesResult,
1107
- ClassifyDocumentResult,
1108
- AnalyzeHealthcareEntitiesResult,
1109
- ExtractSummaryResult,
1110
- AbstractSummaryResult,
1111
- DocumentError,
1112
- ]
1113
- ]
1114
- ]
1115
- ]:
1116
- """Start a long-running operation to perform a variety of text analysis actions over a batch of documents.
1117
-
1118
- We recommend you use this function if you're looking to analyze larger documents, and / or
1119
- combine multiple text analysis actions into one call. Otherwise, we recommend you use
1120
- the action specific endpoints, for example :func:`analyze_sentiment`.
1121
-
1122
- .. note:: The abstractive summarization feature is part of a gated preview. Request access here:
1123
- https://aka.ms/applyforgatedsummarizationfeatures
1124
-
1125
- .. note:: See the service documentation for regional support of custom action features:
1126
- https://aka.ms/azsdk/textanalytics/customfunctionalities
1127
-
1128
- :param documents: The set of documents to process as part of this batch.
1129
- If you wish to specify the ID and language on a per-item basis you must
1130
- use as input a list[:class:`~azure.ai.textanalytics.TextDocumentInput`] or a list of
1131
- dict representations of :class:`~azure.ai.textanalytics.TextDocumentInput`, like
1132
- `{"id": "1", "language": "en", "text": "hello world"}`.
1133
- :type documents:
1134
- list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or list[dict[str, str]]
1135
- :param actions: A heterogeneous list of actions to perform on the input documents.
1136
- Each action object encapsulates the parameters used for the particular action type.
1137
- The action results will be in the same order of the input actions.
1138
- :type actions:
1139
- list[RecognizeEntitiesAction or RecognizePiiEntitiesAction or ExtractKeyPhrasesAction or
1140
- RecognizeLinkedEntitiesAction or AnalyzeSentimentAction or
1141
- RecognizeCustomEntitiesAction or SingleLabelClassifyAction or
1142
- MultiLabelClassifyAction or AnalyzeHealthcareEntitiesAction or ExtractSummaryAction
1143
- or AbstractSummaryAction]
1144
- :keyword str display_name: An optional display name to set for the requested analysis.
1145
- :keyword str language: The 2 letter ISO 639-1 representation of language for the
1146
- entire batch. For example, use "en" for English; "es" for Spanish etc.
1147
- For automatic language detection, use "auto" (Only supported by API version
1148
- 2022-10-01-preview and newer). If not set, uses "en" for English as default.
1149
- Per-document language will take precedence over whole batch language.
1150
- See https://aka.ms/talangs for supported languages in Language API.
1151
- :keyword str autodetect_default_language: Default/fallback language to use for documents requesting
1152
- automatic language detection.
1153
- :keyword bool show_stats: If set to true, response will contain document level statistics.
1154
- :keyword int polling_interval: Waiting time between two polls for LRO operations
1155
- if no Retry-After header is present. Defaults to 5 seconds.
1156
- :keyword str continuation_token:
1157
- Call `continuation_token()` on the poller object to save the long-running operation (LRO)
1158
- state into an opaque token. Pass the value as the `continuation_token` keyword argument
1159
- to restart the LRO from a saved state.
1160
- :return: An instance of an TextAnalysisLROPoller. Call `result()` on the poller
1161
- object to return a pageable heterogeneous list of lists. This list of lists is first ordered
1162
- by the documents you input, then ordered by the actions you input. For example,
1163
- if you have documents input ["Hello", "world"], and actions
1164
- :class:`~azure.ai.textanalytics.RecognizeEntitiesAction` and
1165
- :class:`~azure.ai.textanalytics.AnalyzeSentimentAction`, when iterating over the list of lists,
1166
- you will first iterate over the action results for the "Hello" document, getting the
1167
- :class:`~azure.ai.textanalytics.RecognizeEntitiesResult` of "Hello",
1168
- then the :class:`~azure.ai.textanalytics.AnalyzeSentimentResult` of "Hello".
1169
- Then, you will get the :class:`~azure.ai.textanalytics.RecognizeEntitiesResult` and
1170
- :class:`~azure.ai.textanalytics.AnalyzeSentimentResult` of "world".
1171
- :rtype:
1172
- ~azure.ai.textanalytics.TextAnalysisLROPoller[~azure.core.paging.ItemPaged[
1173
- list[RecognizeEntitiesResult or RecognizeLinkedEntitiesResult or RecognizePiiEntitiesResult or
1174
- ExtractKeyPhrasesResult or AnalyzeSentimentResult or RecognizeCustomEntitiesResult
1175
- or ClassifyDocumentResult or AnalyzeHealthcareEntitiesResult or ExtractSummaryResult
1176
- or AbstractSummaryResult or DocumentError]]]
1177
- :raises ~azure.core.exceptions.HttpResponseError or TypeError or ValueError:
1178
-
1179
- .. versionadded:: v3.1
1180
- The *begin_analyze_actions* client method.
1181
- .. versionadded:: 2022-05-01
1182
- The *RecognizeCustomEntitiesAction*, *SingleLabelClassifyAction*,
1183
- *MultiLabelClassifyAction*, and *AnalyzeHealthcareEntitiesAction* input options and the
1184
- corresponding *RecognizeCustomEntitiesResult*, *ClassifyDocumentResult*,
1185
- and *AnalyzeHealthcareEntitiesResult* result objects
1186
- .. versionadded:: 2022-10-01-preview
1187
- The *ExtractSummaryAction* and *AbstractSummaryAction* input options and the corresponding
1188
- *ExtractSummaryResult* and *AbstractSummaryResult* result objects.
1189
- The *autodetect_default_language* keyword argument.
1190
-
1191
- .. admonition:: Example:
1192
-
1193
- .. literalinclude:: ../samples/sample_analyze_actions.py
1194
- :start-after: [START analyze]
1195
- :end-before: [END analyze]
1196
- :language: python
1197
- :dedent: 4
1198
- :caption: Start a long-running operation to perform a variety of text analysis
1199
- actions over a batch of documents.
1200
- """
1201
-
1202
- continuation_token = kwargs.pop("continuation_token", None)
1203
- display_name = kwargs.pop("display_name", None)
1204
- language_arg = kwargs.pop("language", None)
1205
- show_stats = kwargs.pop("show_stats", None)
1206
- polling_interval = kwargs.pop("polling_interval", 5)
1207
- language = language_arg if language_arg is not None else self._default_language
1208
- bespoke = kwargs.pop("bespoke", False)
1209
- autodetect_default_language = kwargs.pop("autodetect_default_language", None)
1210
-
1211
- if continuation_token:
1212
- return cast(
1213
- AnalyzeActionsResponse,
1214
- _get_result_from_continuation_token(
1215
- self._client._client, # pylint: disable=protected-access
1216
- continuation_token,
1217
- AnalyzeActionsLROPoller,
1218
- AnalyzeActionsLROPollingMethod(
1219
- text_analytics_client=self._client,
1220
- timeout=polling_interval,
1221
- **kwargs
1222
- ),
1223
- self._analyze_result_callback,
1224
- bespoke
1225
- )
1226
- )
1227
-
1228
- models = self._client.models(api_version=self._api_version)
1229
-
1230
- input_model_cls = \
1231
- models.MultiLanguageAnalysisInput if is_language_api(self._api_version) else models.MultiLanguageBatchInput
1232
- docs = input_model_cls(
1233
- documents=_validate_input(documents, "language", language)
1234
- )
1235
- doc_id_order = [doc.get("id") for doc in docs.documents]
1236
- try:
1237
- generated_tasks = [
1238
- action._to_generated(self._api_version, str(idx)) # pylint: disable=protected-access
1239
- for idx, action in enumerate(actions)
1240
- ]
1241
- except AttributeError as e:
1242
- raise TypeError("Unsupported action type in list.") from e
1243
- task_order = [(_determine_action_type(a), a.task_name) for a in generated_tasks]
1244
- response_cls = kwargs.pop(
1245
- "cls",
1246
- lambda pipeline_response, deserialized, _:
1247
- self._analyze_result_callback(
1248
- pipeline_response,
1249
- deserialized,
1250
- doc_id_order,
1251
- task_id_order=task_order,
1252
- show_stats=show_stats,
1253
- bespoke=bespoke
1254
- ),
1255
- )
1256
-
1257
- try:
1258
- if is_language_api(self._api_version):
1259
- return cast(
1260
- AnalyzeActionsResponse,
1261
- self._client.begin_analyze_text_submit_job(
1262
- body=models.AnalyzeTextJobsInput(
1263
- analysis_input=docs,
1264
- display_name=display_name,
1265
- default_language=autodetect_default_language,
1266
- tasks=generated_tasks
1267
- ),
1268
- cls=response_cls,
1269
- polling=AnalyzeActionsLROPollingMethod(
1270
- text_analytics_client=self._client,
1271
- timeout=polling_interval,
1272
- show_stats=show_stats,
1273
- doc_id_order=doc_id_order,
1274
- task_id_order=task_order,
1275
- lro_algorithms=[
1276
- TextAnalyticsOperationResourcePolling(
1277
- show_stats=show_stats,
1278
- )
1279
- ],
1280
- **kwargs
1281
- ),
1282
- continuation_token=continuation_token,
1283
- **kwargs
1284
- )
1285
- )
1286
-
1287
- # v3.1
1288
- analyze_tasks = models.JobManifestTasks(
1289
- entity_recognition_tasks=[
1290
- a for a in generated_tasks
1291
- if _determine_action_type(a) == _AnalyzeActionsType.RECOGNIZE_ENTITIES
1292
- ],
1293
- entity_recognition_pii_tasks=[
1294
- a for a in generated_tasks
1295
- if _determine_action_type(a) == _AnalyzeActionsType.RECOGNIZE_PII_ENTITIES
1296
- ],
1297
- key_phrase_extraction_tasks=[
1298
- a for a in generated_tasks
1299
- if _determine_action_type(a) == _AnalyzeActionsType.EXTRACT_KEY_PHRASES
1300
- ],
1301
- entity_linking_tasks=[
1302
- a for a in generated_tasks
1303
- if _determine_action_type(a) == _AnalyzeActionsType.RECOGNIZE_LINKED_ENTITIES
1304
- ],
1305
- sentiment_analysis_tasks=[
1306
- a for a in generated_tasks
1307
- if _determine_action_type(a) == _AnalyzeActionsType.ANALYZE_SENTIMENT
1308
- ],
1309
- )
1310
- analyze_body = models.AnalyzeBatchInput(
1311
- display_name=display_name, tasks=analyze_tasks, analysis_input=docs
1312
- )
1313
- return cast(
1314
- AnalyzeActionsResponse,
1315
- self._client.begin_analyze(
1316
- body=analyze_body,
1317
- cls=response_cls,
1318
- polling=AnalyzeActionsLROPollingMethod(
1319
- text_analytics_client=self._client,
1320
- timeout=polling_interval,
1321
- show_stats=show_stats,
1322
- doc_id_order=doc_id_order,
1323
- task_id_order=task_order,
1324
- lro_algorithms=[
1325
- TextAnalyticsOperationResourcePolling(
1326
- show_stats=show_stats,
1327
- )
1328
- ],
1329
- **kwargs
1330
- ),
1331
- continuation_token=continuation_token,
1332
- **kwargs
1333
- )
1334
- )
1335
- except HttpResponseError as error:
1336
- return process_http_response_error(error)
1337
-
1338
- @distributed_trace
1339
- @validate_multiapi_args(
1340
- version_method_added="2022-05-01",
1341
- args_mapping={
1342
- "2022-10-01-preview": ["autodetect_default_language"],
1343
- }
1344
- )
1345
- def begin_recognize_custom_entities(
1346
- self,
1347
- documents: Union[List[str], List[TextDocumentInput], List[Dict[str, str]]],
1348
- project_name: str,
1349
- deployment_name: str,
1350
- **kwargs: Any,
1351
- ) -> TextAnalysisLROPoller[ItemPaged[Union[RecognizeCustomEntitiesResult, DocumentError]]]:
1352
- """Start a long-running custom named entity recognition operation.
1353
-
1354
- For information on regional support of custom features and how to train a model to
1355
- recognize custom entities, see https://aka.ms/azsdk/textanalytics/customentityrecognition
1356
-
1357
- :param documents: The set of documents to process as part of this batch.
1358
- If you wish to specify the ID and language on a per-item basis you must
1359
- use as input a list[:class:`~azure.ai.textanalytics.TextDocumentInput`] or a list of
1360
- dict representations of :class:`~azure.ai.textanalytics.TextDocumentInput`, like
1361
- `{"id": "1", "language": "en", "text": "hello world"}`.
1362
- :type documents:
1363
- list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or list[dict[str, str]]
1364
- :param str project_name: Required. This field indicates the project name for the model.
1365
- :param str deployment_name: This field indicates the deployment name for the model.
1366
- :keyword str language: The 2 letter ISO 639-1 representation of language for the
1367
- entire batch. For example, use "en" for English; "es" for Spanish etc.
1368
- For automatic language detection, use "auto" (Only supported by API version
1369
- 2022-10-01-preview and newer). If not set, uses "en" for English as default.
1370
- Per-document language will take precedence over whole batch language.
1371
- See https://aka.ms/talangs for supported languages in Language API.
1372
- :keyword str autodetect_default_language: Default/fallback language to use for documents requesting
1373
- automatic language detection.
1374
- :keyword bool show_stats: If set to true, response will contain document level statistics.
1375
- :keyword bool disable_service_logs: If set to true, you opt-out of having your text input
1376
- logged on the service side for troubleshooting. By default, the Language service logs your
1377
- input text for 48 hours, solely to allow for troubleshooting issues in providing you with
1378
- the service's natural language processing functions. Setting this parameter to true,
1379
- disables input logging and may limit our ability to remediate issues that occur. Please see
1380
- Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
1381
- additional details, and Microsoft Responsible AI principles at
1382
- https://www.microsoft.com/ai/responsible-ai.
1383
- :keyword str string_index_type: Specifies the method used to interpret string offsets.
1384
- `UnicodeCodePoint`, the Python encoding, is the default. To override the Python default,
1385
- you can also pass in `Utf16CodeUnit` or `TextElement_v8`. For additional information
1386
- see https://aka.ms/text-analytics-offsets
1387
- :keyword int polling_interval: Waiting time between two polls for LRO operations
1388
- if no Retry-After header is present. Defaults to 5 seconds.
1389
- :keyword str continuation_token:
1390
- Call `continuation_token()` on the poller object to save the long-running operation (LRO)
1391
- state into an opaque token. Pass the value as the `continuation_token` keyword argument
1392
- to restart the LRO from a saved state.
1393
- :keyword str display_name: An optional display name to set for the requested analysis.
1394
- :return: An instance of an TextAnalysisLROPoller. Call `result()` on the this
1395
- object to return a heterogeneous pageable of
1396
- :class:`~azure.ai.textanalytics.RecognizeCustomEntitiesResult` and
1397
- :class:`~azure.ai.textanalytics.DocumentError`.
1398
- :rtype:
1399
- ~azure.ai.textanalytics.TextAnalysisLROPoller[~azure.core.paging.ItemPaged[
1400
- ~azure.ai.textanalytics.RecognizeCustomEntitiesResult or ~azure.ai.textanalytics.DocumentError]]
1401
- :raises ~azure.core.exceptions.HttpResponseError:
1402
-
1403
- .. versionadded:: 2022-05-01
1404
- The *begin_recognize_custom_entities* client method.
1405
- .. versionadded:: 2022-10-01-preview
1406
- The *autodetect_default_language* keyword argument.
1407
-
1408
- .. admonition:: Example:
1409
-
1410
- .. literalinclude:: ../samples/sample_recognize_custom_entities.py
1411
- :start-after: [START recognize_custom_entities]
1412
- :end-before: [END recognize_custom_entities]
1413
- :language: python
1414
- :dedent: 4
1415
- :caption: Recognize custom entities in a batch of documents.
1416
- """
1417
-
1418
- continuation_token = kwargs.pop("continuation_token", None)
1419
- string_index_type = kwargs.pop("string_index_type", self._string_index_type_default)
1420
- disable_service_logs = kwargs.pop("disable_service_logs", None)
1421
- polling_interval = kwargs.pop("polling_interval", 5)
1422
-
1423
- if continuation_token:
1424
- return cast(
1425
- TextAnalysisLROPoller[ItemPaged[Union[RecognizeCustomEntitiesResult, DocumentError]]],
1426
- _get_result_from_continuation_token(
1427
- self._client._client, # pylint: disable=protected-access
1428
- continuation_token,
1429
- AnalyzeActionsLROPoller,
1430
- AnalyzeActionsLROPollingMethod(
1431
- text_analytics_client=self._client,
1432
- timeout=polling_interval,
1433
- **kwargs
1434
- ),
1435
- self._analyze_result_callback,
1436
- bespoke=True
1437
- )
1438
- )
1439
-
1440
- try:
1441
- return cast(
1442
- TextAnalysisLROPoller[
1443
- ItemPaged[Union[RecognizeCustomEntitiesResult, DocumentError]]
1444
- ],
1445
- self.begin_analyze_actions(
1446
- documents,
1447
- actions=[
1448
- RecognizeCustomEntitiesAction(
1449
- project_name=project_name,
1450
- deployment_name=deployment_name,
1451
- string_index_type=string_index_type,
1452
- disable_service_logs=disable_service_logs
1453
- )
1454
- ],
1455
- polling_interval=polling_interval,
1456
- bespoke=True,
1457
- **kwargs
1458
- )
1459
- )
1460
-
1461
- except HttpResponseError as error:
1462
- return process_http_response_error(error)
1463
-
1464
- @distributed_trace
1465
- @validate_multiapi_args(
1466
- version_method_added="2022-05-01",
1467
- args_mapping={
1468
- "2022-10-01-preview": ["autodetect_default_language"],
1469
- }
1470
- )
1471
- def begin_single_label_classify(
1472
- self,
1473
- documents: Union[List[str], List[TextDocumentInput], List[Dict[str, str]]],
1474
- project_name: str,
1475
- deployment_name: str,
1476
- **kwargs: Any,
1477
- ) -> TextAnalysisLROPoller[ItemPaged[Union[ClassifyDocumentResult, DocumentError]]]:
1478
- """Start a long-running custom single label classification operation.
1479
-
1480
- For information on regional support of custom features and how to train a model to
1481
- classify your documents, see https://aka.ms/azsdk/textanalytics/customfunctionalities
1482
-
1483
- :param documents: The set of documents to process as part of this batch.
1484
- If you wish to specify the ID and language on a per-item basis you must
1485
- use as input a list[:class:`~azure.ai.textanalytics.TextDocumentInput`] or a list of
1486
- dict representations of :class:`~azure.ai.textanalytics.TextDocumentInput`, like
1487
- `{"id": "1", "language": "en", "text": "hello world"}`.
1488
- :type documents:
1489
- list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or list[dict[str, str]]
1490
- :param str project_name: Required. This field indicates the project name for the model.
1491
- :param str deployment_name: This field indicates the deployment name for the model.
1492
- :keyword str language: The 2 letter ISO 639-1 representation of language for the
1493
- entire batch. For example, use "en" for English; "es" for Spanish etc.
1494
- For automatic language detection, use "auto" (Only supported by API version
1495
- 2022-10-01-preview and newer). If not set, uses "en" for English as default.
1496
- Per-document language will take precedence over whole batch language.
1497
- See https://aka.ms/talangs for supported languages in Language API.
1498
- :keyword str autodetect_default_language: Default/fallback language to use for documents requesting
1499
- automatic language detection.
1500
- :keyword bool show_stats: If set to true, response will contain document level statistics.
1501
- :keyword bool disable_service_logs: If set to true, you opt-out of having your text input
1502
- logged on the service side for troubleshooting. By default, the Language service logs your
1503
- input text for 48 hours, solely to allow for troubleshooting issues in providing you with
1504
- the service's natural language processing functions. Setting this parameter to true,
1505
- disables input logging and may limit our ability to remediate issues that occur. Please see
1506
- Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
1507
- additional details, and Microsoft Responsible AI principles at
1508
- https://www.microsoft.com/ai/responsible-ai.
1509
- :keyword int polling_interval: Waiting time between two polls for LRO operations
1510
- if no Retry-After header is present. Defaults to 5 seconds.
1511
- :keyword str continuation_token:
1512
- Call `continuation_token()` on the poller object to save the long-running operation (LRO)
1513
- state into an opaque token. Pass the value as the `continuation_token` keyword argument
1514
- to restart the LRO from a saved state.
1515
- :keyword str display_name: An optional display name to set for the requested analysis.
1516
- :return: An instance of an TextAnalysisLROPoller. Call `result()` on the this
1517
- object to return a heterogeneous pageable of
1518
- :class:`~azure.ai.textanalytics.ClassifyDocumentResult` and
1519
- :class:`~azure.ai.textanalytics.DocumentError`.
1520
- :rtype:
1521
- ~azure.ai.textanalytics.TextAnalysisLROPoller[~azure.core.paging.ItemPaged[
1522
- ~azure.ai.textanalytics.ClassifyDocumentResult or ~azure.ai.textanalytics.DocumentError]]
1523
- :raises ~azure.core.exceptions.HttpResponseError:
1524
-
1525
- .. versionadded:: 2022-05-01
1526
- The *begin_single_label_classify* client method.
1527
- .. versionadded:: 2022-10-01-preview
1528
- The *autodetect_default_language* keyword argument.
1529
-
1530
- .. admonition:: Example:
1531
-
1532
- .. literalinclude:: ../samples/sample_single_label_classify.py
1533
- :start-after: [START single_label_classify]
1534
- :end-before: [END single_label_classify]
1535
- :language: python
1536
- :dedent: 4
1537
- :caption: Perform single label classification on a batch of documents.
1538
- """
1539
-
1540
- continuation_token = kwargs.pop("continuation_token", None)
1541
- disable_service_logs = kwargs.pop("disable_service_logs", None)
1542
- polling_interval = kwargs.pop("polling_interval", 5)
1543
-
1544
- if continuation_token:
1545
- return cast(
1546
- TextAnalysisLROPoller[ItemPaged[Union[ClassifyDocumentResult, DocumentError]]],
1547
- _get_result_from_continuation_token(
1548
- self._client._client, # pylint: disable=protected-access
1549
- continuation_token,
1550
- AnalyzeActionsLROPoller,
1551
- AnalyzeActionsLROPollingMethod(
1552
- text_analytics_client=self._client,
1553
- timeout=polling_interval,
1554
- **kwargs
1555
- ),
1556
- self._analyze_result_callback,
1557
- bespoke=True
1558
- )
1559
- )
1560
-
1561
- try:
1562
- return cast(
1563
- TextAnalysisLROPoller[
1564
- ItemPaged[Union[ClassifyDocumentResult, DocumentError]]
1565
- ],
1566
- self.begin_analyze_actions(
1567
- documents,
1568
- actions=[
1569
- SingleLabelClassifyAction(
1570
- project_name=project_name,
1571
- deployment_name=deployment_name,
1572
- disable_service_logs=disable_service_logs
1573
- )
1574
- ],
1575
- polling_interval=polling_interval,
1576
- bespoke=True,
1577
- **kwargs
1578
- )
1579
- )
1580
-
1581
- except HttpResponseError as error:
1582
- return process_http_response_error(error)
1583
-
1584
- @distributed_trace
1585
- @validate_multiapi_args(
1586
- version_method_added="2022-05-01",
1587
- args_mapping={
1588
- "2022-10-01-preview": ["autodetect_default_language"],
1589
- }
1590
- )
1591
- def begin_multi_label_classify(
1592
- self,
1593
- documents: Union[List[str], List[TextDocumentInput], List[Dict[str, str]]],
1594
- project_name: str,
1595
- deployment_name: str,
1596
- **kwargs: Any,
1597
- ) -> TextAnalysisLROPoller[ItemPaged[Union[ClassifyDocumentResult, DocumentError]]]:
1598
- """Start a long-running custom multi label classification operation.
1599
-
1600
- For information on regional support of custom features and how to train a model to
1601
- classify your documents, see https://aka.ms/azsdk/textanalytics/customfunctionalities
1602
-
1603
- :param documents: The set of documents to process as part of this batch.
1604
- If you wish to specify the ID and language on a per-item basis you must
1605
- use as input a list[:class:`~azure.ai.textanalytics.TextDocumentInput`] or a list of
1606
- dict representations of :class:`~azure.ai.textanalytics.TextDocumentInput`, like
1607
- `{"id": "1", "language": "en", "text": "hello world"}`.
1608
- :type documents:
1609
- list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or list[dict[str, str]]
1610
- :param str project_name: Required. This field indicates the project name for the model.
1611
- :param str deployment_name: This field indicates the deployment name for the model.
1612
- :keyword str language: The 2 letter ISO 639-1 representation of language for the
1613
- entire batch. For example, use "en" for English; "es" for Spanish etc.
1614
- For automatic language detection, use "auto" (Only supported by API version
1615
- 2022-10-01-preview and newer). If not set, uses "en" for English as default.
1616
- Per-document language will take precedence over whole batch language.
1617
- See https://aka.ms/talangs for supported languages in Language API.
1618
- :keyword str autodetect_default_language: Default/fallback language to use for documents requesting
1619
- automatic language detection.
1620
- :keyword bool show_stats: If set to true, response will contain document level statistics.
1621
- :keyword bool disable_service_logs: If set to true, you opt-out of having your text input
1622
- logged on the service side for troubleshooting. By default, the Language service logs your
1623
- input text for 48 hours, solely to allow for troubleshooting issues in providing you with
1624
- the service's natural language processing functions. Setting this parameter to true,
1625
- disables input logging and may limit our ability to remediate issues that occur. Please see
1626
- Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
1627
- additional details, and Microsoft Responsible AI principles at
1628
- https://www.microsoft.com/ai/responsible-ai.
1629
- :keyword int polling_interval: Waiting time between two polls for LRO operations
1630
- if no Retry-After header is present. Defaults to 5 seconds.
1631
- :keyword str continuation_token:
1632
- Call `continuation_token()` on the poller object to save the long-running operation (LRO)
1633
- state into an opaque token. Pass the value as the `continuation_token` keyword argument
1634
- to restart the LRO from a saved state.
1635
- :keyword str display_name: An optional display name to set for the requested analysis.
1636
- :return: An instance of an TextAnalysisLROPoller. Call `result()` on the this
1637
- object to return a heterogeneous pageable of
1638
- :class:`~azure.ai.textanalytics.ClassifyDocumentResult` and
1639
- :class:`~azure.ai.textanalytics.DocumentError`.
1640
- :rtype:
1641
- ~azure.ai.textanalytics.TextAnalysisLROPoller[~azure.core.paging.ItemPaged[
1642
- ~azure.ai.textanalytics.ClassifyDocumentResult or ~azure.ai.textanalytics.DocumentError]]
1643
- :raises ~azure.core.exceptions.HttpResponseError:
1644
-
1645
- .. versionadded:: 2022-05-01
1646
- The *begin_multi_label_classify* client method.
1647
- .. versionadded:: 2022-10-01-preview
1648
- The *autodetect_default_language* keyword argument.
1649
-
1650
- .. admonition:: Example:
1651
-
1652
- .. literalinclude:: ../samples/sample_multi_label_classify.py
1653
- :start-after: [START multi_label_classify]
1654
- :end-before: [END multi_label_classify]
1655
- :language: python
1656
- :dedent: 4
1657
- :caption: Perform multi label classification on a batch of documents.
1658
- """
1659
-
1660
- continuation_token = kwargs.pop("continuation_token", None)
1661
- disable_service_logs = kwargs.pop("disable_service_logs", None)
1662
- polling_interval = kwargs.pop("polling_interval", 5)
1663
-
1664
- if continuation_token:
1665
- return cast(
1666
- TextAnalysisLROPoller[ItemPaged[Union[ClassifyDocumentResult, DocumentError]]],
1667
- _get_result_from_continuation_token(
1668
- self._client._client, # pylint: disable=protected-access
1669
- continuation_token,
1670
- AnalyzeActionsLROPoller,
1671
- AnalyzeActionsLROPollingMethod(
1672
- text_analytics_client=self._client,
1673
- timeout=polling_interval,
1674
- **kwargs
1675
- ),
1676
- self._analyze_result_callback,
1677
- bespoke=True
1678
- )
1679
- )
1680
-
1681
- try:
1682
- return cast(
1683
- TextAnalysisLROPoller[
1684
- ItemPaged[Union[ClassifyDocumentResult, DocumentError]]
1685
- ],
1686
- self.begin_analyze_actions(
1687
- documents,
1688
- actions=[
1689
- MultiLabelClassifyAction(
1690
- project_name=project_name,
1691
- deployment_name=deployment_name,
1692
- disable_service_logs=disable_service_logs
1693
- )
1694
- ],
1695
- polling_interval=polling_interval,
1696
- bespoke=True,
1697
- **kwargs
1698
- )
1699
- )
1700
-
1701
- except HttpResponseError as error:
1702
- return process_http_response_error(error)
1703
-
1704
- @distributed_trace
1705
- @validate_multiapi_args(
1706
- version_method_added="2022-10-01-preview",
1707
- )
1708
- def dynamic_classification(
1709
- self,
1710
- documents: Union[List[str], List[TextDocumentInput], List[Dict[str, str]]],
1711
- categories: List[str],
1712
- **kwargs: Any,
1713
- ) -> List[Union[DynamicClassificationResult, DocumentError]]:
1714
- """Perform dynamic classification on a batch of documents.
1715
-
1716
- On the fly classification of the input documents into one or multiple categories.
1717
- Assigns either one or multiple categories per document. This type of classification
1718
- doesn't require model training.
1719
-
1720
- .. note:: The dynamic classification feature is part of a gated preview. Request access here:
1721
- https://aka.ms/applyforgatedlanguagefeature
1722
-
1723
- See https://aka.ms/azsdk/textanalytics/data-limits for service data limits.
1724
-
1725
- :param documents: The set of documents to process as part of this batch.
1726
- If you wish to specify the ID and language on a per-item basis you must
1727
- use as input a list[:class:`~azure.ai.textanalytics.TextDocumentInput`] or a list
1728
- of dict representations of :class:`~azure.ai.textanalytics.TextDocumentInput`,
1729
- like `{"id": "1", "language": "en", "text": "hello world"}`.
1730
- :type documents:
1731
- list[str] or list[~azure.ai.textanalytics.TextDocumentInput] or list[dict[str, str]]
1732
- :param list[str] categories: A list of categories to which input is classified to.
1733
- :keyword classification_type: Specifies either one or multiple categories per document. Defaults
1734
- to multi classification which may return more than one class for each document. Known values
1735
- are: "Single" and "Multi".
1736
- :paramtype classification_type: str or ~azure.ai.textanalytics.ClassificationType
1737
- :keyword str language: The 2 letter ISO 639-1 representation of language for the
1738
- entire batch. For example, use "en" for English; "es" for Spanish etc.
1739
- If not set, uses "en" for English as default. Per-document language will
1740
- take precedence over whole batch language. See https://aka.ms/talangs for
1741
- supported languages in Language API.
1742
- :keyword str model_version: This value indicates which model will
1743
- be used for scoring, e.g. "latest", "2019-10-01". If a model-version
1744
- is not specified, the API will default to the latest, non-preview version.
1745
- See here for more info: https://aka.ms/text-analytics-model-versioning
1746
- :keyword bool show_stats: If set to true, response will contain document
1747
- level statistics in the `statistics` field of the document-level response.
1748
- :keyword bool disable_service_logs: If set to true, you opt-out of having your text input
1749
- logged on the service side for troubleshooting. By default, the Language service logs your
1750
- input text for 48 hours, solely to allow for troubleshooting issues in providing you with
1751
- the service's natural language processing functions. Setting this parameter to true,
1752
- disables input logging and may limit our ability to remediate issues that occur. Please see
1753
- Cognitive Services Compliance and Privacy notes at https://aka.ms/cs-compliance for
1754
- additional details, and Microsoft Responsible AI principles at
1755
- https://www.microsoft.com/ai/responsible-ai.
1756
- :return: The combined list of :class:`~azure.ai.textanalytics.DynamicClassificationResult` and
1757
- :class:`~azure.ai.textanalytics.DocumentError` in the order the original documents
1758
- were passed in.
1759
- :rtype: list[~azure.ai.textanalytics.DynamicClassificationResult or ~azure.ai.textanalytics.DocumentError]
1760
- :raises ~azure.core.exceptions.HttpResponseError:
1761
-
1762
- .. versionadded:: 2022-10-01-preview
1763
- The *dynamic_classification* client method.
1764
-
1765
- .. admonition:: Example:
1766
-
1767
- .. literalinclude:: ../samples/sample_dynamic_classification.py
1768
- :start-after: [START dynamic_classification]
1769
- :end-before: [END dynamic_classification]
1770
- :language: python
1771
- :dedent: 4
1772
- :caption: Perform dynamic classification on a batch of documents.
1773
- """
1774
- language_arg = kwargs.pop("language", None)
1775
- language = language_arg if language_arg is not None else self._default_language
1776
- docs = _validate_input(documents, "language", language)
1777
- model_version = kwargs.pop("model_version", None)
1778
- show_stats = kwargs.pop("show_stats", None)
1779
- disable_service_logs = kwargs.pop("disable_service_logs", None)
1780
- classification_type = kwargs.pop("classification_type", None)
1781
-
1782
- try:
1783
- models = self._client.models(api_version=self._api_version)
1784
- return cast(
1785
- List[Union[DynamicClassificationResult, DocumentError]],
1786
- self._client.analyze_text(
1787
- body=models.AnalyzeTextDynamicClassificationInput(
1788
- analysis_input={"documents": docs},
1789
- parameters=models.DynamicClassificationTaskParameters(
1790
- categories=categories,
1791
- logging_opt_out=disable_service_logs,
1792
- model_version=model_version,
1793
- classification_type=classification_type,
1794
- )
1795
- ),
1796
- show_stats=show_stats,
1797
- cls=kwargs.pop("cls", dynamic_classification_result),
1798
- **kwargs
1799
- )
1800
- )
1801
- except HttpResponseError as error:
1802
- return process_http_response_error(error)