-
Notifications
You must be signed in to change notification settings - Fork 245
/
azure.ai.translation.text.TextTranslationClient.yml
451 lines (382 loc) · 18.7 KB
/
azure.ai.translation.text.TextTranslationClient.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
### YamlMime:PythonClass
uid: azure.ai.translation.text.TextTranslationClient
name: TextTranslationClient
fullName: azure.ai.translation.text.TextTranslationClient
module: azure.ai.translation.text
inheritances:
- azure.ai.translation.text._client.TextTranslationClient
summary: 'Text translation is a cloud-based REST API feature of the Translator service
that uses neural
machine translation technology to enable quick and accurate source-to-target text
translation
in real time across all supported languages.
The following methods are supported by the Text Translation feature:
Languages. Returns a list of languages supported by Translate, Transliterate, and
Dictionary
Lookup operations.
Translate. Renders single source-language text to multiple target-language texts
with a single
request.
Transliterate. Converts characters or letters of a source language to the corresponding
characters or letters of a target language.
Detect. Returns the source code language code and a boolean variable denoting whether
the
detected language is supported for text translation and transliteration.
Dictionary lookup. Returns equivalent words for the source term in the target language.
Dictionary example Returns grammatical structure and context examples for the source
term and
target term pair.
Combinations of endpoint and credential values:
str + AzureKeyCredential - used custom domain translator endpoint
str + AzureKeyCredential + Region - used for global translator endpoint
str + TokenCredential - used for regional endpoint with token authentication
str + None - used with text translation on-prem container
None + AzureKeyCredential - used for global translator endpoint with global Translator
resource
None + TokenCredential - general translator endpoint with token authentication
None + TokenCredential + Region - general translator endpoint with regional Translator
resource'
constructor:
syntax: 'TextTranslationClient(*, credential: TokenCredential, region: str | None
= None, endpoint: str | None = None, resource_id: str | None = None, audience:
str | None = None, api_version: str = ''3.0'', **kwargs)'
keywordOnlyParameters:
- name: endpoint
description: 'Supported Text Translation endpoints (protocol and hostname, for
example:
[https://api.cognitive.microsofttranslator.com](https://api.cognitive.microsofttranslator.com)).
If not provided, global translator endpoint will be used.'
types:
- <xref:str>
- name: credential
description: Credential used to authenticate with the Translator service
types:
- <xref:typing.Union>[<xref:AzureKeyCredential>, <xref:TokenCredential>]
- name: region
description: Used for National Clouds.
types:
- <xref:str>
- name: resource_id
description: Used with both a TokenCredential combined with a region.
types:
- <xref:str>
- name: audience
description: Scopes of the credentials.
types:
- <xref:str>
- name: api_version
description: 'Default value is "3.0". Note that overriding this default value
may
result in unsupported behavior.'
types:
- <xref:str>
methods:
- uid: azure.ai.translation.text.TextTranslationClient.close
name: close
signature: close() -> None
- uid: azure.ai.translation.text.TextTranslationClient.find_sentence_boundaries
name: find_sentence_boundaries
signature: 'find_sentence_boundaries(body: List[str] | List[InputTextItem] | IO[bytes],
*, client_trace_id: str | None = None, language: str | None = None, script: str
| None = None, **kwargs: Any) -> List[BreakSentenceItem]'
parameters:
- name: body
isRequired: true
keywordOnlyParameters:
- name: client_trace_id
isRequired: true
- name: language
isRequired: true
- name: script
isRequired: true
- uid: azure.ai.translation.text.TextTranslationClient.get_supported_languages
name: get_supported_languages
summary: 'Gets the set of languages currently supported by other operations of the
Translator.
Gets the set of languages currently supported by other operations of the Translator.'
signature: 'get_supported_languages(*, client_trace_id: str | None = None, scope:
str | None = None, accept_language: str | None = None, etag: str | None = None,
match_condition: MatchConditions | None = None, **kwargs: Any) -> GetSupportedLanguagesResult'
keywordOnlyParameters:
- name: client_trace_id
description: 'A client-generated GUID to uniquely identify the request. Default
value is None.'
types:
- <xref:str>
- name: scope
description: 'A comma-separated list of names defining the group of languages
to return.
Allowed group names are: `translation`, `transliteration` and `dictionary`.
If no scope is given, then all groups are returned, which is equivalent to passing
`scope=translation,transliteration,dictionary`. To decide which set of supported
languages
is appropriate for your scenario, see the description of the <xref:response-body>.
Default value is None.'
types:
- <xref:str>
- name: accept_language
description: 'The language to use for user interface strings. Some of the fields
in
the response are names of languages or
names of regions. Use this parameter to define the language in which these names
are returned.
The language is specified by providing a well-formed BCP 47 language tag. For
instance, use
the value `fr`
to request names in French or use the value `zh-Hant` to request names in Chinese
Traditional.
Names are provided in the English language when a target language is not specified
or when
localization
is not available. Default value is None.'
types:
- <xref:str>
- name: etag
description: 'check if resource is changed. Set None to skip checking etag. Default
value is
None.'
types:
- <xref:str>
- name: match_condition
description: The match condition to use upon the etag. Default value is None.
types:
- <xref:azure.core.MatchConditions>
return:
description: 'GetSupportedLanguagesResult. The GetSupportedLanguagesResult is
compatible with
MutableMapping'
types:
- <xref:azure.ai.translation.text.models.GetSupportedLanguagesResult>
exceptions:
- type: azure.core.exceptions.HttpResponseError
examples:
- "<!-- literal_block {\"ids\": [], \"classes\": [], \"names\": [], \"dupnames\"\
: [], \"backrefs\": [], \"xml:space\": \"preserve\", \"force\": false, \"language\"\
: \"python\", \"highlight_args\": {}, \"linenos\": false} -->\n\n````python\n\n\
\ # response body for status code(s): 200\n response == {\n \"dictionary\"\
: {\n \"str\": {\n \"dir\": \"str\", # Directionality,\
\ which is rtl for\n right-to-left languages or ltr for left-to-right\
\ languages. Required.\n Known values are: \"ltr\" and \"rtl\"\
.\n \"name\": \"str\", # Display name of the language in the locale\n\
\ requested via Accept-Language header. Required.\n \
\ \"nativeName\": \"str\", # Display name of the language in the\n \
\ locale native for this language. Required.\n \"translations\"\
: [\n {\n \"code\": \"str\", # Language\
\ code identifying\n the target language. Required.\n\
\ \"dir\": \"str\", # Directionality, which is rtl\n \
\ for right-to-left languages or ltr for left-to-right languages.\n\
\ Required. Known values are: \"ltr\" and \"rtl\".\n \
\ \"name\": \"str\", # Display name of the\n \
\ language in the locale requested via Accept-Language header.\n\
\ Required.\n \"nativeName\": \"\
str\" # Display name of the\n language in the locale\
\ native for this language. Required.\n }\n ]\n\
\ }\n },\n \"translation\": {\n \"str\": {\n \
\ \"dir\": \"str\", # Directionality, which is rtl for\n \
\ right-to-left languages or ltr for left-to-right languages. Required.\n\
\ Known values are: \"ltr\" and \"rtl\".\n \"name\"\
: \"str\", # Display name of the language in the locale\n requested\
\ via Accept-Language header. Required.\n \"nativeName\": \"str\"\
\ # Display name of the language in the\n locale native for this\
\ language. Required.\n }\n },\n \"transliteration\": {\n\
\ \"str\": {\n \"name\": \"str\", # Display name of the\
\ language in the locale\n requested via Accept-Language header.\
\ Required.\n \"nativeName\": \"str\", # Display name of the language\
\ in the\n locale native for this language. Required.\n \
\ \"scripts\": [\n {\n \"code\"\
: \"str\", # Code identifying the\n script. Required.\n\
\ \"dir\": \"str\", # Directionality, which is rtl\n \
\ for right-to-left languages or ltr for left-to-right languages.\n\
\ Required. Known values are: \"ltr\" and \"rtl\".\n \
\ \"name\": \"str\", # Display name of the script\n \
\ in the locale requested via Accept-Language header. Required.\n\
\ \"nativeName\": \"str\", # Display name of the\n \
\ language in the locale native for the language. Required.\n\
\ \"toScripts\": [\n {\n \
\ \"code\": \"str\", # Code\n \
\ identifying the script. Required.\n \
\ \"dir\": \"str\", #\n Directionality, which\
\ is rtl for right-to-left languages\n or ltr\
\ for left-to-right languages. Required. Known\n \
\ values are: \"ltr\" and \"rtl\".\n \"name\"\
: \"str\", # Display\n name of the script in\
\ the locale requested via\n Accept-Language header.\
\ Required.\n \"nativeName\": \"str\" #\n \
\ Display name of the language in the locale native\
\ for the\n language. Required.\n \
\ }\n ]\n }\n \
\ ]\n }\n }\n }\n ````\n"
- uid: azure.ai.translation.text.TextTranslationClient.lookup_dictionary_entries
name: lookup_dictionary_entries
signature: 'lookup_dictionary_entries(body: List[str] | List[InputTextItem] | IO[bytes],
*, from_language: str, to_language: str, client_trace_id: str | None = None, **kwargs:
Any) -> List[DictionaryLookupItem]'
parameters:
- name: body
isRequired: true
keywordOnlyParameters:
- name: from_language
isRequired: true
- name: to_language
isRequired: true
- name: client_trace_id
isRequired: true
- uid: azure.ai.translation.text.TextTranslationClient.lookup_dictionary_examples
name: lookup_dictionary_examples
summary: 'Lookup Dictionary Examples.
Lookup Dictionary Examples.'
signature: 'lookup_dictionary_examples(body: List[DictionaryExampleTextItem] | IO[bytes],
*, from_language: str, to_language: str, client_trace_id: str | None = None, **kwargs:
Any) -> List[DictionaryExampleItem]'
parameters:
- name: body
description: 'Defines the content of the request. Is either a [DictionaryExampleTextItem]
type
or a IO[bytes] type. Required.'
isRequired: true
types:
- <xref:list>[<xref:azure.ai.translation.text.models.DictionaryExampleTextItem>]
- <xref:typing.IO>[<xref:bytes>]
keywordOnlyParameters:
- name: from_language
description: 'Specifies the language of the input text.
The source language must be one of the supported languages included in the dictionary
scope.
Required.'
types:
- <xref:str>
- name: to_language
description: 'Specifies the language of the output text.
The target language must be one of the supported languages included in the dictionary
scope.
Required.'
types:
- <xref:str>
- name: client_trace_id
description: 'A client-generated GUID to uniquely identify the request. Default
value is None.'
types:
- <xref:str>
return:
description: list of DictionaryExampleItem
types:
- <xref:list>[<xref:azure.ai.translation.text.models.DictionaryExampleItem>]
exceptions:
- type: azure.core.exceptions.HttpResponseError
examples:
- "<!-- literal_block {\"ids\": [], \"classes\": [], \"names\": [], \"dupnames\"\
: [], \"backrefs\": [], \"xml:space\": \"preserve\", \"force\": false, \"language\"\
: \"python\", \"highlight_args\": {}, \"linenos\": false} -->\n\n````python\n\n\
\ # response body for status code(s): 200\n response == [\n {\n \
\ \"examples\": [\n {\n \"sourcePrefix\"\
: \"str\", # The string to concatenate\n before the value\
\ of sourceTerm to form a complete example. Do not add\n a\
\ space character, since it is already there when it should be. This\n \
\ value may be an empty string. Required.\n \"\
sourceSuffix\": \"str\", # The string to concatenate\n after\
\ the value of sourceTerm to form a complete example. Do not add\n \
\ a space character, since it is already there when it should be. This\n\
\ value may be an empty string. Required.\n \
\ \"sourceTerm\": \"str\", # A string equal to the actual\n \
\ term looked up. The string is added with sourcePrefix and\n \
\ sourceSuffix to form the complete example. Its value is separated\
\ so\n it can be marked in a user interface, e.g., by bolding\
\ it. Required.\n \"targetPrefix\": \"str\", # A string similar\
\ to\n sourcePrefix but for the target. Required.\n \
\ \"targetSuffix\": \"str\", # A string similar to\n \
\ sourceSuffix but for the target. Required.\n \"targetTerm\"\
: \"str\" # A string similar to sourceTerm\n but for the\
\ target. Required.\n }\n ],\n \"normalizedSource\"\
: \"str\", # A string giving the normalized form of\n the source\
\ term. Generally, this should be identical to the value of the Text\n \
\ field at the matching list index in the body of the request. Required.\n\
\ \"normalizedTarget\": \"str\" # A string giving the normalized form\
\ of\n the target term. Generally, this should be identical to the\
\ value of the\n Translation field at the matching list index in the\
\ body of the request.\n Required.\n }\n ]\n ````\n"
- uid: azure.ai.translation.text.TextTranslationClient.send_request
name: send_request
summary: 'Runs the network request through the client''s chained policies.
```
>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: ''https://www.example.org/''>
>>> response = client.send_request(request)
<HttpResponse: 200 OK>
```
For more information on this code flow, see [https://aka.ms/azsdk/dpcodegen/python/send_request](https://aka.ms/azsdk/dpcodegen/python/send_request)'
signature: 'send_request(request: HttpRequest, *, stream: bool = False, **kwargs:
Any) -> HttpResponse'
parameters:
- name: request
description: The network request you want to make. Required.
isRequired: true
types:
- <xref:azure.core.rest.HttpRequest>
keywordOnlyParameters:
- name: stream
description: Whether the response payload will be streamed. Defaults to False.
types:
- <xref:bool>
return:
description: The response of your network call. Does not do error handling on
your response.
types:
- <xref:azure.core.rest.HttpResponse>
- uid: azure.ai.translation.text.TextTranslationClient.translate
name: translate
signature: 'translate(body: List[str] | List[InputTextItem] | IO[bytes], *, to_language:
List[str], client_trace_id: str | None = None, from_language: str | None = None,
text_type: str | TextType | None = None, category: str | None = None, profanity_action:
str | ProfanityAction | None = None, profanity_marker: str | ProfanityMarker |
None = None, include_alignment: bool | None = None, include_sentence_length: bool
| None = None, suggested_from: str | None = None, from_script: str | None = None,
to_script: str | None = None, allow_fallback: bool | None = None, **kwargs: Any)
-> List[TranslatedTextItem]'
parameters:
- name: body
isRequired: true
keywordOnlyParameters:
- name: to_language
isRequired: true
- name: client_trace_id
isRequired: true
- name: from_language
isRequired: true
- name: text_type
isRequired: true
- name: category
isRequired: true
- name: profanity_action
isRequired: true
- name: profanity_marker
isRequired: true
- name: include_alignment
isRequired: true
- name: include_sentence_length
isRequired: true
- name: suggested_from
isRequired: true
- name: from_script
isRequired: true
- name: to_script
isRequired: true
- name: allow_fallback
isRequired: true
- uid: azure.ai.translation.text.TextTranslationClient.transliterate
name: transliterate
signature: 'transliterate(body: List[str] | List[InputTextItem] | IO[bytes], *,
language: str, from_script: str, to_script: str, client_trace_id: str | None =
None, **kwargs: Any) -> List[TransliteratedText]'
parameters:
- name: body
isRequired: true
keywordOnlyParameters:
- name: language
isRequired: true
- name: from_script
isRequired: true
- name: to_script
isRequired: true
- name: client_trace_id
isRequired: true