azure-ai-textanalytics 5.3.0b2__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 -193
  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.0b2.dist-info → azure_ai_textanalytics-6.0.0b1.dist-info}/METADATA +668 -403
  26. azure_ai_textanalytics-6.0.0b1.dist-info/RECORD +29 -0
  27. {azure_ai_textanalytics-5.3.0b2.dist-info → azure_ai_textanalytics-6.0.0b1.dist-info}/WHEEL +1 -1
  28. azure/ai/textanalytics/_base_client.py +0 -113
  29. azure/ai/textanalytics/_check.py +0 -22
  30. azure/ai/textanalytics/_dict_mixin.py +0 -57
  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 -405
  68. azure/ai/textanalytics/_generated/v2022_10_01_preview/models/_models_py3.py +0 -8420
  69. azure/ai/textanalytics/_generated/v2022_10_01_preview/models/_patch.py +0 -486
  70. azure/ai/textanalytics/_generated/v2022_10_01_preview/models/_text_analytics_client_enums.py +0 -729
  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 -553
  115. azure/ai/textanalytics/_models.py +0 -3158
  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 -583
  119. azure/ai/textanalytics/_text_analytics_client.py +0 -2081
  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 -98
  123. azure/ai/textanalytics/aio/_lro_async.py +0 -503
  124. azure/ai/textanalytics/aio/_response_handlers_async.py +0 -94
  125. azure/ai/textanalytics/aio/_text_analytics_client_async.py +0 -2077
  126. azure_ai_textanalytics-5.3.0b2.dist-info/RECORD +0 -115
  127. {azure_ai_textanalytics-5.3.0b2.dist-info → azure_ai_textanalytics-6.0.0b1.dist-info/licenses}/LICENSE +0 -0
  128. {azure_ai_textanalytics-5.3.0b2.dist-info → azure_ai_textanalytics-6.0.0b1.dist-info}/top_level.txt +0 -0
@@ -1,604 +0,0 @@
1
- # pylint: disable=too-many-lines
2
- # coding=utf-8
3
- # --------------------------------------------------------------------------
4
- # Copyright (c) Microsoft Corporation. All rights reserved.
5
- # Licensed under the MIT License. See License.txt in the project root for license information.
6
- # Code generated by Microsoft (R) AutoRest Code Generator.
7
- # Changes may cause incorrect behavior and will be lost if the code is regenerated.
8
- # --------------------------------------------------------------------------
9
- from typing import Any, Callable, Dict, List, Optional, TypeVar
10
-
11
- from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
12
- from azure.core.pipeline import PipelineResponse
13
- from azure.core.pipeline.transport import HttpResponse
14
- from azure.core.rest import HttpRequest
15
- from azure.core.tracing.decorator import distributed_trace
16
- from azure.core.utils import case_insensitive_dict
17
-
18
- from .. import models as _models
19
- from ..._serialization import Serializer
20
- from .._vendor import MixinABC, _convert_request
21
- T = TypeVar('T')
22
- ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
23
-
24
- _SERIALIZER = Serializer()
25
- _SERIALIZER.client_side_validation = False
26
-
27
- def build_entities_recognition_general_request(
28
- *,
29
- model_version: Optional[str] = None,
30
- show_stats: Optional[bool] = None,
31
- **kwargs: Any
32
- ) -> HttpRequest:
33
- _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
34
- _params = case_insensitive_dict(kwargs.pop("params", {}) or {})
35
-
36
- content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str]
37
- accept = _headers.pop('Accept', "application/json, text/json")
38
-
39
- # Construct URL
40
- _url = kwargs.pop("template_url", "/entities/recognition/general")
41
-
42
- # Construct parameters
43
- if model_version is not None:
44
- _params['model-version'] = _SERIALIZER.query("model_version", model_version, 'str')
45
- if show_stats is not None:
46
- _params['showStats'] = _SERIALIZER.query("show_stats", show_stats, 'bool')
47
-
48
- # Construct headers
49
- if content_type is not None:
50
- _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str')
51
- _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str')
52
-
53
- return HttpRequest(
54
- method="POST",
55
- url=_url,
56
- params=_params,
57
- headers=_headers,
58
- **kwargs
59
- )
60
-
61
-
62
- def build_entities_linking_request(
63
- *,
64
- model_version: Optional[str] = None,
65
- show_stats: Optional[bool] = None,
66
- **kwargs: Any
67
- ) -> HttpRequest:
68
- _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
69
- _params = case_insensitive_dict(kwargs.pop("params", {}) or {})
70
-
71
- content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str]
72
- accept = _headers.pop('Accept', "application/json, text/json")
73
-
74
- # Construct URL
75
- _url = kwargs.pop("template_url", "/entities/linking")
76
-
77
- # Construct parameters
78
- if model_version is not None:
79
- _params['model-version'] = _SERIALIZER.query("model_version", model_version, 'str')
80
- if show_stats is not None:
81
- _params['showStats'] = _SERIALIZER.query("show_stats", show_stats, 'bool')
82
-
83
- # Construct headers
84
- if content_type is not None:
85
- _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str')
86
- _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str')
87
-
88
- return HttpRequest(
89
- method="POST",
90
- url=_url,
91
- params=_params,
92
- headers=_headers,
93
- **kwargs
94
- )
95
-
96
-
97
- def build_key_phrases_request(
98
- *,
99
- model_version: Optional[str] = None,
100
- show_stats: Optional[bool] = None,
101
- **kwargs: Any
102
- ) -> HttpRequest:
103
- _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
104
- _params = case_insensitive_dict(kwargs.pop("params", {}) or {})
105
-
106
- content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str]
107
- accept = _headers.pop('Accept', "application/json, text/json")
108
-
109
- # Construct URL
110
- _url = kwargs.pop("template_url", "/keyPhrases")
111
-
112
- # Construct parameters
113
- if model_version is not None:
114
- _params['model-version'] = _SERIALIZER.query("model_version", model_version, 'str')
115
- if show_stats is not None:
116
- _params['showStats'] = _SERIALIZER.query("show_stats", show_stats, 'bool')
117
-
118
- # Construct headers
119
- if content_type is not None:
120
- _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str')
121
- _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str')
122
-
123
- return HttpRequest(
124
- method="POST",
125
- url=_url,
126
- params=_params,
127
- headers=_headers,
128
- **kwargs
129
- )
130
-
131
-
132
- def build_languages_request(
133
- *,
134
- model_version: Optional[str] = None,
135
- show_stats: Optional[bool] = None,
136
- **kwargs: Any
137
- ) -> HttpRequest:
138
- _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
139
- _params = case_insensitive_dict(kwargs.pop("params", {}) or {})
140
-
141
- content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str]
142
- accept = _headers.pop('Accept', "application/json, text/json")
143
-
144
- # Construct URL
145
- _url = kwargs.pop("template_url", "/languages")
146
-
147
- # Construct parameters
148
- if model_version is not None:
149
- _params['model-version'] = _SERIALIZER.query("model_version", model_version, 'str')
150
- if show_stats is not None:
151
- _params['showStats'] = _SERIALIZER.query("show_stats", show_stats, 'bool')
152
-
153
- # Construct headers
154
- if content_type is not None:
155
- _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str')
156
- _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str')
157
-
158
- return HttpRequest(
159
- method="POST",
160
- url=_url,
161
- params=_params,
162
- headers=_headers,
163
- **kwargs
164
- )
165
-
166
-
167
- def build_sentiment_request(
168
- *,
169
- model_version: Optional[str] = None,
170
- show_stats: Optional[bool] = None,
171
- **kwargs: Any
172
- ) -> HttpRequest:
173
- _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
174
- _params = case_insensitive_dict(kwargs.pop("params", {}) or {})
175
-
176
- content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str]
177
- accept = _headers.pop('Accept', "application/json, text/json")
178
-
179
- # Construct URL
180
- _url = kwargs.pop("template_url", "/sentiment")
181
-
182
- # Construct parameters
183
- if model_version is not None:
184
- _params['model-version'] = _SERIALIZER.query("model_version", model_version, 'str')
185
- if show_stats is not None:
186
- _params['showStats'] = _SERIALIZER.query("show_stats", show_stats, 'bool')
187
-
188
- # Construct headers
189
- if content_type is not None:
190
- _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str')
191
- _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str')
192
-
193
- return HttpRequest(
194
- method="POST",
195
- url=_url,
196
- params=_params,
197
- headers=_headers,
198
- **kwargs
199
- )
200
-
201
- class TextAnalyticsClientOperationsMixin(MixinABC):
202
-
203
- @distributed_trace
204
- def entities_recognition_general(
205
- self,
206
- documents: List[_models.MultiLanguageInput],
207
- model_version: Optional[str] = None,
208
- show_stats: Optional[bool] = None,
209
- **kwargs: Any
210
- ) -> _models.EntitiesResult:
211
- """Named Entity Recognition.
212
-
213
- The API returns a list of general named entities in a given document. For the list of supported
214
- entity types, check :code:`<a href="https://aka.ms/taner">Supported Entity Types in Text
215
- Analytics API</a>`. See the :code:`<a href="https://aka.ms/talangs">Supported languages in Text
216
- Analytics API</a>` for the list of enabled languages.
217
-
218
- :param documents: The set of documents to process as part of this batch. Required.
219
- :type documents: list[~azure.ai.textanalytics.v3_0.models.MultiLanguageInput]
220
- :param model_version: (Optional) This value indicates which model will be used for scoring. If
221
- a model-version is not specified, the API should default to the latest, non-preview version.
222
- Default value is None.
223
- :type model_version: str
224
- :param show_stats: (Optional) if set to true, response will contain input and document level
225
- statistics. Default value is None.
226
- :type show_stats: bool
227
- :keyword callable cls: A custom type or function that will be passed the direct response
228
- :return: EntitiesResult or the result of cls(response)
229
- :rtype: ~azure.ai.textanalytics.v3_0.models.EntitiesResult
230
- :raises ~azure.core.exceptions.HttpResponseError:
231
- """
232
- error_map = {
233
- 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
234
- }
235
- error_map.update(kwargs.pop('error_map', {}) or {})
236
-
237
- _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
238
- _params = kwargs.pop("params", {}) or {}
239
-
240
- content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: str
241
- cls = kwargs.pop('cls', None) # type: ClsType[_models.EntitiesResult]
242
-
243
- _input = _models.MultiLanguageBatchInput(documents=documents)
244
- _json = self._serialize.body(_input, 'MultiLanguageBatchInput')
245
-
246
- request = build_entities_recognition_general_request(
247
- model_version=model_version,
248
- show_stats=show_stats,
249
- content_type=content_type,
250
- json=_json,
251
- template_url=self.entities_recognition_general.metadata['url'],
252
- headers=_headers,
253
- params=_params,
254
- )
255
- request = _convert_request(request)
256
- path_format_arguments = {
257
- "Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
258
- }
259
- request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore
260
-
261
- pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
262
- request,
263
- stream=False,
264
- **kwargs
265
- )
266
-
267
- response = pipeline_response.http_response
268
-
269
- if response.status_code not in [200]:
270
- map_error(status_code=response.status_code, response=response, error_map=error_map)
271
- error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
272
- raise HttpResponseError(response=response, model=error)
273
-
274
- deserialized = self._deserialize('EntitiesResult', pipeline_response)
275
-
276
- if cls:
277
- return cls(pipeline_response, deserialized, {})
278
-
279
- return deserialized
280
-
281
- entities_recognition_general.metadata = {'url': "/entities/recognition/general"} # type: ignore
282
-
283
-
284
- @distributed_trace
285
- def entities_linking(
286
- self,
287
- documents: List[_models.MultiLanguageInput],
288
- model_version: Optional[str] = None,
289
- show_stats: Optional[bool] = None,
290
- **kwargs: Any
291
- ) -> _models.EntityLinkingResult:
292
- """Linked entities from a well-known knowledge base.
293
-
294
- The API returns a list of recognized entities with links to a well-known knowledge base. See
295
- the :code:`<a href="https://aka.ms/talangs">Supported languages in Text Analytics API</a>` for
296
- the list of enabled languages.
297
-
298
- :param documents: The set of documents to process as part of this batch. Required.
299
- :type documents: list[~azure.ai.textanalytics.v3_0.models.MultiLanguageInput]
300
- :param model_version: (Optional) This value indicates which model will be used for scoring. If
301
- a model-version is not specified, the API should default to the latest, non-preview version.
302
- Default value is None.
303
- :type model_version: str
304
- :param show_stats: (Optional) if set to true, response will contain input and document level
305
- statistics. Default value is None.
306
- :type show_stats: bool
307
- :keyword callable cls: A custom type or function that will be passed the direct response
308
- :return: EntityLinkingResult or the result of cls(response)
309
- :rtype: ~azure.ai.textanalytics.v3_0.models.EntityLinkingResult
310
- :raises ~azure.core.exceptions.HttpResponseError:
311
- """
312
- error_map = {
313
- 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
314
- }
315
- error_map.update(kwargs.pop('error_map', {}) or {})
316
-
317
- _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
318
- _params = kwargs.pop("params", {}) or {}
319
-
320
- content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: str
321
- cls = kwargs.pop('cls', None) # type: ClsType[_models.EntityLinkingResult]
322
-
323
- _input = _models.MultiLanguageBatchInput(documents=documents)
324
- _json = self._serialize.body(_input, 'MultiLanguageBatchInput')
325
-
326
- request = build_entities_linking_request(
327
- model_version=model_version,
328
- show_stats=show_stats,
329
- content_type=content_type,
330
- json=_json,
331
- template_url=self.entities_linking.metadata['url'],
332
- headers=_headers,
333
- params=_params,
334
- )
335
- request = _convert_request(request)
336
- path_format_arguments = {
337
- "Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
338
- }
339
- request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore
340
-
341
- pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
342
- request,
343
- stream=False,
344
- **kwargs
345
- )
346
-
347
- response = pipeline_response.http_response
348
-
349
- if response.status_code not in [200]:
350
- map_error(status_code=response.status_code, response=response, error_map=error_map)
351
- error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
352
- raise HttpResponseError(response=response, model=error)
353
-
354
- deserialized = self._deserialize('EntityLinkingResult', pipeline_response)
355
-
356
- if cls:
357
- return cls(pipeline_response, deserialized, {})
358
-
359
- return deserialized
360
-
361
- entities_linking.metadata = {'url': "/entities/linking"} # type: ignore
362
-
363
-
364
- @distributed_trace
365
- def key_phrases(
366
- self,
367
- documents: List[_models.MultiLanguageInput],
368
- model_version: Optional[str] = None,
369
- show_stats: Optional[bool] = None,
370
- **kwargs: Any
371
- ) -> _models.KeyPhraseResult:
372
- """Key Phrases.
373
-
374
- The API returns a list of strings denoting the key phrases in the input text. See the :code:`<a
375
- href="https://aka.ms/talangs">Supported languages in Text Analytics API</a>` for the list of
376
- enabled languages.
377
-
378
- :param documents: The set of documents to process as part of this batch. Required.
379
- :type documents: list[~azure.ai.textanalytics.v3_0.models.MultiLanguageInput]
380
- :param model_version: (Optional) This value indicates which model will be used for scoring. If
381
- a model-version is not specified, the API should default to the latest, non-preview version.
382
- Default value is None.
383
- :type model_version: str
384
- :param show_stats: (Optional) if set to true, response will contain input and document level
385
- statistics. Default value is None.
386
- :type show_stats: bool
387
- :keyword callable cls: A custom type or function that will be passed the direct response
388
- :return: KeyPhraseResult or the result of cls(response)
389
- :rtype: ~azure.ai.textanalytics.v3_0.models.KeyPhraseResult
390
- :raises ~azure.core.exceptions.HttpResponseError:
391
- """
392
- error_map = {
393
- 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
394
- }
395
- error_map.update(kwargs.pop('error_map', {}) or {})
396
-
397
- _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
398
- _params = kwargs.pop("params", {}) or {}
399
-
400
- content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: str
401
- cls = kwargs.pop('cls', None) # type: ClsType[_models.KeyPhraseResult]
402
-
403
- _input = _models.MultiLanguageBatchInput(documents=documents)
404
- _json = self._serialize.body(_input, 'MultiLanguageBatchInput')
405
-
406
- request = build_key_phrases_request(
407
- model_version=model_version,
408
- show_stats=show_stats,
409
- content_type=content_type,
410
- json=_json,
411
- template_url=self.key_phrases.metadata['url'],
412
- headers=_headers,
413
- params=_params,
414
- )
415
- request = _convert_request(request)
416
- path_format_arguments = {
417
- "Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
418
- }
419
- request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore
420
-
421
- pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
422
- request,
423
- stream=False,
424
- **kwargs
425
- )
426
-
427
- response = pipeline_response.http_response
428
-
429
- if response.status_code not in [200]:
430
- map_error(status_code=response.status_code, response=response, error_map=error_map)
431
- error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
432
- raise HttpResponseError(response=response, model=error)
433
-
434
- deserialized = self._deserialize('KeyPhraseResult', pipeline_response)
435
-
436
- if cls:
437
- return cls(pipeline_response, deserialized, {})
438
-
439
- return deserialized
440
-
441
- key_phrases.metadata = {'url': "/keyPhrases"} # type: ignore
442
-
443
-
444
- @distributed_trace
445
- def languages(
446
- self,
447
- documents: List[_models.LanguageInput],
448
- model_version: Optional[str] = None,
449
- show_stats: Optional[bool] = None,
450
- **kwargs: Any
451
- ) -> _models.LanguageResult:
452
- """Detect Language.
453
-
454
- The API returns the detected language and a numeric score between 0 and 1. Scores close to 1
455
- indicate 100% certainty that the identified language is true. See the :code:`<a
456
- href="https://aka.ms/talangs">Supported languages in Text Analytics API</a>` for the list of
457
- enabled languages.
458
-
459
- :param documents: Required.
460
- :type documents: list[~azure.ai.textanalytics.v3_0.models.LanguageInput]
461
- :param model_version: (Optional) This value indicates which model will be used for scoring. If
462
- a model-version is not specified, the API should default to the latest, non-preview version.
463
- Default value is None.
464
- :type model_version: str
465
- :param show_stats: (Optional) if set to true, response will contain input and document level
466
- statistics. Default value is None.
467
- :type show_stats: bool
468
- :keyword callable cls: A custom type or function that will be passed the direct response
469
- :return: LanguageResult or the result of cls(response)
470
- :rtype: ~azure.ai.textanalytics.v3_0.models.LanguageResult
471
- :raises ~azure.core.exceptions.HttpResponseError:
472
- """
473
- error_map = {
474
- 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
475
- }
476
- error_map.update(kwargs.pop('error_map', {}) or {})
477
-
478
- _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
479
- _params = kwargs.pop("params", {}) or {}
480
-
481
- content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: str
482
- cls = kwargs.pop('cls', None) # type: ClsType[_models.LanguageResult]
483
-
484
- _input = _models.LanguageBatchInput(documents=documents)
485
- _json = self._serialize.body(_input, 'LanguageBatchInput')
486
-
487
- request = build_languages_request(
488
- model_version=model_version,
489
- show_stats=show_stats,
490
- content_type=content_type,
491
- json=_json,
492
- template_url=self.languages.metadata['url'],
493
- headers=_headers,
494
- params=_params,
495
- )
496
- request = _convert_request(request)
497
- path_format_arguments = {
498
- "Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
499
- }
500
- request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore
501
-
502
- pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
503
- request,
504
- stream=False,
505
- **kwargs
506
- )
507
-
508
- response = pipeline_response.http_response
509
-
510
- if response.status_code not in [200]:
511
- map_error(status_code=response.status_code, response=response, error_map=error_map)
512
- error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
513
- raise HttpResponseError(response=response, model=error)
514
-
515
- deserialized = self._deserialize('LanguageResult', pipeline_response)
516
-
517
- if cls:
518
- return cls(pipeline_response, deserialized, {})
519
-
520
- return deserialized
521
-
522
- languages.metadata = {'url': "/languages"} # type: ignore
523
-
524
-
525
- @distributed_trace
526
- def sentiment(
527
- self,
528
- documents: List[_models.MultiLanguageInput],
529
- model_version: Optional[str] = None,
530
- show_stats: Optional[bool] = None,
531
- **kwargs: Any
532
- ) -> _models.SentimentResponse:
533
- """Sentiment.
534
-
535
- The API returns a sentiment prediction, as well as sentiment scores for each sentiment class
536
- (Positive, Negative, and Neutral) for the document and each sentence within it. See the
537
- :code:`<a href="https://aka.ms/talangs">Supported languages in Text Analytics API</a>` for the
538
- list of enabled languages.
539
-
540
- :param documents: The set of documents to process as part of this batch. Required.
541
- :type documents: list[~azure.ai.textanalytics.v3_0.models.MultiLanguageInput]
542
- :param model_version: (Optional) This value indicates which model will be used for scoring. If
543
- a model-version is not specified, the API should default to the latest, non-preview version.
544
- Default value is None.
545
- :type model_version: str
546
- :param show_stats: (Optional) if set to true, response will contain input and document level
547
- statistics. Default value is None.
548
- :type show_stats: bool
549
- :keyword callable cls: A custom type or function that will be passed the direct response
550
- :return: SentimentResponse or the result of cls(response)
551
- :rtype: ~azure.ai.textanalytics.v3_0.models.SentimentResponse
552
- :raises ~azure.core.exceptions.HttpResponseError:
553
- """
554
- error_map = {
555
- 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
556
- }
557
- error_map.update(kwargs.pop('error_map', {}) or {})
558
-
559
- _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
560
- _params = kwargs.pop("params", {}) or {}
561
-
562
- content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: str
563
- cls = kwargs.pop('cls', None) # type: ClsType[_models.SentimentResponse]
564
-
565
- _input = _models.MultiLanguageBatchInput(documents=documents)
566
- _json = self._serialize.body(_input, 'MultiLanguageBatchInput')
567
-
568
- request = build_sentiment_request(
569
- model_version=model_version,
570
- show_stats=show_stats,
571
- content_type=content_type,
572
- json=_json,
573
- template_url=self.sentiment.metadata['url'],
574
- headers=_headers,
575
- params=_params,
576
- )
577
- request = _convert_request(request)
578
- path_format_arguments = {
579
- "Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
580
- }
581
- request.url = self._client.format_url(request.url, **path_format_arguments) # type: ignore
582
-
583
- pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
584
- request,
585
- stream=False,
586
- **kwargs
587
- )
588
-
589
- response = pipeline_response.http_response
590
-
591
- if response.status_code not in [200]:
592
- map_error(status_code=response.status_code, response=response, error_map=error_map)
593
- error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
594
- raise HttpResponseError(response=response, model=error)
595
-
596
- deserialized = self._deserialize('SentimentResponse', pipeline_response)
597
-
598
- if cls:
599
- return cls(pipeline_response, deserialized, {})
600
-
601
- return deserialized
602
-
603
- sentiment.metadata = {'url': "/sentiment"} # type: ignore
604
-
@@ -1,20 +0,0 @@
1
- # coding=utf-8
2
- # --------------------------------------------------------------------------
3
- # Copyright (c) Microsoft Corporation. All rights reserved.
4
- # Licensed under the MIT License. See License.txt in the project root for license information.
5
- # Code generated by Microsoft (R) AutoRest Code Generator.
6
- # Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
- # --------------------------------------------------------------------------
8
-
9
- from ._text_analytics_client import TextAnalyticsClient
10
-
11
- try:
12
- from ._patch import __all__ as _patch_all
13
- from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import
14
- except ImportError:
15
- _patch_all = []
16
- from ._patch import patch_sdk as _patch_sdk
17
- __all__ = ['TextAnalyticsClient']
18
- __all__.extend([p for p in _patch_all if p not in __all__])
19
-
20
- _patch_sdk()
@@ -1,66 +0,0 @@
1
- # coding=utf-8
2
- # --------------------------------------------------------------------------
3
- # Copyright (c) Microsoft Corporation. All rights reserved.
4
- # Licensed under the MIT License. See License.txt in the project root for license information.
5
- # Code generated by Microsoft (R) AutoRest Code Generator.
6
- # Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
- # --------------------------------------------------------------------------
8
-
9
- from typing import Any, TYPE_CHECKING
10
-
11
- from azure.core.configuration import Configuration
12
- from azure.core.pipeline import policies
13
-
14
- if TYPE_CHECKING:
15
- # pylint: disable=unused-import,ungrouped-imports
16
- from azure.core.credentials import TokenCredential
17
-
18
- VERSION = "unknown"
19
-
20
- class TextAnalyticsClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
21
- """Configuration for TextAnalyticsClient.
22
-
23
- Note that all parameters used to create this instance are saved as instance
24
- attributes.
25
-
26
- :param credential: Credential needed for the client to connect to Azure. Required.
27
- :type credential: ~azure.core.credentials.TokenCredential
28
- :param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example:
29
- https://westus.api.cognitive.microsoft.com). Required.
30
- :type endpoint: str
31
- """
32
-
33
- def __init__(
34
- self,
35
- credential: "TokenCredential",
36
- endpoint: str,
37
- **kwargs: Any
38
- ) -> None:
39
- super(TextAnalyticsClientConfiguration, self).__init__(**kwargs)
40
- if credential is None:
41
- raise ValueError("Parameter 'credential' must not be None.")
42
- if endpoint is None:
43
- raise ValueError("Parameter 'endpoint' must not be None.")
44
-
45
- self.credential = credential
46
- self.endpoint = endpoint
47
- self.credential_scopes = kwargs.pop('credential_scopes', ['https://cognitiveservices.azure.com/.default'])
48
- kwargs.setdefault('sdk_moniker', 'ai-textanalytics/{}'.format(VERSION))
49
- self._configure(**kwargs)
50
-
51
- def _configure(
52
- self,
53
- **kwargs # type: Any
54
- ):
55
- # type: (...) -> None
56
- self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
57
- self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
58
- self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
59
- self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
60
- self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs)
61
- self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs)
62
- self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
63
- self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
64
- self.authentication_policy = kwargs.get('authentication_policy')
65
- if self.credential and not self.authentication_policy:
66
- self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)