diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/TextTranslationAsyncClient.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/TextTranslationAsyncClient.java index d43270cc3354..79a213bb2a7c 100644 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/TextTranslationAsyncClient.java +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/TextTranslationAsyncClient.java @@ -55,136 +55,6 @@ public final class TextTranslationAsyncClient { this.serviceClient = serviceClient; } - /** - * Translate Text. - *

Query Parameters

- * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Query Parameters
NameTypeRequiredDescription
fromStringNoSpecifies the language of the input text. Find which languages are - * available to translate from by - * looking up supported languages using the translation scope. If the from parameter isn't specified, - * automatic language detection is applied to determine the source language. - * - * You must use the from parameter rather than autodetection when using the dynamic dictionary feature. - * Note: the dynamic dictionary feature is case-sensitive.
textTypeStringNoDefines whether the text being translated is plain text or - * HTML text. Any HTML needs to be a well-formed, - * complete element. Possible values are: plain (default) or html. Allowed values: "Plain", "Html".
categoryStringNoA string specifying the category (domain) of the translation. - * This parameter is used to get translations - * from a customized system built with Custom Translator. Add the Category ID from your Custom Translator - * project details to this parameter to use your deployed customized system. Default value is: general.
profanityActionStringNoSpecifies how profanities should be treated in - * translations. - * Possible values are: NoAction (default), Marked or Deleted. Allowed values: "NoAction", "Marked", - * "Deleted".
profanityMarkerStringNoSpecifies how profanities should be marked in - * translations. - * Possible values are: Asterisk (default) or Tag. . Allowed values: "Asterisk", "Tag".
includeAlignmentBooleanNoSpecifies whether to include alignment projection - * from source text to translated text. - * Possible values are: true or false (default).
includeSentenceLengthBooleanNoSpecifies whether to include sentence boundaries - * for the input text and the translated text. - * Possible values are: true or false (default).
suggestedFromStringNoSpecifies a fallback language if the language of the - * input text can't be identified. - * Language autodetection is applied when the from parameter is omitted. If detection fails, - * the suggestedFrom language will be assumed.
fromScriptStringNoSpecifies the script of the input text.
toScriptStringNoSpecifies the script of the translated text.
allowFallbackBooleanNoSpecifies that the service is allowed to fall back to a - * general system when a custom system doesn't exist. - * Possible values are: true (default) or false. - * - * allowFallback=false specifies that the translation should only use systems trained for the category specified - * by the request. If a translation for language X to language Y requires chaining through a pivot language E, - * then all the systems in the chain (X → E and E → Y) will need to be custom and have the same category. - * If no system is found with the specific category, the request will return a 400 status code. allowFallback=true - * specifies that the service is allowed to fall back to a general system when a custom system doesn't - * exist.
- * You can add these to a request with {@link RequestOptions#addQueryParam} - *

Header Parameters

- * - * - * - * - *
Header Parameters
NameTypeRequiredDescription
X-ClientTraceIdStringNoA client-generated GUID to uniquely identify the - * request.
- * You can add these to a request with {@link RequestOptions#addHeader} - *

Request Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         text: String (Required)
-     *     }
-     * ]
-     * }
-     * 
- * - *

Response Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         detectedLanguage (Optional): {
-     *             language: String (Required)
-     *             score: double (Required)
-     *         }
-     *         translations (Required): [
-     *              (Required){
-     *                 to: String (Required)
-     *                 text: String (Required)
-     *                 transliteration (Optional): {
-     *                     text: String (Required)
-     *                     script: String (Required)
-     *                 }
-     *                 alignment (Optional): {
-     *                     proj: String (Required)
-     *                 }
-     *                 sentLen (Optional): {
-     *                     srcSentLen (Required): [
-     *                         int (Required)
-     *                     ]
-     *                     transSentLen (Required): [
-     *                         int (Required)
-     *                     ]
-     *                 }
-     *             }
-     *         ]
-     *         sourceText (Optional): {
-     *             text: String (Required)
-     *         }
-     *     }
-     * ]
-     * }
-     * 
- * - * @param targetLanguages Specifies the language of the output text. The target language must be one of the - * supported languages included - * in the translation scope. For example, use to=de to translate to German. - * It's possible to translate to multiple languages simultaneously by repeating the parameter in the query string. - * For example, use to=de&to=it to translate to German and Italian. - * @param body Defines the content of the request. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the response body along with {@link Response} on successful completion of {@link Mono}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> translateWithResponse(List targetLanguages, BinaryData body, - RequestOptions requestOptions) { - return this.serviceClient.translateWithResponseAsync(targetLanguages, body, requestOptions); - } - /** * Transliterate Text. *

Header Parameters

@@ -245,209 +115,6 @@ public Mono> transliterateWithResponse(String language, Str body, requestOptions); } - /** - * Find Sentence Boundaries. - *

Query Parameters

- * - * - * - * - * - *
Query Parameters
NameTypeRequiredDescription
languageStringNoLanguage tag identifying the language of the input text. - * If a code isn't specified, automatic language detection will be applied.
scriptStringNoScript tag identifying the script used by the input text. - * If a script isn't specified, the default script of the language will be assumed.
- * You can add these to a request with {@link RequestOptions#addQueryParam} - *

Header Parameters

- * - * - * - * - *
Header Parameters
NameTypeRequiredDescription
X-ClientTraceIdStringNoA client-generated GUID to uniquely identify the - * request.
- * You can add these to a request with {@link RequestOptions#addHeader} - *

Request Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         text: String (Required)
-     *     }
-     * ]
-     * }
-     * 
- * - *

Response Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         detectedLanguage (Optional): {
-     *             language: String (Required)
-     *             score: double (Required)
-     *         }
-     *         sentLen (Required): [
-     *             int (Required)
-     *         ]
-     *     }
-     * ]
-     * }
-     * 
- * - * @param body Defines the content of the request. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the response body along with {@link Response} on successful completion of {@link Mono}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> findSentenceBoundariesWithResponse(BinaryData body, - RequestOptions requestOptions) { - return this.serviceClient.findSentenceBoundariesWithResponseAsync(body, requestOptions); - } - - /** - * Lookup Dictionary Entries. - *

Header Parameters

- * - * - * - * - *
Header Parameters
NameTypeRequiredDescription
X-ClientTraceIdStringNoA client-generated GUID to uniquely identify the - * request.
- * You can add these to a request with {@link RequestOptions#addHeader} - *

Request Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         text: String (Required)
-     *     }
-     * ]
-     * }
-     * 
- * - *

Response Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         normalizedSource: String (Required)
-     *         displaySource: String (Required)
-     *         translations (Required): [
-     *              (Required){
-     *                 normalizedTarget: String (Required)
-     *                 displayTarget: String (Required)
-     *                 posTag: String (Required)
-     *                 confidence: double (Required)
-     *                 prefixWord: String (Required)
-     *                 backTranslations (Required): [
-     *                      (Required){
-     *                         normalizedText: String (Required)
-     *                         displayText: String (Required)
-     *                         numExamples: int (Required)
-     *                         frequencyCount: int (Required)
-     *                     }
-     *                 ]
-     *             }
-     *         ]
-     *     }
-     * ]
-     * }
-     * 
- * - * @param sourceLanguage Specifies the language of the input text. - * The source language must be one of the supported languages included in the dictionary scope. - * @param targetLanguage Specifies the language of the output text. - * The target language must be one of the supported languages included in the dictionary scope. - * @param body Defines the content of the request. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the response body along with {@link Response} on successful completion of {@link Mono}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> lookupDictionaryEntriesWithResponse(String sourceLanguage, String targetLanguage, - BinaryData body, RequestOptions requestOptions) { - return this.serviceClient.lookupDictionaryEntriesWithResponseAsync(sourceLanguage, targetLanguage, body, - requestOptions); - } - - /** - * Lookup Dictionary Examples. - *

Header Parameters

- * - * - * - * - *
Header Parameters
NameTypeRequiredDescription
X-ClientTraceIdStringNoA client-generated GUID to uniquely identify the - * request.
- * You can add these to a request with {@link RequestOptions#addHeader} - *

Request Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         text: String (Required)
-     *         translation: String (Required)
-     *     }
-     * ]
-     * }
-     * 
- * - *

Response Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         normalizedSource: String (Required)
-     *         normalizedTarget: String (Required)
-     *         examples (Required): [
-     *              (Required){
-     *                 sourcePrefix: String (Required)
-     *                 sourceTerm: String (Required)
-     *                 sourceSuffix: String (Required)
-     *                 targetPrefix: String (Required)
-     *                 targetTerm: String (Required)
-     *                 targetSuffix: String (Required)
-     *             }
-     *         ]
-     *     }
-     * ]
-     * }
-     * 
- * - * @param sourceLanguage Specifies the language of the input text. - * The source language must be one of the supported languages included in the dictionary scope. - * @param targetLanguage Specifies the language of the output text. - * The target language must be one of the supported languages included in the dictionary scope. - * @param body Defines the content of the request. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the response body along with {@link Response} on successful completion of {@link Mono}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> lookupDictionaryExamplesWithResponse(String sourceLanguage, String targetLanguage, - BinaryData body, RequestOptions requestOptions) { - return this.serviceClient.lookupDictionaryExamplesWithResponseAsync(sourceLanguage, targetLanguage, body, - requestOptions); - } - /** * Translate Text. * @@ -1033,21 +700,6 @@ public Mono> lookupDictionaryExamples(String sourceL = new TypeReference>() { }; - @Generated - private static final TypeReference> TYPE_REFERENCE_LIST_BREAK_SENTENCE_ITEM - = new TypeReference>() { - }; - - @Generated - private static final TypeReference> TYPE_REFERENCE_LIST_DICTIONARY_LOOKUP_ITEM - = new TypeReference>() { - }; - - @Generated - private static final TypeReference> TYPE_REFERENCE_LIST_DICTIONARY_EXAMPLE_ITEM - = new TypeReference>() { - }; - @Generated private static final TypeReference> TYPE_REFERENCE_LIST_TRANSLATED_TEXT_ITEM = new TypeReference>() { @@ -1266,4 +918,93 @@ private String convertToScopesString(List scopes) { } return result.toString(); } + + /** + * Translate Text. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
X-ClientTraceIdStringNoA client-generated GUID to uniquely identify the + * request.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * [
+     *      (Required){
+     *         text: String (Required)
+     *         script: String (Optional)
+     *         language: String (Optional)
+     *         textType: String(Plain/Html) (Optional)
+     *         targets (Required): [
+     *              (Required){
+     *                 language (Required): [
+     *                     String (Required)
+     *                 ]
+     *                 script: String (Optional)
+     *                 profanityAction: String(NoAction/Marked/Deleted) (Optional)
+     *                 profanityMarker: String(Asterisk/Tag) (Optional)
+     *                 deploymentNameModel: String (Optional)
+     *                 allowFallback: Boolean (Optional)
+     *                 grade: String (Optional)
+     *                 tone: String (Optional)
+     *                 gender: String (Optional)
+     *                 adaptiveDatasetId: String (Optional)
+     *                 referenceTextPairs (Optional): [
+     *                      (Optional){
+     *                         referenceTextPairsSource: String (Required)
+     *                         referenceTextPairsTarget: String (Required)
+     *                     }
+     *                 ]
+     *             }
+     *         ]
+     *     }
+     * ]
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * [
+     *      (Required){
+     *         detectedLanguage (Optional): {
+     *             language: String (Required)
+     *             score: double (Required)
+     *         }
+     *         translations (Required): [
+     *              (Required){
+     *                 to: String (Required)
+     *                 text: String (Required)
+     *                 transliteration (Optional): {
+     *                     text: String (Required)
+     *                     script: String (Required)
+     *                 }
+     *             }
+     *         ]
+     *         sourceText (Optional): {
+     *             text: String (Required)
+     *         }
+     *     }
+     * ]
+     * }
+     * 
+ * + * @param body Defines the content of the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> translateWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.translateWithResponseAsync(body, requestOptions); + } } diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/TextTranslationClient.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/TextTranslationClient.java index 14d6e9528634..2adf0d1c1daf 100644 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/TextTranslationClient.java +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/TextTranslationClient.java @@ -53,136 +53,6 @@ public final class TextTranslationClient { this.serviceClient = serviceClient; } - /** - * Translate Text. - *

Query Parameters

- * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Query Parameters
NameTypeRequiredDescription
fromStringNoSpecifies the language of the input text. Find which languages are - * available to translate from by - * looking up supported languages using the translation scope. If the from parameter isn't specified, - * automatic language detection is applied to determine the source language. - * - * You must use the from parameter rather than autodetection when using the dynamic dictionary feature. - * Note: the dynamic dictionary feature is case-sensitive.
textTypeStringNoDefines whether the text being translated is plain text or - * HTML text. Any HTML needs to be a well-formed, - * complete element. Possible values are: plain (default) or html. Allowed values: "Plain", "Html".
categoryStringNoA string specifying the category (domain) of the translation. - * This parameter is used to get translations - * from a customized system built with Custom Translator. Add the Category ID from your Custom Translator - * project details to this parameter to use your deployed customized system. Default value is: general.
profanityActionStringNoSpecifies how profanities should be treated in - * translations. - * Possible values are: NoAction (default), Marked or Deleted. Allowed values: "NoAction", "Marked", - * "Deleted".
profanityMarkerStringNoSpecifies how profanities should be marked in - * translations. - * Possible values are: Asterisk (default) or Tag. . Allowed values: "Asterisk", "Tag".
includeAlignmentBooleanNoSpecifies whether to include alignment projection - * from source text to translated text. - * Possible values are: true or false (default).
includeSentenceLengthBooleanNoSpecifies whether to include sentence boundaries - * for the input text and the translated text. - * Possible values are: true or false (default).
suggestedFromStringNoSpecifies a fallback language if the language of the - * input text can't be identified. - * Language autodetection is applied when the from parameter is omitted. If detection fails, - * the suggestedFrom language will be assumed.
fromScriptStringNoSpecifies the script of the input text.
toScriptStringNoSpecifies the script of the translated text.
allowFallbackBooleanNoSpecifies that the service is allowed to fall back to a - * general system when a custom system doesn't exist. - * Possible values are: true (default) or false. - * - * allowFallback=false specifies that the translation should only use systems trained for the category specified - * by the request. If a translation for language X to language Y requires chaining through a pivot language E, - * then all the systems in the chain (X → E and E → Y) will need to be custom and have the same category. - * If no system is found with the specific category, the request will return a 400 status code. allowFallback=true - * specifies that the service is allowed to fall back to a general system when a custom system doesn't - * exist.
- * You can add these to a request with {@link RequestOptions#addQueryParam} - *

Header Parameters

- * - * - * - * - *
Header Parameters
NameTypeRequiredDescription
X-ClientTraceIdStringNoA client-generated GUID to uniquely identify the - * request.
- * You can add these to a request with {@link RequestOptions#addHeader} - *

Request Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         text: String (Required)
-     *     }
-     * ]
-     * }
-     * 
- * - *

Response Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         detectedLanguage (Optional): {
-     *             language: String (Required)
-     *             score: double (Required)
-     *         }
-     *         translations (Required): [
-     *              (Required){
-     *                 to: String (Required)
-     *                 text: String (Required)
-     *                 transliteration (Optional): {
-     *                     text: String (Required)
-     *                     script: String (Required)
-     *                 }
-     *                 alignment (Optional): {
-     *                     proj: String (Required)
-     *                 }
-     *                 sentLen (Optional): {
-     *                     srcSentLen (Required): [
-     *                         int (Required)
-     *                     ]
-     *                     transSentLen (Required): [
-     *                         int (Required)
-     *                     ]
-     *                 }
-     *             }
-     *         ]
-     *         sourceText (Optional): {
-     *             text: String (Required)
-     *         }
-     *     }
-     * ]
-     * }
-     * 
- * - * @param targetLanguages Specifies the language of the output text. The target language must be one of the - * supported languages included - * in the translation scope. For example, use to=de to translate to German. - * It's possible to translate to multiple languages simultaneously by repeating the parameter in the query string. - * For example, use to=de&to=it to translate to German and Italian. - * @param body Defines the content of the request. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the response body along with {@link Response}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Response translateWithResponse(List targetLanguages, BinaryData body, - RequestOptions requestOptions) { - return this.serviceClient.translateWithResponse(targetLanguages, body, requestOptions); - } - /** * Transliterate Text. *

Header Parameters

@@ -243,208 +113,6 @@ public Response transliterateWithResponse(String language, String so requestOptions); } - /** - * Find Sentence Boundaries. - *

Query Parameters

- * - * - * - * - * - *
Query Parameters
NameTypeRequiredDescription
languageStringNoLanguage tag identifying the language of the input text. - * If a code isn't specified, automatic language detection will be applied.
scriptStringNoScript tag identifying the script used by the input text. - * If a script isn't specified, the default script of the language will be assumed.
- * You can add these to a request with {@link RequestOptions#addQueryParam} - *

Header Parameters

- * - * - * - * - *
Header Parameters
NameTypeRequiredDescription
X-ClientTraceIdStringNoA client-generated GUID to uniquely identify the - * request.
- * You can add these to a request with {@link RequestOptions#addHeader} - *

Request Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         text: String (Required)
-     *     }
-     * ]
-     * }
-     * 
- * - *

Response Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         detectedLanguage (Optional): {
-     *             language: String (Required)
-     *             score: double (Required)
-     *         }
-     *         sentLen (Required): [
-     *             int (Required)
-     *         ]
-     *     }
-     * ]
-     * }
-     * 
- * - * @param body Defines the content of the request. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the response body along with {@link Response}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Response findSentenceBoundariesWithResponse(BinaryData body, RequestOptions requestOptions) { - return this.serviceClient.findSentenceBoundariesWithResponse(body, requestOptions); - } - - /** - * Lookup Dictionary Entries. - *

Header Parameters

- * - * - * - * - *
Header Parameters
NameTypeRequiredDescription
X-ClientTraceIdStringNoA client-generated GUID to uniquely identify the - * request.
- * You can add these to a request with {@link RequestOptions#addHeader} - *

Request Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         text: String (Required)
-     *     }
-     * ]
-     * }
-     * 
- * - *

Response Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         normalizedSource: String (Required)
-     *         displaySource: String (Required)
-     *         translations (Required): [
-     *              (Required){
-     *                 normalizedTarget: String (Required)
-     *                 displayTarget: String (Required)
-     *                 posTag: String (Required)
-     *                 confidence: double (Required)
-     *                 prefixWord: String (Required)
-     *                 backTranslations (Required): [
-     *                      (Required){
-     *                         normalizedText: String (Required)
-     *                         displayText: String (Required)
-     *                         numExamples: int (Required)
-     *                         frequencyCount: int (Required)
-     *                     }
-     *                 ]
-     *             }
-     *         ]
-     *     }
-     * ]
-     * }
-     * 
- * - * @param sourceLanguage Specifies the language of the input text. - * The source language must be one of the supported languages included in the dictionary scope. - * @param targetLanguage Specifies the language of the output text. - * The target language must be one of the supported languages included in the dictionary scope. - * @param body Defines the content of the request. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the response body along with {@link Response}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Response lookupDictionaryEntriesWithResponse(String sourceLanguage, String targetLanguage, - BinaryData body, RequestOptions requestOptions) { - return this.serviceClient.lookupDictionaryEntriesWithResponse(sourceLanguage, targetLanguage, body, - requestOptions); - } - - /** - * Lookup Dictionary Examples. - *

Header Parameters

- * - * - * - * - *
Header Parameters
NameTypeRequiredDescription
X-ClientTraceIdStringNoA client-generated GUID to uniquely identify the - * request.
- * You can add these to a request with {@link RequestOptions#addHeader} - *

Request Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         text: String (Required)
-     *         translation: String (Required)
-     *     }
-     * ]
-     * }
-     * 
- * - *

Response Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         normalizedSource: String (Required)
-     *         normalizedTarget: String (Required)
-     *         examples (Required): [
-     *              (Required){
-     *                 sourcePrefix: String (Required)
-     *                 sourceTerm: String (Required)
-     *                 sourceSuffix: String (Required)
-     *                 targetPrefix: String (Required)
-     *                 targetTerm: String (Required)
-     *                 targetSuffix: String (Required)
-     *             }
-     *         ]
-     *     }
-     * ]
-     * }
-     * 
- * - * @param sourceLanguage Specifies the language of the input text. - * The source language must be one of the supported languages included in the dictionary scope. - * @param targetLanguage Specifies the language of the output text. - * The target language must be one of the supported languages included in the dictionary scope. - * @param body Defines the content of the request. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the response body along with {@link Response}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Response lookupDictionaryExamplesWithResponse(String sourceLanguage, String targetLanguage, - BinaryData body, RequestOptions requestOptions) { - return this.serviceClient.lookupDictionaryExamplesWithResponse(sourceLanguage, targetLanguage, body, - requestOptions); - } - /** * Translate Text. * @@ -982,52 +650,11 @@ public DictionaryLookupItem lookupDictionaryEntries(String sourceLanguage, Strin return lookupDictionaryEntries(sourceLanguage, targetLanguage, Arrays.asList(text)).get(0); } - /** - * Lookup Dictionary Examples. - * - * @param sourceLanguage Specifies the language of the input text. - * The source language must be one of the supported languages included in the dictionary scope. - * @param targetLanguage Specifies the language of the output text. - * The target language must be one of the supported languages included in the dictionary scope. - * @param body Defines the content of the request. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public List lookupDictionaryExamples(String sourceLanguage, String targetLanguage, - List body) { - // Generated convenience method for lookupDictionaryExamplesWithResponse - RequestOptions requestOptions = new RequestOptions(); - return lookupDictionaryExamplesWithResponse(sourceLanguage, targetLanguage, BinaryData.fromObject(body), - requestOptions).getValue().toObject(TYPE_REFERENCE_LIST_DICTIONARY_EXAMPLE_ITEM); - } - @Generated private static final TypeReference> TYPE_REFERENCE_LIST_TRANSLITERATED_TEXT = new TypeReference>() { }; - @Generated - private static final TypeReference> TYPE_REFERENCE_LIST_BREAK_SENTENCE_ITEM - = new TypeReference>() { - }; - - @Generated - private static final TypeReference> TYPE_REFERENCE_LIST_DICTIONARY_LOOKUP_ITEM - = new TypeReference>() { - }; - - @Generated - private static final TypeReference> TYPE_REFERENCE_LIST_DICTIONARY_EXAMPLE_ITEM - = new TypeReference>() { - }; - @Generated private static final TypeReference> TYPE_REFERENCE_LIST_TRANSLATED_TEXT_ITEM = new TypeReference>() { @@ -1269,4 +896,93 @@ private List lookupDictionaryExamples(String sourceLangua return lookupDictionaryExamplesWithResponse(sourceLanguage, targetLanguage, BinaryData.fromObject(body), requestOptions).getValue().toObject(TYPE_REFERENCE_LIST_DICTIONARY_EXAMPLE_ITEM); } + + /** + * Translate Text. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
X-ClientTraceIdStringNoA client-generated GUID to uniquely identify the + * request.
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * [
+     *      (Required){
+     *         text: String (Required)
+     *         script: String (Optional)
+     *         language: String (Optional)
+     *         textType: String(Plain/Html) (Optional)
+     *         targets (Required): [
+     *              (Required){
+     *                 language (Required): [
+     *                     String (Required)
+     *                 ]
+     *                 script: String (Optional)
+     *                 profanityAction: String(NoAction/Marked/Deleted) (Optional)
+     *                 profanityMarker: String(Asterisk/Tag) (Optional)
+     *                 deploymentNameModel: String (Optional)
+     *                 allowFallback: Boolean (Optional)
+     *                 grade: String (Optional)
+     *                 tone: String (Optional)
+     *                 gender: String (Optional)
+     *                 adaptiveDatasetId: String (Optional)
+     *                 referenceTextPairs (Optional): [
+     *                      (Optional){
+     *                         referenceTextPairsSource: String (Required)
+     *                         referenceTextPairsTarget: String (Required)
+     *                     }
+     *                 ]
+     *             }
+     *         ]
+     *     }
+     * ]
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * [
+     *      (Required){
+     *         detectedLanguage (Optional): {
+     *             language: String (Required)
+     *             score: double (Required)
+     *         }
+     *         translations (Required): [
+     *              (Required){
+     *                 to: String (Required)
+     *                 text: String (Required)
+     *                 transliteration (Optional): {
+     *                     text: String (Required)
+     *                     script: String (Required)
+     *                 }
+     *             }
+     *         ]
+     *         sourceText (Optional): {
+     *             text: String (Required)
+     *         }
+     *     }
+     * ]
+     * }
+     * 
+ * + * @param body Defines the content of the request. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response translateWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.translateWithResponse(body, requestOptions); + } } diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/TextTranslationServiceVersion.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/TextTranslationServiceVersion.java index 242d435b87d2..3dd0929e96ee 100644 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/TextTranslationServiceVersion.java +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/TextTranslationServiceVersion.java @@ -11,9 +11,14 @@ */ public enum TextTranslationServiceVersion implements ServiceVersion { /** - * Enum value 3.0. + * Enum value v3.0. */ - V3_0("3.0"); + V3_0("v3.0"), + + /** + * Enum value 2025-05-01-preview. + */ + V2025_05_01_PREVIEW("2025-05-01-preview"); private final String version; @@ -35,6 +40,6 @@ public String getVersion() { * @return The latest {@link TextTranslationServiceVersion}. */ public static TextTranslationServiceVersion getLatest() { - return V3_0; + return V2025_05_01_PREVIEW; } } diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/implementation/TextTranslationClientImpl.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/implementation/TextTranslationClientImpl.java index 6b380032aeb1..75fed01439db 100644 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/implementation/TextTranslationClientImpl.java +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/implementation/TextTranslationClientImpl.java @@ -33,9 +33,6 @@ import com.azure.core.util.FluxUtil; import com.azure.core.util.serializer.JacksonAdapter; import com.azure.core.util.serializer.SerializerAdapter; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; import reactor.core.publisher.Mono; /** @@ -183,7 +180,6 @@ Response getSupportedLanguagesSync(@HostParam("Endpoint") String end @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> translate(@HostParam("Endpoint") String endpoint, - @QueryParam(value = "to", multipleQueryParams = true) List targetLanguages, @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @@ -195,7 +191,6 @@ Mono> translate(@HostParam("Endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response translateSync(@HostParam("Endpoint") String endpoint, - @QueryParam(value = "to", multipleQueryParams = true) List targetLanguages, @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @@ -223,76 +218,6 @@ Response transliterateSync(@HostParam("Endpoint") String endpoint, @QueryParam("toScript") String targetLanguageScript, @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); - - @Post("/breaksentence") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) - @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) - @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> findSentenceBoundaries(@HostParam("Endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, - @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); - - @Post("/breaksentence") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) - @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) - @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Response findSentenceBoundariesSync(@HostParam("Endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, - @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); - - @Post("/dictionary/lookup") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) - @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) - @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> lookupDictionaryEntries(@HostParam("Endpoint") String endpoint, - @QueryParam("from") String sourceLanguage, @QueryParam("to") String targetLanguage, - @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, - @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); - - @Post("/dictionary/lookup") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) - @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) - @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Response lookupDictionaryEntriesSync(@HostParam("Endpoint") String endpoint, - @QueryParam("from") String sourceLanguage, @QueryParam("to") String targetLanguage, - @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, - @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); - - @Post("/dictionary/examples") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) - @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) - @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> lookupDictionaryExamples(@HostParam("Endpoint") String endpoint, - @QueryParam("from") String sourceLanguage, @QueryParam("to") String targetLanguage, - @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, - @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); - - @Post("/dictionary/examples") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) - @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) - @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Response lookupDictionaryExamplesSync(@HostParam("Endpoint") String endpoint, - @QueryParam("from") String sourceLanguage, @QueryParam("to") String targetLanguage, - @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, - @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); } /** @@ -499,55 +424,6 @@ public Response getSupportedLanguagesWithResponse(RequestOptions req /** * Translate Text. - *

Query Parameters

- * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Query Parameters
NameTypeRequiredDescription
fromStringNoSpecifies the language of the input text. Find which languages are - * available to translate from by - * looking up supported languages using the translation scope. If the from parameter isn't specified, - * automatic language detection is applied to determine the source language. - * - * You must use the from parameter rather than autodetection when using the dynamic dictionary feature. - * Note: the dynamic dictionary feature is case-sensitive.
textTypeStringNoDefines whether the text being translated is plain text or - * HTML text. Any HTML needs to be a well-formed, - * complete element. Possible values are: plain (default) or html. Allowed values: "Plain", "Html".
categoryStringNoA string specifying the category (domain) of the translation. - * This parameter is used to get translations - * from a customized system built with Custom Translator. Add the Category ID from your Custom Translator - * project details to this parameter to use your deployed customized system. Default value is: general.
profanityActionStringNoSpecifies how profanities should be treated in - * translations. - * Possible values are: NoAction (default), Marked or Deleted. Allowed values: "NoAction", "Marked", - * "Deleted".
profanityMarkerStringNoSpecifies how profanities should be marked in - * translations. - * Possible values are: Asterisk (default) or Tag. . Allowed values: "Asterisk", "Tag".
includeAlignmentBooleanNoSpecifies whether to include alignment projection - * from source text to translated text. - * Possible values are: true or false (default).
includeSentenceLengthBooleanNoSpecifies whether to include sentence boundaries - * for the input text and the translated text. - * Possible values are: true or false (default).
suggestedFromStringNoSpecifies a fallback language if the language of the - * input text can't be identified. - * Language autodetection is applied when the from parameter is omitted. If detection fails, - * the suggestedFrom language will be assumed.
fromScriptStringNoSpecifies the script of the input text.
toScriptStringNoSpecifies the script of the translated text.
allowFallbackBooleanNoSpecifies that the service is allowed to fall back to a - * general system when a custom system doesn't exist. - * Possible values are: true (default) or false. - * - * allowFallback=false specifies that the translation should only use systems trained for the category specified - * by the request. If a translation for language X to language Y requires chaining through a pivot language E, - * then all the systems in the chain (X → E and E → Y) will need to be custom and have the same category. - * If no system is found with the specific category, the request will return a 400 status code. allowFallback=true - * specifies that the service is allowed to fall back to a general system when a custom system doesn't - * exist.
- * You can add these to a request with {@link RequestOptions#addQueryParam} *

Header Parameters

* * @@ -563,6 +439,31 @@ public Response getSupportedLanguagesWithResponse(RequestOptions req * [ * (Required){ * text: String (Required) + * script: String (Optional) + * language: String (Optional) + * textType: String(Plain/Html) (Optional) + * targets (Required): [ + * (Required){ + * language (Required): [ + * String (Required) + * ] + * script: String (Optional) + * profanityAction: String(NoAction/Marked/Deleted) (Optional) + * profanityMarker: String(Asterisk/Tag) (Optional) + * deploymentNameModel: String (Optional) + * allowFallback: Boolean (Optional) + * grade: String (Optional) + * tone: String (Optional) + * gender: String (Optional) + * adaptiveDatasetId: String (Optional) + * referenceTextPairs (Optional): [ + * (Optional){ + * referenceTextPairsSource: String (Required) + * referenceTextPairsTarget: String (Required) + * } + * ] + * } + * ] * } * ] * } @@ -586,17 +487,6 @@ public Response getSupportedLanguagesWithResponse(RequestOptions req * text: String (Required) * script: String (Required) * } - * alignment (Optional): { - * proj: String (Required) - * } - * sentLen (Optional): { - * srcSentLen (Required): [ - * int (Required) - * ] - * transSentLen (Required): [ - * int (Required) - * ] - * } * } * ] * sourceText (Optional): { @@ -607,11 +497,6 @@ public Response getSupportedLanguagesWithResponse(RequestOptions req * } * * - * @param targetLanguages Specifies the language of the output text. The target language must be one of the - * supported languages included - * in the translation scope. For example, use to=de to translate to German. - * It's possible to translate to multiple languages simultaneously by repeating the parameter in the query string. - * For example, use to=de&to=it to translate to German and Italian. * @param body Defines the content of the request. * @param requestOptions The options to configure the HTTP request before HTTP client sends it. * @throws HttpResponseException thrown if the request is rejected by server. @@ -621,67 +506,15 @@ public Response getSupportedLanguagesWithResponse(RequestOptions req * @return the response body along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> translateWithResponseAsync(List targetLanguages, BinaryData body, - RequestOptions requestOptions) { + public Mono> translateWithResponseAsync(BinaryData body, RequestOptions requestOptions) { final String contentType = "application/json"; final String accept = "application/json"; - List targetLanguagesConverted - = targetLanguages.stream().map(item -> Objects.toString(item, "")).collect(Collectors.toList()); - return FluxUtil.withContext(context -> service.translate(this.getEndpoint(), targetLanguagesConverted, + return FluxUtil.withContext(context -> service.translate(this.getEndpoint(), this.getServiceVersion().getVersion(), contentType, accept, body, requestOptions, context)); } /** * Translate Text. - *

Query Parameters

- *
Header Parameters
- * - * - * - * - * - * - * - * - * - * - * - * - * - *
Query Parameters
NameTypeRequiredDescription
fromStringNoSpecifies the language of the input text. Find which languages are - * available to translate from by - * looking up supported languages using the translation scope. If the from parameter isn't specified, - * automatic language detection is applied to determine the source language. - * - * You must use the from parameter rather than autodetection when using the dynamic dictionary feature. - * Note: the dynamic dictionary feature is case-sensitive.
textTypeStringNoDefines whether the text being translated is plain text or - * HTML text. Any HTML needs to be a well-formed, - * complete element. Possible values are: plain (default) or html. Allowed values: "Plain", "Html".
categoryStringNoA string specifying the category (domain) of the translation. - * This parameter is used to get translations - * from a customized system built with Custom Translator. Add the Category ID from your Custom Translator - * project details to this parameter to use your deployed customized system. Default value is: general.
profanityActionStringNoSpecifies how profanities should be treated in - * translations. - * Possible values are: NoAction (default), Marked or Deleted. Allowed values: "NoAction", "Marked", - * "Deleted".
profanityMarkerStringNoSpecifies how profanities should be marked in - * translations. - * Possible values are: Asterisk (default) or Tag. . Allowed values: "Asterisk", "Tag".
includeAlignmentBooleanNoSpecifies whether to include alignment projection - * from source text to translated text. - * Possible values are: true or false (default).
includeSentenceLengthBooleanNoSpecifies whether to include sentence boundaries - * for the input text and the translated text. - * Possible values are: true or false (default).
suggestedFromStringNoSpecifies a fallback language if the language of the - * input text can't be identified. - * Language autodetection is applied when the from parameter is omitted. If detection fails, - * the suggestedFrom language will be assumed.
fromScriptStringNoSpecifies the script of the input text.
toScriptStringNoSpecifies the script of the translated text.
allowFallbackBooleanNoSpecifies that the service is allowed to fall back to a - * general system when a custom system doesn't exist. - * Possible values are: true (default) or false. - * - * allowFallback=false specifies that the translation should only use systems trained for the category specified - * by the request. If a translation for language X to language Y requires chaining through a pivot language E, - * then all the systems in the chain (X → E and E → Y) will need to be custom and have the same category. - * If no system is found with the specific category, the request will return a 400 status code. allowFallback=true - * specifies that the service is allowed to fall back to a general system when a custom system doesn't - * exist.
- * You can add these to a request with {@link RequestOptions#addQueryParam} *

Header Parameters

* * @@ -697,6 +530,31 @@ public Mono> translateWithResponseAsync(List target * [ * (Required){ * text: String (Required) + * script: String (Optional) + * language: String (Optional) + * textType: String(Plain/Html) (Optional) + * targets (Required): [ + * (Required){ + * language (Required): [ + * String (Required) + * ] + * script: String (Optional) + * profanityAction: String(NoAction/Marked/Deleted) (Optional) + * profanityMarker: String(Asterisk/Tag) (Optional) + * deploymentNameModel: String (Optional) + * allowFallback: Boolean (Optional) + * grade: String (Optional) + * tone: String (Optional) + * gender: String (Optional) + * adaptiveDatasetId: String (Optional) + * referenceTextPairs (Optional): [ + * (Optional){ + * referenceTextPairsSource: String (Required) + * referenceTextPairsTarget: String (Required) + * } + * ] + * } + * ] * } * ] * } @@ -720,17 +578,6 @@ public Mono> translateWithResponseAsync(List target * text: String (Required) * script: String (Required) * } - * alignment (Optional): { - * proj: String (Required) - * } - * sentLen (Optional): { - * srcSentLen (Required): [ - * int (Required) - * ] - * transSentLen (Required): [ - * int (Required) - * ] - * } * } * ] * sourceText (Optional): { @@ -741,11 +588,6 @@ public Mono> translateWithResponseAsync(List target * } * * - * @param targetLanguages Specifies the language of the output text. The target language must be one of the - * supported languages included - * in the translation scope. For example, use to=de to translate to German. - * It's possible to translate to multiple languages simultaneously by repeating the parameter in the query string. - * For example, use to=de&to=it to translate to German and Italian. * @param body Defines the content of the request. * @param requestOptions The options to configure the HTTP request before HTTP client sends it. * @throws HttpResponseException thrown if the request is rejected by server. @@ -755,14 +597,11 @@ public Mono> translateWithResponseAsync(List target * @return the response body along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response translateWithResponse(List targetLanguages, BinaryData body, - RequestOptions requestOptions) { + public Response translateWithResponse(BinaryData body, RequestOptions requestOptions) { final String contentType = "application/json"; final String accept = "application/json"; - List targetLanguagesConverted - = targetLanguages.stream().map(item -> Objects.toString(item, "")).collect(Collectors.toList()); - return service.translateSync(this.getEndpoint(), targetLanguagesConverted, - this.getServiceVersion().getVersion(), contentType, accept, body, requestOptions, Context.NONE); + return service.translateSync(this.getEndpoint(), this.getServiceVersion().getVersion(), contentType, accept, + body, requestOptions, Context.NONE); } /** @@ -887,417 +726,4 @@ public Response transliterateWithResponse(String language, String so return service.transliterateSync(this.getEndpoint(), language, sourceLanguageScript, targetLanguageScript, this.getServiceVersion().getVersion(), contentType, accept, body, requestOptions, Context.NONE); } - - /** - * Find Sentence Boundaries. - *

Query Parameters

- *
Header Parameters
- * - * - * - * - *
Query Parameters
NameTypeRequiredDescription
languageStringNoLanguage tag identifying the language of the input text. - * If a code isn't specified, automatic language detection will be applied.
scriptStringNoScript tag identifying the script used by the input text. - * If a script isn't specified, the default script of the language will be assumed.
- * You can add these to a request with {@link RequestOptions#addQueryParam} - *

Header Parameters

- * - * - * - * - *
Header Parameters
NameTypeRequiredDescription
X-ClientTraceIdStringNoA client-generated GUID to uniquely identify the - * request.
- * You can add these to a request with {@link RequestOptions#addHeader} - *

Request Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         text: String (Required)
-     *     }
-     * ]
-     * }
-     * 
- * - *

Response Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         detectedLanguage (Optional): {
-     *             language: String (Required)
-     *             score: double (Required)
-     *         }
-     *         sentLen (Required): [
-     *             int (Required)
-     *         ]
-     *     }
-     * ]
-     * }
-     * 
- * - * @param body Defines the content of the request. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the response body along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> findSentenceBoundariesWithResponseAsync(BinaryData body, - RequestOptions requestOptions) { - final String contentType = "application/json"; - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.findSentenceBoundaries(this.getEndpoint(), - this.getServiceVersion().getVersion(), contentType, accept, body, requestOptions, context)); - } - - /** - * Find Sentence Boundaries. - *

Query Parameters

- * - * - * - * - * - *
Query Parameters
NameTypeRequiredDescription
languageStringNoLanguage tag identifying the language of the input text. - * If a code isn't specified, automatic language detection will be applied.
scriptStringNoScript tag identifying the script used by the input text. - * If a script isn't specified, the default script of the language will be assumed.
- * You can add these to a request with {@link RequestOptions#addQueryParam} - *

Header Parameters

- * - * - * - * - *
Header Parameters
NameTypeRequiredDescription
X-ClientTraceIdStringNoA client-generated GUID to uniquely identify the - * request.
- * You can add these to a request with {@link RequestOptions#addHeader} - *

Request Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         text: String (Required)
-     *     }
-     * ]
-     * }
-     * 
- * - *

Response Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         detectedLanguage (Optional): {
-     *             language: String (Required)
-     *             score: double (Required)
-     *         }
-     *         sentLen (Required): [
-     *             int (Required)
-     *         ]
-     *     }
-     * ]
-     * }
-     * 
- * - * @param body Defines the content of the request. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the response body along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response findSentenceBoundariesWithResponse(BinaryData body, RequestOptions requestOptions) { - final String contentType = "application/json"; - final String accept = "application/json"; - return service.findSentenceBoundariesSync(this.getEndpoint(), this.getServiceVersion().getVersion(), - contentType, accept, body, requestOptions, Context.NONE); - } - - /** - * Lookup Dictionary Entries. - *

Header Parameters

- * - * - * - * - *
Header Parameters
NameTypeRequiredDescription
X-ClientTraceIdStringNoA client-generated GUID to uniquely identify the - * request.
- * You can add these to a request with {@link RequestOptions#addHeader} - *

Request Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         text: String (Required)
-     *     }
-     * ]
-     * }
-     * 
- * - *

Response Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         normalizedSource: String (Required)
-     *         displaySource: String (Required)
-     *         translations (Required): [
-     *              (Required){
-     *                 normalizedTarget: String (Required)
-     *                 displayTarget: String (Required)
-     *                 posTag: String (Required)
-     *                 confidence: double (Required)
-     *                 prefixWord: String (Required)
-     *                 backTranslations (Required): [
-     *                      (Required){
-     *                         normalizedText: String (Required)
-     *                         displayText: String (Required)
-     *                         numExamples: int (Required)
-     *                         frequencyCount: int (Required)
-     *                     }
-     *                 ]
-     *             }
-     *         ]
-     *     }
-     * ]
-     * }
-     * 
- * - * @param sourceLanguage Specifies the language of the input text. - * The source language must be one of the supported languages included in the dictionary scope. - * @param targetLanguage Specifies the language of the output text. - * The target language must be one of the supported languages included in the dictionary scope. - * @param body Defines the content of the request. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the response body along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> lookupDictionaryEntriesWithResponseAsync(String sourceLanguage, - String targetLanguage, BinaryData body, RequestOptions requestOptions) { - final String contentType = "application/json"; - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.lookupDictionaryEntries(this.getEndpoint(), sourceLanguage, - targetLanguage, this.getServiceVersion().getVersion(), contentType, accept, body, requestOptions, context)); - } - - /** - * Lookup Dictionary Entries. - *

Header Parameters

- * - * - * - * - *
Header Parameters
NameTypeRequiredDescription
X-ClientTraceIdStringNoA client-generated GUID to uniquely identify the - * request.
- * You can add these to a request with {@link RequestOptions#addHeader} - *

Request Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         text: String (Required)
-     *     }
-     * ]
-     * }
-     * 
- * - *

Response Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         normalizedSource: String (Required)
-     *         displaySource: String (Required)
-     *         translations (Required): [
-     *              (Required){
-     *                 normalizedTarget: String (Required)
-     *                 displayTarget: String (Required)
-     *                 posTag: String (Required)
-     *                 confidence: double (Required)
-     *                 prefixWord: String (Required)
-     *                 backTranslations (Required): [
-     *                      (Required){
-     *                         normalizedText: String (Required)
-     *                         displayText: String (Required)
-     *                         numExamples: int (Required)
-     *                         frequencyCount: int (Required)
-     *                     }
-     *                 ]
-     *             }
-     *         ]
-     *     }
-     * ]
-     * }
-     * 
- * - * @param sourceLanguage Specifies the language of the input text. - * The source language must be one of the supported languages included in the dictionary scope. - * @param targetLanguage Specifies the language of the output text. - * The target language must be one of the supported languages included in the dictionary scope. - * @param body Defines the content of the request. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the response body along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response lookupDictionaryEntriesWithResponse(String sourceLanguage, String targetLanguage, - BinaryData body, RequestOptions requestOptions) { - final String contentType = "application/json"; - final String accept = "application/json"; - return service.lookupDictionaryEntriesSync(this.getEndpoint(), sourceLanguage, targetLanguage, - this.getServiceVersion().getVersion(), contentType, accept, body, requestOptions, Context.NONE); - } - - /** - * Lookup Dictionary Examples. - *

Header Parameters

- * - * - * - * - *
Header Parameters
NameTypeRequiredDescription
X-ClientTraceIdStringNoA client-generated GUID to uniquely identify the - * request.
- * You can add these to a request with {@link RequestOptions#addHeader} - *

Request Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         text: String (Required)
-     *         translation: String (Required)
-     *     }
-     * ]
-     * }
-     * 
- * - *

Response Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         normalizedSource: String (Required)
-     *         normalizedTarget: String (Required)
-     *         examples (Required): [
-     *              (Required){
-     *                 sourcePrefix: String (Required)
-     *                 sourceTerm: String (Required)
-     *                 sourceSuffix: String (Required)
-     *                 targetPrefix: String (Required)
-     *                 targetTerm: String (Required)
-     *                 targetSuffix: String (Required)
-     *             }
-     *         ]
-     *     }
-     * ]
-     * }
-     * 
- * - * @param sourceLanguage Specifies the language of the input text. - * The source language must be one of the supported languages included in the dictionary scope. - * @param targetLanguage Specifies the language of the output text. - * The target language must be one of the supported languages included in the dictionary scope. - * @param body Defines the content of the request. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the response body along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> lookupDictionaryExamplesWithResponseAsync(String sourceLanguage, - String targetLanguage, BinaryData body, RequestOptions requestOptions) { - final String contentType = "application/json"; - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.lookupDictionaryExamples(this.getEndpoint(), sourceLanguage, - targetLanguage, this.getServiceVersion().getVersion(), contentType, accept, body, requestOptions, context)); - } - - /** - * Lookup Dictionary Examples. - *

Header Parameters

- * - * - * - * - *
Header Parameters
NameTypeRequiredDescription
X-ClientTraceIdStringNoA client-generated GUID to uniquely identify the - * request.
- * You can add these to a request with {@link RequestOptions#addHeader} - *

Request Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         text: String (Required)
-     *         translation: String (Required)
-     *     }
-     * ]
-     * }
-     * 
- * - *

Response Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         normalizedSource: String (Required)
-     *         normalizedTarget: String (Required)
-     *         examples (Required): [
-     *              (Required){
-     *                 sourcePrefix: String (Required)
-     *                 sourceTerm: String (Required)
-     *                 sourceSuffix: String (Required)
-     *                 targetPrefix: String (Required)
-     *                 targetTerm: String (Required)
-     *                 targetSuffix: String (Required)
-     *             }
-     *         ]
-     *     }
-     * ]
-     * }
-     * 
- * - * @param sourceLanguage Specifies the language of the input text. - * The source language must be one of the supported languages included in the dictionary scope. - * @param targetLanguage Specifies the language of the output text. - * The target language must be one of the supported languages included in the dictionary scope. - * @param body Defines the content of the request. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the response body along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response lookupDictionaryExamplesWithResponse(String sourceLanguage, String targetLanguage, - BinaryData body, RequestOptions requestOptions) { - final String contentType = "application/json"; - final String accept = "application/json"; - return service.lookupDictionaryExamplesSync(this.getEndpoint(), sourceLanguage, targetLanguage, - this.getServiceVersion().getVersion(), contentType, accept, body, requestOptions, Context.NONE); - } } diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/ReferenceSentencePair.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/ReferenceSentencePair.java new file mode 100644 index 000000000000..b6425bb8bda6 --- /dev/null +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/ReferenceSentencePair.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.translation.text.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Reference sentence pair. + */ +@Immutable +public final class ReferenceSentencePair implements JsonSerializable { + /* + * Source reference sentence. + */ + @Generated + private final String referenceTextPairsSource; + + /* + * Target reference sentence. + */ + @Generated + private final String referenceTextPairsTarget; + + /** + * Creates an instance of ReferenceSentencePair class. + * + * @param referenceTextPairsSource the referenceTextPairsSource value to set. + * @param referenceTextPairsTarget the referenceTextPairsTarget value to set. + */ + @Generated + public ReferenceSentencePair(String referenceTextPairsSource, String referenceTextPairsTarget) { + this.referenceTextPairsSource = referenceTextPairsSource; + this.referenceTextPairsTarget = referenceTextPairsTarget; + } + + /** + * Get the referenceTextPairsSource property: Source reference sentence. + * + * @return the referenceTextPairsSource value. + */ + @Generated + public String getReferenceTextPairsSource() { + return this.referenceTextPairsSource; + } + + /** + * Get the referenceTextPairsTarget property: Target reference sentence. + * + * @return the referenceTextPairsTarget value. + */ + @Generated + public String getReferenceTextPairsTarget() { + return this.referenceTextPairsTarget; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("referenceTextPairsSource", this.referenceTextPairsSource); + jsonWriter.writeStringField("referenceTextPairsTarget", this.referenceTextPairsTarget); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ReferenceSentencePair from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ReferenceSentencePair if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ReferenceSentencePair. + */ + @Generated + public static ReferenceSentencePair fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String referenceTextPairsSource = null; + String referenceTextPairsTarget = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("referenceTextPairsSource".equals(fieldName)) { + referenceTextPairsSource = reader.getString(); + } else if ("referenceTextPairsTarget".equals(fieldName)) { + referenceTextPairsTarget = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new ReferenceSentencePair(referenceTextPairsSource, referenceTextPairsTarget); + }); + } +} diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslateBody.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslateBody.java new file mode 100644 index 000000000000..57be1f6c8426 --- /dev/null +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslateBody.java @@ -0,0 +1,230 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.translation.text.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Element containing the text for translation. + */ +@Fluent +public final class TranslateBody extends InputTextItem { + /* + * Text to translate. + */ + @Generated + private final String text; + + /* + * Specifies the script of the input text. + */ + @Generated + private String script; + + /* + * Specifies the language of the input text. Find which languages are available to translate by + * looking up supported languages using the translation scope. If the language parameter isn't + * specified, automatic language detection is applied to determine the source language. + * + * You must use the language parameter rather than autodetection when using the dynamic dictionary feature. + * Note: the dynamic dictionary feature is case-sensitive. + */ + @Generated + private String language; + + /* + * Defines whether the text being translated is plain text or HTML text. Any HTML needs to be a well-formed, + * complete element. Possible values are: plain (default) or html. + */ + @Generated + private TextType textType; + + /* + * Translation target parameters. + */ + @Generated + private final List targets; + + /** + * Creates an instance of TranslateBody class. + * + * @param text the text value to set. + * @param targets the targets value to set. + */ + @Generated + public TranslateBody(String text, List targets) { + super(text); + this.targets = targets; + } + + /** + * Get the text property: Text to translate. + * + * @return the text value. + */ + @Generated + public String getText() { + return this.text; + } + + /** + * Get the script property: Specifies the script of the input text. + * + * @return the script value. + */ + @Generated + public String getScript() { + return this.script; + } + + /** + * Set the script property: Specifies the script of the input text. + * + * @param script the script value to set. + * @return the TranslateBody object itself. + */ + @Generated + public TranslateBody setScript(String script) { + this.script = script; + return this; + } + + /** + * Get the language property: Specifies the language of the input text. Find which languages are available to + * translate by + * looking up supported languages using the translation scope. If the language parameter isn't + * specified, automatic language detection is applied to determine the source language. + * + * You must use the language parameter rather than autodetection when using the dynamic dictionary feature. + * Note: the dynamic dictionary feature is case-sensitive. + * + * @return the language value. + */ + @Generated + public String getLanguage() { + return this.language; + } + + /** + * Set the language property: Specifies the language of the input text. Find which languages are available to + * translate by + * looking up supported languages using the translation scope. If the language parameter isn't + * specified, automatic language detection is applied to determine the source language. + * + * You must use the language parameter rather than autodetection when using the dynamic dictionary feature. + * Note: the dynamic dictionary feature is case-sensitive. + * + * @param language the language value to set. + * @return the TranslateBody object itself. + */ + @Generated + public TranslateBody setLanguage(String language) { + this.language = language; + return this; + } + + /** + * Get the textType property: Defines whether the text being translated is plain text or HTML text. Any HTML needs + * to be a well-formed, + * complete element. Possible values are: plain (default) or html. + * + * @return the textType value. + */ + @Generated + public TextType getTextType() { + return this.textType; + } + + /** + * Set the textType property: Defines whether the text being translated is plain text or HTML text. Any HTML needs + * to be a well-formed, + * complete element. Possible values are: plain (default) or html. + * + * @param textType the textType value to set. + * @return the TranslateBody object itself. + */ + @Generated + public TranslateBody setTextType(TextType textType) { + this.textType = textType; + return this; + } + + /** + * Get the targets property: Translation target parameters. + * + * @return the targets value. + */ + @Generated + public List getTargets() { + return this.targets; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("text", getText()); + jsonWriter.writeStringField("text", this.text); + jsonWriter.writeArrayField("targets", this.targets, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("script", this.script); + jsonWriter.writeStringField("language", this.language); + jsonWriter.writeStringField("textType", this.textType == null ? null : this.textType.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TranslateBody from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TranslateBody if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the TranslateBody. + */ + @Generated + public static TranslateBody fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String text = null; + String text = null; + List targets = null; + String script = null; + String language = null; + TextType textType = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("text".equals(fieldName)) { + text = reader.getString(); + } else if ("targets".equals(fieldName)) { + targets = reader.readArray(reader1 -> TranslateTarget.fromJson(reader1)); + } else if ("script".equals(fieldName)) { + script = reader.getString(); + } else if ("language".equals(fieldName)) { + language = reader.getString(); + } else if ("textType".equals(fieldName)) { + textType = TextType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + TranslateBody deserializedTranslateBody = new TranslateBody(text, text, targets); + deserializedTranslateBody.script = script; + deserializedTranslateBody.language = language; + deserializedTranslateBody.textType = textType; + + return deserializedTranslateBody; + }); + } +} diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslateTarget.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslateTarget.java new file mode 100644 index 000000000000..464ad87993fc --- /dev/null +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslateTarget.java @@ -0,0 +1,482 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.translation.text.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Translate targets parameters. + */ +@Fluent +public final class TranslateTarget implements JsonSerializable { + /* + * Specifies the language of the output text. The target language must be one of the supported languages included + * in the translation scope. It's possible to translate to multiple languages simultaneously by including + * multiple string values in the targetsLanguage array. + */ + @Generated + private final List language; + + /* + * Specifies the script of the translated text. + */ + @Generated + private String script; + + /* + * Specifies how profanities should be treated in translations. + * Possible values are: NoAction (default), Marked or Deleted. + */ + @Generated + private ProfanityAction profanityAction; + + /* + * Specifies how profanities should be marked in translations. + * Possible values are: Asterisk (default) or Tag. + */ + @Generated + private ProfanityMarker profanityMarker; + + /* + * Default is ‘general’, which uses NMT system. + * ‘abc-inc-gpt-4o’, and ‘abc-inc-gpt-4o-mini’ are examples of deployment names which use GPT-4o uses or + * GPT-4o-mini model. ‘gpt-4o’ uses GPT-4o model. + * + * ‘’ uses the custom NMT model tuned by customer. + * ‘best’ system determines which is the best model to use for the request. This intelligence could be introduced + * in future. Customer should have deployed it in their resource. + */ + @Generated + private String deploymentNameModel; + + /* + * In the case where a custom system is being used, specifies that the service is allowed to fall back to a + * general system when a custom system doesn't exist. + * In the case where a Large Language Model is being used, specifies that the service is allowed to fall + * back to a Small Language Model if an error occurs. + * Possible values are: true (default) or false. + * + * allowFallback=false specifies that the translation should only use systems trained for the category specified + * by the request. If a translation for language X to language Y requires chaining through a pivot language E, + * then all the systems in the chain (X → E and E → Y) will need to be custom and have the same category. + * If no system is found with the specific category, the request will return a 400 status code. allowFallback=true + * specifies that the service is allowed to fall back to a general system when a custom system doesn't exist. + */ + @Generated + private Boolean allowFallback; + + /* + * Defines complexity of LLM prompts to provide high accuracy translation. + */ + @Generated + private String grade; + + /* + * Desired tone of target translation. + */ + @Generated + private String tone; + + /* + * Desired gender of target translation. + */ + @Generated + private String gender; + + /* + * Reference dataset ID having sentence pair to generate adaptive customized translation. + */ + @Generated + private String adaptiveDatasetId; + + /* + * Reference sentence pairs to generate adaptive results. + */ + @Generated + private List referenceTextPairs; + + /** + * Creates an instance of TranslateTarget class. + * + * @param language the language value to set. + */ + @Generated + public TranslateTarget(List language) { + this.language = language; + } + + /** + * Get the language property: Specifies the language of the output text. The target language must be one of the + * supported languages included + * in the translation scope. It's possible to translate to multiple languages simultaneously by including + * multiple string values in the targetsLanguage array. + * + * @return the language value. + */ + @Generated + public List getLanguage() { + return this.language; + } + + /** + * Get the script property: Specifies the script of the translated text. + * + * @return the script value. + */ + @Generated + public String getScript() { + return this.script; + } + + /** + * Set the script property: Specifies the script of the translated text. + * + * @param script the script value to set. + * @return the TranslateTarget object itself. + */ + @Generated + public TranslateTarget setScript(String script) { + this.script = script; + return this; + } + + /** + * Get the profanityAction property: Specifies how profanities should be treated in translations. + * Possible values are: NoAction (default), Marked or Deleted. + * + * @return the profanityAction value. + */ + @Generated + public ProfanityAction getProfanityAction() { + return this.profanityAction; + } + + /** + * Set the profanityAction property: Specifies how profanities should be treated in translations. + * Possible values are: NoAction (default), Marked or Deleted. + * + * @param profanityAction the profanityAction value to set. + * @return the TranslateTarget object itself. + */ + @Generated + public TranslateTarget setProfanityAction(ProfanityAction profanityAction) { + this.profanityAction = profanityAction; + return this; + } + + /** + * Get the profanityMarker property: Specifies how profanities should be marked in translations. + * Possible values are: Asterisk (default) or Tag. + * + * @return the profanityMarker value. + */ + @Generated + public ProfanityMarker getProfanityMarker() { + return this.profanityMarker; + } + + /** + * Set the profanityMarker property: Specifies how profanities should be marked in translations. + * Possible values are: Asterisk (default) or Tag. + * + * @param profanityMarker the profanityMarker value to set. + * @return the TranslateTarget object itself. + */ + @Generated + public TranslateTarget setProfanityMarker(ProfanityMarker profanityMarker) { + this.profanityMarker = profanityMarker; + return this; + } + + /** + * Get the deploymentNameModel property: Default is ‘general’, which uses NMT system. + * ‘abc-inc-gpt-4o’, and ‘abc-inc-gpt-4o-mini’ are examples of deployment names which use GPT-4o uses or + * GPT-4o-mini model. ‘gpt-4o’ uses GPT-4o model. + * + * ‘<custom model id>’ uses the custom NMT model tuned by customer. + * ‘best’ system determines which is the best model to use for the request. This intelligence could be introduced + * in future. Customer should have deployed it in their resource. + * + * @return the deploymentNameModel value. + */ + @Generated + public String getDeploymentNameModel() { + return this.deploymentNameModel; + } + + /** + * Set the deploymentNameModel property: Default is ‘general’, which uses NMT system. + * ‘abc-inc-gpt-4o’, and ‘abc-inc-gpt-4o-mini’ are examples of deployment names which use GPT-4o uses or + * GPT-4o-mini model. ‘gpt-4o’ uses GPT-4o model. + * + * ‘<custom model id>’ uses the custom NMT model tuned by customer. + * ‘best’ system determines which is the best model to use for the request. This intelligence could be introduced + * in future. Customer should have deployed it in their resource. + * + * @param deploymentNameModel the deploymentNameModel value to set. + * @return the TranslateTarget object itself. + */ + @Generated + public TranslateTarget setDeploymentNameModel(String deploymentNameModel) { + this.deploymentNameModel = deploymentNameModel; + return this; + } + + /** + * Get the allowFallback property: In the case where a custom system is being used, specifies that the service is + * allowed to fall back to a + * general system when a custom system doesn't exist. + * In the case where a Large Language Model is being used, specifies that the service is allowed to fall + * back to a Small Language Model if an error occurs. + * Possible values are: true (default) or false. + * + * allowFallback=false specifies that the translation should only use systems trained for the category specified + * by the request. If a translation for language X to language Y requires chaining through a pivot language E, + * then all the systems in the chain (X → E and E → Y) will need to be custom and have the same category. + * If no system is found with the specific category, the request will return a 400 status code. allowFallback=true + * specifies that the service is allowed to fall back to a general system when a custom system doesn't exist. + * + * @return the allowFallback value. + */ + @Generated + public Boolean isAllowFallback() { + return this.allowFallback; + } + + /** + * Set the allowFallback property: In the case where a custom system is being used, specifies that the service is + * allowed to fall back to a + * general system when a custom system doesn't exist. + * In the case where a Large Language Model is being used, specifies that the service is allowed to fall + * back to a Small Language Model if an error occurs. + * Possible values are: true (default) or false. + * + * allowFallback=false specifies that the translation should only use systems trained for the category specified + * by the request. If a translation for language X to language Y requires chaining through a pivot language E, + * then all the systems in the chain (X → E and E → Y) will need to be custom and have the same category. + * If no system is found with the specific category, the request will return a 400 status code. allowFallback=true + * specifies that the service is allowed to fall back to a general system when a custom system doesn't exist. + * + * @param allowFallback the allowFallback value to set. + * @return the TranslateTarget object itself. + */ + @Generated + public TranslateTarget setAllowFallback(Boolean allowFallback) { + this.allowFallback = allowFallback; + return this; + } + + /** + * Get the grade property: Defines complexity of LLM prompts to provide high accuracy translation. + * + * @return the grade value. + */ + @Generated + public String getGrade() { + return this.grade; + } + + /** + * Set the grade property: Defines complexity of LLM prompts to provide high accuracy translation. + * + * @param grade the grade value to set. + * @return the TranslateTarget object itself. + */ + @Generated + public TranslateTarget setGrade(String grade) { + this.grade = grade; + return this; + } + + /** + * Get the tone property: Desired tone of target translation. + * + * @return the tone value. + */ + @Generated + public String getTone() { + return this.tone; + } + + /** + * Set the tone property: Desired tone of target translation. + * + * @param tone the tone value to set. + * @return the TranslateTarget object itself. + */ + @Generated + public TranslateTarget setTone(String tone) { + this.tone = tone; + return this; + } + + /** + * Get the gender property: Desired gender of target translation. + * + * @return the gender value. + */ + @Generated + public String getGender() { + return this.gender; + } + + /** + * Set the gender property: Desired gender of target translation. + * + * @param gender the gender value to set. + * @return the TranslateTarget object itself. + */ + @Generated + public TranslateTarget setGender(String gender) { + this.gender = gender; + return this; + } + + /** + * Get the adaptiveDatasetId property: Reference dataset ID having sentence pair to generate adaptive customized + * translation. + * + * @return the adaptiveDatasetId value. + */ + @Generated + public String getAdaptiveDatasetId() { + return this.adaptiveDatasetId; + } + + /** + * Set the adaptiveDatasetId property: Reference dataset ID having sentence pair to generate adaptive customized + * translation. + * + * @param adaptiveDatasetId the adaptiveDatasetId value to set. + * @return the TranslateTarget object itself. + */ + @Generated + public TranslateTarget setAdaptiveDatasetId(String adaptiveDatasetId) { + this.adaptiveDatasetId = adaptiveDatasetId; + return this; + } + + /** + * Get the referenceTextPairs property: Reference sentence pairs to generate adaptive results. + * + * @return the referenceTextPairs value. + */ + @Generated + public List getReferenceTextPairs() { + return this.referenceTextPairs; + } + + /** + * Set the referenceTextPairs property: Reference sentence pairs to generate adaptive results. + * + * @param referenceTextPairs the referenceTextPairs value to set. + * @return the TranslateTarget object itself. + */ + @Generated + public TranslateTarget setReferenceTextPairs(List referenceTextPairs) { + this.referenceTextPairs = referenceTextPairs; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("language", this.language, (writer, element) -> writer.writeString(element)); + jsonWriter.writeStringField("script", this.script); + jsonWriter.writeStringField("profanityAction", + this.profanityAction == null ? null : this.profanityAction.toString()); + jsonWriter.writeStringField("profanityMarker", + this.profanityMarker == null ? null : this.profanityMarker.toString()); + jsonWriter.writeStringField("deploymentNameModel", this.deploymentNameModel); + jsonWriter.writeBooleanField("allowFallback", this.allowFallback); + jsonWriter.writeStringField("grade", this.grade); + jsonWriter.writeStringField("tone", this.tone); + jsonWriter.writeStringField("gender", this.gender); + jsonWriter.writeStringField("adaptiveDatasetId", this.adaptiveDatasetId); + jsonWriter.writeArrayField("referenceTextPairs", this.referenceTextPairs, + (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TranslateTarget from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TranslateTarget if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the TranslateTarget. + */ + @Generated + public static TranslateTarget fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List language = null; + String script = null; + ProfanityAction profanityAction = null; + ProfanityMarker profanityMarker = null; + String deploymentNameModel = null; + Boolean allowFallback = null; + String grade = null; + String tone = null; + String gender = null; + String adaptiveDatasetId = null; + List referenceTextPairs = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("language".equals(fieldName)) { + language = reader.readArray(reader1 -> reader1.getString()); + } else if ("script".equals(fieldName)) { + script = reader.getString(); + } else if ("profanityAction".equals(fieldName)) { + profanityAction = ProfanityAction.fromString(reader.getString()); + } else if ("profanityMarker".equals(fieldName)) { + profanityMarker = ProfanityMarker.fromString(reader.getString()); + } else if ("deploymentNameModel".equals(fieldName)) { + deploymentNameModel = reader.getString(); + } else if ("allowFallback".equals(fieldName)) { + allowFallback = reader.getNullable(JsonReader::getBoolean); + } else if ("grade".equals(fieldName)) { + grade = reader.getString(); + } else if ("tone".equals(fieldName)) { + tone = reader.getString(); + } else if ("gender".equals(fieldName)) { + gender = reader.getString(); + } else if ("adaptiveDatasetId".equals(fieldName)) { + adaptiveDatasetId = reader.getString(); + } else if ("referenceTextPairs".equals(fieldName)) { + referenceTextPairs = reader.readArray(reader1 -> ReferenceSentencePair.fromJson(reader1)); + } else { + reader.skipChildren(); + } + } + TranslateTarget deserializedTranslateTarget = new TranslateTarget(language); + deserializedTranslateTarget.script = script; + deserializedTranslateTarget.profanityAction = profanityAction; + deserializedTranslateTarget.profanityMarker = profanityMarker; + deserializedTranslateTarget.deploymentNameModel = deploymentNameModel; + deserializedTranslateTarget.allowFallback = allowFallback; + deserializedTranslateTarget.grade = grade; + deserializedTranslateTarget.tone = tone; + deserializedTranslateTarget.gender = gender; + deserializedTranslateTarget.adaptiveDatasetId = adaptiveDatasetId; + deserializedTranslateTarget.referenceTextPairs = referenceTextPairs; + + return deserializedTranslateTarget; + }); + } +} diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslationText.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslationText.java index 9c667b5a147f..a1edac48bea5 100644 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslationText.java +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslationText.java @@ -29,18 +29,6 @@ public final class TranslationText implements JsonSerializable @Generated private TransliteratedText transliteration; - /* - * Alignment information. - */ - @Generated - private TranslatedTextAlignment alignment; - - /* - * Sentence boundaries in the input and output texts. - */ - @Generated - private SentenceBoundaries sentenceBoundaries; - /** * Creates an instance of TranslationText class. * @@ -84,26 +72,6 @@ public TransliteratedText getTransliteration() { return this.transliteration; } - /** - * Get the alignment property: Alignment information. - * - * @return the alignment value. - */ - @Generated - public TranslatedTextAlignment getAlignment() { - return this.alignment; - } - - /** - * Get the sentenceBoundaries property: Sentence boundaries in the input and output texts. - * - * @return the sentenceBoundaries value. - */ - @Generated - public SentenceBoundaries getSentenceBoundaries() { - return this.sentenceBoundaries; - } - /* * A string representing the language code of the target language. */ @@ -120,8 +88,6 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStringField("to", this.targetLanguage); jsonWriter.writeStringField("text", this.text); jsonWriter.writeJsonField("transliteration", this.transliteration); - jsonWriter.writeJsonField("alignment", this.alignment); - jsonWriter.writeJsonField("sentLen", this.sentenceBoundaries); return jsonWriter.writeEndObject(); } @@ -140,8 +106,6 @@ public static TranslationText fromJson(JsonReader jsonReader) throws IOException String targetLanguage = null; String text = null; TransliteratedText transliteration = null; - TranslatedTextAlignment alignment = null; - SentenceBoundaries sentenceBoundaries = null; while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); @@ -151,18 +115,12 @@ public static TranslationText fromJson(JsonReader jsonReader) throws IOException text = reader.getString(); } else if ("transliteration".equals(fieldName)) { transliteration = TransliteratedText.fromJson(reader); - } else if ("alignment".equals(fieldName)) { - alignment = TranslatedTextAlignment.fromJson(reader); - } else if ("sentLen".equals(fieldName)) { - sentenceBoundaries = SentenceBoundaries.fromJson(reader); } else { reader.skipChildren(); } } TranslationText deserializedTranslationText = new TranslationText(targetLanguage, text); deserializedTranslationText.transliteration = transliteration; - deserializedTranslationText.alignment = alignment; - deserializedTranslationText.sentenceBoundaries = sentenceBoundaries; return deserializedTranslationText; }); } diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/package-info.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/package-info.java index b1a9c262309d..7cd6ccf90652 100644 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/package-info.java +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/package-info.java @@ -19,10 +19,6 @@ * * 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. * */ package com.azure.ai.translation.text.models; diff --git a/sdk/translation/azure-ai-translation-text/src/main/resources/META-INF/azure-ai-translation-text_apiview_properties.json b/sdk/translation/azure-ai-translation-text/src/main/resources/META-INF/azure-ai-translation-text_apiview_properties.json index fb99b1295b77..bec22582d04a 100644 --- a/sdk/translation/azure-ai-translation-text/src/main/resources/META-INF/azure-ai-translation-text_apiview_properties.json +++ b/sdk/translation/azure-ai-translation-text/src/main/resources/META-INF/azure-ai-translation-text_apiview_properties.json @@ -2,52 +2,34 @@ "flavor": "azure", "CrossLanguageDefinitionId": { "com.azure.ai.translation.text.TextTranslationAsyncClient": "TextTranslation", - "com.azure.ai.translation.text.TextTranslationAsyncClient.findSentenceBoundaries": "TextTranslation.findSentenceBoundaries", - "com.azure.ai.translation.text.TextTranslationAsyncClient.findSentenceBoundariesWithResponse": "TextTranslation.findSentenceBoundaries", "com.azure.ai.translation.text.TextTranslationAsyncClient.getSupportedLanguages": "TextTranslation.getSupportedLanguages", "com.azure.ai.translation.text.TextTranslationAsyncClient.getSupportedLanguagesWithResponse": "TextTranslation.getSupportedLanguages", - "com.azure.ai.translation.text.TextTranslationAsyncClient.lookupDictionaryEntries": "TextTranslation.lookupDictionaryEntries", - "com.azure.ai.translation.text.TextTranslationAsyncClient.lookupDictionaryEntriesWithResponse": "TextTranslation.lookupDictionaryEntries", - "com.azure.ai.translation.text.TextTranslationAsyncClient.lookupDictionaryExamples": "TextTranslation.lookupDictionaryExamples", - "com.azure.ai.translation.text.TextTranslationAsyncClient.lookupDictionaryExamplesWithResponse": "TextTranslation.lookupDictionaryExamples", "com.azure.ai.translation.text.TextTranslationAsyncClient.translate": "TextTranslation.translate", "com.azure.ai.translation.text.TextTranslationAsyncClient.translateWithResponse": "TextTranslation.translate", "com.azure.ai.translation.text.TextTranslationAsyncClient.transliterate": "TextTranslation.transliterate", "com.azure.ai.translation.text.TextTranslationAsyncClient.transliterateWithResponse": "TextTranslation.transliterate", "com.azure.ai.translation.text.TextTranslationClient": "TextTranslation", - "com.azure.ai.translation.text.TextTranslationClient.findSentenceBoundaries": "TextTranslation.findSentenceBoundaries", - "com.azure.ai.translation.text.TextTranslationClient.findSentenceBoundariesWithResponse": "TextTranslation.findSentenceBoundaries", "com.azure.ai.translation.text.TextTranslationClient.getSupportedLanguages": "TextTranslation.getSupportedLanguages", "com.azure.ai.translation.text.TextTranslationClient.getSupportedLanguagesWithResponse": "TextTranslation.getSupportedLanguages", - "com.azure.ai.translation.text.TextTranslationClient.lookupDictionaryEntries": "TextTranslation.lookupDictionaryEntries", - "com.azure.ai.translation.text.TextTranslationClient.lookupDictionaryEntriesWithResponse": "TextTranslation.lookupDictionaryEntries", - "com.azure.ai.translation.text.TextTranslationClient.lookupDictionaryExamples": "TextTranslation.lookupDictionaryExamples", - "com.azure.ai.translation.text.TextTranslationClient.lookupDictionaryExamplesWithResponse": "TextTranslation.lookupDictionaryExamples", "com.azure.ai.translation.text.TextTranslationClient.translate": "TextTranslation.translate", "com.azure.ai.translation.text.TextTranslationClient.translateWithResponse": "TextTranslation.translate", "com.azure.ai.translation.text.TextTranslationClient.transliterate": "TextTranslation.transliterate", "com.azure.ai.translation.text.TextTranslationClient.transliterateWithResponse": "TextTranslation.transliterate", "com.azure.ai.translation.text.TextTranslationClientBuilder": "TextTranslation", - "com.azure.ai.translation.text.models.BackTranslation": "TextTranslation.BackTranslation", - "com.azure.ai.translation.text.models.BreakSentenceItem": "TextTranslation.BreakSentenceItem", "com.azure.ai.translation.text.models.DetectedLanguage": "TextTranslation.DetectedLanguage", - "com.azure.ai.translation.text.models.DictionaryExample": "TextTranslation.DictionaryExample", - "com.azure.ai.translation.text.models.DictionaryExampleItem": "TextTranslation.DictionaryExampleItem", - "com.azure.ai.translation.text.models.DictionaryExampleTextItem": "TextTranslation.DictionaryExampleTextItem", - "com.azure.ai.translation.text.models.DictionaryLookupItem": "TextTranslation.DictionaryLookupItem", - "com.azure.ai.translation.text.models.DictionaryTranslation": "TextTranslation.DictionaryTranslation", "com.azure.ai.translation.text.models.GetSupportedLanguagesResult": "TextTranslation.GetSupportedLanguagesResult", "com.azure.ai.translation.text.models.InputTextItem": "TextTranslation.InputTextItem", "com.azure.ai.translation.text.models.LanguageDirectionality": "TextTranslation.LanguageDirectionality", "com.azure.ai.translation.text.models.LanguageScript": "TextTranslation.LanguageScript", "com.azure.ai.translation.text.models.ProfanityAction": "TextTranslation.ProfanityAction", "com.azure.ai.translation.text.models.ProfanityMarker": "TextTranslation.ProfanityMarker", - "com.azure.ai.translation.text.models.SentenceBoundaries": "TextTranslation.SentenceBoundaries", + "com.azure.ai.translation.text.models.ReferenceSentencePair": "TextTranslation.ReferenceSentencePair", "com.azure.ai.translation.text.models.SourceDictionaryLanguage": "TextTranslation.SourceDictionaryLanguage", "com.azure.ai.translation.text.models.SourceText": "TextTranslation.SourceText", "com.azure.ai.translation.text.models.TargetDictionaryLanguage": "TextTranslation.TargetDictionaryLanguage", "com.azure.ai.translation.text.models.TextType": "TextTranslation.TextType", - "com.azure.ai.translation.text.models.TranslatedTextAlignment": "TextTranslation.TranslatedTextAlignment", + "com.azure.ai.translation.text.models.TranslateBody": "TextTranslation.TranslateBody", + "com.azure.ai.translation.text.models.TranslateTarget": "TextTranslation.TranslateTarget", "com.azure.ai.translation.text.models.TranslatedTextItem": "TextTranslation.TranslatedTextItem", "com.azure.ai.translation.text.models.TranslationLanguage": "TextTranslation.TranslationLanguage", "com.azure.ai.translation.text.models.TranslationText": "TextTranslation.TranslationText", diff --git a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/generated/GetsTheSetOfLanguagesCurrentlySupportedByOtherOperationsOfTheTranslator.java b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/generated/GetsTheSetOfLanguagesCurrentlySupportedByOtherOperationsOfTheTranslator.java new file mode 100644 index 000000000000..544a2851b373 --- /dev/null +++ b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/generated/GetsTheSetOfLanguagesCurrentlySupportedByOtherOperationsOfTheTranslator.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.translation.text.generated; + +import com.azure.ai.translation.text.TextTranslationClient; +import com.azure.ai.translation.text.TextTranslationClientBuilder; +import com.azure.ai.translation.text.models.GetSupportedLanguagesResult; +import com.azure.core.util.Configuration; + +public class GetsTheSetOfLanguagesCurrentlySupportedByOtherOperationsOfTheTranslator { + public static void main(String[] args) { + TextTranslationClient textTranslationClient + = new TextTranslationClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.ai.translation.text.generated.getsupportedlanguages.getsthesetoflanguagescurrentlysupportedbyotheroperationsofthetranslator + GetSupportedLanguagesResult response = textTranslationClient.getSupportedLanguages("kayfnugjec", + "translation,transliteration,dictionary", "en", "fpnhruttllvc"); + // END:com.azure.ai.translation.text.generated.getsupportedlanguages.getsthesetoflanguagescurrentlysupportedbyotheroperationsofthetranslator + } +} diff --git a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/generated/GetsTheSetOfLanguagesCurrentlySupportedByOtherOperationsOfTheTranslatorWithMinimumProperties.java b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/generated/GetsTheSetOfLanguagesCurrentlySupportedByOtherOperationsOfTheTranslatorWithMinimumProperties.java new file mode 100644 index 000000000000..1688a848debc --- /dev/null +++ b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/generated/GetsTheSetOfLanguagesCurrentlySupportedByOtherOperationsOfTheTranslatorWithMinimumProperties.java @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.translation.text.generated; + +import com.azure.ai.translation.text.TextTranslationClient; +import com.azure.ai.translation.text.TextTranslationClientBuilder; +import com.azure.ai.translation.text.models.GetSupportedLanguagesResult; +import com.azure.core.util.Configuration; + +public class GetsTheSetOfLanguagesCurrentlySupportedByOtherOperationsOfTheTranslatorWithMinimumProperties { + public static void main(String[] args) { + TextTranslationClient textTranslationClient + = new TextTranslationClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.ai.translation.text.generated.getsupportedlanguages.getsthesetoflanguagescurrentlysupportedbyotheroperationsofthetranslatorwithminimumproperties + GetSupportedLanguagesResult response = textTranslationClient.getSupportedLanguages(null, null, null, null); + // END:com.azure.ai.translation.text.generated.getsupportedlanguages.getsthesetoflanguagescurrentlysupportedbyotheroperationsofthetranslatorwithminimumproperties + } +} diff --git a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/generated/TranslateText.java b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/generated/TranslateText.java new file mode 100644 index 000000000000..6ab1df164908 --- /dev/null +++ b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/generated/TranslateText.java @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.translation.text.generated; + +import com.azure.ai.translation.text.TextTranslationClient; +import com.azure.ai.translation.text.TextTranslationClientBuilder; +import com.azure.ai.translation.text.models.ProfanityAction; +import com.azure.ai.translation.text.models.ProfanityMarker; +import com.azure.ai.translation.text.models.ReferenceSentencePair; +import com.azure.ai.translation.text.models.TextType; +import com.azure.ai.translation.text.models.TranslateBody; +import com.azure.ai.translation.text.models.TranslateTarget; +import com.azure.ai.translation.text.models.TranslatedTextItem; +import com.azure.core.util.Configuration; +import java.util.Arrays; +import java.util.List; + +public class TranslateText { + public static void main(String[] args) { + TextTranslationClient textTranslationClient + = new TextTranslationClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.ai.translation.text.generated.translate.translatetext + List response + = textTranslationClient + .translate( + Arrays.asList(new TranslateBody(null, "This is a test.", + Arrays.asList(new TranslateTarget(Arrays.asList("cs")).setScript("Latn") + .setProfanityAction(ProfanityAction.NO_ACTION) + .setProfanityMarker(ProfanityMarker.ASTERISK) + .setDeploymentNameModel("general") + .setAllowFallback(true) + .setGrade("basic") + .setTone("formal") + .setGender("neutral") + .setAdaptiveDatasetId("21000") + .setReferenceTextPairs(Arrays + .asList(new ReferenceSentencePair("Please test this out.", "Vyzkoušejte si to."))))) + .setScript("Latn") + .setLanguage("en") + .setTextType(TextType.PLAIN)), + "ndbkaatzsnoetqkiehappoza"); + // END:com.azure.ai.translation.text.generated.translate.translatetext + } +} diff --git a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/generated/TranslateTextWithMinimumProperties.java b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/generated/TranslateTextWithMinimumProperties.java new file mode 100644 index 000000000000..a074dd4ce0e5 --- /dev/null +++ b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/generated/TranslateTextWithMinimumProperties.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.translation.text.generated; + +import com.azure.ai.translation.text.TextTranslationClient; +import com.azure.ai.translation.text.TextTranslationClientBuilder; +import com.azure.ai.translation.text.models.TranslateBody; +import com.azure.ai.translation.text.models.TranslateTarget; +import com.azure.ai.translation.text.models.TranslatedTextItem; +import com.azure.core.util.Configuration; +import java.util.Arrays; +import java.util.List; + +public class TranslateTextWithMinimumProperties { + public static void main(String[] args) { + TextTranslationClient textTranslationClient + = new TextTranslationClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.ai.translation.text.generated.translate.translatetextwithminimumproperties + List response = textTranslationClient.translate( + Arrays.asList( + new TranslateBody(null, "This is a test.", Arrays.asList(new TranslateTarget(Arrays.asList("cs"))))), + null); + // END:com.azure.ai.translation.text.generated.translate.translatetextwithminimumproperties + } +} diff --git a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/generated/TransliterateText.java b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/generated/TransliterateText.java new file mode 100644 index 000000000000..dd4cf67eec1a --- /dev/null +++ b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/generated/TransliterateText.java @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.translation.text.generated; + +import com.azure.ai.translation.text.TextTranslationClient; +import com.azure.ai.translation.text.TextTranslationClientBuilder; +import com.azure.ai.translation.text.models.InputTextItem; +import com.azure.ai.translation.text.models.TransliteratedText; +import com.azure.core.util.Configuration; +import java.util.Arrays; +import java.util.List; + +public class TransliterateText { + public static void main(String[] args) { + TextTranslationClient textTranslationClient + = new TextTranslationClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.ai.translation.text.generated.transliterate.transliteratetext + List response = textTranslationClient.transliterate("zh-Hans", "Hans", "Latn", + Arrays.asList(new InputTextItem("这是个测试。")), "dzncrimwmvtwjnheh"); + // END:com.azure.ai.translation.text.generated.transliterate.transliteratetext + } +} diff --git a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/generated/TransliterateTextWithMinimumProperties.java b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/generated/TransliterateTextWithMinimumProperties.java new file mode 100644 index 000000000000..630920131dc2 --- /dev/null +++ b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/generated/TransliterateTextWithMinimumProperties.java @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.translation.text.generated; + +import com.azure.ai.translation.text.TextTranslationClient; +import com.azure.ai.translation.text.TextTranslationClientBuilder; +import com.azure.ai.translation.text.models.InputTextItem; +import com.azure.ai.translation.text.models.TransliteratedText; +import com.azure.core.util.Configuration; +import java.util.Arrays; +import java.util.List; + +public class TransliterateTextWithMinimumProperties { + public static void main(String[] args) { + TextTranslationClient textTranslationClient + = new TextTranslationClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.ai.translation.text.generated.transliterate.transliteratetextwithminimumproperties + List response = textTranslationClient.transliterate("zh-Hans", "Hans", "Latn", + Arrays.asList(new InputTextItem("这是个测试。")), null); + // END:com.azure.ai.translation.text.generated.transliterate.transliteratetextwithminimumproperties + } +} diff --git a/sdk/translation/azure-ai-translation-text/tsp-location.yaml b/sdk/translation/azure-ai-translation-text/tsp-location.yaml index 146d196467b0..0451f5a6157c 100644 --- a/sdk/translation/azure-ai-translation-text/tsp-location.yaml +++ b/sdk/translation/azure-ai-translation-text/tsp-location.yaml @@ -1,3 +1,4 @@ directory: specification/translation/Azure.AI.TextTranslation -commit: 2ddcc49aa62928eff65f3864a88832fb4959166c +commit: 147495e1b6cfe5607d481278e31857dc929b42fa repo: Azure/azure-rest-api-specs +additionalDirectories: