diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index 0ea94f0a1f2a..e4e6ca299bd7 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -55,7 +55,7 @@ com.azure:azure-ai-personalizer;1.0.0-beta.1;1.0.0-beta.2 com.azure:azure-ai-projects;1.0.0-beta.3;1.0.0-beta.4 com.azure:azure-ai-textanalytics;5.5.11;5.6.0-beta.1 com.azure:azure-ai-textanalytics-perf;1.0.0-beta.1;1.0.0-beta.1 -com.azure:azure-ai-translation-text;1.1.7;1.2.0-beta.1 +com.azure:azure-ai-translation-text;1.1.7;2.0.0-beta.1 com.azure:azure-ai-translation-document;1.0.6;1.1.0-beta.1 com.azure:azure-ai-vision-face;1.0.0-beta.2;1.0.0-beta.3 com.azure:azure-ai-voicelive;1.0.0-beta.2;1.0.0-beta.3 diff --git a/sdk/translation/azure-ai-translation-text/CHANGELOG.md b/sdk/translation/azure-ai-translation-text/CHANGELOG.md index 9d77a8ab502c..542660e33105 100644 --- a/sdk/translation/azure-ai-translation-text/CHANGELOG.md +++ b/sdk/translation/azure-ai-translation-text/CHANGELOG.md @@ -1,11 +1,20 @@ # Release History -## 1.2.0-beta.1 (Unreleased) +## 2.0.0-beta.1 (Unreleased) ### Features Added +- Added support for the latest Azure AI Translator API, including translations using LLM models, adaptive custom translation, tone variant translations, and gender-specific translations. +- Added `TranslationTarget` class for configuring translation options. + ### Breaking Changes +- Added `Models` property to `GetSupportedLanguagesResult` to include the list of LLM models available for translations. +- Changed the name of `TargetLanguage` property to `Language` in `TranslationText`. +- Changed the name of `Confidence` property to `Score` in `DetectedLanguage`. +- Removed `SourceText` and `Transliteration` properties in translation responses. +- Dictionary, sentence boundaries and text alignments features have been deprecated and relevant classes and properties have been removed. + ### Bugs Fixed ### Other Changes diff --git a/sdk/translation/azure-ai-translation-text/README.md b/sdk/translation/azure-ai-translation-text/README.md index 2b1a507e6525..208e330fbaac 100644 --- a/sdk/translation/azure-ai-translation-text/README.md +++ b/sdk/translation/azure-ai-translation-text/README.md @@ -36,7 +36,7 @@ Various documentation is available to help you get started com.azure azure-ai-translation-text - 1.2.0-beta.1 + 2.0.0-beta.1 ``` [//]: # ({x-version-update-end}) @@ -100,7 +100,7 @@ GetSupportedLanguagesResult languages = client.getSupportedLanguages(); System.out.println("Number of supported languages for translate operation: " + languages.getTranslation().size() + "."); System.out.println("Number of supported languages for transliterate operation: " + languages.getTransliteration().size() + "."); -System.out.println("Number of supported languages for dictionary operations: " + languages.getDictionary().size() + "."); +System.out.println("Number of supported models for translate operation: " + languages.getModels().size() + "."); System.out.println("Translation Languages:"); for (Map.Entry translationLanguage : languages.getTranslation().entrySet()) { @@ -112,9 +112,9 @@ for (Map.Entry transliterationLanguage : langua System.out.println(transliterationLanguage.getKey() + " -- name: " + transliterationLanguage.getValue().getName() + ", supported script count: " + transliterationLanguage.getValue().getScripts().size()); } -System.out.println("Dictionary Languages:"); -for (Map.Entry dictionaryLanguage : languages.getDictionary().entrySet()) { - System.out.println(dictionaryLanguage.getKey() + " -- name: " + dictionaryLanguage.getValue().getName() + ", supported target languages count: " + dictionaryLanguage.getValue().getTranslations().size()); +System.out.println("Available models:"); +for (String model : languages.getModels()) { + System.out.println(model); } ``` @@ -125,14 +125,15 @@ Please refer to the service documentation for a conceptual discussion of [langua Renders single source-language text to multiple target-language texts with a single request. ```java getTextTranslationMultiple -TranslateOptions translateOptions = new TranslateOptions() - .setSourceLanguage("en") - .addTargetLanguage("es"); +TranslateInputItem input = new TranslateInputItem( + "This is a test.", + Arrays.asList(new TranslationTarget("es"), new TranslationTarget("fr"))); +input.setLanguage("en"); -TranslatedTextItem translation = client.translate("This is a test.", translateOptions); +TranslatedTextItem translation = client.translate(input); for (TranslationText textTranslation : translation.getTranslations()) { - System.out.println("Text was translated to: '" + textTranslation.getTargetLanguage() + "' and the result is: '" + textTranslation.getText() + "'."); + System.out.println("Text was translated to: '" + textTranslation.getLanguage() + "' and the result is: '" + textTranslation.getText() + "'."); } ``` @@ -155,58 +156,6 @@ System.out.println("Input text was transliterated to '" + transliteration.getScr Please refer to the service documentation for a conceptual discussion of [transliterate][transliterate_doc]. -### Break Sentence - -Identifies the positioning of sentence boundaries in a piece of text. - -```java getTextTranslationSentenceBoundaries -String sourceLanguage = "zh-Hans"; -String sourceScript = "Latn"; -String content = "zhè shì gè cè shì。"; - -BreakSentenceItem breakSentence = client.findSentenceBoundaries(content, sourceLanguage, sourceScript); - -System.out.println("The detected sentence boundaries: " + breakSentence.getSentencesLengths()); -``` - -Please refer to the service documentation for a conceptual discussion of [break sentence][breaksentence_doc]. - -### Dictionary Lookup - -Returns equivalent words for the source term in the target language. - -```java getTextTranslationDictionaryLookup -String sourceLanguage = "en"; -String targetLanguage = "es"; -String content = "fly"; - -DictionaryLookupItem dictionaryEntry = client.lookupDictionaryEntries(sourceLanguage, targetLanguage, content); - -System.out.println("For the given input " + dictionaryEntry.getTranslations().size() + " entries were found in the dictionary."); -System.out.println("First entry: '" + dictionaryEntry.getTranslations().get(0).getDisplayTarget() + "', confidence: " + dictionaryEntry.getTranslations().get(0).getConfidence()); -``` - -Please refer to the service documentation for a conceptual discussion of [dictionary lookup][dictionarylookup_doc]. - -### Dictionary Examples - -Returns grammatical structure and context examples for the source term and target term pair. - -```java getTextTranslationDictionaryExamples -String sourceLanguage = "en"; -String targetLanguage = "es"; -List content = new ArrayList<>(); -content.add(new DictionaryExampleTextItem("fly", "volar")); - -List dictionaryEntries = client.lookupDictionaryExamples(sourceLanguage, targetLanguage, content); - -for (DictionaryExampleItem dictionaryEntry : dictionaryEntries) { - System.out.println("For the given input " + dictionaryEntry.getExamples().size() + " entries were found in the dictionary."); - System.out.println("Example: '" + dictionaryEntry.getExamples().get(0).getTargetPrefix() + dictionaryEntry.getExamples().get(0).getTargetTerm() + dictionaryEntry.getExamples().get(0).getTargetSuffix()); -} -``` - -Please refer to the service documentation for a conceptual discussion of [dictionary examples][dictionaryexamples_doc]. ## Troubleshooting @@ -250,7 +199,7 @@ For details on contributing to this repository, see the [contributing guide](htt 1. Create new Pull Request -[product_documentation]: https://learn.microsoft.com/azure/cognitive-services/translator/reference/v3-0-reference +[product_documentation]: https://learn.microsoft.com/azure/ai-services/translator/text-translation/preview/overview [docs]: https://azure.github.io/azure-sdk-for-java/ [jdk]: https://learn.microsoft.com/java/azure/jdk/ [azure_subscription]: https://azure.microsoft.com/free/ @@ -259,32 +208,23 @@ For details on contributing to this repository, see the [contributing guide](htt [azure_cli]: https://learn.microsoft.com/cli/azure [azure_portal]: https://portal.azure.com -[translator_auth]: https://learn.microsoft.com/azure/cognitive-services/translator/reference/v3-0-reference#authentication +[translator_auth]: https://learn.microsoft.com/azure/ai-services/translator/text-translation/reference/authentication [translator_limits]: https://learn.microsoft.com/azure/cognitive-services/translator/request-limits -[languages_doc]: https://learn.microsoft.com/azure/cognitive-services/translator/reference/v3-0-languages -[translate_doc]: https://learn.microsoft.com/azure/cognitive-services/translator/reference/v3-0-translate -[transliterate_doc]: https://learn.microsoft.com/azure/cognitive-services/translator/reference/v3-0-transliterate -[breaksentence_doc]: https://learn.microsoft.com/azure/cognitive-services/translator/reference/v3-0-break-sentence -[dictionarylookup_doc]: https://learn.microsoft.com/azure/cognitive-services/translator/reference/v3-0-dictionary-lookup -[dictionaryexamples_doc]: https://learn.microsoft.com/azure/cognitive-services/translator/reference/v3-0-dictionary-examples +[languages_doc]: https://learn.microsoft.com/azure/ai-services/translator/text-translation/preview/get-languages +[translate_doc]: https://learn.microsoft.com/azure/ai-services/translator/text-translation/preview/translate-api +[transliterate_doc]: https://learn.microsoft.com/azure/ai-services/translator/text-translation/preview/transliterate-api -[sample_breaksentence]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/BreakSentence.java -[sample_dictionaryexamples]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/DictionaryExamples.java -[sample_dictionarylookup]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/DictionaryLookup.java [sample_getlanguages]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/GetLanguages.java [sample_getlanguagesaccept]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/GetLanguagesAcceptLanguage.java [sample_getlanguagesscope]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/GetLanguagesScope.java [sample_translate]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/Translate.java -[sample_translatealignments]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateAlignments.java [sample_translatecustom]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateCustom.java [sample_translatedetection]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateDetection.java -[sample_translatedictionary]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateDictionary.java [sample_translatesources]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateMultipleSources.java [sample_translatetargets]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateMultipleTargets.java [sample_translatenotranslate]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateNoTranslate.java [sample_translateprofanity]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateProfanity.java -[sample_translatesentencelength]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateSentenceLength.java [sample_translatetexttypes]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateTextType.java [sample_translatetransliteration]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateWithTransliteration.java [sample_transliterate]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/Transliterate.java diff --git a/sdk/translation/azure-ai-translation-text/assets.json b/sdk/translation/azure-ai-translation-text/assets.json index 902a16a54e37..7e1e2965d2fd 100644 --- a/sdk/translation/azure-ai-translation-text/assets.json +++ b/sdk/translation/azure-ai-translation-text/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "java", "TagPrefix": "java/translation/azure-ai-translation-text", - "Tag": "java/translation/azure-ai-translation-text_177e917101" + "Tag": "java/translation/azure-ai-translation-text_3fac03d964" } diff --git a/sdk/translation/azure-ai-translation-text/pom.xml b/sdk/translation/azure-ai-translation-text/pom.xml index 37308ddbab4a..b1fb36e924a1 100644 --- a/sdk/translation/azure-ai-translation-text/pom.xml +++ b/sdk/translation/azure-ai-translation-text/pom.xml @@ -11,7 +11,7 @@ com.azure azure-ai-translation-text - 1.2.0-beta.1 + 2.0.0-beta.1 Microsoft Azure client library for Text Translation This package contains Microsoft Azure Text Translation client library. 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..60af6f04af06 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 @@ -4,18 +4,16 @@ package com.azure.ai.translation.text; import com.azure.ai.translation.text.implementation.TextTranslationClientImpl; -import com.azure.ai.translation.text.models.BreakSentenceItem; -import com.azure.ai.translation.text.models.DictionaryExampleItem; -import com.azure.ai.translation.text.models.DictionaryExampleTextItem; -import com.azure.ai.translation.text.models.DictionaryLookupItem; import com.azure.ai.translation.text.models.GetSupportedLanguagesResult; import com.azure.ai.translation.text.models.InputTextItem; import com.azure.ai.translation.text.models.LanguageScope; -import com.azure.ai.translation.text.models.ProfanityAction; -import com.azure.ai.translation.text.models.ProfanityMarker; -import com.azure.ai.translation.text.models.TextType; -import com.azure.ai.translation.text.models.TranslateOptions; +import com.azure.ai.translation.text.models.TranslateBody; +import com.azure.ai.translation.text.models.TranslateInputItem; import com.azure.ai.translation.text.models.TranslatedTextItem; +import com.azure.ai.translation.text.models.TranslationResult; +import com.azure.ai.translation.text.models.TranslationTarget; +import com.azure.ai.translation.text.models.TransliterateBody; +import com.azure.ai.translation.text.models.TransliterateResult; import com.azure.ai.translation.text.models.TransliteratedText; import com.azure.core.annotation.Generated; import com.azure.core.annotation.ReturnType; @@ -30,7 +28,6 @@ import com.azure.core.http.rest.Response; import com.azure.core.util.BinaryData; import com.azure.core.util.FluxUtil; -import com.azure.core.util.serializer.TypeReference; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -56,54 +53,17 @@ public final class TextTranslationAsyncClient { } /** - * Translate Text. + * Gets the set of languages currently supported by other operations of the Translator. *

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.
scopeStringNoA comma-separated list of names defining the group of languages + * to return. + * Allowed group names are: `translation`, `transliteration` and `dictionary`. + * If no scope is given, then all groups are returned, which is equivalent to passing + * `scope=translation,transliteration,dictionary`. To decide which set of supported languages + * is appropriate for your scenario, see the description of the [response object](#response-body).
* You can add these to a request with {@link RequestOptions#addQueryParam} *

Header Parameters

@@ -112,278 +72,171 @@ public final class TextTranslationAsyncClient { * NameTypeRequiredDescription * X-ClientTraceIdStringNoA client-generated GUID to uniquely identify the * request. + * Accept-LanguageStringNoThe language to use for user interface strings. Some of + * the fields in the response are names of languages or + * names of regions. Use this parameter to define the language in which these names are returned. + * The language is specified by providing a well-formed BCP 47 language tag. For instance, use the value `fr` + * to request names in French or use the value `zh-Hant` to request names in Chinese Traditional. + * Names are provided in the English language when a target language is not specified or when localization + * is not available. + * If-None-MatchStringNoPassing the value of the ETag response header in an + * If-None-Match field will allow the service to optimize the response. + * If the resource has not been modified, the service will return status code 304 and an empty response + * body. * * 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)
+     * {
+     *     translation (Optional): {
+     *         String (Required): {
+     *             name: String (Required)
+     *             nativeName: String (Required)
+     *             dir: String(ltr/rtl) (Required)
+     *             models (Required): [
+     *                 String (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)
+     *     }
+     *     transliteration (Optional): {
+     *         String (Required): {
+     *             name: String (Required)
+     *             nativeName: String (Required)
+     *             scripts (Required): [
+     *                  (Required){
+     *                     code: String (Required)
+     *                     name: String (Required)
+     *                     nativeName: String (Required)
+     *                     dir: String(ltr/rtl) (Required)
+     *                     toScripts (Required): [
+     *                          (Required){
+     *                             code: String (Required)
+     *                             name: String (Required)
+     *                             nativeName: String (Required)
+     *                             dir: String(ltr/rtl) (Required)
+     *                         }
      *                     ]
      *                 }
-     *             }
-     *         ]
-     *         sourceText (Optional): {
-     *             text: String (Required)
+     *             ]
      *         }
      *     }
-     * ]
+     *     models (Optional): [
+     *         String (Optional)
+     *     ]
+     * }
      * }
      * 
* - * @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}. + * @return the set of languages currently supported by other operations of the Translator 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); + public Mono> getSupportedLanguagesWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getSupportedLanguagesWithResponseAsync(requestOptions); } /** - * Transliterate 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)
-     *     }
-     * ]
-     * }
-     * 
- * - *

Response Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         text: String (Required)
-     *         script: String (Required)
-     *     }
-     * ]
-     * }
-     * 
+ * Gets the set of languages currently supported by other operations of the Translator. * - * @param language Specifies the language of the text to convert from one script to another. - * Possible languages are listed in the transliteration scope obtained by querying the service - * for its supported languages. - * @param sourceLanguageScript Specifies the script used by the input text. Look up supported languages using the - * transliteration scope, - * to find input scripts available for the selected language. - * @param targetLanguageScript Specifies the output script. Look up supported languages using the transliteration - * scope, to find output - * scripts available for the selected combination of input language and input script. - * @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}. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the set of languages currently supported by other operations of the Translator on successful completion + * of {@link Mono}. */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> transliterateWithResponse(String language, String sourceLanguageScript, - String targetLanguageScript, BinaryData body, RequestOptions requestOptions) { - return this.serviceClient.transliterateWithResponseAsync(language, sourceLanguageScript, targetLanguageScript, - body, requestOptions); + public Mono getSupportedLanguages() { + // Generated convenience method for getSupportedLanguagesWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getSupportedLanguagesWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(GetSupportedLanguagesResult.class)); } /** - * 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)
-     *         ]
-     *     }
-     * ]
-     * }
-     * 
+ * Gets the set of languages currently supported by other operations of the Translator. * - * @param body Defines the content of the request. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @param scope A comma-separated list of names defining the group of languages to return. + * Allowed group names are: `translation`, `transliteration` and `models`. + * If no scope is given, then all groups are returned, which is equivalent to passing + * `scope=translation,transliteration,models`. To decide which set of supported languages + * is appropriate for your scenario, see the description of the [response object](#response-body). + * @param acceptLanguage The language to use for user interface strings. Some of the fields in the response are + * names of languages or + * names of regions. Use this parameter to define the language in which these names are returned. + * The language is specified by providing a well-formed BCP 47 language tag. For instance, use the value `fr` + * to request names in French or use the value `zh-Hant` to request names in Chinese Traditional. + * Names are provided in the English language when a target language is not specified or when localization + * is not available. + * @param ifNoneMatch Passing the value of the ETag response header in an If-None-Match field will allow the service + * to optimize the response. + * If the resource has not been modified, the service will return status code 304 and an empty response body. + * @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. - * @return the response body along with {@link Response} on successful completion of {@link Mono}. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the set of languages currently supported by other operations of the Translator on successful completion + * of {@link Mono}. */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> findSentenceBoundariesWithResponse(BinaryData body, - RequestOptions requestOptions) { - return this.serviceClient.findSentenceBoundariesWithResponseAsync(body, requestOptions); + private Mono getSupportedLanguages(String scope, String acceptLanguage, + String ifNoneMatch) { + // Generated convenience method for getSupportedLanguagesWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (scope != null) { + requestOptions.addQueryParam("scope", scope, false); + } + if (acceptLanguage != null) { + requestOptions.setHeader(HttpHeaderName.ACCEPT_LANGUAGE, acceptLanguage); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + return getSupportedLanguagesWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(GetSupportedLanguagesResult.class)); } /** - * 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)
-     *                     }
-     *                 ]
-     *             }
-     *         ]
-     *     }
-     * ]
-     * }
-     * 
+ * Gets the set of languages currently supported by other operations of the Translator. * - * @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. + * @param scopes List of names defining the group of languages to return. + * @param acceptLanguage The language to use for user interface strings. Some of the fields in the response are + * names of languages or + * names of regions. Use this parameter to define the language in which these names are returned. + * The language is specified by providing a well-formed BCP 47 language tag. For instance, use the value `fr` + * to request names in French or use the value `zh-Hant` to request names in Chinese Traditional. + * Names are provided in the English language when a target language is not specified or when localization + * is not available. + * @param ifNoneMatch Passing the value of the ETag response header in an If-None-Match field will allow the service + * to optimize the response. + * If the resource has not been modified, the service will return status code 304 and an empty response body. + * @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. - * @return the response body along with {@link Response} on successful completion of {@link Mono}. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the set of languages currently supported by other operations of the Translator. */ - @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> lookupDictionaryEntriesWithResponse(String sourceLanguage, String targetLanguage, - BinaryData body, RequestOptions requestOptions) { - return this.serviceClient.lookupDictionaryEntriesWithResponseAsync(sourceLanguage, targetLanguage, body, - requestOptions); + public Mono getSupportedLanguages(List scopes, String acceptLanguage, + String ifNoneMatch) { + return getSupportedLanguages(convertToScopesString(scopes), acceptLanguage, ifNoneMatch); } /** - * Lookup Dictionary Examples. + * Transliterate Text. *

Header Parameters

* * @@ -396,12 +249,13 @@ public Mono> lookupDictionaryEntriesWithResponse(String sou * *
      * {@code
-     * [
-     *      (Required){
-     *         text: String (Required)
-     *         translation: String (Required)
-     *     }
-     * ]
+     * {
+     *     inputs (Required): [
+     *          (Required){
+     *             text: String (Required)
+     *         }
+     *     ]
+     * }
      * }
      * 
* @@ -409,527 +263,54 @@ public Mono> lookupDictionaryEntriesWithResponse(String sou * *
      * {@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)
-     *             }
-     *         ]
-     *     }
-     * ]
+     * {
+     *     value (Required): [
+     *          (Required){
+     *             text: String (Required)
+     *             script: 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 language Specifies the language of the text to convert from one script to another. + * Possible languages are listed in the transliteration scope obtained by querying the service + * for its supported languages. + * @param fromScript Specifies the script used by the input text. Look up supported languages using the + * transliteration scope, + * to find input scripts available for the selected language. + * @param toScript Specifies the output script. Look up supported languages using the transliteration scope, to find + * output + * scripts available for the selected combination of input language and input script. * @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. - * - * @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 clientTraceId A client-generated GUID to uniquely identify the request. - * @param sourceLanguage Specifies 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. - * @param textType 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 category A 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. - * @param profanityAction Specifies how profanities should be treated in translations. - * Possible values are: NoAction (default), Marked or Deleted. - * @param profanityMarker Specifies how profanities should be marked in translations. - * Possible values are: Asterisk (default) or Tag. - * @param includeAlignment Specifies whether to include alignment projection from source text to translated text. - * Possible values are: true or false (default). - * @param includeSentenceLength Specifies whether to include sentence boundaries for the input text and the - * translated text. - * Possible values are: true or false (default). - * @param suggestedSourceLanguage Specifies 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. - * @param sourceLanguageScript Specifies the script of the input text. - * @param targetLanguageScript Specifies the script of the translated text. - * @param allowFallback Specifies 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. - * @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 body on successful completion of {@link Mono}. - */ - private Mono> translate(List targetLanguages, List body, - String clientTraceId, String sourceLanguage, TextType textType, String category, - ProfanityAction profanityAction, ProfanityMarker profanityMarker, Boolean includeAlignment, - Boolean includeSentenceLength, String suggestedSourceLanguage, String sourceLanguageScript, - String targetLanguageScript, Boolean allowFallback) { - // Generated convenience method for translateWithResponse - RequestOptions requestOptions = new RequestOptions(); - if (clientTraceId != null) { - requestOptions.setHeader(HttpHeaderName.fromString("X-ClientTraceId"), clientTraceId); - } - if (sourceLanguage != null) { - requestOptions.addQueryParam("from", sourceLanguage, false); - } - if (textType != null) { - requestOptions.addQueryParam("textType", textType.toString(), false); - } - if (category != null) { - requestOptions.addQueryParam("category", category, false); - } - if (profanityAction != null) { - requestOptions.addQueryParam("profanityAction", profanityAction.toString(), false); - } - if (profanityMarker != null) { - requestOptions.addQueryParam("profanityMarker", profanityMarker.toString(), false); - } - if (includeAlignment != null) { - requestOptions.addQueryParam("includeAlignment", String.valueOf(includeAlignment), false); - } - if (includeSentenceLength != null) { - requestOptions.addQueryParam("includeSentenceLength", String.valueOf(includeSentenceLength), false); - } - if (suggestedSourceLanguage != null) { - requestOptions.addQueryParam("suggestedFrom", suggestedSourceLanguage, false); - } - if (sourceLanguageScript != null) { - requestOptions.addQueryParam("fromScript", sourceLanguageScript, false); - } - if (targetLanguageScript != null) { - requestOptions.addQueryParam("toScript", targetLanguageScript, false); - } - if (allowFallback != null) { - requestOptions.addQueryParam("allowFallback", String.valueOf(allowFallback), false); - } - return translateWithResponse(targetLanguages, BinaryData.fromObject(body), requestOptions) - .flatMap(FluxUtil::toMono) - .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_TRANSLATED_TEXT_ITEM)); - } - - /** - * Translate Text. - * - * @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. - * @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 body on successful completion of {@link Mono}. - */ - private Mono> translateInner(List targetLanguages, List body) { - // Generated convenience method for translateWithResponse - RequestOptions requestOptions = new RequestOptions(); - return translateWithResponse(targetLanguages, BinaryData.fromObject(body), requestOptions) - .flatMap(FluxUtil::toMono) - .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_TRANSLATED_TEXT_ITEM)); - } - - /** - * Translate Text. - *

- * This method is used when you have single target language and multiple texts to translate. - *

- * - * @param targetLanguage 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 texts 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. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> translate(String targetLanguage, List texts) { - return translateInner(Arrays.asList(targetLanguage), convertTextToData(texts)); - } - - /** - * Translate Text. - *

- * This method is used when you have single target language and single text to translate. - *

- * - * @param targetLanguage 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 text 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. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono translate(String targetLanguage, String text) { - return translate(targetLanguage, Arrays.asList(text)) - .map(translatedTextItems -> translatedTextItems.isEmpty() ? null : translatedTextItems.get(0)) - .defaultIfEmpty(null); - } - - /** - * Translate Text. - *

- * This method is used when you have one input text and the optional parameters are needed such as specification - * of a source language, profanity handling etc. - *

- * - * @param text Text to translate. - * @param translateOptions Translate Options. - * @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. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono translate(String text, TranslateOptions translateOptions) { - return translate(Arrays.asList(text), translateOptions) - .map(translatedTextItems -> translatedTextItems.isEmpty() ? null : translatedTextItems.get(0)) - .defaultIfEmpty(null); - } - - /** - * Translate Text. - *

- * This method is used when you have multiple texts and the optional parameters are needed such as specification - * of a source language, profanity handling etc.. - *

- * - * @param texts List of text to translate. - * @param translateOptions Translate Options. - * @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. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> translate(List texts, TranslateOptions translateOptions) { - List content = new ArrayList<>(); - for (String text : texts) { - content.add(new InputTextItem(text)); - } - return translate(translateOptions.getTargetLanguages(), content, translateOptions.getClientTraceId(), - translateOptions.getSourceLanguage(), translateOptions.getTextType(), translateOptions.getCategory(), - translateOptions.getProfanityAction(), translateOptions.getProfanityMarker(), - translateOptions.isIncludeAlignment(), translateOptions.isIncludeSentenceLength(), - translateOptions.getSuggestedSourceLanguage(), translateOptions.getSourceLanguageScript(), - translateOptions.getTargetLanguageScript(), translateOptions.isAllowFallback()); - } - - /** - * Transliterate Text. - * - * @param language Specifies the language of the text to convert from one script to another. - * Possible languages are listed in the transliteration scope obtained by querying the service - * for its supported languages. - * @param sourceLanguageScript Specifies the script used by the input text. Look up supported languages using the - * transliteration scope, - * to find input scripts available for the selected language. - * @param targetLanguageScript Specifies the output script. Look up supported languages using the transliteration - * scope, to find output - * scripts available for the selected combination of input language and input script. - * @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 body on successful completion of {@link Mono}. - */ - private Mono> transliterateInner(String language, String sourceLanguageScript, - String targetLanguageScript, List body) { - // Generated convenience method for transliterateWithResponse - RequestOptions requestOptions = new RequestOptions(); - return transliterateWithResponse(language, sourceLanguageScript, targetLanguageScript, - BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) - .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_TRANSLITERATED_TEXT)); - } - - /** - * Transliterate Text. - *

- * This method is used when you have multiple texts to transliterate and you want to provide client trace id. - *

- * - * @param language Specifies the language of the text to convert from one script to another. - * Possible languages are listed in the transliteration scope obtained by querying the service - * for its supported languages. - * @param sourceLanguageScript Specifies the script used by the input text. Look up supported languages using the - * transliteration scope, - * to find input scripts available for the selected language. - * @param targetLanguageScript Specifies the output script. Look up supported languages using the transliteration - * scope, to find output - * scripts available for the selected combination of input language and input script. - * @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. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> transliterate(String language, String sourceLanguageScript, - String targetLanguageScript, List body) { - return transliterateInner(language, sourceLanguageScript, targetLanguageScript, convertTextToData(body)); - } - - /** - * Transliterate Text. - *

- * This method is used when you have single text to transliterate and you want to provide client trace id. - *

- * - * @param language Specifies the language of the text to convert from one script to another. - * Possible languages are listed in the transliteration scope obtained by querying the service - * for its supported languages. - * @param sourceLanguageScript Specifies the script used by the input text. Look up supported languages using the - * transliteration scope, - * to find input scripts available for the selected language. - * @param targetLanguageScript Specifies the output script. Look up supported languages using the transliteration - * scope, to find output - * scripts available for the selected combination of input language and input script. - * @param text 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. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono transliterate(String language, String sourceLanguageScript, - String targetLanguageScript, String text) { - return transliterate(language, sourceLanguageScript, targetLanguageScript, Arrays.asList(text)) - .map(translatedTextItems -> translatedTextItems.isEmpty() ? null : translatedTextItems.get(0)) - .defaultIfEmpty(null); - } - - /** - * Find Sentence Boundaries. - * - * @param body Defines the content of the request. - * @param language Language tag identifying the language of the input text. - * If a code isn't specified, automatic language detection will be applied. - * @param script Script tag identifying the script used by the input text. - * If a script isn't specified, the default script of the language will be assumed. - * @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 body on successful completion of {@link Mono}. - */ - private Mono> findSentenceBoundariesInner(List body, String language, - String script) { - // Generated convenience method for findSentenceBoundariesWithResponse - RequestOptions requestOptions = new RequestOptions(); - if (language != null) { - requestOptions.addQueryParam("language", language, false); - } - if (script != null) { - requestOptions.addQueryParam("script", script, false); - } - return findSentenceBoundariesWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) - .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_BREAK_SENTENCE_ITEM)); - } - - /** - * Find Sentence Boundaries. - *

- * This method is used when you have multiple texts for which you want to find sentence boundaries and you want to - * provide - * client trace id. - *

- * - * @param texts Defines the content of the request. - * @param language Language tag identifying the language of the input text. - * If a code isn't specified, automatic language detection will be applied. - * @param script Script tag identifying the script used by the input text. - * If a script isn't specified, the default script of the language will be assumed. - * @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. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> findSentenceBoundaries(List texts, String language, String script) { - return findSentenceBoundariesInner(convertTextToData(texts), language, script); - } - - /** - * Find Sentence Boundaries. - *

- * This method is used when you have single text for which you want to find sentence boundaries and you want to - * provide - * client trace id. - *

- * - * @param text Defines the content of the request. - * @param language Language tag identifying the language of the input text. - * If a code isn't specified, automatic language detection will be applied. - * @param script Script tag identifying the script used by the input text. - * If a script isn't specified, the default script of the language will be assumed. - * @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. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono findSentenceBoundaries(String text, String language, String script) { - return findSentenceBoundaries(Arrays.asList(text), language, script) - .map(translatedTextItems -> translatedTextItems.isEmpty() ? null : translatedTextItems.get(0)) - .defaultIfEmpty(null); - } - - /** - * Find Sentence Boundaries. - * - * @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 body on successful completion of {@link Mono}. - */ - private Mono> findSentenceBoundariesInner(List body) { - // Generated convenience method for findSentenceBoundariesWithResponse - RequestOptions requestOptions = new RequestOptions(); - return findSentenceBoundariesWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) - .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_BREAK_SENTENCE_ITEM)); - } - - /** - * Find Sentence Boundaries. - *

- * This method is used when you have multiple texts for which you want to find sentence boundaries and you want - * the source language to be auto-detected by the service. - *

- * - * @param texts 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. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> findSentenceBoundaries(List texts) { - return findSentenceBoundariesInner(convertTextToData(texts)); - } - - /** - * Find Sentence Boundaries. - *

- * This method is used when you have single text for which you want to find sentence boundaries and you want - * the source language to be auto-detected by the service. - *

- * - * @param text 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. + * @return response for the transliteration API along with {@link Response} on successful completion of + * {@link Mono}. */ + @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono findSentenceBoundaries(String text) { - return findSentenceBoundaries(Arrays.asList(text)) - .map(translatedTextItems -> translatedTextItems.isEmpty() ? null : translatedTextItems.get(0)) - .defaultIfEmpty(null); + public Mono> transliterateWithResponse(String language, String fromScript, String toScript, + BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.transliterateWithResponseAsync(language, fromScript, toScript, body, requestOptions); } /** - * Lookup Dictionary Entries. + * Transliterate Text. * - * @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 language Specifies the language of the text to convert from one script to another. + * Possible languages are listed in the transliteration scope obtained by querying the service + * for its supported languages. + * @param sourceLanguageScript Specifies the script used by the input text. Look up supported languages using the + * transliteration scope, + * to find input scripts available for the selected language. + * @param targetLanguageScript Specifies the output script. Look up supported languages using the transliteration + * scope, to find output + * scripts available for the selected combination of input language and input script. * @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. @@ -939,27 +320,34 @@ public Mono findSentenceBoundaries(String text) { * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the response body on successful completion of {@link Mono}. */ - private Mono> lookupDictionaryEntriesInner(String sourceLanguage, String targetLanguage, - List body) { - // Generated convenience method for lookupDictionaryEntriesWithResponse + private Mono> transliterateInner(String language, String sourceLanguageScript, + String targetLanguageScript, List body) { RequestOptions requestOptions = new RequestOptions(); - return lookupDictionaryEntriesWithResponse(sourceLanguage, targetLanguage, BinaryData.fromObject(body), - requestOptions).flatMap(FluxUtil::toMono) - .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_DICTIONARY_LOOKUP_ITEM)); + TransliterateBody transliterateBody = new TransliterateBody(body); + return transliterateWithResponse(language, sourceLanguageScript, targetLanguageScript, + BinaryData.fromObject(transliterateBody), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> { + TransliterateResult result = protocolMethodData.toObject(TransliterateResult.class); + return result.getValue(); + }); } /** - * Lookup Dictionary Entries. + * Transliterate Text. *

- * This method is used when you want lookup multiple entries in the dictionary and you want to provide - * client trace id. + * This method is used when you have multiple texts to transliterate and you want to provide client trace id. *

* - * @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 texts Defines the content of the request. + * @param language Specifies the language of the text to convert from one script to another. + * Possible languages are listed in the transliteration scope obtained by querying the service + * for its supported languages. + * @param sourceLanguageScript Specifies the script used by the input text. Look up supported languages using the + * transliteration scope, + * to find input scripts available for the selected language. + * @param targetLanguageScript Specifies the output script. Look up supported languages using the transliteration + * scope, to find output + * scripts available for the selected combination of input language and input script. + * @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. @@ -968,23 +356,28 @@ private Mono> lookupDictionaryEntriesInner(String sou * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the response. */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> lookupDictionaryEntries(String sourceLanguage, String targetLanguage, - List texts) { - return lookupDictionaryEntriesInner(sourceLanguage, targetLanguage, convertTextToData(texts)); + @ServiceMethod(returns = ReturnType.COLLECTION) + public Mono> transliterate(String language, String sourceLanguageScript, + String targetLanguageScript, List body) { + return transliterateInner(language, sourceLanguageScript, targetLanguageScript, + convertTextsToInputTextItems(body)); } /** - * Lookup Dictionary Entries. + * Transliterate Text. *

- * This method is used when you want lookup single entry in the dictionary and you want to provide - * client trace id. + * This method is used when you have single text to transliterate and you want to provide client trace id. *

* - * @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 language Specifies the language of the text to convert from one script to another. + * Possible languages are listed in the transliteration scope obtained by querying the service + * for its supported languages. + * @param sourceLanguageScript Specifies the script used by the input text. Look up supported languages using the + * transliteration scope, + * to find input scripts available for the selected language. + * @param targetLanguageScript Specifies the output script. Look up supported languages using the transliteration + * scope, to find output + * scripts available for the selected combination of input language and input script. * @param text Defines the content of the request. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. @@ -995,257 +388,204 @@ public Mono> lookupDictionaryEntries(String sourceLan * @return the response. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono lookupDictionaryEntries(String sourceLanguage, String targetLanguage, - String text) { - return lookupDictionaryEntries(sourceLanguage, targetLanguage, Arrays.asList(text)) + public Mono transliterate(String language, String sourceLanguageScript, + String targetLanguageScript, String text) { + return transliterate(language, sourceLanguageScript, targetLanguageScript, Arrays.asList(text)) .map(translatedTextItems -> translatedTextItems.isEmpty() ? null : translatedTextItems.get(0)) .defaultIfEmpty(null); } /** - * 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 body on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> lookupDictionaryExamples(String sourceLanguage, String targetLanguage, - List body) { - // Generated convenience method for lookupDictionaryExamplesWithResponse - RequestOptions requestOptions = new RequestOptions(); - return lookupDictionaryExamplesWithResponse(sourceLanguage, targetLanguage, BinaryData.fromObject(body), - requestOptions).flatMap(FluxUtil::toMono) - .map(protocolMethodData -> protocolMethodData.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>() { - }; - - /** - * Gets the set of languages currently supported by other operations of the Translator. - *

Query Parameters

- *
Header Parameters
- * - * - * - *
Query Parameters
NameTypeRequiredDescription
scopeStringNoA comma-separated list of names defining the group of languages - * to return. - * Allowed group names are: `translation`, `transliteration` and `dictionary`. - * If no scope is given, then all groups are returned, which is equivalent to passing - * `scope=translation,transliteration,dictionary`. To decide which set of supported languages - * is appropriate for your scenario, see the description of the [response object](#response-body).
- * You can add these to a request with {@link RequestOptions#addQueryParam} + * Translate Text. *

Header Parameters

* * * * - * - * *
Header Parameters
NameTypeRequiredDescription
X-ClientTraceIdStringNoA client-generated GUID to uniquely identify the * request.
Accept-LanguageStringNoThe language to use for user interface strings. Some of - * the fields in the response are names of languages or - * names of regions. Use this parameter to define the language in which these names are returned. - * The language is specified by providing a well-formed BCP 47 language tag. For instance, use the value `fr` - * to request names in French or use the value `zh-Hant` to request names in Chinese Traditional. - * Names are provided in the English language when a target language is not specified or when localization - * is not available.
If-None-MatchStringNoPassing the value of the ETag response header in an - * If-None-Match field will allow the service to optimize the response. - * If the resource has not been modified, the service will return status code 304 and an empty response - * body.
* You can add these to a request with {@link RequestOptions#addHeader} - *

Response Body Schema

+ *

Request Body Schema

* *
      * {@code
      * {
-     *     translation (Optional): {
-     *         String (Required): {
-     *             name: String (Required)
-     *             nativeName: String (Required)
-     *             dir: String(ltr/rtl) (Required)
-     *         }
-     *     }
-     *     transliteration (Optional): {
-     *         String (Required): {
-     *             name: String (Required)
-     *             nativeName: String (Required)
-     *             scripts (Required): [
+     *     inputs (Required): [
+     *          (Required){
+     *             text: String (Required)
+     *             script: String (Optional)
+     *             language: String (Optional)
+     *             textType: String(Plain/Html) (Optional)
+     *             targets (Required): [
      *                  (Required){
-     *                     code: String (Required)
-     *                     name: String (Required)
-     *                     nativeName: String (Required)
-     *                     dir: String(ltr/rtl) (Required)
-     *                     toScripts (Required): [
-     *                          (Required){
-     *                             code: String (Required)
-     *                             name: String (Required)
-     *                             nativeName: String (Required)
-     *                             dir: String(ltr/rtl) (Required)
+     *                     language: String (Required)
+     *                     script: String (Optional)
+     *                     profanityAction: String(NoAction/Marked/Deleted) (Optional)
+     *                     profanityMarker: String(Asterisk/Tag) (Optional)
+     *                     deploymentName: String (Optional)
+     *                     allowFallback: Boolean (Optional)
+     *                     grade: String (Optional)
+     *                     tone: String (Optional)
+     *                     gender: String (Optional)
+     *                     adaptiveDatasetId: String (Optional)
+     *                     referenceTextPairs (Optional): [
+     *                          (Optional){
+     *                             source: String (Required)
+     *                             target: String (Required)
      *                         }
      *                     ]
      *                 }
      *             ]
      *         }
-     *     }
-     *     dictionary (Optional): {
-     *         String (Required): {
-     *             name: String (Required)
-     *             nativeName: String (Required)
-     *             dir: String(ltr/rtl) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *          (Required){
+     *             detectedLanguage (Optional): {
+     *                 language: String (Required)
+     *                 score: double (Required)
+     *             }
      *             translations (Required): [
      *                  (Required){
-     *                     name: String (Required)
-     *                     nativeName: String (Required)
-     *                     dir: String(ltr/rtl) (Required)
-     *                     code: String (Required)
+     *                     language: String (Required)
+     *                     sourceCharacters: Integer (Optional)
+     *                     instructionTokens: Integer (Optional)
+     *                     sourceTokens: Integer (Optional)
+     *                     responseTokens: Integer (Optional)
+     *                     targetTokens: Integer (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 set of languages currently supported by other operations of the Translator along with - * {@link Response} on successful completion of {@link Mono}. + * @return response for the translation API along with {@link Response} on successful completion of {@link Mono}. */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getSupportedLanguagesWithResponse(RequestOptions requestOptions) { - return this.serviceClient.getSupportedLanguagesWithResponseAsync(requestOptions); + public Mono> translateWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.translateWithResponseAsync(body, requestOptions); } /** - * Gets the set of languages currently supported by other operations of the Translator. + * Translate Text. * - * @param scope A comma-separated list of names defining the group of languages to return. - * Allowed group names are: `translation`, `transliteration` and `dictionary`. - * If no scope is given, then all groups are returned, which is equivalent to passing - * `scope=translation,transliteration,dictionary`. To decide which set of supported languages - * is appropriate for your scenario, see the description of the [response object](#response-body). - * @param acceptLanguage The language to use for user interface strings. Some of the fields in the response are - * names of languages or - * names of regions. Use this parameter to define the language in which these names are returned. - * The language is specified by providing a well-formed BCP 47 language tag. For instance, use the value `fr` - * to request names in French or use the value `zh-Hant` to request names in Chinese Traditional. - * Names are provided in the English language when a target language is not specified or when localization - * is not available. - * @param ifNoneMatch Passing the value of the ETag response header in an If-None-Match field will allow the service - * to optimize the response. - * If the resource has not been modified, the service will return status code 304 and an empty response body. + * @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 set of languages currently supported by other operations of the Translator on successful completion - * of {@link Mono}. + * @return the response body on successful completion of {@link Mono}. */ - private Mono getSupportedLanguages(String scope, String acceptLanguage, - String ifNoneMatch) { - // Generated convenience method for getSupportedLanguagesWithResponse + @ServiceMethod(returns = ReturnType.COLLECTION) + public Mono> translate(List body) { + // Generated convenience method for translateWithResponse RequestOptions requestOptions = new RequestOptions(); - if (scope != null) { - requestOptions.addQueryParam("scope", scope, false); - } - if (acceptLanguage != null) { - requestOptions.setHeader(HttpHeaderName.ACCEPT_LANGUAGE, acceptLanguage); - } - if (ifNoneMatch != null) { - requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); - } - return getSupportedLanguagesWithResponse(requestOptions).flatMap(FluxUtil::toMono) - .map(protocolMethodData -> protocolMethodData.toObject(GetSupportedLanguagesResult.class)); + TranslateBody translateBody = new TranslateBody(body); + return translateWithResponse(BinaryData.fromObject(translateBody), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> { + TranslationResult result = protocolMethodData.toObject(TranslationResult.class); + return result.getValue(); + }); } /** - * Gets the set of languages currently supported by other operations of the Translator. + * Translate Text. * - * @param scopes List of names defining the group of languages to return. - * @param acceptLanguage The language to use for user interface strings. Some of the fields in the response are - * names of languages or - * names of regions. Use this parameter to define the language in which these names are returned. - * The language is specified by providing a well-formed BCP 47 language tag. For instance, use the value `fr` - * to request names in French or use the value `zh-Hant` to request names in Chinese Traditional. - * Names are provided in the English language when a target language is not specified or when localization - * is not available. - * @param ifNoneMatch Passing the value of the ETag response header in an If-None-Match field will allow the service - * to optimize the response. - * If the resource has not been modified, the service will return status code 304 and an empty response body. + * @param input 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 set of languages currently supported by other operations of the Translator. + * @return the response body on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getSupportedLanguages(List scopes, String acceptLanguage, - String ifNoneMatch) { - return getSupportedLanguages(convertToScopesString(scopes), acceptLanguage, ifNoneMatch); + public Mono translate(TranslateInputItem input) { + return translate(Arrays.asList(input)) + .map(translatedTextItems -> translatedTextItems.isEmpty() ? null : translatedTextItems.get(0)) + .defaultIfEmpty(null); } /** - * Gets the set of languages currently supported by other operations of the Translator. + * Translate Text. + *

+ * This method is used when you have single target language and multiple texts to translate. + *

* + * @param targetLanguage 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 texts 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 set of languages currently supported by other operations of the Translator on successful completion - * of {@link Mono}. + * @return the response. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public Mono> translate(String targetLanguage, List texts) { + List body = new ArrayList<>(); + for (String text : texts) { + TranslateInputItem translateInputItem + = new TranslateInputItem(text, Arrays.asList(new TranslationTarget(targetLanguage))); + body.add(translateInputItem); + } + return translate(body); + } + + /** + * Translate Text. + *

+ * This method is used when you have single target language and single text to translate. + *

+ * + * @param targetLanguage 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 text 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 Mono getSupportedLanguages() { - // Generated convenience method for getSupportedLanguagesWithResponse - RequestOptions requestOptions = new RequestOptions(); - return getSupportedLanguagesWithResponse(requestOptions).flatMap(FluxUtil::toMono) - .map(protocolMethodData -> protocolMethodData.toObject(GetSupportedLanguagesResult.class)); + public Mono translate(String targetLanguage, String text) { + return translate(targetLanguage, Arrays.asList(text)) + .map(translatedTextItems -> translatedTextItems.isEmpty() ? null : translatedTextItems.get(0)) + .defaultIfEmpty(null); } - private List convertTextToData(List texts) { + private List convertTextsToInputTextItems(List texts) { List content = new ArrayList<>(); for (String text : texts) { content.add(new InputTextItem(text)); 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..943205531fc5 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 @@ -4,18 +4,16 @@ package com.azure.ai.translation.text; import com.azure.ai.translation.text.implementation.TextTranslationClientImpl; -import com.azure.ai.translation.text.models.BreakSentenceItem; -import com.azure.ai.translation.text.models.DictionaryExampleItem; -import com.azure.ai.translation.text.models.DictionaryExampleTextItem; -import com.azure.ai.translation.text.models.DictionaryLookupItem; import com.azure.ai.translation.text.models.GetSupportedLanguagesResult; import com.azure.ai.translation.text.models.InputTextItem; import com.azure.ai.translation.text.models.LanguageScope; -import com.azure.ai.translation.text.models.ProfanityAction; -import com.azure.ai.translation.text.models.ProfanityMarker; -import com.azure.ai.translation.text.models.TextType; -import com.azure.ai.translation.text.models.TranslateOptions; +import com.azure.ai.translation.text.models.TranslateBody; +import com.azure.ai.translation.text.models.TranslateInputItem; import com.azure.ai.translation.text.models.TranslatedTextItem; +import com.azure.ai.translation.text.models.TranslationResult; +import com.azure.ai.translation.text.models.TranslationTarget; +import com.azure.ai.translation.text.models.TransliterateBody; +import com.azure.ai.translation.text.models.TransliterateResult; import com.azure.ai.translation.text.models.TransliteratedText; import com.azure.core.annotation.Generated; import com.azure.core.annotation.ReturnType; @@ -29,7 +27,6 @@ import com.azure.core.http.rest.RequestOptions; import com.azure.core.http.rest.Response; import com.azure.core.util.BinaryData; -import com.azure.core.util.serializer.TypeReference; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -54,54 +51,17 @@ public final class TextTranslationClient { } /** - * Translate Text. + * Gets the set of languages currently supported by other operations of the Translator. *

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.
scopeStringNoA comma-separated list of names defining the group of languages + * to return. + * Allowed group names are: `translation`, `transliteration` and `dictionary`. + * If no scope is given, then all groups are returned, which is equivalent to passing + * `scope=translation,transliteration,dictionary`. To decide which set of supported languages + * is appropriate for your scenario, see the description of the [response object](#response-body).
* You can add these to a request with {@link RequestOptions#addQueryParam} *

Header Parameters

@@ -110,277 +70,166 @@ public final class TextTranslationClient { * NameTypeRequiredDescription * X-ClientTraceIdStringNoA client-generated GUID to uniquely identify the * request. + * Accept-LanguageStringNoThe language to use for user interface strings. Some of + * the fields in the response are names of languages or + * names of regions. Use this parameter to define the language in which these names are returned. + * The language is specified by providing a well-formed BCP 47 language tag. For instance, use the value `fr` + * to request names in French or use the value `zh-Hant` to request names in Chinese Traditional. + * Names are provided in the English language when a target language is not specified or when localization + * is not available. + * If-None-MatchStringNoPassing the value of the ETag response header in an + * If-None-Match field will allow the service to optimize the response. + * If the resource has not been modified, the service will return status code 304 and an empty response + * body. * * 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)
+     * {
+     *     translation (Optional): {
+     *         String (Required): {
+     *             name: String (Required)
+     *             nativeName: String (Required)
+     *             dir: String(ltr/rtl) (Required)
+     *             models (Required): [
+     *                 String (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)
+     *     }
+     *     transliteration (Optional): {
+     *         String (Required): {
+     *             name: String (Required)
+     *             nativeName: String (Required)
+     *             scripts (Required): [
+     *                  (Required){
+     *                     code: String (Required)
+     *                     name: String (Required)
+     *                     nativeName: String (Required)
+     *                     dir: String(ltr/rtl) (Required)
+     *                     toScripts (Required): [
+     *                          (Required){
+     *                             code: String (Required)
+     *                             name: String (Required)
+     *                             nativeName: String (Required)
+     *                             dir: String(ltr/rtl) (Required)
+     *                         }
      *                     ]
      *                 }
-     *             }
-     *         ]
-     *         sourceText (Optional): {
-     *             text: String (Required)
+     *             ]
      *         }
      *     }
-     * ]
+     *     models (Optional): [
+     *         String (Optional)
+     *     ]
+     * }
      * }
      * 
* - * @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}. + * @return the set of languages currently supported by other operations of the Translator 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); + public Response getSupportedLanguagesWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getSupportedLanguagesWithResponse(requestOptions); } /** - * Transliterate 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)
-     *     }
-     * ]
-     * }
-     * 
- * - *

Response Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         text: String (Required)
-     *         script: String (Required)
-     *     }
-     * ]
-     * }
-     * 
+ * Gets the set of languages currently supported by other operations of the Translator. * - * @param language Specifies the language of the text to convert from one script to another. - * Possible languages are listed in the transliteration scope obtained by querying the service - * for its supported languages. - * @param sourceLanguageScript Specifies the script used by the input text. Look up supported languages using the - * transliteration scope, - * to find input scripts available for the selected language. - * @param targetLanguageScript Specifies the output script. Look up supported languages using the transliteration - * scope, to find output - * scripts available for the selected combination of input language and input script. - * @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}. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the set of languages currently supported by other operations of the Translator. */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Response transliterateWithResponse(String language, String sourceLanguageScript, - String targetLanguageScript, BinaryData body, RequestOptions requestOptions) { - return this.serviceClient.transliterateWithResponse(language, sourceLanguageScript, targetLanguageScript, body, - requestOptions); + public GetSupportedLanguagesResult getSupportedLanguages() { + // Generated convenience method for getSupportedLanguagesWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getSupportedLanguagesWithResponse(requestOptions).getValue().toObject(GetSupportedLanguagesResult.class); } /** - * 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)
-     *         ]
-     *     }
-     * ]
-     * }
-     * 
+ * Gets the set of languages currently supported by other operations of the Translator. * - * @param body Defines the content of the request. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @param scope A comma-separated list of names defining the group of languages to return. + * Allowed group names are: `translation`, `transliteration` and `models`. + * If no scope is given, then all groups are returned, which is equivalent to passing + * `scope=translation,transliteration,models`. To decide which set of supported languages + * is appropriate for your scenario, see the description of the [response object](#response-body). + * @param acceptLanguage The language to use for user interface strings. Some of the fields in the response are + * names of languages or + * names of regions. Use this parameter to define the language in which these names are returned. + * The language is specified by providing a well-formed BCP 47 language tag. For instance, use the value `fr` + * to request names in French or use the value `zh-Hant` to request names in Chinese Traditional. + * Names are provided in the English language when a target language is not specified or when localization + * is not available. + * @param ifNoneMatch Passing the value of the ETag response header in an If-None-Match field will allow the service + * to optimize the response. + * If the resource has not been modified, the service will return status code 304 and an empty response body. + * @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. - * @return the response body along with {@link Response}. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the set of languages currently supported by other operations of the Translator. */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Response findSentenceBoundariesWithResponse(BinaryData body, RequestOptions requestOptions) { - return this.serviceClient.findSentenceBoundariesWithResponse(body, requestOptions); + private GetSupportedLanguagesResult getSupportedLanguages(String scope, String acceptLanguage, String ifNoneMatch) { + // Generated convenience method for getSupportedLanguagesWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (scope != null) { + requestOptions.addQueryParam("scope", scope, false); + } + if (acceptLanguage != null) { + requestOptions.setHeader(HttpHeaderName.ACCEPT_LANGUAGE, acceptLanguage); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + return getSupportedLanguagesWithResponse(requestOptions).getValue().toObject(GetSupportedLanguagesResult.class); } /** - * 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)
-     *                     }
-     *                 ]
-     *             }
-     *         ]
-     *     }
-     * ]
-     * }
-     * 
+ * Gets the set of languages currently supported by other operations of the Translator. * - * @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. + * @param scopes List of names defining the group of languages to return. + * @param acceptLanguage The language to use for user interface strings. Some of the fields in the response are + * names of languages or + * names of regions. Use this parameter to define the language in which these names are returned. + * The language is specified by providing a well-formed BCP 47 language tag. For instance, use the value `fr` + * to request names in French or use the value `zh-Hant` to request names in Chinese Traditional. + * Names are provided in the English language when a target language is not specified or when localization + * is not available. + * @param ifNoneMatch Passing the value of the ETag response header in an If-None-Match field will allow the service + * to optimize the response. + * If the resource has not been modified, the service will return status code 304 and an empty response body. + * @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. - * @return the response body along with {@link Response}. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the set of languages currently supported by other operations of the Translator. */ - @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Response lookupDictionaryEntriesWithResponse(String sourceLanguage, String targetLanguage, - BinaryData body, RequestOptions requestOptions) { - return this.serviceClient.lookupDictionaryEntriesWithResponse(sourceLanguage, targetLanguage, body, - requestOptions); + public GetSupportedLanguagesResult getSupportedLanguages(List scopes, String acceptLanguage, + String ifNoneMatch) { + return getSupportedLanguages(convertToScopesString(scopes), acceptLanguage, ifNoneMatch); } /** - * Lookup Dictionary Examples. + * Transliterate Text. *

Header Parameters

* * @@ -393,12 +242,13 @@ public Response lookupDictionaryEntriesWithResponse(String sourceLan * *
      * {@code
-     * [
-     *      (Required){
-     *         text: String (Required)
-     *         translation: String (Required)
-     *     }
-     * ]
+     * {
+     *     inputs (Required): [
+     *          (Required){
+     *             text: String (Required)
+     *         }
+     *     ]
+     * }
      * }
      * 
* @@ -406,514 +256,53 @@ public Response lookupDictionaryEntriesWithResponse(String sourceLan * *
      * {@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)
-     *             }
-     *         ]
-     *     }
-     * ]
+     * {
+     *     value (Required): [
+     *          (Required){
+     *             text: String (Required)
+     *             script: 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 language Specifies the language of the text to convert from one script to another. + * Possible languages are listed in the transliteration scope obtained by querying the service + * for its supported languages. + * @param fromScript Specifies the script used by the input text. Look up supported languages using the + * transliteration scope, + * to find input scripts available for the selected language. + * @param toScript Specifies the output script. Look up supported languages using the transliteration scope, to find + * output + * scripts available for the selected combination of input language and input script. * @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}. + * @return response for the transliteration API along with {@link Response}. */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Response lookupDictionaryExamplesWithResponse(String sourceLanguage, String targetLanguage, + public Response transliterateWithResponse(String language, String fromScript, String toScript, BinaryData body, RequestOptions requestOptions) { - return this.serviceClient.lookupDictionaryExamplesWithResponse(sourceLanguage, targetLanguage, body, - requestOptions); - } - - /** - * Translate Text. - * - * @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 clientTraceId A client-generated GUID to uniquely identify the request. - * @param sourceLanguage Specifies 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. - * @param textType 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 category A 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. - * @param profanityAction Specifies how profanities should be treated in translations. - * Possible values are: NoAction (default), Marked or Deleted. - * @param profanityMarker Specifies how profanities should be marked in translations. - * Possible values are: Asterisk (default) or Tag. - * @param includeAlignment Specifies whether to include alignment projection from source text to translated text. - * Possible values are: true or false (default). - * @param includeSentenceLength Specifies whether to include sentence boundaries for the input text and the - * translated text. - * Possible values are: true or false (default). - * @param suggestedSourceLanguage Specifies 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. - * @param sourceLanguageScript Specifies the script of the input text. - * @param targetLanguageScript Specifies the script of the translated text. - * @param allowFallback Specifies 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. - * @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. - */ - private List translate(List targetLanguages, List body, - String clientTraceId, String sourceLanguage, TextType textType, String category, - ProfanityAction profanityAction, ProfanityMarker profanityMarker, Boolean includeAlignment, - Boolean includeSentenceLength, String suggestedSourceLanguage, String sourceLanguageScript, - String targetLanguageScript, Boolean allowFallback) { - // Generated convenience method for translateWithResponse - RequestOptions requestOptions = new RequestOptions(); - if (clientTraceId != null) { - requestOptions.setHeader(HttpHeaderName.fromString("X-ClientTraceId"), clientTraceId); - } - if (sourceLanguage != null) { - requestOptions.addQueryParam("from", sourceLanguage, false); - } - if (textType != null) { - requestOptions.addQueryParam("textType", textType.toString(), false); - } - if (category != null) { - requestOptions.addQueryParam("category", category, false); - } - if (profanityAction != null) { - requestOptions.addQueryParam("profanityAction", profanityAction.toString(), false); - } - if (profanityMarker != null) { - requestOptions.addQueryParam("profanityMarker", profanityMarker.toString(), false); - } - if (includeAlignment != null) { - requestOptions.addQueryParam("includeAlignment", String.valueOf(includeAlignment), false); - } - if (includeSentenceLength != null) { - requestOptions.addQueryParam("includeSentenceLength", String.valueOf(includeSentenceLength), false); - } - if (suggestedSourceLanguage != null) { - requestOptions.addQueryParam("suggestedFrom", suggestedSourceLanguage, false); - } - if (sourceLanguageScript != null) { - requestOptions.addQueryParam("fromScript", sourceLanguageScript, false); - } - if (targetLanguageScript != null) { - requestOptions.addQueryParam("toScript", targetLanguageScript, false); - } - if (allowFallback != null) { - requestOptions.addQueryParam("allowFallback", String.valueOf(allowFallback), false); - } - return translateWithResponse(targetLanguages, BinaryData.fromObject(body), requestOptions).getValue() - .toObject(TYPE_REFERENCE_LIST_TRANSLATED_TEXT_ITEM); - } - - /** - * Translate Text. - * - * @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. - * @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. - */ - private List translateInner(List targetLanguages, List body) { - // Generated convenience method for translateWithResponse - RequestOptions requestOptions = new RequestOptions(); - return translateWithResponse(targetLanguages, BinaryData.fromObject(body), requestOptions).getValue() - .toObject(TYPE_REFERENCE_LIST_TRANSLATED_TEXT_ITEM); - } - - /** - * Translate Text. - *

- * This method is used when you have single target language and multiple texts to translate. - *

- * - * @param targetLanguage 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 texts 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. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public List translate(String targetLanguage, List texts) { - return translateInner(Arrays.asList(targetLanguage), convertTextToData(texts)); - } - - /** - * Translate Text. - *

- * This method is used when you have single target language and single text to translate. - *

- * - * @param targetLanguage 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 text 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. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public TranslatedTextItem translate(String targetLanguage, String text) { - return translate(targetLanguage, Arrays.asList(text)).get(0); - } - - /** - * Translate Text. - *

- * This method is used when you have one input text and the optional parameters are needed such as specification - * of a source language, profanity handling etc. - *

- * - * @param text Text to translate. - * @param translateOptions Translate Options. - * @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. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public TranslatedTextItem translate(String text, TranslateOptions translateOptions) { - return translate(Arrays.asList(text), translateOptions).get(0); - } - - /** - * Translate Text. - *

- * This method is used when you have multiple texts and the optional parameters are needed such as specification - * of a source language, profanity handling etc.. - *

- * - * @param texts List of text to translate. - * @param translateOptions Translate Options. - * @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. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public List translate(List texts, TranslateOptions translateOptions) { - List content = new ArrayList<>(); - for (String text : texts) { - content.add(new InputTextItem(text)); - } - return translate(translateOptions.getTargetLanguages(), content, translateOptions.getClientTraceId(), - translateOptions.getSourceLanguage(), translateOptions.getTextType(), translateOptions.getCategory(), - translateOptions.getProfanityAction(), translateOptions.getProfanityMarker(), - translateOptions.isIncludeAlignment(), translateOptions.isIncludeSentenceLength(), - translateOptions.getSuggestedSourceLanguage(), translateOptions.getSourceLanguageScript(), - translateOptions.getTargetLanguageScript(), translateOptions.isAllowFallback()); - } - - /** - * Transliterate Text. - * - * @param language Specifies the language of the text to convert from one script to another. - * Possible languages are listed in the transliteration scope obtained by querying the service - * for its supported languages. - * @param sourceLanguageScript Specifies the script used by the input text. Look up supported languages using the - * transliteration scope, - * to find input scripts available for the selected language. - * @param targetLanguageScript Specifies the output script. Look up supported languages using the transliteration - * scope, to find output - * scripts available for the selected combination of input language and input script. - * @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. - */ - private List transliterateInner(String language, String sourceLanguageScript, - String targetLanguageScript, List body) { - // Generated convenience method for transliterateWithResponse - RequestOptions requestOptions = new RequestOptions(); - return transliterateWithResponse(language, sourceLanguageScript, targetLanguageScript, - BinaryData.fromObject(body), requestOptions).getValue().toObject(TYPE_REFERENCE_LIST_TRANSLITERATED_TEXT); - } - - /** - * Transliterate Text. - *

- * This method is used when you have multiple texts to transliterate and you want to provide client trace id. - *

- * - * @param language Specifies the language of the text to convert from one script to another. - * Possible languages are listed in the transliteration scope obtained by querying the service - * for its supported languages. - * @param sourceLanguageScript Specifies the script used by the input text. Look up supported languages using the - * transliteration scope, - * to find input scripts available for the selected language. - * @param targetLanguageScript Specifies the output script. Look up supported languages using the transliteration - * scope, to find output - * scripts available for the selected combination of input language and input script. - * @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. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public List transliterate(String language, String sourceLanguageScript, - String targetLanguageScript, List body) { - return transliterateInner(language, sourceLanguageScript, targetLanguageScript, convertTextToData(body)); - } - - /** - * Transliterate Text. - *

- * This method is used when you have single text to transliterate and you want to provide client trace id. - *

- * - * @param language Specifies the language of the text to convert from one script to another. - * Possible languages are listed in the transliteration scope obtained by querying the service - * for its supported languages. - * @param sourceLanguageScript Specifies the script used by the input text. Look up supported languages using the - * transliteration scope, - * to find input scripts available for the selected language. - * @param targetLanguageScript Specifies the output script. Look up supported languages using the transliteration - * scope, to find output - * scripts available for the selected combination of input language and input script. - * @param text 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. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public TransliteratedText transliterate(String language, String sourceLanguageScript, String targetLanguageScript, - String text) { - return transliterate(language, sourceLanguageScript, targetLanguageScript, Arrays.asList(text)).get(0); - } - - /** - * Find Sentence Boundaries. - * - * @param body Defines the content of the request. - * @param language Language tag identifying the language of the input text. - * If a code isn't specified, automatic language detection will be applied. - * @param script Script tag identifying the script used by the input text. - * If a script isn't specified, the default script of the language will be assumed. - * @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. - */ - private List findSentenceBoundariesInner(List body, String language, - String script) { - // Generated convenience method for findSentenceBoundariesWithResponse - RequestOptions requestOptions = new RequestOptions(); - if (language != null) { - requestOptions.addQueryParam("language", language, false); - } - if (script != null) { - requestOptions.addQueryParam("script", script, false); - } - return findSentenceBoundariesWithResponse(BinaryData.fromObject(body), requestOptions).getValue() - .toObject(TYPE_REFERENCE_LIST_BREAK_SENTENCE_ITEM); - } - - /** - * Find Sentence Boundaries. - *

- * This method is used when you have multiple texts for which you want to find sentence boundaries and you want to - * provide - * client trace id. - *

- * - * @param texts Defines the content of the request. - * @param language Language tag identifying the language of the input text. - * If a code isn't specified, automatic language detection will be applied. - * @param script Script tag identifying the script used by the input text. - * If a script isn't specified, the default script of the language will be assumed. - * @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. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public List findSentenceBoundaries(List texts, String language, String script) { - return findSentenceBoundariesInner(convertTextToData(texts), language, script); - } - - /** - * Find Sentence Boundaries. - *

- * This method is used when you have single text for which you want to find sentence boundaries and you want to - * provide - * client trace id. - *

- * - * @param text Defines the content of the request. - * @param language Language tag identifying the language of the input text. - * If a code isn't specified, automatic language detection will be applied. - * @param script Script tag identifying the script used by the input text. - * If a script isn't specified, the default script of the language will be assumed. - * @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. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public BreakSentenceItem findSentenceBoundaries(String text, String language, String script) { - return findSentenceBoundaries(Arrays.asList(text), language, script).get(0); - } - - /** - * Find Sentence Boundaries. - * - * @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. - */ - private List findSentenceBoundariesInner(List body) { - // Generated convenience method for findSentenceBoundariesWithResponse - RequestOptions requestOptions = new RequestOptions(); - return findSentenceBoundariesWithResponse(BinaryData.fromObject(body), requestOptions).getValue() - .toObject(TYPE_REFERENCE_LIST_BREAK_SENTENCE_ITEM); - } - - /** - * Find Sentence Boundaries. - *

- * This method is used when you have multiple texts for which you want to find sentence boundaries and you want - * the source language to be auto-detected by the service. - *

- * - * @param texts 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. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public List findSentenceBoundaries(List texts) { - return findSentenceBoundariesInner(convertTextToData(texts)); - } - - /** - * Find Sentence Boundaries. - *

- * This method is used when you have single text for which you want to find sentence boundaries and you want - * the source language to be auto-detected by the service. - *

- * - * @param text 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. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public BreakSentenceItem findSentenceBoundaries(String text) { - return findSentenceBoundaries(Arrays.asList(text)).get(0); + return this.serviceClient.transliterateWithResponse(language, fromScript, toScript, body, requestOptions); } /** - * Lookup Dictionary Entries. + * Transliterate Text. * - * @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 language Specifies the language of the text to convert from one script to another. + * Possible languages are listed in the transliteration scope obtained by querying the service + * for its supported languages. + * @param sourceLanguageScript Specifies the script used by the input text. Look up supported languages using the + * transliteration scope, + * to find input scripts available for the selected language. + * @param targetLanguageScript Specifies the output script. Look up supported languages using the transliteration + * scope, to find output + * scripts available for the selected combination of input language and input script. * @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. @@ -923,26 +312,31 @@ public BreakSentenceItem findSentenceBoundaries(String text) { * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the response. */ - private List lookupDictionaryEntriesInner(String sourceLanguage, String targetLanguage, - List body) { - // Generated convenience method for lookupDictionaryEntriesWithResponse + private List transliterateInner(String language, String sourceLanguageScript, + String targetLanguageScript, List body) { RequestOptions requestOptions = new RequestOptions(); - return lookupDictionaryEntriesWithResponse(sourceLanguage, targetLanguage, BinaryData.fromObject(body), - requestOptions).getValue().toObject(TYPE_REFERENCE_LIST_DICTIONARY_LOOKUP_ITEM); + TransliterateBody transliterateBody = new TransliterateBody(body); + TransliterateResult result = transliterateWithResponse(language, sourceLanguageScript, targetLanguageScript, + BinaryData.fromObject(transliterateBody), requestOptions).getValue().toObject(TransliterateResult.class); + return result.getValue(); } /** - * Lookup Dictionary Entries. + * Transliterate Text. *

- * This method is used when you want lookup multiple entries in the dictionary and you want to provide - * client trace id. + * This method is used when you have multiple texts to transliterate and you want to provide client trace id. *

* - * @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 texts Defines the content of the request. + * @param language Specifies the language of the text to convert from one script to another. + * Possible languages are listed in the transliteration scope obtained by querying the service + * for its supported languages. + * @param sourceLanguageScript Specifies the script used by the input text. Look up supported languages using the + * transliteration scope, + * to find input scripts available for the selected language. + * @param targetLanguageScript Specifies the output script. Look up supported languages using the transliteration + * scope, to find output + * scripts available for the selected combination of input language and input script. + * @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. @@ -951,23 +345,28 @@ private List lookupDictionaryEntriesInner(String sourceLan * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the response. */ - @ServiceMethod(returns = ReturnType.SINGLE) - public List lookupDictionaryEntries(String sourceLanguage, String targetLanguage, - List texts) { - return lookupDictionaryEntriesInner(sourceLanguage, targetLanguage, convertTextToData(texts)); + @ServiceMethod(returns = ReturnType.COLLECTION) + public List transliterate(String language, String sourceLanguageScript, + String targetLanguageScript, List body) { + return transliterateInner(language, sourceLanguageScript, targetLanguageScript, + convertTextsToInputTextItems(body)); } /** - * Lookup Dictionary Entries. + * Transliterate Text. *

- * This method is used when you want lookup single entry in the dictionary and you want to provide - * client trace id. + * This method is used when you have single text to transliterate and you want to provide client trace id. *

* - * @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 language Specifies the language of the text to convert from one script to another. + * Possible languages are listed in the transliteration scope obtained by querying the service + * for its supported languages. + * @param sourceLanguageScript Specifies the script used by the input text. Look up supported languages using the + * transliteration scope, + * to find input scripts available for the selected language. + * @param targetLanguageScript Specifies the output script. Look up supported languages using the transliteration + * scope, to find output + * scripts available for the selected combination of input language and input script. * @param text Defines the content of the request. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. @@ -978,249 +377,197 @@ public List lookupDictionaryEntries(String sourceLanguage, * @return the response. */ @ServiceMethod(returns = ReturnType.SINGLE) - public DictionaryLookupItem lookupDictionaryEntries(String sourceLanguage, String targetLanguage, String text) { - 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); + public TransliteratedText transliterate(String language, String sourceLanguageScript, String targetLanguageScript, + String text) { + return transliterate(language, sourceLanguageScript, targetLanguageScript, Arrays.asList(text)).get(0); } - @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>() { - }; - /** - * Gets the set of languages currently supported by other operations of the Translator. - *

Query Parameters

- *
Header Parameters
- * - * - * - *
Query Parameters
NameTypeRequiredDescription
scopeStringNoA comma-separated list of names defining the group of languages - * to return. - * Allowed group names are: `translation`, `transliteration` and `dictionary`. - * If no scope is given, then all groups are returned, which is equivalent to passing - * `scope=translation,transliteration,dictionary`. To decide which set of supported languages - * is appropriate for your scenario, see the description of the [response object](#response-body).
- * You can add these to a request with {@link RequestOptions#addQueryParam} + * Translate Text. *

Header Parameters

* * * * - * - * *
Header Parameters
NameTypeRequiredDescription
X-ClientTraceIdStringNoA client-generated GUID to uniquely identify the * request.
Accept-LanguageStringNoThe language to use for user interface strings. Some of - * the fields in the response are names of languages or - * names of regions. Use this parameter to define the language in which these names are returned. - * The language is specified by providing a well-formed BCP 47 language tag. For instance, use the value `fr` - * to request names in French or use the value `zh-Hant` to request names in Chinese Traditional. - * Names are provided in the English language when a target language is not specified or when localization - * is not available.
If-None-MatchStringNoPassing the value of the ETag response header in an - * If-None-Match field will allow the service to optimize the response. - * If the resource has not been modified, the service will return status code 304 and an empty response - * body.
* You can add these to a request with {@link RequestOptions#addHeader} - *

Response Body Schema

+ *

Request Body Schema

* *
      * {@code
      * {
-     *     translation (Optional): {
-     *         String (Required): {
-     *             name: String (Required)
-     *             nativeName: String (Required)
-     *             dir: String(ltr/rtl) (Required)
-     *         }
-     *     }
-     *     transliteration (Optional): {
-     *         String (Required): {
-     *             name: String (Required)
-     *             nativeName: String (Required)
-     *             scripts (Required): [
+     *     inputs (Required): [
+     *          (Required){
+     *             text: String (Required)
+     *             script: String (Optional)
+     *             language: String (Optional)
+     *             textType: String(Plain/Html) (Optional)
+     *             targets (Required): [
      *                  (Required){
-     *                     code: String (Required)
-     *                     name: String (Required)
-     *                     nativeName: String (Required)
-     *                     dir: String(ltr/rtl) (Required)
-     *                     toScripts (Required): [
-     *                          (Required){
-     *                             code: String (Required)
-     *                             name: String (Required)
-     *                             nativeName: String (Required)
-     *                             dir: String(ltr/rtl) (Required)
+     *                     language: String (Required)
+     *                     script: String (Optional)
+     *                     profanityAction: String(NoAction/Marked/Deleted) (Optional)
+     *                     profanityMarker: String(Asterisk/Tag) (Optional)
+     *                     deploymentName: String (Optional)
+     *                     allowFallback: Boolean (Optional)
+     *                     grade: String (Optional)
+     *                     tone: String (Optional)
+     *                     gender: String (Optional)
+     *                     adaptiveDatasetId: String (Optional)
+     *                     referenceTextPairs (Optional): [
+     *                          (Optional){
+     *                             source: String (Required)
+     *                             target: String (Required)
      *                         }
      *                     ]
      *                 }
      *             ]
      *         }
-     *     }
-     *     dictionary (Optional): {
-     *         String (Required): {
-     *             name: String (Required)
-     *             nativeName: String (Required)
-     *             dir: String(ltr/rtl) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *          (Required){
+     *             detectedLanguage (Optional): {
+     *                 language: String (Required)
+     *                 score: double (Required)
+     *             }
      *             translations (Required): [
      *                  (Required){
-     *                     name: String (Required)
-     *                     nativeName: String (Required)
-     *                     dir: String(ltr/rtl) (Required)
-     *                     code: String (Required)
+     *                     language: String (Required)
+     *                     sourceCharacters: Integer (Optional)
+     *                     instructionTokens: Integer (Optional)
+     *                     sourceTokens: Integer (Optional)
+     *                     responseTokens: Integer (Optional)
+     *                     targetTokens: Integer (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 set of languages currently supported by other operations of the Translator along with - * {@link Response}. + * @return response for the translation API along with {@link Response}. */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Response getSupportedLanguagesWithResponse(RequestOptions requestOptions) { - return this.serviceClient.getSupportedLanguagesWithResponse(requestOptions); + public Response translateWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.translateWithResponse(body, requestOptions); } /** - * Gets the set of languages currently supported by other operations of the Translator. + * Translate Text. * - * @param scope A comma-separated list of names defining the group of languages to return. - * Allowed group names are: `translation`, `transliteration` and `dictionary`. - * If no scope is given, then all groups are returned, which is equivalent to passing - * `scope=translation,transliteration,dictionary`. To decide which set of supported languages - * is appropriate for your scenario, see the description of the [response object](#response-body). - * @param acceptLanguage The language to use for user interface strings. Some of the fields in the response are - * names of languages or - * names of regions. Use this parameter to define the language in which these names are returned. - * The language is specified by providing a well-formed BCP 47 language tag. For instance, use the value `fr` - * to request names in French or use the value `zh-Hant` to request names in Chinese Traditional. - * Names are provided in the English language when a target language is not specified or when localization - * is not available. - * @param ifNoneMatch Passing the value of the ETag response header in an If-None-Match field will allow the service - * to optimize the response. - * If the resource has not been modified, the service will return status code 304 and an empty response body. + * @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 set of languages currently supported by other operations of the Translator. + * @return the response. */ - private GetSupportedLanguagesResult getSupportedLanguages(String scope, String acceptLanguage, String ifNoneMatch) { - // Generated convenience method for getSupportedLanguagesWithResponse + @ServiceMethod(returns = ReturnType.COLLECTION) + public List translate(List body) { + // Generated convenience method for translateWithResponse RequestOptions requestOptions = new RequestOptions(); - if (scope != null) { - requestOptions.addQueryParam("scope", scope, false); - } - if (acceptLanguage != null) { - requestOptions.setHeader(HttpHeaderName.ACCEPT_LANGUAGE, acceptLanguage); - } - if (ifNoneMatch != null) { - requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); - } - return getSupportedLanguagesWithResponse(requestOptions).getValue().toObject(GetSupportedLanguagesResult.class); + TranslateBody translateBody = new TranslateBody(body); + TranslationResult result + = translateWithResponse(BinaryData.fromObject(translateBody), requestOptions).getValue() + .toObject(TranslationResult.class); + return result.getValue(); } /** - * Gets the set of languages currently supported by other operations of the Translator. + * Translate Text. * - * @param scopes List of names defining the group of languages to return. - * @param acceptLanguage The language to use for user interface strings. Some of the fields in the response are - * names of languages or - * names of regions. Use this parameter to define the language in which these names are returned. - * The language is specified by providing a well-formed BCP 47 language tag. For instance, use the value `fr` - * to request names in French or use the value `zh-Hant` to request names in Chinese Traditional. - * Names are provided in the English language when a target language is not specified or when localization - * is not available. - * @param ifNoneMatch Passing the value of the ETag response header in an If-None-Match field will allow the service - * to optimize the response. - * If the resource has not been modified, the service will return status code 304 and an empty response body. + * @param input 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 set of languages currently supported by other operations of the Translator. + * @return the response. */ @ServiceMethod(returns = ReturnType.SINGLE) - public GetSupportedLanguagesResult getSupportedLanguages(List scopes, String acceptLanguage, - String ifNoneMatch) { - return getSupportedLanguages(convertToScopesString(scopes), acceptLanguage, ifNoneMatch); + public TranslatedTextItem translate(TranslateInputItem input) { + return translate(Arrays.asList(input)).get(0); } /** - * Gets the set of languages currently supported by other operations of the Translator. + * Translate Text. + *

+ * This method is used when you have single target language and multiple texts to translate. + *

* + * @param targetLanguage 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 texts 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 set of languages currently supported by other operations of the Translator. + * @return the response. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public List translate(String targetLanguage, List texts) { + List body = new ArrayList<>(); + for (String text : texts) { + TranslateInputItem translateInputItem + = new TranslateInputItem(text, Arrays.asList(new TranslationTarget(targetLanguage))); + body.add(translateInputItem); + } + return translate(body); + } + + /** + * Translate Text. + *

+ * This method is used when you have single target language and single text to translate. + *

+ * + * @param targetLanguage 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 text 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 GetSupportedLanguagesResult getSupportedLanguages() { - // Generated convenience method for getSupportedLanguagesWithResponse - RequestOptions requestOptions = new RequestOptions(); - return getSupportedLanguagesWithResponse(requestOptions).getValue().toObject(GetSupportedLanguagesResult.class); + public TranslatedTextItem translate(String targetLanguage, String text) { + return translate(targetLanguage, Arrays.asList(text)).get(0); } - private List convertTextToData(List texts) { + private List convertTextsToInputTextItems(List texts) { List content = new ArrayList<>(); for (String text : texts) { content.add(new InputTextItem(text)); @@ -1241,32 +588,4 @@ private String convertToScopesString(List scopes) { } return result.toString(); } - - /** - * 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. - * @param clientTraceId A client-generated GUID to uniquely identify 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. - */ - private List lookupDictionaryExamples(String sourceLanguage, String targetLanguage, - List body, String clientTraceId) { - // Generated convenience method for lookupDictionaryExamplesWithResponse - RequestOptions requestOptions = new RequestOptions(); - if (clientTraceId != null) { - requestOptions.setHeader(HttpHeaderName.fromString("X-ClientTraceId"), clientTraceId); - } - return lookupDictionaryExamplesWithResponse(sourceLanguage, targetLanguage, BinaryData.fromObject(body), - requestOptions).getValue().toObject(TYPE_REFERENCE_LIST_DICTIONARY_EXAMPLE_ITEM); - } } 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..2e101a504d35 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 @@ -13,7 +13,12 @@ public enum TextTranslationServiceVersion implements ServiceVersion { /** * Enum value 3.0. */ - V3_0("3.0"); + V3_0("3.0"), + + /** + * Enum value 2025-10-01-preview. + */ + V2025_10_01_PREVIEW("2025-10-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_10_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 18b1cb1dc711..8a5f5217e50c 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); @@ -207,8 +202,8 @@ Response translateSync(@HostParam("Endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Mono> transliterate(@HostParam("Endpoint") String endpoint, - @QueryParam("language") String language, @QueryParam("fromScript") String sourceLanguageScript, - @QueryParam("toScript") String targetLanguageScript, @QueryParam("api-version") String apiVersion, + @QueryParam("language") String language, @QueryParam("fromScript") String fromScript, + @QueryParam("toScript") String toScript, @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @@ -219,80 +214,10 @@ Mono> transliterate(@HostParam("Endpoint") String endpoint, @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) Response transliterateSync(@HostParam("Endpoint") String endpoint, - @QueryParam("language") String language, @QueryParam("fromScript") String sourceLanguageScript, - @QueryParam("toScript") String targetLanguageScript, @QueryParam("api-version") String apiVersion, + @QueryParam("language") String language, @QueryParam("fromScript") String fromScript, + @QueryParam("toScript") String toScript, @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); } /** @@ -338,6 +263,9 @@ Response lookupDictionaryExamplesSync(@HostParam("Endpoint") String * name: String (Required) * nativeName: String (Required) * dir: String(ltr/rtl) (Required) + * models (Required): [ + * String (Required) + * ] * } * } * transliteration (Optional): { @@ -362,21 +290,9 @@ Response lookupDictionaryExamplesSync(@HostParam("Endpoint") String * ] * } * } - * dictionary (Optional): { - * String (Required): { - * name: String (Required) - * nativeName: String (Required) - * dir: String(ltr/rtl) (Required) - * translations (Required): [ - * (Required){ - * name: String (Required) - * nativeName: String (Required) - * dir: String(ltr/rtl) (Required) - * code: String (Required) - * } - * ] - * } - * } + * models (Optional): [ + * String (Optional) + * ] * } * } * @@ -439,6 +355,9 @@ public Mono> getSupportedLanguagesWithResponseAsync(Request * name: String (Required) * nativeName: String (Required) * dir: String(ltr/rtl) (Required) + * models (Required): [ + * String (Required) + * ] * } * } * transliteration (Optional): { @@ -463,21 +382,9 @@ public Mono> getSupportedLanguagesWithResponseAsync(Request * ] * } * } - * dictionary (Optional): { - * String (Required): { - * name: String (Required) - * nativeName: String (Required) - * dir: String(ltr/rtl) (Required) - * translations (Required): [ - * (Required){ - * name: String (Required) - * nativeName: String (Required) - * dir: String(ltr/rtl) (Required) - * code: String (Required) - * } - * ] - * } - * } + * models (Optional): [ + * String (Optional) + * ] * } * } * @@ -499,55 +406,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

* * @@ -560,11 +418,36 @@ public Response getSupportedLanguagesWithResponse(RequestOptions req * *
      * {@code
-     * [
-     *      (Required){
-     *         text: String (Required)
-     *     }
-     * ]
+     * {
+     *     inputs (Required): [
+     *          (Required){
+     *             text: String (Required)
+     *             script: String (Optional)
+     *             language: String (Optional)
+     *             textType: String(Plain/Html) (Optional)
+     *             targets (Required): [
+     *                  (Required){
+     *                     language: String (Required)
+     *                     script: String (Optional)
+     *                     profanityAction: String(NoAction/Marked/Deleted) (Optional)
+     *                     profanityMarker: String(Asterisk/Tag) (Optional)
+     *                     deploymentName: String (Optional)
+     *                     allowFallback: Boolean (Optional)
+     *                     grade: String (Optional)
+     *                     tone: String (Optional)
+     *                     gender: String (Optional)
+     *                     adaptiveDatasetId: String (Optional)
+     *                     referenceTextPairs (Optional): [
+     *                          (Optional){
+     *                             source: String (Required)
+     *                             target: String (Required)
+     *                         }
+     *                     ]
+     *                 }
+     *             ]
+     *         }
+     *     ]
+     * }
      * }
      * 
* @@ -572,116 +455,48 @@ public Response getSupportedLanguagesWithResponse(RequestOptions req * *
      * {@code
-     * [
-     *      (Required){
-     *         detectedLanguage (Optional): {
-     *             language: String (Required)
-     *             score: double (Required)
-     *         }
-     *         translations (Required): [
-     *              (Required){
-     *                 to: String (Required)
-     *                 text: String (Required)
-     *                 transliteration (Optional): {
+     * {
+     *     value (Required): [
+     *          (Required){
+     *             detectedLanguage (Optional): {
+     *                 language: String (Required)
+     *                 score: double (Required)
+     *             }
+     *             translations (Required): [
+     *                  (Required){
+     *                     language: String (Required)
+     *                     sourceCharacters: Integer (Optional)
+     *                     instructionTokens: Integer (Optional)
+     *                     sourceTokens: Integer (Optional)
+     *                     responseTokens: Integer (Optional)
+     *                     targetTokens: Integer (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}. + * @return response for the translation API 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

* * @@ -694,11 +509,36 @@ public Mono> translateWithResponseAsync(List target * *
      * {@code
-     * [
-     *      (Required){
-     *         text: String (Required)
-     *     }
-     * ]
+     * {
+     *     inputs (Required): [
+     *          (Required){
+     *             text: String (Required)
+     *             script: String (Optional)
+     *             language: String (Optional)
+     *             textType: String(Plain/Html) (Optional)
+     *             targets (Required): [
+     *                  (Required){
+     *                     language: String (Required)
+     *                     script: String (Optional)
+     *                     profanityAction: String(NoAction/Marked/Deleted) (Optional)
+     *                     profanityMarker: String(Asterisk/Tag) (Optional)
+     *                     deploymentName: String (Optional)
+     *                     allowFallback: Boolean (Optional)
+     *                     grade: String (Optional)
+     *                     tone: String (Optional)
+     *                     gender: String (Optional)
+     *                     adaptiveDatasetId: String (Optional)
+     *                     referenceTextPairs (Optional): [
+     *                          (Optional){
+     *                             source: String (Required)
+     *                             target: String (Required)
+     *                         }
+     *                     ]
+     *                 }
+     *             ]
+     *         }
+     *     ]
+     * }
      * }
      * 
* @@ -706,63 +546,44 @@ public Mono> translateWithResponseAsync(List target * *
      * {@code
-     * [
-     *      (Required){
-     *         detectedLanguage (Optional): {
-     *             language: String (Required)
-     *             score: double (Required)
-     *         }
-     *         translations (Required): [
-     *              (Required){
-     *                 to: String (Required)
-     *                 text: String (Required)
-     *                 transliteration (Optional): {
+     * {
+     *     value (Required): [
+     *          (Required){
+     *             detectedLanguage (Optional): {
+     *                 language: String (Required)
+     *                 score: double (Required)
+     *             }
+     *             translations (Required): [
+     *                  (Required){
+     *                     language: String (Required)
+     *                     sourceCharacters: Integer (Optional)
+     *                     instructionTokens: Integer (Optional)
+     *                     sourceTokens: Integer (Optional)
+     *                     responseTokens: Integer (Optional)
+     *                     targetTokens: Integer (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}. + * @return response for the translation API 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); } /** @@ -779,11 +600,13 @@ public Response translateWithResponse(List targetLanguages, * *
      * {@code
-     * [
-     *      (Required){
-     *         text: String (Required)
-     *     }
-     * ]
+     * {
+     *     inputs (Required): [
+     *          (Required){
+     *             text: String (Required)
+     *         }
+     *     ]
+     * }
      * }
      * 
* @@ -791,23 +614,25 @@ public Response translateWithResponse(List targetLanguages, * *
      * {@code
-     * [
-     *      (Required){
-     *         text: String (Required)
-     *         script: String (Required)
-     *     }
-     * ]
+     * {
+     *     value (Required): [
+     *          (Required){
+     *             text: String (Required)
+     *             script: String (Required)
+     *         }
+     *     ]
+     * }
      * }
      * 
* * @param language Specifies the language of the text to convert from one script to another. * Possible languages are listed in the transliteration scope obtained by querying the service * for its supported languages. - * @param sourceLanguageScript Specifies the script used by the input text. Look up supported languages using the + * @param fromScript Specifies the script used by the input text. Look up supported languages using the * transliteration scope, * to find input scripts available for the selected language. - * @param targetLanguageScript Specifies the output script. Look up supported languages using the transliteration - * scope, to find output + * @param toScript Specifies the output script. Look up supported languages using the transliteration scope, to find + * output * scripts available for the selected combination of input language and input script. * @param body Defines the content of the request. * @param requestOptions The options to configure the HTTP request before HTTP client sends it. @@ -815,16 +640,16 @@ public Response translateWithResponse(List targetLanguages, * @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}. + * @return response for the transliteration API along with {@link Response} on successful completion of + * {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> transliterateWithResponseAsync(String language, String sourceLanguageScript, - String targetLanguageScript, BinaryData body, RequestOptions requestOptions) { + public Mono> transliterateWithResponseAsync(String language, String fromScript, + String toScript, BinaryData body, RequestOptions requestOptions) { final String contentType = "application/json"; final String accept = "application/json"; - return FluxUtil.withContext( - context -> service.transliterate(this.getEndpoint(), language, sourceLanguageScript, targetLanguageScript, - this.getServiceVersion().getVersion(), contentType, accept, body, requestOptions, context)); + return FluxUtil.withContext(context -> service.transliterate(this.getEndpoint(), language, fromScript, toScript, + this.getServiceVersion().getVersion(), contentType, accept, body, requestOptions, context)); } /** @@ -841,11 +666,13 @@ public Mono> transliterateWithResponseAsync(String language * *
      * {@code
-     * [
-     *      (Required){
-     *         text: String (Required)
-     *     }
-     * ]
+     * {
+     *     inputs (Required): [
+     *          (Required){
+     *             text: String (Required)
+     *         }
+     *     ]
+     * }
      * }
      * 
* @@ -853,23 +680,25 @@ public Mono> transliterateWithResponseAsync(String language * *
      * {@code
-     * [
-     *      (Required){
-     *         text: String (Required)
-     *         script: String (Required)
-     *     }
-     * ]
+     * {
+     *     value (Required): [
+     *          (Required){
+     *             text: String (Required)
+     *             script: String (Required)
+     *         }
+     *     ]
+     * }
      * }
      * 
* * @param language Specifies the language of the text to convert from one script to another. * Possible languages are listed in the transliteration scope obtained by querying the service * for its supported languages. - * @param sourceLanguageScript Specifies the script used by the input text. Look up supported languages using the + * @param fromScript Specifies the script used by the input text. Look up supported languages using the * transliteration scope, * to find input scripts available for the selected language. - * @param targetLanguageScript Specifies the output script. Look up supported languages using the transliteration - * scope, to find output + * @param toScript Specifies the output script. Look up supported languages using the transliteration scope, to find + * output * scripts available for the selected combination of input language and input script. * @param body Defines the content of the request. * @param requestOptions The options to configure the HTTP request before HTTP client sends it. @@ -877,427 +706,14 @@ public Mono> transliterateWithResponseAsync(String language * @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 transliterateWithResponse(String language, String sourceLanguageScript, - String targetLanguageScript, BinaryData body, RequestOptions requestOptions) { - final String contentType = "application/json"; - final String accept = "application/json"; - 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}. + * @return response for the transliteration API along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response lookupDictionaryExamplesWithResponse(String sourceLanguage, String targetLanguage, + public Response transliterateWithResponse(String language, String fromScript, String toScript, BinaryData body, RequestOptions requestOptions) { final String contentType = "application/json"; final String accept = "application/json"; - return service.lookupDictionaryExamplesSync(this.getEndpoint(), sourceLanguage, targetLanguage, + return service.transliterateSync(this.getEndpoint(), language, fromScript, toScript, 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/BackTranslation.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/BackTranslation.java deleted file mode 100644 index 73ed1cdbcf4d..000000000000 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/BackTranslation.java +++ /dev/null @@ -1,170 +0,0 @@ -// 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; - -/** - * Back Translation. - */ -@Immutable -public final class BackTranslation implements JsonSerializable { - - /* - * A string giving the normalized form of the source term that is a back-translation of the target. - * This value should be used as input to lookup examples. - */ - @Generated - private final String normalizedText; - - /* - * A string giving the source term that is a back-translation of the target in a form best - * suited for end-user display. - */ - @Generated - private final String displayText; - - /* - * An integer representing the number of examples that are available for this translation pair. - * Actual examples must be retrieved with a separate call to lookup examples. The number is mostly - * intended to facilitate display in a UX. For example, a user interface may add a hyperlink - * to the back-translation if the number of examples is greater than zero and show the back-translation - * as plain text if there are no examples. Note that the actual number of examples returned - * by a call to lookup examples may be less than numExamples, because additional filtering may be - * applied on the fly to remove "bad" examples. - */ - @Generated - private final int examplesCount; - - /* - * An integer representing the frequency of this translation pair in the data. The main purpose of this - * field is to provide a user interface with a means to sort back-translations so the most frequent terms are first. - */ - @Generated - private final int frequencyCount; - - /** - * Creates an instance of BackTranslation class. - * - * @param normalizedText the normalizedText value to set. - * @param displayText the displayText value to set. - * @param examplesCount the examplesCount value to set. - * @param frequencyCount the frequencyCount value to set. - */ - @Generated - private BackTranslation(String normalizedText, String displayText, int examplesCount, int frequencyCount) { - this.normalizedText = normalizedText; - this.displayText = displayText; - this.examplesCount = examplesCount; - this.frequencyCount = frequencyCount; - } - - /** - * Get the normalizedText property: A string giving the normalized form of the source term that is a - * back-translation of the target. - * This value should be used as input to lookup examples. - * - * @return the normalizedText value. - */ - @Generated - public String getNormalizedText() { - return this.normalizedText; - } - - /** - * Get the displayText property: A string giving the source term that is a back-translation of the target in a form - * best - * suited for end-user display. - * - * @return the displayText value. - */ - @Generated - public String getDisplayText() { - return this.displayText; - } - - /** - * Get the examplesCount property: An integer representing the number of examples that are available for this - * translation pair. - * Actual examples must be retrieved with a separate call to lookup examples. The number is mostly - * intended to facilitate display in a UX. For example, a user interface may add a hyperlink - * to the back-translation if the number of examples is greater than zero and show the back-translation - * as plain text if there are no examples. Note that the actual number of examples returned - * by a call to lookup examples may be less than numExamples, because additional filtering may be - * applied on the fly to remove "bad" examples. - * - * @return the examplesCount value. - */ - @Generated - public int getExamplesCount() { - return this.examplesCount; - } - - /** - * Get the frequencyCount property: An integer representing the frequency of this translation pair in the data. The - * main purpose of this - * field is to provide a user interface with a means to sort back-translations so the most frequent terms are first. - * - * @return the frequencyCount value. - */ - @Generated - public int getFrequencyCount() { - return this.frequencyCount; - } - - /** - * {@inheritDoc} - */ - @Generated - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeStringField("normalizedText", this.normalizedText); - jsonWriter.writeStringField("displayText", this.displayText); - jsonWriter.writeIntField("numExamples", this.examplesCount); - jsonWriter.writeIntField("frequencyCount", this.frequencyCount); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of BackTranslation from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of BackTranslation 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 BackTranslation. - */ - @Generated - public static BackTranslation fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - String normalizedText = null; - String displayText = null; - int examplesCount = 0; - int frequencyCount = 0; - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - if ("normalizedText".equals(fieldName)) { - normalizedText = reader.getString(); - } else if ("displayText".equals(fieldName)) { - displayText = reader.getString(); - } else if ("numExamples".equals(fieldName)) { - examplesCount = reader.getInt(); - } else if ("frequencyCount".equals(fieldName)) { - frequencyCount = reader.getInt(); - } else { - reader.skipChildren(); - } - } - return new BackTranslation(normalizedText, displayText, examplesCount, frequencyCount); - }); - } -} diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/BreakSentenceItem.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/BreakSentenceItem.java deleted file mode 100644 index 649f0c9a0dd7..000000000000 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/BreakSentenceItem.java +++ /dev/null @@ -1,108 +0,0 @@ -// 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; -import java.util.List; - -/** - * Item containing break sentence result. - */ -@Immutable -public final class BreakSentenceItem implements JsonSerializable { - - /* - * The detectedLanguage property is only present in the result object when language auto-detection is requested. - */ - @Generated - private DetectedLanguage detectedLanguage; - - /* - * An integer array representing the lengths of the sentences in the input text. - * The length of the array is the number of sentences, and the values are the length of each sentence. - */ - @Generated - private final List sentencesLengths; - - /** - * Creates an instance of BreakSentenceItem class. - * - * @param sentencesLengths the sentencesLengths value to set. - */ - @Generated - private BreakSentenceItem(List sentencesLengths) { - this.sentencesLengths = sentencesLengths; - } - - /** - * Get the detectedLanguage property: The detectedLanguage property is only present in the result object when - * language auto-detection is requested. - * - * @return the detectedLanguage value. - */ - @Generated - public DetectedLanguage getDetectedLanguage() { - return this.detectedLanguage; - } - - /** - * Get the sentencesLengths property: An integer array representing the lengths of the sentences in the input text. - * The length of the array is the number of sentences, and the values are the length of each sentence. - * - * @return the sentencesLengths value. - */ - @Generated - public List getSentencesLengths() { - return this.sentencesLengths; - } - - /** - * {@inheritDoc} - */ - @Generated - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeArrayField("sentLen", this.sentencesLengths, (writer, element) -> writer.writeInt(element)); - jsonWriter.writeJsonField("detectedLanguage", this.detectedLanguage); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of BreakSentenceItem from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of BreakSentenceItem 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 BreakSentenceItem. - */ - @Generated - public static BreakSentenceItem fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - List sentencesLengths = null; - DetectedLanguage detectedLanguage = null; - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - if ("sentLen".equals(fieldName)) { - sentencesLengths = reader.readArray(reader1 -> reader1.getInt()); - } else if ("detectedLanguage".equals(fieldName)) { - detectedLanguage = DetectedLanguage.fromJson(reader); - } else { - reader.skipChildren(); - } - } - BreakSentenceItem deserializedBreakSentenceItem = new BreakSentenceItem(sentencesLengths); - deserializedBreakSentenceItem.detectedLanguage = detectedLanguage; - return deserializedBreakSentenceItem; - }); - } -} diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/DetectedLanguage.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/DetectedLanguage.java index 4d519097e781..b73667a0c0d2 100644 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/DetectedLanguage.java +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/DetectedLanguage.java @@ -23,23 +23,16 @@ public final class DetectedLanguage implements JsonSerializable { String language = null; - double confidence = 0.0; + double score = 0.0; while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); if ("language".equals(fieldName)) { language = reader.getString(); } else if ("score".equals(fieldName)) { - confidence = reader.getDouble(); + score = reader.getDouble(); } else { reader.skipChildren(); } } - return new DetectedLanguage(language, confidence); + return new DetectedLanguage(language, score); }); } + + /* + * A float value indicating the confidence in the result. + * The score is between zero and one and a low score indicates a low confidence. + */ + @Generated + private final double score; + + /** + * Get the score property: A float value indicating the confidence in the result. + * The score is between zero and one and a low score indicates a low confidence. + * + * @return the score value. + */ + @Generated + public double getScore() { + return this.score; + } } diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/DictionaryExample.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/DictionaryExample.java deleted file mode 100644 index c998adefbdb5..000000000000 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/DictionaryExample.java +++ /dev/null @@ -1,208 +0,0 @@ -// 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; - -/** - * Dictionary Example. - */ -@Immutable -public final class DictionaryExample implements JsonSerializable { - - /* - * The string to concatenate before the value of sourceTerm to form a complete example. - * Do not add a space character, since it is already there when it should be. - * This value may be an empty string. - */ - @Generated - private final String sourcePrefix; - - /* - * A string equal to the actual term looked up. The string is added with sourcePrefix - * and sourceSuffix to form the complete example. Its value is separated so it can be - * marked in a user interface, e.g., by bolding it. - */ - @Generated - private final String sourceTerm; - - /* - * The string to concatenate after the value of sourceTerm to form a complete example. - * Do not add a space character, since it is already there when it should be. - * This value may be an empty string. - */ - @Generated - private final String sourceSuffix; - - /* - * A string similar to sourcePrefix but for the target. - */ - @Generated - private final String targetPrefix; - - /* - * A string similar to sourceTerm but for the target. - */ - @Generated - private final String targetTerm; - - /* - * A string similar to sourceSuffix but for the target. - */ - @Generated - private final String targetSuffix; - - /** - * Creates an instance of DictionaryExample class. - * - * @param sourcePrefix the sourcePrefix value to set. - * @param sourceTerm the sourceTerm value to set. - * @param sourceSuffix the sourceSuffix value to set. - * @param targetPrefix the targetPrefix value to set. - * @param targetTerm the targetTerm value to set. - * @param targetSuffix the targetSuffix value to set. - */ - @Generated - private DictionaryExample(String sourcePrefix, String sourceTerm, String sourceSuffix, String targetPrefix, - String targetTerm, String targetSuffix) { - this.sourcePrefix = sourcePrefix; - this.sourceTerm = sourceTerm; - this.sourceSuffix = sourceSuffix; - this.targetPrefix = targetPrefix; - this.targetTerm = targetTerm; - this.targetSuffix = targetSuffix; - } - - /** - * Get the sourcePrefix property: The string to concatenate before the value of sourceTerm to form a complete - * example. - * Do not add a space character, since it is already there when it should be. - * This value may be an empty string. - * - * @return the sourcePrefix value. - */ - @Generated - public String getSourcePrefix() { - return this.sourcePrefix; - } - - /** - * Get the sourceTerm property: A string equal to the actual term looked up. The string is added with sourcePrefix - * and sourceSuffix to form the complete example. Its value is separated so it can be - * marked in a user interface, e.g., by bolding it. - * - * @return the sourceTerm value. - */ - @Generated - public String getSourceTerm() { - return this.sourceTerm; - } - - /** - * Get the sourceSuffix property: The string to concatenate after the value of sourceTerm to form a complete - * example. - * Do not add a space character, since it is already there when it should be. - * This value may be an empty string. - * - * @return the sourceSuffix value. - */ - @Generated - public String getSourceSuffix() { - return this.sourceSuffix; - } - - /** - * Get the targetPrefix property: A string similar to sourcePrefix but for the target. - * - * @return the targetPrefix value. - */ - @Generated - public String getTargetPrefix() { - return this.targetPrefix; - } - - /** - * Get the targetTerm property: A string similar to sourceTerm but for the target. - * - * @return the targetTerm value. - */ - @Generated - public String getTargetTerm() { - return this.targetTerm; - } - - /** - * Get the targetSuffix property: A string similar to sourceSuffix but for the target. - * - * @return the targetSuffix value. - */ - @Generated - public String getTargetSuffix() { - return this.targetSuffix; - } - - /** - * {@inheritDoc} - */ - @Generated - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeStringField("sourcePrefix", this.sourcePrefix); - jsonWriter.writeStringField("sourceTerm", this.sourceTerm); - jsonWriter.writeStringField("sourceSuffix", this.sourceSuffix); - jsonWriter.writeStringField("targetPrefix", this.targetPrefix); - jsonWriter.writeStringField("targetTerm", this.targetTerm); - jsonWriter.writeStringField("targetSuffix", this.targetSuffix); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of DictionaryExample from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of DictionaryExample 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 DictionaryExample. - */ - @Generated - public static DictionaryExample fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - String sourcePrefix = null; - String sourceTerm = null; - String sourceSuffix = null; - String targetPrefix = null; - String targetTerm = null; - String targetSuffix = null; - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - if ("sourcePrefix".equals(fieldName)) { - sourcePrefix = reader.getString(); - } else if ("sourceTerm".equals(fieldName)) { - sourceTerm = reader.getString(); - } else if ("sourceSuffix".equals(fieldName)) { - sourceSuffix = reader.getString(); - } else if ("targetPrefix".equals(fieldName)) { - targetPrefix = reader.getString(); - } else if ("targetTerm".equals(fieldName)) { - targetTerm = reader.getString(); - } else if ("targetSuffix".equals(fieldName)) { - targetSuffix = reader.getString(); - } else { - reader.skipChildren(); - } - } - return new DictionaryExample(sourcePrefix, sourceTerm, sourceSuffix, targetPrefix, targetTerm, - targetSuffix); - }); - } -} diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/DictionaryExampleItem.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/DictionaryExampleItem.java deleted file mode 100644 index 5ba37ece88d1..000000000000 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/DictionaryExampleItem.java +++ /dev/null @@ -1,133 +0,0 @@ -// 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; -import java.util.List; - -/** - * Dictionary Example element. - */ -@Immutable -public final class DictionaryExampleItem implements JsonSerializable { - - /* - * A string giving the normalized form of the source term. Generally, this should be identical - * to the value of the Text field at the matching list index in the body of the request. - */ - @Generated - private final String normalizedSource; - - /* - * A string giving the normalized form of the target term. Generally, this should be identical - * to the value of the Translation field at the matching list index in the body of the request. - */ - @Generated - private final String normalizedTarget; - - /* - * A list of examples for the (source term, target term) pair. - */ - @Generated - private final List examples; - - /** - * Creates an instance of DictionaryExampleItem class. - * - * @param normalizedSource the normalizedSource value to set. - * @param normalizedTarget the normalizedTarget value to set. - * @param examples the examples value to set. - */ - @Generated - private DictionaryExampleItem(String normalizedSource, String normalizedTarget, List examples) { - this.normalizedSource = normalizedSource; - this.normalizedTarget = normalizedTarget; - this.examples = examples; - } - - /** - * Get the normalizedSource property: A string giving the normalized form of the source term. Generally, this should - * be identical - * to the value of the Text field at the matching list index in the body of the request. - * - * @return the normalizedSource value. - */ - @Generated - public String getNormalizedSource() { - return this.normalizedSource; - } - - /** - * Get the normalizedTarget property: A string giving the normalized form of the target term. Generally, this should - * be identical - * to the value of the Translation field at the matching list index in the body of the request. - * - * @return the normalizedTarget value. - */ - @Generated - public String getNormalizedTarget() { - return this.normalizedTarget; - } - - /** - * Get the examples property: A list of examples for the (source term, target term) pair. - * - * @return the examples value. - */ - @Generated - public List getExamples() { - return this.examples; - } - - /** - * {@inheritDoc} - */ - @Generated - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeStringField("normalizedSource", this.normalizedSource); - jsonWriter.writeStringField("normalizedTarget", this.normalizedTarget); - jsonWriter.writeArrayField("examples", this.examples, (writer, element) -> writer.writeJson(element)); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of DictionaryExampleItem from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of DictionaryExampleItem 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 DictionaryExampleItem. - */ - @Generated - public static DictionaryExampleItem fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - String normalizedSource = null; - String normalizedTarget = null; - List examples = null; - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - if ("normalizedSource".equals(fieldName)) { - normalizedSource = reader.getString(); - } else if ("normalizedTarget".equals(fieldName)) { - normalizedTarget = reader.getString(); - } else if ("examples".equals(fieldName)) { - examples = reader.readArray(reader1 -> DictionaryExample.fromJson(reader1)); - } else { - reader.skipChildren(); - } - } - return new DictionaryExampleItem(normalizedSource, normalizedTarget, examples); - }); - } -} diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/DictionaryExampleTextItem.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/DictionaryExampleTextItem.java deleted file mode 100644 index 312c6073c9cb..000000000000 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/DictionaryExampleTextItem.java +++ /dev/null @@ -1,92 +0,0 @@ -// 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.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; - -/** - * Element containing the text with translation. - */ -@Immutable -public final class DictionaryExampleTextItem extends InputTextItem { - - /* - * A string specifying the translated text previously returned by the Dictionary lookup operation. - * This should be the value from the normalizedTarget field in the translations list of the Dictionary - * lookup response. The service will return examples for the specific source-target word-pair. - */ - @Generated - private final String translation; - - /** - * Creates an instance of DictionaryExampleTextItem class. - * - * @param text the text value to set. - * @param translation the translation value to set. - */ - @Generated - public DictionaryExampleTextItem(String text, String translation) { - super(text); - this.translation = translation; - } - - /** - * Get the translation property: A string specifying the translated text previously returned by the Dictionary - * lookup operation. - * This should be the value from the normalizedTarget field in the translations list of the Dictionary - * lookup response. The service will return examples for the specific source-target word-pair. - * - * @return the translation value. - */ - @Generated - public String getTranslation() { - return this.translation; - } - - /** - * {@inheritDoc} - */ - @Generated - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeStringField("text", getText()); - jsonWriter.writeStringField("translation", this.translation); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of DictionaryExampleTextItem from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of DictionaryExampleTextItem 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 DictionaryExampleTextItem. - */ - @Generated - public static DictionaryExampleTextItem fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - String text = null; - String translation = null; - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - if ("text".equals(fieldName)) { - text = reader.getString(); - } else if ("translation".equals(fieldName)) { - translation = reader.getString(); - } else { - reader.skipChildren(); - } - } - return new DictionaryExampleTextItem(text, translation); - }); - } -} diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/DictionaryLookupItem.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/DictionaryLookupItem.java deleted file mode 100644 index 172ab52bba1b..000000000000 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/DictionaryLookupItem.java +++ /dev/null @@ -1,136 +0,0 @@ -// 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; -import java.util.List; - -/** - * Dictionary Lookup Element. - */ -@Immutable -public final class DictionaryLookupItem implements JsonSerializable { - - /* - * A string giving the normalized form of the source term. - * For example, if the request is "JOHN", the normalized form will be "john". - * The content of this field becomes the input to lookup examples. - */ - @Generated - private final String normalizedSource; - - /* - * A string giving the source term in a form best suited for end-user display. - * For example, if the input is "JOHN", the display form will reflect the usual - * spelling of the name: "John". - */ - @Generated - private final String displaySource; - - /* - * A list of translations for the source term. - */ - @Generated - private final List translations; - - /** - * Creates an instance of DictionaryLookupItem class. - * - * @param normalizedSource the normalizedSource value to set. - * @param displaySource the displaySource value to set. - * @param translations the translations value to set. - */ - @Generated - private DictionaryLookupItem(String normalizedSource, String displaySource, - List translations) { - this.normalizedSource = normalizedSource; - this.displaySource = displaySource; - this.translations = translations; - } - - /** - * Get the normalizedSource property: A string giving the normalized form of the source term. - * For example, if the request is "JOHN", the normalized form will be "john". - * The content of this field becomes the input to lookup examples. - * - * @return the normalizedSource value. - */ - @Generated - public String getNormalizedSource() { - return this.normalizedSource; - } - - /** - * Get the displaySource property: A string giving the source term in a form best suited for end-user display. - * For example, if the input is "JOHN", the display form will reflect the usual - * spelling of the name: "John". - * - * @return the displaySource value. - */ - @Generated - public String getDisplaySource() { - return this.displaySource; - } - - /** - * Get the translations property: A list of translations for the source term. - * - * @return the translations value. - */ - @Generated - public List getTranslations() { - return this.translations; - } - - /** - * {@inheritDoc} - */ - @Generated - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeStringField("normalizedSource", this.normalizedSource); - jsonWriter.writeStringField("displaySource", this.displaySource); - jsonWriter.writeArrayField("translations", this.translations, (writer, element) -> writer.writeJson(element)); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of DictionaryLookupItem from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of DictionaryLookupItem 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 DictionaryLookupItem. - */ - @Generated - public static DictionaryLookupItem fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - String normalizedSource = null; - String displaySource = null; - List translations = null; - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - if ("normalizedSource".equals(fieldName)) { - normalizedSource = reader.getString(); - } else if ("displaySource".equals(fieldName)) { - displaySource = reader.getString(); - } else if ("translations".equals(fieldName)) { - translations = reader.readArray(reader1 -> DictionaryTranslation.fromJson(reader1)); - } else { - reader.skipChildren(); - } - } - return new DictionaryLookupItem(normalizedSource, displaySource, translations); - }); - } -} diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/DictionaryTranslation.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/DictionaryTranslation.java deleted file mode 100644 index 124f6555b1ae..000000000000 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/DictionaryTranslation.java +++ /dev/null @@ -1,223 +0,0 @@ -// 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; -import java.util.List; - -/** - * Translation source term. - */ -@Immutable -public final class DictionaryTranslation implements JsonSerializable { - - /* - * A string giving the normalized form of this term in the target language. - * This value should be used as input to lookup examples. - */ - @Generated - private final String normalizedTarget; - - /* - * A string giving the term in the target language and in a form best suited - * for end-user display. Generally, this will only differ from the normalizedTarget - * in terms of capitalization. For example, a proper noun like "Juan" will have - * normalizedTarget = "juan" and displayTarget = "Juan". - */ - @Generated - private final String displayTarget; - - /* - * A string associating this term with a part-of-speech tag. - */ - @Generated - private final String posTag; - - /* - * A value between 0.0 and 1.0 which represents the "confidence" - * (or perhaps more accurately, "probability in the training data") of that translation pair. - * The sum of confidence scores for one source word may or may not sum to 1.0. - */ - @Generated - private final double confidence; - - /* - * A string giving the word to display as a prefix of the translation. Currently, - * this is the gendered determiner of nouns, in languages that have gendered determiners. - * For example, the prefix of the Spanish word "mosca" is "la", since "mosca" is a feminine noun in Spanish. - * This is only dependent on the translation, and not on the source. - * If there is no prefix, it will be the empty string. - */ - @Generated - private final String prefixWord; - - /* - * A list of "back translations" of the target. For example, source words that the target can translate to. - * The list is guaranteed to contain the source word that was requested (e.g., if the source word being - * looked up is "fly", then it is guaranteed that "fly" will be in the backTranslations list). - * However, it is not guaranteed to be in the first position, and often will not be. - */ - @Generated - private final List backTranslations; - - /** - * Creates an instance of DictionaryTranslation class. - * - * @param normalizedTarget the normalizedTarget value to set. - * @param displayTarget the displayTarget value to set. - * @param posTag the posTag value to set. - * @param confidence the confidence value to set. - * @param prefixWord the prefixWord value to set. - * @param backTranslations the backTranslations value to set. - */ - @Generated - private DictionaryTranslation(String normalizedTarget, String displayTarget, String posTag, double confidence, - String prefixWord, List backTranslations) { - this.normalizedTarget = normalizedTarget; - this.displayTarget = displayTarget; - this.posTag = posTag; - this.confidence = confidence; - this.prefixWord = prefixWord; - this.backTranslations = backTranslations; - } - - /** - * Get the normalizedTarget property: A string giving the normalized form of this term in the target language. - * This value should be used as input to lookup examples. - * - * @return the normalizedTarget value. - */ - @Generated - public String getNormalizedTarget() { - return this.normalizedTarget; - } - - /** - * Get the displayTarget property: A string giving the term in the target language and in a form best suited - * for end-user display. Generally, this will only differ from the normalizedTarget - * in terms of capitalization. For example, a proper noun like "Juan" will have - * normalizedTarget = "juan" and displayTarget = "Juan". - * - * @return the displayTarget value. - */ - @Generated - public String getDisplayTarget() { - return this.displayTarget; - } - - /** - * Get the posTag property: A string associating this term with a part-of-speech tag. - * - * @return the posTag value. - */ - @Generated - public String getPosTag() { - return this.posTag; - } - - /** - * Get the confidence property: A value between 0.0 and 1.0 which represents the "confidence" - * (or perhaps more accurately, "probability in the training data") of that translation pair. - * The sum of confidence scores for one source word may or may not sum to 1.0. - * - * @return the confidence value. - */ - @Generated - public double getConfidence() { - return this.confidence; - } - - /** - * Get the prefixWord property: A string giving the word to display as a prefix of the translation. Currently, - * this is the gendered determiner of nouns, in languages that have gendered determiners. - * For example, the prefix of the Spanish word "mosca" is "la", since "mosca" is a feminine noun in Spanish. - * This is only dependent on the translation, and not on the source. - * If there is no prefix, it will be the empty string. - * - * @return the prefixWord value. - */ - @Generated - public String getPrefixWord() { - return this.prefixWord; - } - - /** - * Get the backTranslations property: A list of "back translations" of the target. For example, source words that - * the target can translate to. - * The list is guaranteed to contain the source word that was requested (e.g., if the source word being - * looked up is "fly", then it is guaranteed that "fly" will be in the backTranslations list). - * However, it is not guaranteed to be in the first position, and often will not be. - * - * @return the backTranslations value. - */ - @Generated - public List getBackTranslations() { - return this.backTranslations; - } - - /** - * {@inheritDoc} - */ - @Generated - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeStringField("normalizedTarget", this.normalizedTarget); - jsonWriter.writeStringField("displayTarget", this.displayTarget); - jsonWriter.writeStringField("posTag", this.posTag); - jsonWriter.writeDoubleField("confidence", this.confidence); - jsonWriter.writeStringField("prefixWord", this.prefixWord); - jsonWriter.writeArrayField("backTranslations", this.backTranslations, - (writer, element) -> writer.writeJson(element)); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of DictionaryTranslation from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of DictionaryTranslation 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 DictionaryTranslation. - */ - @Generated - public static DictionaryTranslation fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - String normalizedTarget = null; - String displayTarget = null; - String posTag = null; - double confidence = 0.0; - String prefixWord = null; - List backTranslations = null; - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - if ("normalizedTarget".equals(fieldName)) { - normalizedTarget = reader.getString(); - } else if ("displayTarget".equals(fieldName)) { - displayTarget = reader.getString(); - } else if ("posTag".equals(fieldName)) { - posTag = reader.getString(); - } else if ("confidence".equals(fieldName)) { - confidence = reader.getDouble(); - } else if ("prefixWord".equals(fieldName)) { - prefixWord = reader.getString(); - } else if ("backTranslations".equals(fieldName)) { - backTranslations = reader.readArray(reader1 -> BackTranslation.fromJson(reader1)); - } else { - reader.skipChildren(); - } - } - return new DictionaryTranslation(normalizedTarget, displayTarget, posTag, confidence, prefixWord, - backTranslations); - }); - } -} diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/GetSupportedLanguagesResult.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/GetSupportedLanguagesResult.java index b4e2db20f224..46fd90f39608 100644 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/GetSupportedLanguagesResult.java +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/GetSupportedLanguagesResult.java @@ -10,6 +10,7 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; +import java.util.List; import java.util.Map; /** @@ -30,12 +31,6 @@ public final class GetSupportedLanguagesResult implements JsonSerializable transliteration; - /* - * Languages that support dictionary API. - */ - @Generated - private Map dictionary; - /** * Creates an instance of GetSupportedLanguagesResult class. */ @@ -63,16 +58,6 @@ public Map getTransliteration() { return this.transliteration; } - /** - * Get the dictionary property: Languages that support dictionary API. - * - * @return the dictionary value. - */ - @Generated - public Map getDictionary() { - return this.dictionary; - } - /** * {@inheritDoc} */ @@ -80,10 +65,6 @@ public Map getDictionary() { @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeMapField("translation", this.translation, (writer, element) -> writer.writeJson(element)); - jsonWriter.writeMapField("transliteration", this.transliteration, - (writer, element) -> writer.writeJson(element)); - jsonWriter.writeMapField("dictionary", this.dictionary, (writer, element) -> writer.writeJson(element)); return jsonWriter.writeEndObject(); } @@ -110,10 +91,9 @@ public static GetSupportedLanguagesResult fromJson(JsonReader jsonReader) throws Map transliteration = reader.readMap(reader1 -> TransliterationLanguage.fromJson(reader1)); deserializedGetSupportedLanguagesResult.transliteration = transliteration; - } else if ("dictionary".equals(fieldName)) { - Map dictionary - = reader.readMap(reader1 -> SourceDictionaryLanguage.fromJson(reader1)); - deserializedGetSupportedLanguagesResult.dictionary = dictionary; + } else if ("models".equals(fieldName)) { + List models = reader.readArray(reader1 -> reader1.getString()); + deserializedGetSupportedLanguagesResult.models = models; } else { reader.skipChildren(); } @@ -121,4 +101,20 @@ public static GetSupportedLanguagesResult fromJson(JsonReader jsonReader) throws return deserializedGetSupportedLanguagesResult; }); } + + /* + * LLM models supported. + */ + @Generated + private List models; + + /** + * Get the models property: LLM models supported. + * + * @return the models value. + */ + @Generated + public List getModels() { + return this.models; + } } diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/InputTextItem.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/InputTextItem.java index 73e602ce5eeb..dac9c161d511 100644 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/InputTextItem.java +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/InputTextItem.java @@ -15,7 +15,7 @@ * Element containing the text for translation. */ @Immutable -public class InputTextItem implements JsonSerializable { +public final class InputTextItem implements JsonSerializable { /* * Text to translate. diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/LanguageScope.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/LanguageScope.java index 16d4791aced4..d51a76013b18 100644 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/LanguageScope.java +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/LanguageScope.java @@ -23,9 +23,9 @@ public final class LanguageScope extends ExpandableStringEnum { public static final LanguageScope TRANSLITERATION = fromString("Transliteration"); /** - * Static value Dictionary for LanguageScope. + * Static value Models for LanguageScope. */ - public static final LanguageScope DICTIONARY = fromString("Dictionary"); + public static final LanguageScope MODELS = fromString("Models"); /** * Creates a new instance of LanguageScope value. diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/ReferenceTextPair.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/ReferenceTextPair.java new file mode 100644 index 000000000000..797fda6676b7 --- /dev/null +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/ReferenceTextPair.java @@ -0,0 +1,104 @@ +// 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 text pair to generate adaptive customized translation. + */ +@Immutable +public final class ReferenceTextPair implements JsonSerializable { + + /* + * Source reference sentence. + */ + @Generated + private final String source; + + /* + * Target reference sentence. + */ + @Generated + private final String target; + + /** + * Creates an instance of ReferenceTextPair class. + * + * @param source the source value to set. + * @param target the target value to set. + */ + @Generated + public ReferenceTextPair(String source, String target) { + this.source = source; + this.target = target; + } + + /** + * Get the source property: Source reference sentence. + * + * @return the source value. + */ + @Generated + public String getSource() { + return this.source; + } + + /** + * Get the target property: Target reference sentence. + * + * @return the target value. + */ + @Generated + public String getTarget() { + return this.target; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("source", this.source); + jsonWriter.writeStringField("target", this.target); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ReferenceTextPair from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ReferenceTextPair 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 ReferenceTextPair. + */ + @Generated + public static ReferenceTextPair fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String source = null; + String target = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("source".equals(fieldName)) { + source = reader.getString(); + } else if ("target".equals(fieldName)) { + target = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new ReferenceTextPair(source, target); + }); + } +} diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/SentenceBoundaries.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/SentenceBoundaries.java deleted file mode 100644 index cd3749333639..000000000000 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/SentenceBoundaries.java +++ /dev/null @@ -1,113 +0,0 @@ -// 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; -import java.util.List; - -/** - * An object returning sentence boundaries in the input and output texts. - */ -@Immutable -public final class SentenceBoundaries implements JsonSerializable { - - /* - * An integer array representing the lengths of the sentences in the input text. - * The length of the array is the number of sentences, and the values are the length of each sentence. - */ - @Generated - private final List sourceSentencesLengths; - - /* - * An integer array representing the lengths of the sentences in the translated text. - * The length of the array is the number of sentences, and the values are the length of each sentence. - */ - @Generated - private final List translatedSentencesLengths; - - /** - * Creates an instance of SentenceBoundaries class. - * - * @param sourceSentencesLengths the sourceSentencesLengths value to set. - * @param translatedSentencesLengths the translatedSentencesLengths value to set. - */ - @Generated - private SentenceBoundaries(List sourceSentencesLengths, List translatedSentencesLengths) { - this.sourceSentencesLengths = sourceSentencesLengths; - this.translatedSentencesLengths = translatedSentencesLengths; - } - - /** - * Get the sourceSentencesLengths property: An integer array representing the lengths of the sentences in the input - * text. - * The length of the array is the number of sentences, and the values are the length of each sentence. - * - * @return the sourceSentencesLengths value. - */ - @Generated - public List getSourceSentencesLengths() { - return this.sourceSentencesLengths; - } - - /** - * Get the translatedSentencesLengths property: An integer array representing the lengths of the sentences in the - * translated text. - * The length of the array is the number of sentences, and the values are the length of each sentence. - * - * @return the translatedSentencesLengths value. - */ - @Generated - public List getTranslatedSentencesLengths() { - return this.translatedSentencesLengths; - } - - /** - * {@inheritDoc} - */ - @Generated - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeArrayField("srcSentLen", this.sourceSentencesLengths, - (writer, element) -> writer.writeInt(element)); - jsonWriter.writeArrayField("transSentLen", this.translatedSentencesLengths, - (writer, element) -> writer.writeInt(element)); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of SentenceBoundaries from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of SentenceBoundaries 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 SentenceBoundaries. - */ - @Generated - public static SentenceBoundaries fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - List sourceSentencesLengths = null; - List translatedSentencesLengths = null; - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - if ("srcSentLen".equals(fieldName)) { - sourceSentencesLengths = reader.readArray(reader1 -> reader1.getInt()); - } else if ("transSentLen".equals(fieldName)) { - translatedSentencesLengths = reader.readArray(reader1 -> reader1.getInt()); - } else { - reader.skipChildren(); - } - } - return new SentenceBoundaries(sourceSentencesLengths, translatedSentencesLengths); - }); - } -} diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/SourceDictionaryLanguage.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/SourceDictionaryLanguage.java deleted file mode 100644 index 49b777bf10ac..000000000000 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/SourceDictionaryLanguage.java +++ /dev/null @@ -1,152 +0,0 @@ -// 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; -import java.util.List; - -/** - * Properties ot the source dictionary language. - */ -@Immutable -public final class SourceDictionaryLanguage implements JsonSerializable { - - /* - * Display name of the language in the locale requested via Accept-Language header. - */ - @Generated - private final String name; - - /* - * Display name of the language in the locale native for this language. - */ - @Generated - private final String nativeName; - - /* - * Directionality, which is rtl for right-to-left languages or ltr for left-to-right languages. - */ - @Generated - private final LanguageDirectionality directionality; - - /* - * List of languages with alterative translations and examples for the query expressed in the source language. - */ - @Generated - private final List translations; - - /** - * Creates an instance of SourceDictionaryLanguage class. - * - * @param name the name value to set. - * @param nativeName the nativeName value to set. - * @param directionality the directionality value to set. - * @param translations the translations value to set. - */ - @Generated - private SourceDictionaryLanguage(String name, String nativeName, LanguageDirectionality directionality, - List translations) { - this.name = name; - this.nativeName = nativeName; - this.directionality = directionality; - this.translations = translations; - } - - /** - * Get the name property: Display name of the language in the locale requested via Accept-Language header. - * - * @return the name value. - */ - @Generated - public String getName() { - return this.name; - } - - /** - * Get the nativeName property: Display name of the language in the locale native for this language. - * - * @return the nativeName value. - */ - @Generated - public String getNativeName() { - return this.nativeName; - } - - /** - * Get the directionality property: Directionality, which is rtl for right-to-left languages or ltr for - * left-to-right languages. - * - * @return the directionality value. - */ - @Generated - public LanguageDirectionality getDirectionality() { - return this.directionality; - } - - /** - * Get the translations property: List of languages with alterative translations and examples for the query - * expressed in the source language. - * - * @return the translations value. - */ - @Generated - public List getTranslations() { - return this.translations; - } - - /** - * {@inheritDoc} - */ - @Generated - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeStringField("name", this.name); - jsonWriter.writeStringField("nativeName", this.nativeName); - jsonWriter.writeStringField("dir", this.directionality == null ? null : this.directionality.toString()); - jsonWriter.writeArrayField("translations", this.translations, (writer, element) -> writer.writeJson(element)); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of SourceDictionaryLanguage from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of SourceDictionaryLanguage 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 SourceDictionaryLanguage. - */ - @Generated - public static SourceDictionaryLanguage fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - String name = null; - String nativeName = null; - LanguageDirectionality directionality = null; - List translations = null; - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - if ("name".equals(fieldName)) { - name = reader.getString(); - } else if ("nativeName".equals(fieldName)) { - nativeName = reader.getString(); - } else if ("dir".equals(fieldName)) { - directionality = LanguageDirectionality.fromString(reader.getString()); - } else if ("translations".equals(fieldName)) { - translations = reader.readArray(reader1 -> TargetDictionaryLanguage.fromJson(reader1)); - } else { - reader.skipChildren(); - } - } - return new SourceDictionaryLanguage(name, nativeName, directionality, translations); - }); - } -} diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TargetDictionaryLanguage.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TargetDictionaryLanguage.java deleted file mode 100644 index 1bab0ee966e4..000000000000 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TargetDictionaryLanguage.java +++ /dev/null @@ -1,150 +0,0 @@ -// 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; - -/** - * Properties of the target dictionary language. - */ -@Immutable -public final class TargetDictionaryLanguage implements JsonSerializable { - - /* - * Display name of the language in the locale requested via Accept-Language header. - */ - @Generated - private final String name; - - /* - * Display name of the language in the locale native for this language. - */ - @Generated - private final String nativeName; - - /* - * Directionality, which is rtl for right-to-left languages or ltr for left-to-right languages. - */ - @Generated - private final LanguageDirectionality directionality; - - /* - * Language code identifying the target language. - */ - @Generated - private final String code; - - /** - * Creates an instance of TargetDictionaryLanguage class. - * - * @param name the name value to set. - * @param nativeName the nativeName value to set. - * @param directionality the directionality value to set. - * @param code the code value to set. - */ - @Generated - private TargetDictionaryLanguage(String name, String nativeName, LanguageDirectionality directionality, - String code) { - this.name = name; - this.nativeName = nativeName; - this.directionality = directionality; - this.code = code; - } - - /** - * Get the name property: Display name of the language in the locale requested via Accept-Language header. - * - * @return the name value. - */ - @Generated - public String getName() { - return this.name; - } - - /** - * Get the nativeName property: Display name of the language in the locale native for this language. - * - * @return the nativeName value. - */ - @Generated - public String getNativeName() { - return this.nativeName; - } - - /** - * Get the directionality property: Directionality, which is rtl for right-to-left languages or ltr for - * left-to-right languages. - * - * @return the directionality value. - */ - @Generated - public LanguageDirectionality getDirectionality() { - return this.directionality; - } - - /** - * Get the code property: Language code identifying the target language. - * - * @return the code value. - */ - @Generated - public String getCode() { - return this.code; - } - - /** - * {@inheritDoc} - */ - @Generated - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeStringField("name", this.name); - jsonWriter.writeStringField("nativeName", this.nativeName); - jsonWriter.writeStringField("dir", this.directionality == null ? null : this.directionality.toString()); - jsonWriter.writeStringField("code", this.code); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of TargetDictionaryLanguage from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of TargetDictionaryLanguage 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 TargetDictionaryLanguage. - */ - @Generated - public static TargetDictionaryLanguage fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - String name = null; - String nativeName = null; - LanguageDirectionality directionality = null; - String code = null; - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - if ("name".equals(fieldName)) { - name = reader.getString(); - } else if ("nativeName".equals(fieldName)) { - nativeName = reader.getString(); - } else if ("dir".equals(fieldName)) { - directionality = LanguageDirectionality.fromString(reader.getString()); - } else if ("code".equals(fieldName)) { - code = reader.getString(); - } else { - reader.skipChildren(); - } - } - return new TargetDictionaryLanguage(name, nativeName, directionality, code); - }); - } -} 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..f1b6439e01f2 --- /dev/null +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslateBody.java @@ -0,0 +1,83 @@ +// 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; +import java.util.List; + +/** + * Request data for translate. + */ +@Immutable +public final class TranslateBody implements JsonSerializable { + + /* + * Array of the input text elements to translate. + */ + @Generated + private final List inputs; + + /** + * Creates an instance of TranslateBody class. + * + * @param inputs the inputs value to set. + */ + @Generated + public TranslateBody(List inputs) { + this.inputs = inputs; + } + + /** + * Get the inputs property: Array of the input text elements to translate. + * + * @return the inputs value. + */ + @Generated + public List getInputs() { + return this.inputs; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("inputs", this.inputs, (writer, element) -> writer.writeJson(element)); + 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 -> { + List inputs = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("inputs".equals(fieldName)) { + inputs = reader.readArray(reader1 -> TranslateInputItem.fromJson(reader1)); + } else { + reader.skipChildren(); + } + } + return new TranslateBody(inputs); + }); + } +} diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslateInputItem.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslateInputItem.java new file mode 100644 index 000000000000..9a8102e61226 --- /dev/null +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslateInputItem.java @@ -0,0 +1,227 @@ +// 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; + +/** + * Element containing the text for translation. + */ +@Fluent +public final class TranslateInputItem implements JsonSerializable { + + /* + * 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 translationTargets; + + /** + * Creates an instance of TranslateInputItem class. + * + * @param text the text value to set. + * @param translationTargets the translationTargets value to set. + */ + @Generated + public TranslateInputItem(String text, List translationTargets) { + this.text = text; + this.translationTargets = translationTargets; + } + + /** + * 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 TranslateInputItem object itself. + */ + @Generated + public TranslateInputItem 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 TranslateInputItem object itself. + */ + @Generated + public TranslateInputItem 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 TranslateInputItem object itself. + */ + @Generated + public TranslateInputItem setTextType(TextType textType) { + this.textType = textType; + return this; + } + + /** + * Get the translationTargets property: Translation target parameters. + * + * @return the translationTargets value. + */ + @Generated + public List getTranslationTargets() { + return this.translationTargets; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("text", this.text); + jsonWriter.writeArrayField("targets", this.translationTargets, (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 TranslateInputItem from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TranslateInputItem 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 TranslateInputItem. + */ + @Generated + public static TranslateInputItem fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String text = null; + List translationTargets = 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)) { + translationTargets = reader.readArray(reader1 -> TranslationTarget.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(); + } + } + TranslateInputItem deserializedTranslateInputItem = new TranslateInputItem(text, translationTargets); + deserializedTranslateInputItem.script = script; + deserializedTranslateInputItem.language = language; + deserializedTranslateInputItem.textType = textType; + return deserializedTranslateInputItem; + }); + } +} diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslateOptions.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslateOptions.java deleted file mode 100644 index 707af477adcf..000000000000 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslateOptions.java +++ /dev/null @@ -1,289 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.ai.translation.text.models; - -import com.azure.core.annotation.Fluent; -import java.util.ArrayList; -import java.util.List; - -/** - * Options that may be passed when translating a text. - */ -@Fluent -public final class TranslateOptions { - private String sourceLanguage = null; - private List targetLanguages = new ArrayList(); - private String clientTraceId = null; - private TextType textType = TextType.PLAIN; - private String category = null; - private ProfanityAction profanityAction = ProfanityAction.NO_ACTION; - private ProfanityMarker profanityMarker = ProfanityMarker.ASTERISK; - private Boolean includeAlignment = false; - private Boolean includeSentenceLength = false; - private String suggestedSourceLanguage = null; - private String sourceLanguageScript = null; - private String targetLanguageScript = null; - private Boolean allowFallback = false; - - /** - * Creates a new instance of the TranslateOptions class. - */ - public TranslateOptions() { - - } - - /** - * Returns the list of target languages. - * @return the list of target languages. - */ - public List getTargetLanguages() { - return targetLanguages; - } - - /** - * Sets the list of target languages. - * @param targetLanguages the list of target languages. - * @return The updated options. - */ - public TranslateOptions setTargetLanguages(List targetLanguages) { - this.targetLanguages = targetLanguages; - return this; - } - - /** - * Adds a language to the list of target languages. - * - * @param targetLanguage language to add to the list of target languages. - * @return The updated options. - */ - public TranslateOptions addTargetLanguage(String targetLanguage) { - if (targetLanguages == null) { - targetLanguages = new ArrayList(); - } - targetLanguages.add(targetLanguage); - return this; - } - - /** - * Returns the source language. - * - * @return Specifies the language of the input text. - */ - public String getSourceLanguage() { - return sourceLanguage; - } - - /** - * Sets the source language. - * - * @param sourceLanguage Specifies the language of the input text. - * @return The updated options. - */ - public TranslateOptions setSourceLanguage(String sourceLanguage) { - this.sourceLanguage = sourceLanguage; - return this; - } - - /** - * Returns the client-generated GUID to uniquely identify the request. - * - * @return client-generated GUID to uniquely identify the request. - */ - public String getClientTraceId() { - return clientTraceId; - } - - /** - * Sets the client-generated GUID to uniquely identify the request. - * @param clientTraceId client-generated GUID to uniquely identify the request. - * @return The updated options. - */ - public TranslateOptions setClientTraceId(String clientTraceId) { - this.clientTraceId = clientTraceId; - return this; - } - - /** - * Returns whether the text being translated is plain text or HTML text. - * @return specifies whether the text being translated is plain text or HTML text. - */ - public TextType getTextType() { - return textType; - } - - /** - * Sets whether the text being translated is plain text or HTML text. - * - * @param textType specifies whether the text being translated is plain text or HTML text. - * @return The updated options. - */ - public TranslateOptions setTextType(TextType textType) { - this.textType = textType; - return this; - } - - /** - * Returns the category (domain) of the translation. - * @return specifying the category (domain) of the translation. - */ - public String getCategory() { - return category; - } - - /** - * Sets the category (domain) of the translation. - * - * @param category specifying the category (domain) of the translation. - * @return The updated options. - */ - public TranslateOptions setCategory(String category) { - this.category = category; - return this; - } - - /** - * Returns how profanities should be treated in translations. - * @return specifies how profanities should be treated in translations. - */ - public ProfanityAction getProfanityAction() { - return profanityAction; - } - - /** - * Sets how profanities should be treated in translations. - * @param profanityAction specifies how profanities should be treated in translations. - * @return The updated options. - */ - public TranslateOptions setProfanityAction(ProfanityAction profanityAction) { - this.profanityAction = profanityAction; - return this; - } - - /** - * Returns how profanities should be marked in translations. - * @return specifies how profanities should be marked in translations. - */ - public ProfanityMarker getProfanityMarker() { - return profanityMarker; - } - - /** - * Sets how profanities should be marked in translations. - * @param profanityMarker specifies how profanities should be marked in translations. - * @return The updated options. - */ - public TranslateOptions setProfanityMarker(ProfanityMarker profanityMarker) { - this.profanityMarker = profanityMarker; - return this; - } - - /** - * Returns whether to include alignment projection from source text to translated text. - * @return Whether to include alignment projection from source text to translated text. - */ - public Boolean isIncludeAlignment() { - return includeAlignment; - } - - /** - * Sets whether to include alignment projection from source text to translated text. - * @param includeAlignment Whether to include alignment projection from source text to translated text. - * @return The updated options. - */ - public TranslateOptions setIncludeAlignment(Boolean includeAlignment) { - this.includeAlignment = includeAlignment; - return this; - } - - /** - * Returns whether to include sentence boundaries for the input text and the translated text. - * @return Whether to include sentence boundaries for the input text and the translated text. - */ - public Boolean isIncludeSentenceLength() { - return includeSentenceLength; - } - - /** - * Sets whether to include sentence boundaries for the input text and the translated text. - * @param includeSentenceLength Whether to include sentence boundaries for the input text and the translated text. - * @return The updated options. - */ - public TranslateOptions setIncludeSentenceLength(Boolean includeSentenceLength) { - this.includeSentenceLength = includeSentenceLength; - return this; - } - - /** - * Returns the fallback language if the language of the input text can't be identified. - * @return fallback language if the language of the input text can't be identified. - */ - public String getSuggestedSourceLanguage() { - return suggestedSourceLanguage; - } - - /** - * Sets the fallback language if the language of the input text can't be identified. - * @param suggestedSourceLanguage fallback language if the language of the input text can't be identified. - * @return The updated options. - */ - public TranslateOptions setSuggestedSourceLanguage(String suggestedSourceLanguage) { - this.suggestedSourceLanguage = suggestedSourceLanguage; - return this; - } - - /** - * Returns the script of the input text. - * @return the script of the input text. - */ - public String getSourceLanguageScript() { - return sourceLanguageScript; - } - - /** - * Sets the script of the input text. - * @param sourceLanguageScript the script of the input text. - * @return The updated options. - */ - public TranslateOptions setSourceLanguageScript(String sourceLanguageScript) { - this.sourceLanguageScript = sourceLanguageScript; - return this; - } - - /** - * Returns the script of the translated text. - * @return the script of the translated text. - */ - public String getTargetLanguageScript() { - return targetLanguageScript; - } - - /** - * Sets the script of the translated text. - * @param targetLanguageScript the script of the translated text. - * @return The updated options. - */ - public TranslateOptions setTargetLanguageScript(String targetLanguageScript) { - this.targetLanguageScript = targetLanguageScript; - return this; - } - - /** - * Returns whether the service allows fallback for Custom Translator requests. - * @return Whether the service allows fallback for Custom Translator requests. - */ - public Boolean isAllowFallback() { - return allowFallback; - } - - /** - * Sets whether the service allows fallback for Custom Translator requests. - * @param allowFallback Whether the service allows fallback for Custom Translator requests. - * @return The updated options. - */ - public TranslateOptions setAllowFallback(Boolean allowFallback) { - this.allowFallback = allowFallback; - return this; - } -} diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslatedTextAlignment.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslatedTextAlignment.java deleted file mode 100644 index 99894c25998d..000000000000 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslatedTextAlignment.java +++ /dev/null @@ -1,93 +0,0 @@ -// 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; - -/** - * Alignment information object. - */ -@Immutable -public final class TranslatedTextAlignment implements JsonSerializable { - - /* - * Maps input text to translated text. The alignment information is only provided when the request - * parameter includeAlignment is true. Alignment is returned as a string value of the following - * format: [[SourceTextStartIndex]:[SourceTextEndIndex]–[TgtTextStartIndex]:[TgtTextEndIndex]]. - * The colon separates start and end index, the dash separates the languages, and space separates the words. - * One word may align with zero, one, or multiple words in the other language, and the aligned words may - * be non-contiguous. When no alignment information is available, the alignment element will be empty. - */ - @Generated - private final String projections; - - /** - * Creates an instance of TranslatedTextAlignment class. - * - * @param projections the projections value to set. - */ - @Generated - private TranslatedTextAlignment(String projections) { - this.projections = projections; - } - - /** - * Get the projections property: Maps input text to translated text. The alignment information is only provided when - * the request - * parameter includeAlignment is true. Alignment is returned as a string value of the following - * format: [[SourceTextStartIndex]:[SourceTextEndIndex]–[TgtTextStartIndex]:[TgtTextEndIndex]]. - * The colon separates start and end index, the dash separates the languages, and space separates the words. - * One word may align with zero, one, or multiple words in the other language, and the aligned words may - * be non-contiguous. When no alignment information is available, the alignment element will be empty. - * - * @return the projections value. - */ - @Generated - public String getProjections() { - return this.projections; - } - - /** - * {@inheritDoc} - */ - @Generated - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeStringField("proj", this.projections); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of TranslatedTextAlignment from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of TranslatedTextAlignment 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 TranslatedTextAlignment. - */ - @Generated - public static TranslatedTextAlignment fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - String projections = null; - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - if ("proj".equals(fieldName)) { - projections = reader.getString(); - } else { - reader.skipChildren(); - } - } - return new TranslatedTextAlignment(projections); - }); - } -} diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslatedTextItem.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslatedTextItem.java index b8d8026cc01e..e280e5f70b29 100644 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslatedTextItem.java +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslatedTextItem.java @@ -29,26 +29,7 @@ public final class TranslatedTextItem implements JsonSerializable translations; - - /* - * Input text in the default script of the source language. sourceText property is present only when - * the input is expressed in a script that's not the usual script for the language. For example, - * if the input were Arabic written in Latin script, then sourceText.text would be the same Arabic text - * converted into Arab script. - */ - @Generated - private SourceText sourceText; - - /** - * Creates an instance of TranslatedTextItem class. - * - * @param translations the translations value to set. - */ - @Generated - private TranslatedTextItem(List translations) { - this.translations = translations; - } + private List translations; /** * Get the detectedLanguage property: The detectedLanguage property is only present in the result object when @@ -73,20 +54,6 @@ public List getTranslations() { return this.translations; } - /** - * Get the sourceText property: Input text in the default script of the source language. sourceText property is - * present only when - * the input is expressed in a script that's not the usual script for the language. For example, - * if the input were Arabic written in Latin script, then sourceText.text would be the same Arabic text - * converted into Arab script. - * - * @return the sourceText value. - */ - @Generated - public SourceText getSourceText() { - return this.sourceText; - } - /** * {@inheritDoc} */ @@ -94,9 +61,7 @@ public SourceText getSourceText() { @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeArrayField("translations", this.translations, (writer, element) -> writer.writeJson(element)); jsonWriter.writeJsonField("detectedLanguage", this.detectedLanguage); - jsonWriter.writeJsonField("sourceText", this.sourceText); return jsonWriter.writeEndObject(); } @@ -112,26 +77,27 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { @Generated public static TranslatedTextItem fromJson(JsonReader jsonReader) throws IOException { return jsonReader.readObject(reader -> { - List translations = null; - DetectedLanguage detectedLanguage = null; - SourceText sourceText = null; + TranslatedTextItem deserializedTranslatedTextItem = new TranslatedTextItem(); while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); if ("translations".equals(fieldName)) { - translations = reader.readArray(reader1 -> TranslationText.fromJson(reader1)); + List translations = reader.readArray(reader1 -> TranslationText.fromJson(reader1)); + deserializedTranslatedTextItem.translations = translations; } else if ("detectedLanguage".equals(fieldName)) { - detectedLanguage = DetectedLanguage.fromJson(reader); - } else if ("sourceText".equals(fieldName)) { - sourceText = SourceText.fromJson(reader); + deserializedTranslatedTextItem.detectedLanguage = DetectedLanguage.fromJson(reader); } else { reader.skipChildren(); } } - TranslatedTextItem deserializedTranslatedTextItem = new TranslatedTextItem(translations); - deserializedTranslatedTextItem.detectedLanguage = detectedLanguage; - deserializedTranslatedTextItem.sourceText = sourceText; return deserializedTranslatedTextItem; }); } + + /** + * Creates an instance of TranslatedTextItem class. + */ + @Generated + private TranslatedTextItem() { + } } diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslationLanguage.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslationLanguage.java index 51a715a9ddd4..8fd4a2516f89 100644 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslationLanguage.java +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslationLanguage.java @@ -10,6 +10,7 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; +import java.util.List; /** * The value of the translation property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. @@ -109,6 +110,7 @@ public static TranslationLanguage fromJson(JsonReader jsonReader) throws IOExcep String name = null; String nativeName = null; LanguageDirectionality directionality = null; + List models = null; while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); @@ -118,11 +120,32 @@ public static TranslationLanguage fromJson(JsonReader jsonReader) throws IOExcep nativeName = reader.getString(); } else if ("dir".equals(fieldName)) { directionality = LanguageDirectionality.fromString(reader.getString()); + } else if ("models".equals(fieldName)) { + models = reader.readArray(reader1 -> reader1.getString()); } else { reader.skipChildren(); } } - return new TranslationLanguage(name, nativeName, directionality); + TranslationLanguage deserializedTranslationLanguage + = new TranslationLanguage(name, nativeName, directionality); + deserializedTranslationLanguage.models = models; + return deserializedTranslationLanguage; }); } + + /* + * LLM models supported for translation. + */ + @Generated + private List models; + + /** + * Get the models property: LLM models supported for translation. + * + * @return the models value. + */ + @Generated + public List getModels() { + return this.models; + } } diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/SourceText.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslationResult.java similarity index 54% rename from sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/SourceText.java rename to sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslationResult.java index 7173b54098c1..5ad65659e791 100644 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/SourceText.java +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslationResult.java @@ -10,37 +10,35 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; +import java.util.List; /** - * Input text in the default script of the source language. + * Response for the translation API. */ @Immutable -public final class SourceText implements JsonSerializable { +public final class TranslationResult implements JsonSerializable { /* - * Input text in the default script of the source language. + * Array of the translated text elements. */ @Generated - private final String text; + private List value; /** - * Creates an instance of SourceText class. - * - * @param text the text value to set. + * Creates an instance of TranslationResult class. */ @Generated - private SourceText(String text) { - this.text = text; + private TranslationResult() { } /** - * Get the text property: Input text in the default script of the source language. + * Get the value property: Array of the translated text elements. * - * @return the text value. + * @return the value value. */ @Generated - public String getText() { - return this.text; + public List getValue() { + return this.value; } /** @@ -50,33 +48,33 @@ public String getText() { @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField("text", this.text); return jsonWriter.writeEndObject(); } /** - * Reads an instance of SourceText from the JsonReader. + * Reads an instance of TranslationResult from the JsonReader. * * @param jsonReader The JsonReader being read. - * @return An instance of SourceText if the JsonReader was pointing to an instance of it, or null if it was pointing - * to JSON null. + * @return An instance of TranslationResult 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 SourceText. + * @throws IOException If an error occurs while reading the TranslationResult. */ @Generated - public static SourceText fromJson(JsonReader jsonReader) throws IOException { + public static TranslationResult fromJson(JsonReader jsonReader) throws IOException { return jsonReader.readObject(reader -> { - String text = null; + TranslationResult deserializedTranslationResult = new TranslationResult(); while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); - if ("text".equals(fieldName)) { - text = reader.getString(); + if ("value".equals(fieldName)) { + List value = reader.readArray(reader1 -> TranslatedTextItem.fromJson(reader1)); + deserializedTranslationResult.value = value; } else { reader.skipChildren(); } } - return new SourceText(text); + return deserializedTranslationResult; }); } } diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslationTarget.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslationTarget.java new file mode 100644 index 000000000000..c36b55157a5b --- /dev/null +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslationTarget.java @@ -0,0 +1,480 @@ +// 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; + +/** + * Target language and translation configuration parameters. + */ +@Fluent +public final class TranslationTarget 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 String 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 deploymentName; + + /* + * 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 text pairs to generate adaptive customized translation. + */ + @Generated + private List referenceTextPairs; + + /** + * Creates an instance of TranslationTarget class. + * + * @param language the language value to set. + */ + @Generated + public TranslationTarget(String 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 String 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 TranslationTarget object itself. + */ + @Generated + public TranslationTarget 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 TranslationTarget object itself. + */ + @Generated + public TranslationTarget 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 TranslationTarget object itself. + */ + @Generated + public TranslationTarget setProfanityMarker(ProfanityMarker profanityMarker) { + this.profanityMarker = profanityMarker; + return this; + } + + /** + * Get the deploymentName 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 deploymentName value. + */ + @Generated + public String getDeploymentName() { + return this.deploymentName; + } + + /** + * Set the deploymentName 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 deploymentName the deploymentName value to set. + * @return the TranslationTarget object itself. + */ + @Generated + public TranslationTarget setDeploymentName(String deploymentName) { + this.deploymentName = deploymentName; + 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 TranslationTarget object itself. + */ + @Generated + public TranslationTarget 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 TranslationTarget object itself. + */ + @Generated + public TranslationTarget 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 TranslationTarget object itself. + */ + @Generated + public TranslationTarget 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 TranslationTarget object itself. + */ + @Generated + public TranslationTarget 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 TranslationTarget object itself. + */ + @Generated + public TranslationTarget setAdaptiveDatasetId(String adaptiveDatasetId) { + this.adaptiveDatasetId = adaptiveDatasetId; + return this; + } + + /** + * Get the referenceTextPairs property: Reference text pairs to generate adaptive customized translation. + * + * @return the referenceTextPairs value. + */ + @Generated + public List getReferenceTextPairs() { + return this.referenceTextPairs; + } + + /** + * Set the referenceTextPairs property: Reference text pairs to generate adaptive customized translation. + * + * @param referenceTextPairs the referenceTextPairs value to set. + * @return the TranslationTarget object itself. + */ + @Generated + public TranslationTarget setReferenceTextPairs(List referenceTextPairs) { + this.referenceTextPairs = referenceTextPairs; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("language", this.language); + 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("deploymentName", this.deploymentName); + 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 TranslationTarget from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TranslationTarget 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 TranslationTarget. + */ + @Generated + public static TranslationTarget fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String language = null; + String script = null; + ProfanityAction profanityAction = null; + ProfanityMarker profanityMarker = null; + String deploymentName = 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.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 ("deploymentName".equals(fieldName)) { + deploymentName = 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 -> ReferenceTextPair.fromJson(reader1)); + } else { + reader.skipChildren(); + } + } + TranslationTarget deserializedTranslationTarget = new TranslationTarget(language); + deserializedTranslationTarget.script = script; + deserializedTranslationTarget.profanityAction = profanityAction; + deserializedTranslationTarget.profanityMarker = profanityMarker; + deserializedTranslationTarget.deploymentName = deploymentName; + deserializedTranslationTarget.allowFallback = allowFallback; + deserializedTranslationTarget.grade = grade; + deserializedTranslationTarget.tone = tone; + deserializedTranslationTarget.gender = gender; + deserializedTranslationTarget.adaptiveDatasetId = adaptiveDatasetId; + deserializedTranslationTarget.referenceTextPairs = referenceTextPairs; + return deserializedTranslationTarget; + }); + } +} 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..40f85de865c0 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 @@ -23,46 +23,18 @@ public final class TranslationText implements JsonSerializable @Generated private final String text; - /* - * An object giving the translated text in the script specified by the toScript parameter. - */ - @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. * - * @param targetLanguage the targetLanguage value to set. + * @param language the language value to set. * @param text the text value to set. */ @Generated - private TranslationText(String targetLanguage, String text) { - this.targetLanguage = targetLanguage; + private TranslationText(String language, String text) { + this.language = language; this.text = text; } - /** - * Get the targetLanguage property: A string representing the language code of the target language. - * - * @return the targetLanguage value. - */ - @Generated - public String getTargetLanguage() { - return this.targetLanguage; - } - /** * Get the text property: A string giving the translated text. * @@ -73,43 +45,6 @@ public String getText() { return this.text; } - /** - * Get the transliteration property: An object giving the translated text in the script specified by the toScript - * parameter. - * - * @return the transliteration value. - */ - @Generated - 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. - */ - @Generated - private final String targetLanguage; - /** * {@inheritDoc} */ @@ -117,11 +52,13 @@ public SentenceBoundaries getSentenceBoundaries() { @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField("to", this.targetLanguage); + jsonWriter.writeStringField("language", this.language); jsonWriter.writeStringField("text", this.text); - jsonWriter.writeJsonField("transliteration", this.transliteration); - jsonWriter.writeJsonField("alignment", this.alignment); - jsonWriter.writeJsonField("sentLen", this.sentenceBoundaries); + jsonWriter.writeNumberField("sourceCharacters", this.sourceCharacters); + jsonWriter.writeNumberField("instructionTokens", this.instructionTokens); + jsonWriter.writeNumberField("sourceTokens", this.sourceTokens); + jsonWriter.writeNumberField("responseTokens", this.responseTokens); + jsonWriter.writeNumberField("targetTokens", this.targetTokens); return jsonWriter.writeEndObject(); } @@ -137,33 +74,138 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { @Generated public static TranslationText fromJson(JsonReader jsonReader) throws IOException { return jsonReader.readObject(reader -> { - String targetLanguage = null; + String language = null; String text = null; - TransliteratedText transliteration = null; - TranslatedTextAlignment alignment = null; - SentenceBoundaries sentenceBoundaries = null; + Integer sourceCharacters = null; + Integer instructionTokens = null; + Integer sourceTokens = null; + Integer responseTokens = null; + Integer targetTokens = null; while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); - if ("to".equals(fieldName)) { - targetLanguage = reader.getString(); + if ("language".equals(fieldName)) { + language = reader.getString(); } else if ("text".equals(fieldName)) { 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 if ("sourceCharacters".equals(fieldName)) { + sourceCharacters = reader.getNullable(JsonReader::getInt); + } else if ("instructionTokens".equals(fieldName)) { + instructionTokens = reader.getNullable(JsonReader::getInt); + } else if ("sourceTokens".equals(fieldName)) { + sourceTokens = reader.getNullable(JsonReader::getInt); + } else if ("responseTokens".equals(fieldName)) { + responseTokens = reader.getNullable(JsonReader::getInt); + } else if ("targetTokens".equals(fieldName)) { + targetTokens = reader.getNullable(JsonReader::getInt); } else { reader.skipChildren(); } } - TranslationText deserializedTranslationText = new TranslationText(targetLanguage, text); - deserializedTranslationText.transliteration = transliteration; - deserializedTranslationText.alignment = alignment; - deserializedTranslationText.sentenceBoundaries = sentenceBoundaries; + TranslationText deserializedTranslationText = new TranslationText(language, text); + deserializedTranslationText.sourceCharacters = sourceCharacters; + deserializedTranslationText.instructionTokens = instructionTokens; + deserializedTranslationText.sourceTokens = sourceTokens; + deserializedTranslationText.responseTokens = responseTokens; + deserializedTranslationText.targetTokens = targetTokens; return deserializedTranslationText; }); } + + /* + * A string representing the language code of the target language. + */ + @Generated + private final String language; + + /* + * An integer indicating the number of characters in the source text string + */ + @Generated + private Integer sourceCharacters; + + /* + * An integer indicating the number of tokens used in generating the translated text + */ + @Generated + private Integer instructionTokens; + + /* + * An integer indicating the number of tokens used in the source sentence + */ + @Generated + private Integer sourceTokens; + + /* + * An integer indicating the number of tokens used in the translation response + */ + @Generated + private Integer responseTokens; + + /* + * An integer indicating the number of tokens used in the target sentence + */ + @Generated + private Integer targetTokens; + + /** + * Get the language property: A string representing the language code of the target language. + * + * @return the language value. + */ + @Generated + public String getLanguage() { + return this.language; + } + + /** + * Get the sourceCharacters property: An integer indicating the number of characters in the source text string. + * + * @return the sourceCharacters value. + */ + @Generated + public Integer getSourceCharacters() { + return this.sourceCharacters; + } + + /** + * Get the instructionTokens property: An integer indicating the number of tokens used in generating the translated + * text. + * + * @return the instructionTokens value. + */ + @Generated + public Integer getInstructionTokens() { + return this.instructionTokens; + } + + /** + * Get the sourceTokens property: An integer indicating the number of tokens used in the source sentence. + * + * @return the sourceTokens value. + */ + @Generated + public Integer getSourceTokens() { + return this.sourceTokens; + } + + /** + * Get the responseTokens property: An integer indicating the number of tokens used in the translation response. + * + * @return the responseTokens value. + */ + @Generated + public Integer getResponseTokens() { + return this.responseTokens; + } + + /** + * Get the targetTokens property: An integer indicating the number of tokens used in the target sentence. + * + * @return the targetTokens value. + */ + @Generated + public Integer getTargetTokens() { + return this.targetTokens; + } } diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TransliterableScript.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TransliterableScript.java index 9b5e708e5091..d308563a5fcb 100644 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TransliterableScript.java +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TransliterableScript.java @@ -24,31 +24,15 @@ public final class TransliterableScript extends LanguageScript { * @param name the name value to set. * @param nativeName the nativeName value to set. * @param directionality the directionality value to set. - * @param targetLanguageScripts the targetLanguageScripts value to set. + * @param toScripts the toScripts value to set. */ @Generated private TransliterableScript(String code, String name, String nativeName, LanguageDirectionality directionality, - List targetLanguageScripts) { + List toScripts) { super(code, name, nativeName, directionality); - this.targetLanguageScripts = targetLanguageScripts; + this.toScripts = toScripts; } - /** - * Get the targetLanguageScripts property: List of scripts available to convert text to. - * - * @return the targetLanguageScripts value. - */ - @Generated - public List getTargetLanguageScripts() { - return this.targetLanguageScripts; - } - - /* - * List of scripts available to convert text to. - */ - @Generated - private final List targetLanguageScripts; - /** * {@inheritDoc} */ @@ -60,8 +44,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStringField("name", getName()); jsonWriter.writeStringField("nativeName", getNativeName()); jsonWriter.writeStringField("dir", getDirectionality() == null ? null : getDirectionality().toString()); - jsonWriter.writeArrayField("toScripts", this.targetLanguageScripts, - (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("toScripts", this.toScripts, (writer, element) -> writer.writeJson(element)); return jsonWriter.writeEndObject(); } @@ -81,7 +64,7 @@ public static TransliterableScript fromJson(JsonReader jsonReader) throws IOExce String name = null; String nativeName = null; LanguageDirectionality directionality = null; - List targetLanguageScripts = null; + List toScripts = null; while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); @@ -94,12 +77,28 @@ public static TransliterableScript fromJson(JsonReader jsonReader) throws IOExce } else if ("dir".equals(fieldName)) { directionality = LanguageDirectionality.fromString(reader.getString()); } else if ("toScripts".equals(fieldName)) { - targetLanguageScripts = reader.readArray(reader1 -> LanguageScript.fromJson(reader1)); + toScripts = reader.readArray(reader1 -> LanguageScript.fromJson(reader1)); } else { reader.skipChildren(); } } - return new TransliterableScript(code, name, nativeName, directionality, targetLanguageScripts); + return new TransliterableScript(code, name, nativeName, directionality, toScripts); }); } + + /* + * List of scripts available to convert text to. + */ + @Generated + private final List toScripts; + + /** + * Get the toScripts property: List of scripts available to convert text to. + * + * @return the toScripts value. + */ + @Generated + public List getToScripts() { + return this.toScripts; + } } diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TransliterateBody.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TransliterateBody.java new file mode 100644 index 000000000000..4b350b930876 --- /dev/null +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TransliterateBody.java @@ -0,0 +1,83 @@ +// 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; +import java.util.List; + +/** + * Request data for transliterate. + */ +@Immutable +public final class TransliterateBody implements JsonSerializable { + + /* + * Array of the input text elements to transliterate. + */ + @Generated + private final List inputs; + + /** + * Creates an instance of TransliterateBody class. + * + * @param inputs the inputs value to set. + */ + @Generated + public TransliterateBody(List inputs) { + this.inputs = inputs; + } + + /** + * Get the inputs property: Array of the input text elements to transliterate. + * + * @return the inputs value. + */ + @Generated + public List getInputs() { + return this.inputs; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("inputs", this.inputs, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TransliterateBody from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TransliterateBody 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 TransliterateBody. + */ + @Generated + public static TransliterateBody fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List inputs = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("inputs".equals(fieldName)) { + inputs = reader.readArray(reader1 -> InputTextItem.fromJson(reader1)); + } else { + reader.skipChildren(); + } + } + return new TransliterateBody(inputs); + }); + } +} diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TransliterateResult.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TransliterateResult.java new file mode 100644 index 000000000000..b520121f2747 --- /dev/null +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TransliterateResult.java @@ -0,0 +1,80 @@ +// 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; +import java.util.List; + +/** + * Response for the transliteration API. + */ +@Immutable +public final class TransliterateResult implements JsonSerializable { + + /* + * Array of transliterated texts + */ + @Generated + private List value; + + /** + * Creates an instance of TransliterateResult class. + */ + @Generated + private TransliterateResult() { + } + + /** + * Get the value property: Array of transliterated texts. + * + * @return the value value. + */ + @Generated + public List getValue() { + return this.value; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TransliterateResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TransliterateResult 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 TransliterateResult. + */ + @Generated + public static TransliterateResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + TransliterateResult deserializedTransliterateResult = new TransliterateResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("value".equals(fieldName)) { + List value = reader.readArray(reader1 -> TransliteratedText.fromJson(reader1)); + deserializedTransliterateResult.value = value; + } else { + reader.skipChildren(); + } + } + return deserializedTransliterateResult; + }); + } +} diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TransliterationLanguage.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TransliterationLanguage.java index eddca15e4b28..66a8043d76e8 100644 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TransliterationLanguage.java +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TransliterationLanguage.java @@ -36,21 +36,7 @@ public final class TransliterationLanguage implements JsonSerializable scripts; - - /** - * Creates an instance of TransliterationLanguage class. - * - * @param name the name value to set. - * @param nativeName the nativeName value to set. - * @param scripts the scripts value to set. - */ - @Generated - private TransliterationLanguage(String name, String nativeName, List scripts) { - this.name = name; - this.nativeName = nativeName; - this.scripts = scripts; - } + private List scripts; /** * Get the name property: Display name of the language in the locale requested via Accept-Language header. @@ -91,7 +77,6 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); jsonWriter.writeStringField("name", this.name); jsonWriter.writeStringField("nativeName", this.nativeName); - jsonWriter.writeArrayField("scripts", this.scripts, (writer, element) -> writer.writeJson(element)); return jsonWriter.writeEndObject(); } @@ -123,7 +108,21 @@ public static TransliterationLanguage fromJson(JsonReader jsonReader) throws IOE reader.skipChildren(); } } - return new TransliterationLanguage(name, nativeName, scripts); + TransliterationLanguage deserializedTransliterationLanguage = new TransliterationLanguage(name, nativeName); + deserializedTransliterationLanguage.scripts = scripts; + return deserializedTransliterationLanguage; }); } + + /** + * Creates an instance of TransliterationLanguage class. + * + * @param name the name value to set. + * @param nativeName the nativeName value to set. + */ + @Generated + private TransliterationLanguage(String name, String nativeName) { + this.name = name; + this.nativeName = nativeName; + } } 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..316728877a5d 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,56 +2,39 @@ "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.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.ReferenceTextPair": "TextTranslation.ReferenceTextPair", "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.TranslateInputItem": "TextTranslation.TranslateInputItem", "com.azure.ai.translation.text.models.TranslatedTextItem": "TextTranslation.TranslatedTextItem", "com.azure.ai.translation.text.models.TranslationLanguage": "TextTranslation.TranslationLanguage", + "com.azure.ai.translation.text.models.TranslationResult": "TextTranslation.TranslationResult", + "com.azure.ai.translation.text.models.TranslationTarget": "TextTranslation.TranslationTarget", "com.azure.ai.translation.text.models.TranslationText": "TextTranslation.TranslationText", "com.azure.ai.translation.text.models.TransliterableScript": "TextTranslation.TransliterableScript", + "com.azure.ai.translation.text.models.TransliterateBody": "TextTranslation.TransliterateBody", + "com.azure.ai.translation.text.models.TransliterateResult": "TextTranslation.TransliterateResult", "com.azure.ai.translation.text.models.TransliteratedText": "TextTranslation.TransliteratedText", "com.azure.ai.translation.text.models.TransliterationLanguage": "TextTranslation.TransliterationLanguage" } diff --git a/sdk/translation/azure-ai-translation-text/src/main/resources/META-INF/azure-ai-translation-text_metadata.json b/sdk/translation/azure-ai-translation-text/src/main/resources/META-INF/azure-ai-translation-text_metadata.json index 39074129fc9e..98b61d1410e7 100644 --- a/sdk/translation/azure-ai-translation-text/src/main/resources/META-INF/azure-ai-translation-text_metadata.json +++ b/sdk/translation/azure-ai-translation-text/src/main/resources/META-INF/azure-ai-translation-text_metadata.json @@ -1 +1 @@ -{"flavor":"azure","apiVersion":"3.0","crossLanguageDefinitions":{"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.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.TranslatedTextItem":"TextTranslation.TranslatedTextItem","com.azure.ai.translation.text.models.TranslationLanguage":"TextTranslation.TranslationLanguage","com.azure.ai.translation.text.models.TranslationText":"TextTranslation.TranslationText","com.azure.ai.translation.text.models.TransliterableScript":"TextTranslation.TransliterableScript","com.azure.ai.translation.text.models.TransliteratedText":"TextTranslation.TransliteratedText","com.azure.ai.translation.text.models.TransliterationLanguage":"TextTranslation.TransliterationLanguage"},"generatedFiles":["src/main/java/com/azure/ai/translation/text/TextTranslationAsyncClient.java","src/main/java/com/azure/ai/translation/text/TextTranslationClient.java","src/main/java/com/azure/ai/translation/text/TextTranslationClientBuilder.java","src/main/java/com/azure/ai/translation/text/TextTranslationServiceVersion.java","src/main/java/com/azure/ai/translation/text/implementation/TextTranslationClientImpl.java","src/main/java/com/azure/ai/translation/text/implementation/package-info.java","src/main/java/com/azure/ai/translation/text/models/BackTranslation.java","src/main/java/com/azure/ai/translation/text/models/BreakSentenceItem.java","src/main/java/com/azure/ai/translation/text/models/DetectedLanguage.java","src/main/java/com/azure/ai/translation/text/models/DictionaryExample.java","src/main/java/com/azure/ai/translation/text/models/DictionaryExampleItem.java","src/main/java/com/azure/ai/translation/text/models/DictionaryExampleTextItem.java","src/main/java/com/azure/ai/translation/text/models/DictionaryLookupItem.java","src/main/java/com/azure/ai/translation/text/models/DictionaryTranslation.java","src/main/java/com/azure/ai/translation/text/models/GetSupportedLanguagesResult.java","src/main/java/com/azure/ai/translation/text/models/InputTextItem.java","src/main/java/com/azure/ai/translation/text/models/LanguageDirectionality.java","src/main/java/com/azure/ai/translation/text/models/LanguageScript.java","src/main/java/com/azure/ai/translation/text/models/ProfanityAction.java","src/main/java/com/azure/ai/translation/text/models/ProfanityMarker.java","src/main/java/com/azure/ai/translation/text/models/SentenceBoundaries.java","src/main/java/com/azure/ai/translation/text/models/SourceDictionaryLanguage.java","src/main/java/com/azure/ai/translation/text/models/SourceText.java","src/main/java/com/azure/ai/translation/text/models/TargetDictionaryLanguage.java","src/main/java/com/azure/ai/translation/text/models/TextType.java","src/main/java/com/azure/ai/translation/text/models/TranslatedTextAlignment.java","src/main/java/com/azure/ai/translation/text/models/TranslatedTextItem.java","src/main/java/com/azure/ai/translation/text/models/TranslationLanguage.java","src/main/java/com/azure/ai/translation/text/models/TranslationText.java","src/main/java/com/azure/ai/translation/text/models/TransliterableScript.java","src/main/java/com/azure/ai/translation/text/models/TransliteratedText.java","src/main/java/com/azure/ai/translation/text/models/TransliterationLanguage.java","src/main/java/com/azure/ai/translation/text/models/package-info.java","src/main/java/com/azure/ai/translation/text/package-info.java","src/main/java/module-info.java"]} \ No newline at end of file +{"flavor":"azure","apiVersion":"2025-10-01-preview","crossLanguageDefinitions":{"com.azure.ai.translation.text.TextTranslationAsyncClient":"TextTranslation","com.azure.ai.translation.text.TextTranslationAsyncClient.getSupportedLanguages":"TextTranslation.getSupportedLanguages","com.azure.ai.translation.text.TextTranslationAsyncClient.getSupportedLanguagesWithResponse":"TextTranslation.getSupportedLanguages","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.getSupportedLanguages":"TextTranslation.getSupportedLanguages","com.azure.ai.translation.text.TextTranslationClient.getSupportedLanguagesWithResponse":"TextTranslation.getSupportedLanguages","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.DetectedLanguage":"TextTranslation.DetectedLanguage","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.ReferenceTextPair":"TextTranslation.ReferenceTextPair","com.azure.ai.translation.text.models.TextType":"TextTranslation.TextType","com.azure.ai.translation.text.models.TranslateBody":"TextTranslation.TranslateBody","com.azure.ai.translation.text.models.TranslateInputItem":"TextTranslation.TranslateInputItem","com.azure.ai.translation.text.models.TranslatedTextItem":"TextTranslation.TranslatedTextItem","com.azure.ai.translation.text.models.TranslationLanguage":"TextTranslation.TranslationLanguage","com.azure.ai.translation.text.models.TranslationResult":"TextTranslation.TranslationResult","com.azure.ai.translation.text.models.TranslationTarget":"TextTranslation.TranslationTarget","com.azure.ai.translation.text.models.TranslationText":"TextTranslation.TranslationText","com.azure.ai.translation.text.models.TransliterableScript":"TextTranslation.TransliterableScript","com.azure.ai.translation.text.models.TransliterateBody":"TextTranslation.TransliterateBody","com.azure.ai.translation.text.models.TransliterateResult":"TextTranslation.TransliterateResult","com.azure.ai.translation.text.models.TransliteratedText":"TextTranslation.TransliteratedText","com.azure.ai.translation.text.models.TransliterationLanguage":"TextTranslation.TransliterationLanguage"},"generatedFiles":["src/main/java/com/azure/ai/translation/text/TextTranslationAsyncClient.java","src/main/java/com/azure/ai/translation/text/TextTranslationClient.java","src/main/java/com/azure/ai/translation/text/TextTranslationClientBuilder.java","src/main/java/com/azure/ai/translation/text/TextTranslationServiceVersion.java","src/main/java/com/azure/ai/translation/text/implementation/TextTranslationClientImpl.java","src/main/java/com/azure/ai/translation/text/implementation/package-info.java","src/main/java/com/azure/ai/translation/text/models/DetectedLanguage.java","src/main/java/com/azure/ai/translation/text/models/GetSupportedLanguagesResult.java","src/main/java/com/azure/ai/translation/text/models/InputTextItem.java","src/main/java/com/azure/ai/translation/text/models/LanguageDirectionality.java","src/main/java/com/azure/ai/translation/text/models/LanguageScript.java","src/main/java/com/azure/ai/translation/text/models/ProfanityAction.java","src/main/java/com/azure/ai/translation/text/models/ProfanityMarker.java","src/main/java/com/azure/ai/translation/text/models/ReferenceTextPair.java","src/main/java/com/azure/ai/translation/text/models/TextType.java","src/main/java/com/azure/ai/translation/text/models/TranslateBody.java","src/main/java/com/azure/ai/translation/text/models/TranslateInputItem.java","src/main/java/com/azure/ai/translation/text/models/TranslatedTextItem.java","src/main/java/com/azure/ai/translation/text/models/TranslationLanguage.java","src/main/java/com/azure/ai/translation/text/models/TranslationResult.java","src/main/java/com/azure/ai/translation/text/models/TranslationTarget.java","src/main/java/com/azure/ai/translation/text/models/TranslationText.java","src/main/java/com/azure/ai/translation/text/models/TransliterableScript.java","src/main/java/com/azure/ai/translation/text/models/TransliterateBody.java","src/main/java/com/azure/ai/translation/text/models/TransliterateResult.java","src/main/java/com/azure/ai/translation/text/models/TransliteratedText.java","src/main/java/com/azure/ai/translation/text/models/TransliterationLanguage.java","src/main/java/com/azure/ai/translation/text/models/package-info.java","src/main/java/com/azure/ai/translation/text/package-info.java","src/main/java/module-info.java"]} \ No newline at end of file diff --git a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/BreakSentence.java b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/BreakSentence.java deleted file mode 100644 index 390b7a350137..000000000000 --- a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/BreakSentence.java +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.ai.translation.text; - -import com.azure.ai.translation.text.models.BreakSentenceItem; -import com.azure.core.credential.AzureKeyCredential; - -/** - * Break Sentence API call. - */ -public class BreakSentence { - /** - * Main method to invoke this demo. - * - * @param args Unused arguments to the program. - */ - public static void main(final String[] args) { - String apiKey = System.getenv("TEXT_TRANSLATOR_API_KEY"); - String region = System.getenv("TEXT_TRANSLATOR_API_REGION"); - AzureKeyCredential credential = new AzureKeyCredential(apiKey); - - TextTranslationClient client = new TextTranslationClientBuilder() - .credential(credential) - .region(region) - .endpoint("https://api.cognitive.microsofttranslator.com") - .buildClient(); - - // BEGIN: getTextTranslationSentenceBoundaries - String sourceLanguage = "zh-Hans"; - String sourceScript = "Latn"; - String content = "zhè shì gè cè shì。"; - - BreakSentenceItem breakSentence = client.findSentenceBoundaries(content, sourceLanguage, sourceScript); - - System.out.println("The detected sentence boundaries: " + breakSentence.getSentencesLengths()); - // END: getTextTranslationSentenceBoundaries - } -} diff --git a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/DictionaryExamples.java b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/DictionaryExamples.java deleted file mode 100644 index f1660ff1fe1b..000000000000 --- a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/DictionaryExamples.java +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.ai.translation.text; - -import java.util.List; -import java.util.ArrayList; -import com.azure.core.credential.AzureKeyCredential; -import com.azure.ai.translation.text.models.DictionaryExampleItem; -import com.azure.ai.translation.text.models.DictionaryExampleTextItem; - -/** - * Returns grammatical structure and context examples for the source term and target term pair. - */ -public class DictionaryExamples { - /** - * Main method to invoke this demo. - * - * @param args Unused arguments to the program. - */ - public static void main(final String[] args) { - String apiKey = System.getenv("TEXT_TRANSLATOR_API_KEY"); - String region = System.getenv("TEXT_TRANSLATOR_API_REGION"); - AzureKeyCredential credential = new AzureKeyCredential(apiKey); - - TextTranslationClient client = new TextTranslationClientBuilder() - .credential(credential) - .region(region) - .endpoint("https://api.cognitive.microsofttranslator.com") - .buildClient(); - - // BEGIN: getTextTranslationDictionaryExamples - String sourceLanguage = "en"; - String targetLanguage = "es"; - List content = new ArrayList<>(); - content.add(new DictionaryExampleTextItem("fly", "volar")); - - List dictionaryEntries = client.lookupDictionaryExamples(sourceLanguage, targetLanguage, content); - - for (DictionaryExampleItem dictionaryEntry : dictionaryEntries) { - System.out.println("For the given input " + dictionaryEntry.getExamples().size() + " entries were found in the dictionary."); - System.out.println("Example: '" + dictionaryEntry.getExamples().get(0).getTargetPrefix() + dictionaryEntry.getExamples().get(0).getTargetTerm() + dictionaryEntry.getExamples().get(0).getTargetSuffix()); - } - // END: getTextTranslationDictionaryExamples - } -} diff --git a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/DictionaryLookup.java b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/DictionaryLookup.java deleted file mode 100644 index 181559167d4c..000000000000 --- a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/DictionaryLookup.java +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.ai.translation.text; - -import com.azure.ai.translation.text.models.DictionaryLookupItem; -import com.azure.core.credential.AzureKeyCredential; - -/** - * Returns equivalent words for the source term in the target language. - */ -public class DictionaryLookup { - /** - * Main method to invoke this demo. - * - * @param args Unused arguments to the program. - */ - public static void main(final String[] args) { - String apiKey = System.getenv("TEXT_TRANSLATOR_API_KEY"); - String region = System.getenv("TEXT_TRANSLATOR_API_REGION"); - AzureKeyCredential credential = new AzureKeyCredential(apiKey); - - TextTranslationClient client = new TextTranslationClientBuilder() - .credential(credential) - .region(region) - .endpoint("https://api.cognitive.microsofttranslator.com") - .buildClient(); - - // BEGIN: getTextTranslationDictionaryLookup - String sourceLanguage = "en"; - String targetLanguage = "es"; - String content = "fly"; - - DictionaryLookupItem dictionaryEntry = client.lookupDictionaryEntries(sourceLanguage, targetLanguage, content); - - System.out.println("For the given input " + dictionaryEntry.getTranslations().size() + " entries were found in the dictionary."); - System.out.println("First entry: '" + dictionaryEntry.getTranslations().get(0).getDisplayTarget() + "', confidence: " + dictionaryEntry.getTranslations().get(0).getConfidence()); - // END: getTextTranslationDictionaryLookup - } -} diff --git a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/GetLanguages.java b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/GetLanguages.java index cb7a9b43e32c..e3ea56fdfa38 100644 --- a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/GetLanguages.java +++ b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/GetLanguages.java @@ -5,7 +5,6 @@ import java.util.Map; import com.azure.ai.translation.text.models.GetSupportedLanguagesResult; -import com.azure.ai.translation.text.models.SourceDictionaryLanguage; import com.azure.ai.translation.text.models.TranslationLanguage; import com.azure.ai.translation.text.models.TransliterationLanguage; @@ -28,7 +27,7 @@ public static void main(final String[] args) { System.out.println("Number of supported languages for translate operation: " + languages.getTranslation().size() + "."); System.out.println("Number of supported languages for transliterate operation: " + languages.getTransliteration().size() + "."); - System.out.println("Number of supported languages for dictionary operations: " + languages.getDictionary().size() + "."); + System.out.println("Number of supported models for translate operation: " + languages.getModels().size() + "."); System.out.println("Translation Languages:"); for (Map.Entry translationLanguage : languages.getTranslation().entrySet()) { @@ -40,9 +39,9 @@ public static void main(final String[] args) { System.out.println(transliterationLanguage.getKey() + " -- name: " + transliterationLanguage.getValue().getName() + ", supported script count: " + transliterationLanguage.getValue().getScripts().size()); } - System.out.println("Dictionary Languages:"); - for (Map.Entry dictionaryLanguage : languages.getDictionary().entrySet()) { - System.out.println(dictionaryLanguage.getKey() + " -- name: " + dictionaryLanguage.getValue().getName() + ", supported target languages count: " + dictionaryLanguage.getValue().getTranslations().size()); + System.out.println("Available models:"); + for (String model : languages.getModels()) { + System.out.println(model); } // END: getTextTranslationLanguages } diff --git a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/GetLanguagesAcceptLanguage.java b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/GetLanguagesAcceptLanguage.java index d3693a61b70f..0ad1985da32a 100644 --- a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/GetLanguagesAcceptLanguage.java +++ b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/GetLanguagesAcceptLanguage.java @@ -5,7 +5,6 @@ import java.util.Map; import com.azure.ai.translation.text.models.GetSupportedLanguagesResult; -import com.azure.ai.translation.text.models.SourceDictionaryLanguage; import com.azure.ai.translation.text.models.TranslationLanguage; import com.azure.ai.translation.text.models.TransliterationLanguage; @@ -33,7 +32,7 @@ public static void main(final String[] args) { System.out.println("Number of supported languages for translate operation: " + languages.getTranslation().size() + "."); System.out.println("Number of supported languages for transliterate operation: " + languages.getTransliteration().size() + "."); - System.out.println("Number of supported languages for dictionary operations: " + languages.getDictionary().size() + "."); + System.out.println("Number of supported models for translate operation: " + languages.getModels().size() + "."); System.out.println("Translation Languages:"); for (Map.Entry translationLanguage : languages.getTranslation().entrySet()) { @@ -45,9 +44,9 @@ public static void main(final String[] args) { System.out.println(transliterationLanguage.getKey() + " -- name: " + transliterationLanguage.getValue().getName() + ", supported script count: " + transliterationLanguage.getValue().getScripts().size()); } - System.out.println("Dictionary Languages:"); - for (Map.Entry dictionaryLanguage : languages.getDictionary().entrySet()) { - System.out.println(dictionaryLanguage.getKey() + " -- name: " + dictionaryLanguage.getValue().getName() + ", supported target languages count: " + dictionaryLanguage.getValue().getTranslations().size()); + System.out.println("Available models:"); + for (String model : languages.getModels()) { + System.out.println(model); } } } diff --git a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/GetLanguagesScope.java b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/GetLanguagesScope.java index bfc2137424c7..a21a480289b9 100644 --- a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/GetLanguagesScope.java +++ b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/GetLanguagesScope.java @@ -33,7 +33,7 @@ public static void main(final String[] args) { System.out.println("Number of supported languages for translate operation: " + languages.getTranslation().size() + "."); System.out.println("Number of supported languages for transliterate operation: " + (languages.getTransliteration() == null ? 0 : languages.getTransliteration().size()) + "."); - System.out.println("Number of supported languages for dictionary operations: " + (languages.getDictionary() == null ? 0 : languages.getDictionary().size()) + "."); + System.out.println("Number of supported models for translate operation: " + languages.getModels().size() + "."); System.out.println("Translation Languages:"); diff --git a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/Translate.java b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/Translate.java index 45a225e27ad2..c5c972ea2207 100644 --- a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/Translate.java +++ b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/Translate.java @@ -3,8 +3,11 @@ package com.azure.ai.translation.text; -import com.azure.ai.translation.text.models.TranslateOptions; +import java.util.Arrays; + +import com.azure.ai.translation.text.models.TranslateInputItem; import com.azure.ai.translation.text.models.TranslatedTextItem; +import com.azure.ai.translation.text.models.TranslationTarget; import com.azure.ai.translation.text.models.TranslationText; import com.azure.core.credential.AzureKeyCredential; @@ -29,14 +32,15 @@ public static void main(final String[] args) { .buildClient(); // BEGIN: getTextTranslationMultiple - TranslateOptions translateOptions = new TranslateOptions() - .setSourceLanguage("en") - .addTargetLanguage("es"); + TranslateInputItem input = new TranslateInputItem( + "This is a test.", + Arrays.asList(new TranslationTarget("es"), new TranslationTarget("fr"))); + input.setLanguage("en"); - TranslatedTextItem translation = client.translate("This is a test.", translateOptions); + TranslatedTextItem translation = client.translate(input); for (TranslationText textTranslation : translation.getTranslations()) { - System.out.println("Text was translated to: '" + textTranslation.getTargetLanguage() + "' and the result is: '" + textTranslation.getText() + "'."); + System.out.println("Text was translated to: '" + textTranslation.getLanguage() + "' and the result is: '" + textTranslation.getText() + "'."); } // END: getTextTranslationMultiple } diff --git a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateAlignments.java b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateAlignments.java deleted file mode 100644 index 259ae06de4aa..000000000000 --- a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateAlignments.java +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.ai.translation.text; - -import com.azure.ai.translation.text.models.TranslateOptions; -import com.azure.ai.translation.text.models.TranslatedTextItem; -import com.azure.ai.translation.text.models.TranslationText; -import com.azure.core.credential.AzureKeyCredential; - -/** - * You can ask translation service to include alignment projection from source text to translated text. - */ -public class TranslateAlignments { - /** - * Main method to invoke this demo. - * - * @param args Unused arguments to the program. - */ - public static void main(final String[] args) { - String apiKey = System.getenv("TEXT_TRANSLATOR_API_KEY"); - String region = System.getenv("TEXT_TRANSLATOR_API_REGION"); - AzureKeyCredential credential = new AzureKeyCredential(apiKey); - - TextTranslationClient client = new TextTranslationClientBuilder() - .credential(credential) - .region(region) - .endpoint("https://api.cognitive.microsofttranslator.com") - .buildClient(); - - TranslateOptions translateOptions = new TranslateOptions() - .setSourceLanguage("en") - .addTargetLanguage("cs") - .setIncludeAlignment(true); - - TranslatedTextItem translation = client.translate("The answer lies in machine translation.", translateOptions); - - for (TranslationText textTranslation : translation.getTranslations()) { - System.out.println("Text was translated to: '" + textTranslation.getTargetLanguage() + "' and the result is: '" + textTranslation.getText() + "'."); - System.out.println("Alignments: " + textTranslation.getAlignment().getProjections()); - } - } -} diff --git a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateCustom.java b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateCustom.java index 1a529f84fc41..3ef0e1cfc149 100644 --- a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateCustom.java +++ b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateCustom.java @@ -3,8 +3,11 @@ package com.azure.ai.translation.text; -import com.azure.ai.translation.text.models.TranslateOptions; +import java.util.Arrays; + +import com.azure.ai.translation.text.models.TranslateInputItem; import com.azure.ai.translation.text.models.TranslatedTextItem; +import com.azure.ai.translation.text.models.TranslationTarget; import com.azure.ai.translation.text.models.TranslationText; import com.azure.core.credential.AzureKeyCredential; @@ -42,15 +45,15 @@ public static void main(final String[] args) { .endpoint("https://api.cognitive.microsofttranslator.com") .buildClient(); - TranslateOptions translateOptions = new TranslateOptions() - .setSourceLanguage("en") - .addTargetLanguage("cs") - .setCategory("<>"); + TranslationTarget target = + new TranslationTarget("cs").setDeploymentName("<>"); + TranslateInputItem input = + new TranslateInputItem("This is a test.", Arrays.asList(target)).setLanguage("en"); - TranslatedTextItem translation = client.translate("This is a test.", translateOptions); + TranslatedTextItem translation = client.translate(input); for (TranslationText textTranslation : translation.getTranslations()) { - System.out.println("Text was translated to: '" + textTranslation.getTargetLanguage() + "' and the result is: '" + textTranslation.getText() + "'."); + System.out.println("Text was translated to: '" + textTranslation.getLanguage() + "' and the result is: '" + textTranslation.getText() + "'."); } } } diff --git a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateDetection.java b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateDetection.java index 7c295b56f5d4..79524de1a280 100644 --- a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateDetection.java +++ b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateDetection.java @@ -39,11 +39,11 @@ public static void main(final String[] args) { if (translation.getDetectedLanguage() != null) { DetectedLanguage detectedLanguage = translation.getDetectedLanguage(); - System.out.println("Detected languages of the input text: " + detectedLanguage.getLanguage() + " with score: " + detectedLanguage.getConfidence() + "."); + System.out.println("Detected languages of the input text: " + detectedLanguage.getLanguage() + " with score: " + detectedLanguage.getScore() + "."); } for (TranslationText textTranslation : translation.getTranslations()) { - System.out.println("Text was translated to: '" + textTranslation.getTargetLanguage() + "' and the result is: '" + textTranslation.getText() + "'."); + System.out.println("Text was translated to: '" + textTranslation.getLanguage() + "' and the result is: '" + textTranslation.getText() + "'."); } } } diff --git a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateDictionary.java b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateDictionary.java deleted file mode 100644 index 141e2a2c3d38..000000000000 --- a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateDictionary.java +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.ai.translation.text; - -import com.azure.ai.translation.text.models.TranslateOptions; -import com.azure.ai.translation.text.models.TranslatedTextItem; -import com.azure.ai.translation.text.models.TranslationText; -import com.azure.core.credential.AzureKeyCredential; - -/** - * If you already know the translation you want to apply to a word or a phrase, you can supply - * it as markup within the request. The dynamic dictionary is safe only for compound nouns - * like proper names and product names. - * - * > Note You must include the From parameter in your API translation request instead of using - * the autodetect feature. - */ -public class TranslateDictionary { - /** - * Main method to invoke this demo. - * - * @param args Unused arguments to the program. - */ - public static void main(final String[] args) { - String apiKey = System.getenv("TEXT_TRANSLATOR_API_KEY"); - String region = System.getenv("TEXT_TRANSLATOR_API_REGION"); - AzureKeyCredential credential = new AzureKeyCredential(apiKey); - - TextTranslationClient client = new TextTranslationClientBuilder() - .credential(credential) - .region(region) - .endpoint("https://api.cognitive.microsofttranslator.com") - .buildClient(); - - TranslateOptions translateOptions = new TranslateOptions() - .setSourceLanguage("en") - .addTargetLanguage("cs"); - - TranslatedTextItem translation = client.translate("The word < mstrans:dictionary translation =\"wordomatic\">wordomatic is a dictionary entry.", translateOptions); - - for (TranslationText textTranslation : translation.getTranslations()) { - System.out.println("Text was translated to: '" + textTranslation.getTargetLanguage() + "' and the result is: '" + textTranslation.getText() + "'."); - } - } -} diff --git a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateLlm.java b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateLlm.java new file mode 100644 index 000000000000..d6aff63bc2f3 --- /dev/null +++ b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateLlm.java @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.translation.text; + +import java.util.Arrays; + +import com.azure.ai.translation.text.models.TranslateInputItem; +import com.azure.ai.translation.text.models.TranslatedTextItem; +import com.azure.ai.translation.text.models.TranslationTarget; +import com.azure.ai.translation.text.models.TranslationText; +import com.azure.core.credential.AzureKeyCredential; + +/** + * By default, Azure Translator uses neural Machine Translation (NMT) technology. With the newest preview + * release, you now can optionally select either the standard NMT translation or Large Language Model (LLM) + * models — GPT-4o-mini or GPT-4o. You can choose a large language model for translation based on factors such + * as quality, cost, and other considerations. However, using an LLM model requires you to have a [Microsoft + * Foundry resource]. + * + * https://learn.microsoft.com/azure/ai-services/translator/how-to/create-translator-resource?tabs=foundry + * + * To use an LLM model for translation, set the `deploymentName` property in the `TranslationTarget` object to the + * name of your Foundry resource deployment, e.g., `gpt-4o-mini` or `gpt-4o`. You can also configure the tone and + * gender of the translation by setting the `tone` and `gender` properties. + * + */ +public class TranslateLlm { + /** + * Main method to invoke this demo. + * + * @param args Unused arguments to the program. + */ + public static void main(final String[] args) { + String apiKey = System.getenv("TEXT_TRANSLATOR_API_KEY"); + String region = System.getenv("TEXT_TRANSLATOR_API_REGION"); + AzureKeyCredential credential = new AzureKeyCredential(apiKey); + + TextTranslationClient client = new TextTranslationClientBuilder() + .credential(credential) + .region(region) + .endpoint("https://api.cognitive.microsofttranslator.com") + .buildClient(); + + TranslationTarget target = new TranslationTarget("es") + .setDeploymentName("gpt-4o-mini") + .setTone("formal") + .setGender("female"); + TranslateInputItem input = new TranslateInputItem( + "Doctor is available next Monday. Do you want to schedule an appointment?", + Arrays.asList(target)); + + TranslatedTextItem translation = client.translate(input); + + for (TranslationText textTranslation : translation.getTranslations()) { + System.out.println("Text was translated to: '" + textTranslation.getLanguage() + "' and the result is: '" + textTranslation.getText() + "'."); + } + } +} diff --git a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateMultipleSources.java b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateMultipleSources.java index 3a1506b2f2b3..27ba4f6fc31e 100644 --- a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateMultipleSources.java +++ b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateMultipleSources.java @@ -44,11 +44,11 @@ public static void main(final String[] args) { for (TranslatedTextItem translation : translations) { if (translation.getDetectedLanguage() != null) { DetectedLanguage detectedLanguage = translation.getDetectedLanguage(); - System.out.println("Detected languages of the input text: " + detectedLanguage.getLanguage() + " with score: " + detectedLanguage.getConfidence() + "."); + System.out.println("Detected languages of the input text: " + detectedLanguage.getLanguage() + " with score: " + detectedLanguage.getScore() + "."); } for (TranslationText textTranslation : translation.getTranslations()) { - System.out.println("Text was translated to: '" + textTranslation.getTargetLanguage() + "' and the result is: '" + textTranslation.getText() + "'."); + System.out.println("Text was translated to: '" + textTranslation.getLanguage() + "' and the result is: '" + textTranslation.getText() + "'."); } } } diff --git a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateMultipleTargets.java b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateMultipleTargets.java index 36de71b20a63..2b34a11c5f3f 100644 --- a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateMultipleTargets.java +++ b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateMultipleTargets.java @@ -3,8 +3,12 @@ package com.azure.ai.translation.text; -import com.azure.ai.translation.text.models.TranslateOptions; +import java.util.Arrays; +import java.util.List; + +import com.azure.ai.translation.text.models.TranslateInputItem; import com.azure.ai.translation.text.models.TranslatedTextItem; +import com.azure.ai.translation.text.models.TranslationTarget; import com.azure.ai.translation.text.models.TranslationText; import com.azure.core.credential.AzureKeyCredential; @@ -29,16 +33,16 @@ public static void main(final String[] args) { .endpoint("https://api.cognitive.microsofttranslator.com") .buildClient(); - TranslateOptions translateOptions = new TranslateOptions() - .setSourceLanguage("en") - .addTargetLanguage("cs") - .addTargetLanguage("es") - .addTargetLanguage("de"); + List targets = Arrays.asList( + new TranslationTarget("cs"), + new TranslationTarget("es"), + new TranslationTarget("de")); + TranslateInputItem input = new TranslateInputItem("This is a test.", targets).setLanguage("en"); - TranslatedTextItem translation = client.translate("This is a test.", translateOptions); + TranslatedTextItem translation = client.translate(input); for (TranslationText textTranslation : translation.getTranslations()) { - System.out.println("Text was translated to: '" + textTranslation.getTargetLanguage() + "' and the result is: '" + textTranslation.getText() + "'."); + System.out.println("Text was translated to: '" + textTranslation.getLanguage() + "' and the result is: '" + textTranslation.getText() + "'."); } } } diff --git a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateNoTranslate.java b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateNoTranslate.java index 1d1455a37ed4..26d1bac0b0a6 100644 --- a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateNoTranslate.java +++ b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateNoTranslate.java @@ -3,9 +3,12 @@ package com.azure.ai.translation.text; +import java.util.Arrays; + import com.azure.ai.translation.text.models.TextType; -import com.azure.ai.translation.text.models.TranslateOptions; +import com.azure.ai.translation.text.models.TranslateInputItem; import com.azure.ai.translation.text.models.TranslatedTextItem; +import com.azure.ai.translation.text.models.TranslationTarget; import com.azure.ai.translation.text.models.TranslationText; import com.azure.core.credential.AzureKeyCredential; @@ -32,15 +35,15 @@ public static void main(final String[] args) { .endpoint("https://api.cognitive.microsofttranslator.com") .buildClient(); - TranslateOptions translateOptions = new TranslateOptions() - .addTargetLanguage("en") - .setSourceLanguage("cs") - .setTextType(TextType.HTML); + TranslateInputItem input = new TranslateInputItem( + "
This will not be translated.
This will be translated.
", + Arrays.asList(new TranslationTarget("en")) + ).setLanguage("cs").setTextType(TextType.HTML); - TranslatedTextItem translation = client.translate("
This will not be translated.
This will be translated.
", translateOptions); + TranslatedTextItem translation = client.translate(input); for (TranslationText textTranslation : translation.getTranslations()) { - System.out.println("Text was translated to: '" + textTranslation.getTargetLanguage() + "' and the result is: '" + textTranslation.getText() + "'."); + System.out.println("Text was translated to: '" + textTranslation.getLanguage() + "' and the result is: '" + textTranslation.getText() + "'."); } } } diff --git a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateProfanity.java b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateProfanity.java index 58868ef5085e..03f25f7ae9a4 100644 --- a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateProfanity.java +++ b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateProfanity.java @@ -3,10 +3,13 @@ package com.azure.ai.translation.text; +import java.util.Arrays; + import com.azure.ai.translation.text.models.ProfanityAction; import com.azure.ai.translation.text.models.ProfanityMarker; -import com.azure.ai.translation.text.models.TranslateOptions; +import com.azure.ai.translation.text.models.TranslateInputItem; import com.azure.ai.translation.text.models.TranslatedTextItem; +import com.azure.ai.translation.text.models.TranslationTarget; import com.azure.ai.translation.text.models.TranslationText; import com.azure.core.credential.AzureKeyCredential; @@ -40,16 +43,16 @@ public static void main(final String[] args) { .endpoint("https://api.cognitive.microsofttranslator.com") .buildClient(); - TranslateOptions translateOptions = new TranslateOptions() - .setSourceLanguage("en") - .addTargetLanguage("cs") + TranslationTarget target = new TranslationTarget("cs") .setProfanityAction(ProfanityAction.MARKED) .setProfanityMarker(ProfanityMarker.ASTERISK); + TranslateInputItem input = new TranslateInputItem("This is ***.", Arrays.asList(target)) + .setLanguage("en"); - TranslatedTextItem translation = client.translate("This is ***.", translateOptions); + TranslatedTextItem translation = client.translate(input); for (TranslationText textTranslation : translation.getTranslations()) { - System.out.println("Text was translated to: '" + textTranslation.getTargetLanguage() + "' and the result is: '" + textTranslation.getText() + "'."); + System.out.println("Text was translated to: '" + textTranslation.getLanguage() + "' and the result is: '" + textTranslation.getText() + "'."); } } } diff --git a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateSentenceLength.java b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateSentenceLength.java deleted file mode 100644 index 76efc45c60c4..000000000000 --- a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateSentenceLength.java +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.ai.translation.text; - -import com.azure.ai.translation.text.models.TranslateOptions; -import com.azure.ai.translation.text.models.TranslatedTextItem; -import com.azure.ai.translation.text.models.TranslationText; -import com.azure.core.credential.AzureKeyCredential; - -/** - * You can ask translator service to include sentence boundaries for the input text and the translated text. - */ -public class TranslateSentenceLength { - /** - * Main method to invoke this demo. - * - * @param args Unused arguments to the program. - */ - public static void main(final String[] args) { - String apiKey = System.getenv("TEXT_TRANSLATOR_API_KEY"); - String region = System.getenv("TEXT_TRANSLATOR_API_REGION"); - AzureKeyCredential credential = new AzureKeyCredential(apiKey); - - TextTranslationClient client = new TextTranslationClientBuilder() - .credential(credential) - .region(region) - .endpoint("https://api.cognitive.microsofttranslator.com") - .buildClient(); - - TranslateOptions translateOptions = new TranslateOptions() - .setSourceLanguage("en") - .addTargetLanguage("cs") - .setIncludeSentenceLength(true); - - TranslatedTextItem translation = client.translate("The answer lies in machine translation. This is a test.", translateOptions); - - for (TranslationText textTranslation : translation.getTranslations()) { - System.out.println("Text was translated to: '" + textTranslation.getTargetLanguage() + "' and the result is: '" + textTranslation.getText() + "'."); - System.out.println("Source Sentence length: " + textTranslation.getSentenceBoundaries().getSourceSentencesLengths()); - System.out.println("Translated Sentence length: " + textTranslation.getSentenceBoundaries().getTranslatedSentencesLengths()); - } - } -} diff --git a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateTextType.java b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateTextType.java index 066090bcd37e..e567bedfa224 100644 --- a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateTextType.java +++ b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateTextType.java @@ -3,9 +3,12 @@ package com.azure.ai.translation.text; +import java.util.Arrays; + import com.azure.ai.translation.text.models.TextType; -import com.azure.ai.translation.text.models.TranslateOptions; +import com.azure.ai.translation.text.models.TranslateInputItem; import com.azure.ai.translation.text.models.TranslatedTextItem; +import com.azure.ai.translation.text.models.TranslationTarget; import com.azure.ai.translation.text.models.TranslationText; import com.azure.core.credential.AzureKeyCredential; @@ -29,16 +32,16 @@ public static void main(final String[] args) { .region(region) .endpoint("https://api.cognitive.microsofttranslator.com") .buildClient(); + + TranslateInputItem input = new TranslateInputItem( + "This is a test.", + Arrays.asList(new TranslationTarget("en")) + ).setLanguage("cs").setTextType(TextType.HTML); - TranslateOptions translateOptions = new TranslateOptions() - .addTargetLanguage("en") - .setSourceLanguage("cs") - .setTextType(TextType.HTML); - - TranslatedTextItem translation = client.translate("This is a test.", translateOptions); + TranslatedTextItem translation = client.translate(input); for (TranslationText textTranslation : translation.getTranslations()) { - System.out.println("Text was translated to: '" + textTranslation.getTargetLanguage() + "' and the result is: '" + textTranslation.getText() + "'."); + System.out.println("Text was translated to: '" + textTranslation.getLanguage() + "' and the result is: '" + textTranslation.getText() + "'."); } } } diff --git a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateWithTransliteration.java b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateWithTransliteration.java index cb30c33bf85f..171aeb00dd5e 100644 --- a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateWithTransliteration.java +++ b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateWithTransliteration.java @@ -3,8 +3,11 @@ package com.azure.ai.translation.text; -import com.azure.ai.translation.text.models.TranslateOptions; +import java.util.Arrays; + +import com.azure.ai.translation.text.models.TranslateInputItem; import com.azure.ai.translation.text.models.TranslatedTextItem; +import com.azure.ai.translation.text.models.TranslationTarget; import com.azure.ai.translation.text.models.TranslationText; import com.azure.core.credential.AzureKeyCredential; @@ -28,18 +31,14 @@ public static void main(final String[] args) { .endpoint("https://api.cognitive.microsofttranslator.com") .buildClient(); - TranslateOptions translateOptions = new TranslateOptions() - .addTargetLanguage("zh-Hans") - .setSourceLanguage("ar") - .setSourceLanguageScript("Latn") - .setTargetLanguageScript("Latn"); + TranslationTarget target = new TranslationTarget("zh-Hans").setScript("Latn"); + TranslateInputItem input = new TranslateInputItem("hudha akhtabar.", Arrays.asList(target)) + .setLanguage("ar").setScript("Latn"); - TranslatedTextItem translation = client.translate("hudha akhtabar.", translateOptions); + TranslatedTextItem translation = client.translate(input); - System.out.println("Source Text: " + translation.getSourceText().getText()); for (TranslationText textTranslation : translation.getTranslations()) { - System.out.println("Text was translated to: '" + textTranslation.getTargetLanguage() + "' and the result is: '" + textTranslation.getText() + "'."); - System.out.println("Transliterated text (" + textTranslation.getTransliteration().getScript() + "): " + textTranslation.getTransliteration().getText()); + System.out.println("Text was translated to: '" + textTranslation.getLanguage() + "' and the result is: '" + textTranslation.getText() + "'."); } } } diff --git a/sdk/translation/azure-ai-translation-text/src/test/java/com/azure/ai/translation/text/BreakSentenceTests.java b/sdk/translation/azure-ai-translation-text/src/test/java/com/azure/ai/translation/text/BreakSentenceTests.java deleted file mode 100644 index 42d8633c172f..000000000000 --- a/sdk/translation/azure-ai-translation-text/src/test/java/com/azure/ai/translation/text/BreakSentenceTests.java +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.ai.translation.text; - -import org.junit.jupiter.api.Test; -import com.azure.ai.translation.text.models.BreakSentenceItem; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import java.util.ArrayList; -import java.util.List; - -public class BreakSentenceTests extends TextTranslationClientBase { - - @Test - public void breakSentenceWithAutoDetect() { - BreakSentenceItem response = getTranslationClient().findSentenceBoundaries("hello world"); - assertEquals("en", response.getDetectedLanguage().getLanguage()); - assertTrue(response.getDetectedLanguage().getConfidence() > 0.8); - assertEquals(11, response.getSentencesLengths().get(0)); - } - - @Test - public void breakSentenceWithLanguage() { - String content - = "Mi familia es muy muy bonita. no padre .mi madre es bonita y muy bajo . mi hermano es alto. Me gusta mi familia."; - - BreakSentenceItem response = getTranslationClient().findSentenceBoundaries(content, "es", null); - int[] expectedLengths = new int[] { 30, 42, 20, 20 }; - for (int i = 0; i < expectedLengths.length; i++) { - assertEquals(expectedLengths[i], response.getSentencesLengths().get(i)); - } - } - - @Test - public void breakSentenceWithLanguageAndScript() { - BreakSentenceItem response - = getTranslationClient().findSentenceBoundaries("zhè shì gè cè shì。", "zh-Hans", "Latn"); - assertEquals(18, response.getSentencesLengths().get(0)); - } - - @Test - public void breakSentenceWithMultipleLanguages() { - ArrayList content = new ArrayList<>(); - content.add("hello world"); - content.add("العالم هو مكان مثير جدا للاهتمام"); - - List response = getTranslationClient().findSentenceBoundaries(content); - assertEquals("en", response.get(0).getDetectedLanguage().getLanguage()); - assertEquals("ar", response.get(1).getDetectedLanguage().getLanguage()); - assertEquals(11, response.get(0).getSentencesLengths().get(0)); - assertEquals(32, response.get(1).getSentencesLengths().get(0)); - } -} diff --git a/sdk/translation/azure-ai-translation-text/src/test/java/com/azure/ai/translation/text/DictionaryExamplesTest.java b/sdk/translation/azure-ai-translation-text/src/test/java/com/azure/ai/translation/text/DictionaryExamplesTest.java deleted file mode 100644 index 5f17827c6647..000000000000 --- a/sdk/translation/azure-ai-translation-text/src/test/java/com/azure/ai/translation/text/DictionaryExamplesTest.java +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.azure.ai.translation.text; - -import com.azure.ai.translation.text.models.DictionaryExampleItem; -import com.azure.ai.translation.text.models.DictionaryExampleTextItem; -import org.junit.jupiter.api.Test; - -import java.util.ArrayList; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class DictionaryExamplesTest extends TextTranslationClientBase { - @Test - public void singleInputItem() { - - ArrayList content = new ArrayList<>(); - content.add(new DictionaryExampleTextItem("fly", "volar")); - - List response = getTranslationClient().lookupDictionaryExamples("en", "es", content); - - assertEquals("fly", response.get(0).getNormalizedSource()); - assertEquals("volar", response.get(0).getNormalizedTarget()); - } - - @Test - public void multipleInputItems() { - - ArrayList content = new ArrayList<>(); - content.add(new DictionaryExampleTextItem("fly", "volar")); - content.add(new DictionaryExampleTextItem("beef", "came")); - - List response = getTranslationClient().lookupDictionaryExamples("en", "es", content); - assertEquals(2, response.size()); - } -} diff --git a/sdk/translation/azure-ai-translation-text/src/test/java/com/azure/ai/translation/text/DictionaryLookupTests.java b/sdk/translation/azure-ai-translation-text/src/test/java/com/azure/ai/translation/text/DictionaryLookupTests.java deleted file mode 100644 index bd9bbda02b3e..000000000000 --- a/sdk/translation/azure-ai-translation-text/src/test/java/com/azure/ai/translation/text/DictionaryLookupTests.java +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.azure.ai.translation.text; - -import com.azure.ai.translation.text.models.DictionaryLookupItem; -import org.junit.jupiter.api.Test; - -import java.util.ArrayList; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class DictionaryLookupTests extends TextTranslationClientBase { - @Test - public void singleInputItem() { - DictionaryLookupItem response = getTranslationClient().lookupDictionaryEntries("en", "es", "fly"); - - assertEquals("fly", response.getNormalizedSource()); - assertEquals("fly", response.getDisplaySource()); - } - - @Test - public void multipleInputItems() { - ArrayList content = new ArrayList<>(); - content.add("fly"); - content.add("fox"); - - List response = getTranslationClient().lookupDictionaryEntries("en", "es", content); - assertEquals(2, response.size()); - } -} diff --git a/sdk/translation/azure-ai-translation-text/src/test/java/com/azure/ai/translation/text/GetLanguagesTests.java b/sdk/translation/azure-ai-translation-text/src/test/java/com/azure/ai/translation/text/GetLanguagesTests.java index 2a0f3e500e2b..0f5fc8d727e3 100644 --- a/sdk/translation/azure-ai-translation-text/src/test/java/com/azure/ai/translation/text/GetLanguagesTests.java +++ b/sdk/translation/azure-ai-translation-text/src/test/java/com/azure/ai/translation/text/GetLanguagesTests.java @@ -18,7 +18,7 @@ public class GetLanguagesTests extends TextTranslationClientBase { public void getSupportedLanguagesAllScopes() { GetSupportedLanguagesResult response = getTranslationClient().getSupportedLanguages(); assertFalse(response.getTranslation().isEmpty()); - assertFalse(response.getDictionary().isEmpty()); + assertFalse(response.getModels().isEmpty()); assertFalse(response.getTransliteration().isEmpty()); } @@ -50,26 +50,14 @@ public void getSupportedLanguagesTransliterationScope() { assertNotNull(response.getTransliteration().get("be").getScripts().get(0).getDirectionality()); assertNotNull(response.getTransliteration().get("be").getScripts().get(0).getName()); assertNotNull(response.getTransliteration().get("be").getScripts().get(0).getNativeName()); - assertNotNull(response.getTransliteration().get("be").getScripts().get(0).getTargetLanguageScripts()); + assertNotNull(response.getTransliteration().get("be").getScripts().get(0).getToScripts()); + assertNotNull(response.getTransliteration().get("be").getScripts().get(0).getToScripts().get(0).getCode()); assertNotNull( - response.getTransliteration().get("be").getScripts().get(0).getTargetLanguageScripts().get(0).getCode()); - assertNotNull(response.getTransliteration() - .get("be") - .getScripts() - .get(0) - .getTargetLanguageScripts() - .get(0) - .getDirectionality()); + response.getTransliteration().get("be").getScripts().get(0).getToScripts().get(0).getDirectionality()); + assertNotNull(response.getTransliteration().get("be").getScripts().get(0).getToScripts().get(0).getName()); assertNotNull( - response.getTransliteration().get("be").getScripts().get(0).getTargetLanguageScripts().get(0).getName()); - assertNotNull(response.getTransliteration() - .get("be") - .getScripts() - .get(0) - .getTargetLanguageScripts() - .get(0) - .getNativeName()); + response.getTransliteration().get("be").getScripts().get(0).getToScripts().get(0).getNativeName()); } @Test @@ -84,43 +72,8 @@ public void getSupportedLanguagesTransliterationScopeMultipleScripts() { assertNotNull(response.getTransliteration().get("zh-Hant").getNativeName()); assertNotNull(response.getTransliteration().get("zh-Hant").getScripts()); - assertTrue( - response.getTransliteration().get("zh-Hant").getScripts().get(0).getTargetLanguageScripts().size() > 1); - assertTrue( - response.getTransliteration().get("zh-Hant").getScripts().get(1).getTargetLanguageScripts().size() > 1); - } - - @Test - public void getSupportedLanguagesDictionaryScope() { - ArrayList scopes = new ArrayList<>(); - scopes.add(LanguageScope.DICTIONARY); - GetSupportedLanguagesResult response = getTranslationClient().getSupportedLanguages(scopes, null, null); - assertFalse(response.getDictionary().isEmpty()); - assertTrue(response.getDictionary().containsKey("de")); - - assertNotNull(response.getDictionary().get("de").getName()); - assertNotNull(response.getDictionary().get("de").getNativeName()); - assertNotNull(response.getDictionary().get("de").getDirectionality()); - - assertNotNull(response.getDictionary().get("de").getTranslations().get(0).getCode()); - assertNotNull(response.getDictionary().get("de").getTranslations().get(0).getDirectionality()); - assertNotNull(response.getDictionary().get("de").getTranslations().get(0).getName()); - assertNotNull(response.getDictionary().get("de").getTranslations().get(0).getNativeName()); - } - - @Test - public void getSupportedLanguagesDictionaryScopeMultipleTranslations() { - ArrayList scopes = new ArrayList<>(); - scopes.add(LanguageScope.DICTIONARY); - GetSupportedLanguagesResult response = getTranslationClient().getSupportedLanguages(scopes, null, null); - assertFalse(response.getDictionary().isEmpty()); - assertTrue(response.getDictionary().containsKey("en")); - - assertNotNull(response.getDictionary().get("en").getName()); - assertNotNull(response.getDictionary().get("en").getNativeName()); - assertNotNull(response.getDictionary().get("en").getDirectionality()); - - assertTrue(response.getDictionary().get("en").getTranslations().size() > 1); + assertTrue(response.getTransliteration().get("zh-Hant").getScripts().get(0).getToScripts().size() > 1); + assertTrue(response.getTransliteration().get("zh-Hant").getScripts().get(1).getToScripts().size() > 1); } @Test @@ -128,7 +81,7 @@ public void getSupportedLanguagesWithCulture() { GetSupportedLanguagesResult response = getTranslationClient().getSupportedLanguages(null, "es", null); assertFalse(response.getTransliteration().isEmpty()); assertFalse(response.getTranslation().isEmpty()); - assertFalse(response.getDictionary().isEmpty()); + assertFalse(response.getModels().isEmpty()); assertNotNull(response.getTranslation().get("en").getDirectionality()); assertNotNull(response.getTranslation().get("en").getName()); diff --git a/sdk/translation/azure-ai-translation-text/src/test/java/com/azure/ai/translation/text/TranslateTests.java b/sdk/translation/azure-ai-translation-text/src/test/java/com/azure/ai/translation/text/TranslateTests.java index 51fb8587cd57..7f023d1fc7ef 100644 --- a/sdk/translation/azure-ai-translation-text/src/test/java/com/azure/ai/translation/text/TranslateTests.java +++ b/sdk/translation/azure-ai-translation-text/src/test/java/com/azure/ai/translation/text/TranslateTests.java @@ -3,17 +3,17 @@ package com.azure.ai.translation.text; -import com.azure.core.test.annotation.LiveOnly; - import com.azure.ai.translation.text.models.ProfanityAction; import com.azure.ai.translation.text.models.ProfanityMarker; import com.azure.ai.translation.text.models.TextType; +import com.azure.ai.translation.text.models.TranslateInputItem; import com.azure.ai.translation.text.models.TranslatedTextItem; -import com.azure.ai.translation.text.models.TranslateOptions; +import com.azure.ai.translation.text.models.TranslationTarget; + import org.junit.jupiter.api.Test; -import com.azure.core.test.annotation.PlaybackOnly; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -23,110 +23,69 @@ public class TranslateTests extends TextTranslationClientBase { @Test - @LiveOnly public void translateBasic() { TranslatedTextItem response = getTranslationClient().translate("cs", "Hola mundo"); assertEquals(1, response.getTranslations().size()); - assertEquals("cs", response.getTranslations().get(0).getTargetLanguage()); + assertEquals("cs", response.getTranslations().get(0).getLanguage()); assertNotNull(response.getTranslations().get(0).getText()); } @Test - @LiveOnly - public void translateOneItemWithOptions() { - TranslateOptions translateOptions = new TranslateOptions().addTargetLanguage("cs"); - - TranslatedTextItem response = getTranslationClient().translate("Hola mundo", translateOptions); - - assertEquals(1, response.getTranslations().size()); - assertEquals("cs", response.getTranslations().get(0).getTargetLanguage()); - assertNotNull(response.getTranslations().get(0).getText()); - } - - @Test - @LiveOnly - public void translateMultipleItemsWithOptions() { - ArrayList content = new ArrayList<>(); - content.add("This is a test."); - content.add("This is a test sentence two."); - content.add("This is another test."); - - TranslateOptions translateOptions = new TranslateOptions().addTargetLanguage("cs"); - - List response = getTranslationClient().translate(content, translateOptions); - - assertEquals(1, response.get(0).getTranslations().size()); - assertEquals("cs", response.get(0).getTranslations().get(0).getTargetLanguage()); - assertNotNull(response.get(0).getTranslations().get(0).getText()); - } - - @Test - @LiveOnly public void translateWithAutoDetect() { - TranslateOptions translateOptions = new TranslateOptions().addTargetLanguage("cs"); - - TranslatedTextItem response = getTranslationClient().translate("This is a test.", translateOptions); + TranslatedTextItem response = getTranslationClient().translate("cs", "This is a test."); assertEquals("en", response.getDetectedLanguage().getLanguage()); assertEquals(1, response.getTranslations().size()); - assertEquals("cs", response.getTranslations().get(0).getTargetLanguage()); + assertEquals("cs", response.getTranslations().get(0).getLanguage()); assertNotNull(response.getTranslations().get(0).getText()); } @Test - @LiveOnly public void translateWithNoTranslateTag() { - TranslateOptions translateOptions - = new TranslateOptions().addTargetLanguage("en").setSourceLanguage("zh-Hans").setTextType(TextType.HTML); - - TranslatedTextItem response - = getTranslationClient().translate("今天是怎么回事是非常可怕的", translateOptions); + TranslateInputItem input = new TranslateInputItem("今天是怎么回事是非常可怕的", + Arrays.asList(new TranslationTarget("en"))); + input.setLanguage("zh-Hans"); + input.setTextType(TextType.HTML); + TranslatedTextItem response = getTranslationClient().translate(input); assertEquals(1, response.getTranslations().size()); assertTrue(response.getTranslations().get(0).getText().contains("今天是怎么回事是")); } @Test - @LiveOnly public void translateWithDictionaryTag() { - TranslateOptions translateOptions = new TranslateOptions().setSourceLanguage("en").addTargetLanguage("es"); - - TranslatedTextItem response = getTranslationClient().translate( + TranslateInputItem input = new TranslateInputItem( "The word < mstrans:dictionary translation =\"wordomatic\">wordomatic is a dictionary entry.", - translateOptions); + Arrays.asList(new TranslationTarget("es"))); + input.setLanguage("en"); + input.setTextType(TextType.HTML); + TranslatedTextItem response = getTranslationClient().translate(input); assertEquals(1, response.getTranslations().size()); - assertEquals("es", response.getTranslations().get(0).getTargetLanguage()); + assertEquals("es", response.getTranslations().get(0).getLanguage()); assertTrue(response.getTranslations().get(0).getText().contains("wordomatic")); } @Test - @LiveOnly public void translateWithTransliteration() { - TranslateOptions translateOptions = new TranslateOptions().addTargetLanguage("zh-Hans") - .setSourceLanguage("ar") - .setSourceLanguageScript("Latn") - .setTargetLanguageScript("Latn"); - - TranslatedTextItem response = getTranslationClient().translate("hudha akhtabar.", translateOptions); + TranslateInputItem input = new TranslateInputItem("hudha akhtabar.", + Arrays.asList(new TranslationTarget("zh-Hans").setScript("Latn"))).setLanguage("ar").setScript("Latn"); + TranslatedTextItem response = getTranslationClient().translate(input); - assertNotNull(response.getSourceText().getText()); - assertEquals("zh-Hans", response.getTranslations().get(0).getTargetLanguage()); + assertEquals("zh-Hans", response.getTranslations().get(0).getLanguage()); assertNotNull(response.getTranslations().get(0).getText()); } @Test public void translateFromLatinToLatinScript() { - TranslateOptions translateOptions = new TranslateOptions().addTargetLanguage("ta") - .setSourceLanguage("hi") - .setSourceLanguageScript("Latn") - .setTargetLanguageScript("Latn"); - - TranslatedTextItem response = getTranslationClient().translate("ap kaise ho", translateOptions); + TranslateInputItem input + = new TranslateInputItem("ap kaise ho", Arrays.asList(new TranslationTarget("ta").setScript("Latn"))) + .setLanguage("hi") + .setScript("Latn"); + TranslatedTextItem response = getTranslationClient().translate(input); - assertNotNull(response.getTranslations().get(0).getTransliteration().getScript()); - assertEquals("eppadi irukkiraai?", response.getTranslations().get(0).getTransliteration().getText()); + assertEquals("eppadi irukkiraai?", response.getTranslations().get(0).getText()); } @Test @@ -136,18 +95,16 @@ public void translateWithMultipleInputTexts() { content.add("Esto es una prueba."); content.add("Dies ist ein Test."); - TranslateOptions translateOptions = new TranslateOptions().addTargetLanguage("cs"); - - List response = getTranslationClient().translate(content, translateOptions); + List response = getTranslationClient().translate("cs", content); assertEquals(3, response.size()); assertEquals("en", response.get(0).getDetectedLanguage().getLanguage()); assertEquals("es", response.get(1).getDetectedLanguage().getLanguage()); assertEquals("de", response.get(2).getDetectedLanguage().getLanguage()); - assertEquals(1, response.get(0).getDetectedLanguage().getConfidence()); - assertEquals(1, response.get(1).getDetectedLanguage().getConfidence()); - assertEquals(1, response.get(2).getDetectedLanguage().getConfidence()); + assertEquals(1, response.get(0).getDetectedLanguage().getScore()); + assertEquals(1, response.get(1).getDetectedLanguage().getScore()); + assertEquals(1, response.get(2).getDetectedLanguage().getScore()); assertNotNull(response.get(0).getTranslations().get(0).getText()); assertNotNull(response.get(1).getTranslations().get(0).getText()); @@ -156,111 +113,74 @@ public void translateWithMultipleInputTexts() { @Test public void translateMultipleTargetLanguages() { - TranslateOptions translateOptions - = new TranslateOptions().addTargetLanguage("cs").addTargetLanguage("es").addTargetLanguage("de"); + TranslateInputItem input = new TranslateInputItem("This is a test.", + Arrays.asList(new TranslationTarget("cs"), new TranslationTarget("es"), new TranslationTarget("de"))); - TranslatedTextItem response = getTranslationClient().translate("This is a test.", translateOptions); + TranslatedTextItem response = getTranslationClient().translate(input); assertEquals(3, response.getTranslations().size()); assertEquals("en", response.getDetectedLanguage().getLanguage()); - assertEquals(1, response.getDetectedLanguage().getConfidence()); + assertEquals(1, response.getDetectedLanguage().getScore()); assertNotNull(response.getTranslations().get(0).getText()); assertNotNull(response.getTranslations().get(1).getText()); assertNotNull(response.getTranslations().get(2).getText()); } @Test - public void translateDifferentTextTypes() { - TranslateOptions translateOptions = new TranslateOptions().addTargetLanguage("cs").setTextType(TextType.HTML); - - TranslatedTextItem response - = getTranslationClient().translate("This is a test.", translateOptions); + public void translateWithLlm() { + TranslationTarget target = new TranslationTarget("cs").setDeploymentName("gpt-4o-mini"); + TranslateInputItem input = new TranslateInputItem("This is a test", Arrays.asList(target)); + TranslatedTextItem response = getTranslationClient().translate(input); assertEquals(1, response.getTranslations().size()); assertEquals("en", response.getDetectedLanguage().getLanguage()); - assertEquals(1, response.getDetectedLanguage().getConfidence()); - } - - @Test - public void translateWithProfanity() { - TranslateOptions translateOptions = new TranslateOptions().addTargetLanguage("zh-Hans") - .setProfanityAction(ProfanityAction.MARKED) - .setProfanityMarker(ProfanityMarker.ASTERISK); - - TranslatedTextItem response - = getTranslationClient().translate("shit this is fucking crazy shit fuck", translateOptions); - - assertEquals(1, response.getTranslations().size()); - assertEquals("en", response.getDetectedLanguage().getLanguage()); - assertEquals(1, response.getDetectedLanguage().getConfidence()); - assertTrue(response.getTranslations().get(0).getText().contains("***")); + assertNotNull(response.getTranslations().get(0).getText()); } @Test - public void translateWithAlignment() { - TranslateOptions translateOptions = new TranslateOptions().addTargetLanguage("cs").setIncludeAlignment(true); - - TranslatedTextItem response = getTranslationClient().translate("It is a beautiful morning", translateOptions); + public void translateDifferentTextTypes() { + TranslateInputItem input = new TranslateInputItem("This is a test.", + Arrays.asList(new TranslationTarget("cs"))).setTextType(TextType.HTML); + TranslatedTextItem response = getTranslationClient().translate(input); assertEquals(1, response.getTranslations().size()); assertEquals("en", response.getDetectedLanguage().getLanguage()); - assertEquals(1, response.getDetectedLanguage().getConfidence()); - assertNotNull(response.getTranslations().get(0).getAlignment().getProjections()); + assertEquals(1, response.getDetectedLanguage().getScore()); } @Test - public void translateWithIncludeSentenceLength() { - TranslateOptions translateOptions - = new TranslateOptions().addTargetLanguage("fr").setIncludeSentenceLength(true); + public void translateWithProfanity() { + TranslationTarget target = new TranslationTarget("zh-Hans").setProfanityAction(ProfanityAction.MARKED) + .setProfanityMarker(ProfanityMarker.ASTERISK); + TranslateInputItem input + = new TranslateInputItem("shit this is fucking crazy shit fuck", Arrays.asList(target)); - TranslatedTextItem response = getTranslationClient().translate( - "La réponse se trouve dans la traduction automatique. La meilleure technologie de traduction automatique ne peut pas toujours fournir des traductions adaptées à un site ou des utilisateurs comme un être humain. Il suffit de copier et coller un extrait de code n'importe où.", - translateOptions); + TranslatedTextItem response = getTranslationClient().translate(input); - assertEquals("fr", response.getDetectedLanguage().getLanguage()); - assertEquals(1, response.getDetectedLanguage().getConfidence()); assertEquals(1, response.getTranslations().size()); - assertEquals(3, response.getTranslations().get(0).getSentenceBoundaries().getSourceSentencesLengths().size()); - assertEquals(3, - response.getTranslations().get(0).getSentenceBoundaries().getTranslatedSentencesLengths().size()); - } - - @Test - public void translateWithCustomEndpoint() { - TranslateOptions translateOptions = new TranslateOptions().addTargetLanguage("cs"); - - TranslatedTextItem response - = getTranslationClientWithCustomEndpoint().translate("It is a beautiful morning", translateOptions); - assertEquals("en", response.getDetectedLanguage().getLanguage()); - assertEquals(1, response.getDetectedLanguage().getConfidence()); - assertEquals(1, response.getTranslations().size()); - assertNotNull(response.getTranslations().get(0).getText()); + assertTrue(response.getDetectedLanguage().getScore() > 0.5); + assertTrue(response.getTranslations().get(0).getText().contains("***")); } @Test public void translateWithToken() throws Exception { - TranslateOptions translateOptions = new TranslateOptions().addTargetLanguage("cs"); - - TranslatedTextItem response = getTranslationClientWithToken().translate("This is a test.", translateOptions); + TranslatedTextItem response = getTranslationClientWithToken().translate("cs", "This is a test."); assertNotNull(response.getTranslations().get(0).getText()); assertEquals("en", response.getDetectedLanguage().getLanguage()); - assertEquals(1, response.getDetectedLanguage().getConfidence()); + assertEquals(1, response.getDetectedLanguage().getScore()); assertEquals(1, response.getTranslations().size()); assertNotNull(response.getTranslations().get(0).getText()); } @Test - @PlaybackOnly public void translateWithAad() throws Exception { - TranslateOptions translateOptions = new TranslateOptions().addTargetLanguage("cs"); - - TranslatedTextItem response = getTranslationClientWithAadAuth().translate("This is a test.", translateOptions); + TranslatedTextItem response = getTranslationClientWithAadAuth().translate("cs", "This is a test."); assertNotNull(response.getTranslations().get(0).getText()); assertEquals("en", response.getDetectedLanguage().getLanguage()); - assertEquals(1, response.getDetectedLanguage().getConfidence()); + assertEquals(1, response.getDetectedLanguage().getScore()); assertEquals(1, response.getTranslations().size()); assertNotNull(response.getTranslations().get(0).getText()); } diff --git a/sdk/translation/azure-ai-translation-text/tsp-location.yaml b/sdk/translation/azure-ai-translation-text/tsp-location.yaml index ce9ae8318b49..06ec6bdb5561 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/data-plane/TextTranslation -commit: 6267b64842af3d744c5b092a3f3beef49729ad6d +commit: 2e8781ac5a8a916ee824bbc9e3c0adaf750ef444 repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/translation/test-resources.json b/sdk/translation/test-resources.json index 09527df9c73a..c9896504ddac 100644 --- a/sdk/translation/test-resources.json +++ b/sdk/translation/test-resources.json @@ -82,7 +82,7 @@ }, "kind": "TextTranslation", "identity": { - "type": "SystemAssigned" + "type": "SystemAssigned" }, "properties": { "customSubDomainName": "[variables('uniqueSubDomainName')]" @@ -99,7 +99,7 @@ }, { "type": "Microsoft.Storage/storageAccounts", - "apiVersion": "2022-05-01", + "apiVersion": "2019-04-01", "name": "[variables('storageAccountName')]", "location": "[parameters('location')]", "sku": { @@ -112,8 +112,7 @@ "supportsHttpsTrafficOnly": true, "allowSharedKeyAccess": false, "encryption": "[variables('encryption')]", - "accessTier": "Hot", - "minimumTlsVersion": "TLS1_2" + "accessTier": "Hot" } }, { @@ -133,50 +132,97 @@ }, { "type": "Microsoft.CognitiveServices/accounts", - "apiVersion": "2017-04-18", + "apiVersion": "2023-05-01", "name": "[variables('txtUniqueSubDomainName')]", "location": "[parameters('location')]", "sku": { - "name": "S1" + "name": "S0" + }, + "kind": "AIServices", + "identity": { + "type": "SystemAssigned" }, - "kind": "TextTranslation", "properties": { - "customSubDomainName": "[variables('txtUniqueSubDomainName')]" - } + "customSubDomainName": "[variables('txtUniqueSubDomainName')]", + "publicNetworkAccess": "Enabled" + }, + "resources": [ + { + "type": "deployments", + "apiVersion": "2023-05-01", + "name": "gpt-4o-mini", + "dependsOn": [ + "[resourceId('Microsoft.CognitiveServices/accounts', variables('txtUniqueSubDomainName'))]" + ], + "sku": { + "name": "Standard", + "capacity": 10 + }, + "properties": { + "model": { + "format": "OpenAI", + "name": "gpt-4o-mini", + "version": "2024-07-18" + }, + "versionUpgradeOption": "OnceNewDefaultVersionAvailable" + } + } + ] + }, + { + "type": "Microsoft.Authorization/roleAssignments", + "apiVersion": "2018-09-01-preview", + "name": "[guid(concat('foundryUserRoleId', resourceGroup().id))]", + "properties": { + "roleDefinitionId": "[variables('roleDefinitionId')]", + "principalId": "[reference(resourceId('Microsoft.CognitiveServices/accounts', variables('txtUniqueSubDomainName')), '2023-05-01', 'full').identity.principalId]", + "principalType": "ServicePrincipal" + }, + "dependsOn": [ + "[resourceId('Microsoft.CognitiveServices/accounts', variables('txtUniqueSubDomainName'))]" + ] } ], "outputs": { - "DOCUMENT_TRANSLATION_API_KEY": { + "TEXT_TRANSLATION_ENDPOINT": { "type": "string", - "value": "[listKeys(resourceId('Microsoft.CognitiveServices/accounts', variables('uniqueSubDomainName')), '2017-04-18').key1]" + "value": "[variables('txtEndpointValue')]" }, - "DOCUMENT_TRANSLATION_ENDPOINT": { + "TEXT_TRANSLATION_API_KEY": { "type": "string", - "value": "[variables('endpointValue')]" + "value": "[listKeys(resourceId('Microsoft.CognitiveServices/accounts', variables('txtUniqueSubDomainName')), '2023-05-01').key1]" }, - "DOCUMENT_TRANSLATION_STORAGE_NAME": { + "TEXT_TRANSLATION_CUSTOM_ENDPOINT": { "type": "string", - "value": "[variables('storageAccountName')]" + "value": "[variables('txtCustomEndpointValue')]" }, - "TEXT_TRANSLATION_API_KEY": { + "TEXT_TRANSLATION_REGION": { "type": "string", - "value": "[listKeys(resourceId('Microsoft.CognitiveServices/accounts', variables('txtUniqueSubDomainName')), '2017-04-18').key1]" + "value": "[variables('txtRegionValue')]" }, - "TEXT_TRANSLATION_ENDPOINT": { + "DOCUMENT_TRANSLATION_ENDPOINT": { "type": "string", - "value": "[variables('txtEndpointValue')]" + "value": "[variables('endpointValue')]" }, - "TEXT_TRANSLATION_CUSTOM_ENDPOINT": { + "DOCUMENT_TRANSLATION_API_KEY": { "type": "string", - "value": "[variables('txtCustomEndpointValue')]" + "value": "[listKeys(resourceId('Microsoft.CognitiveServices/accounts', variables('uniqueSubDomainName')), '2017-04-18').key1]" }, - "TEXT_TRANSLATION_REGION": { + "DOCUMENT_TRANSLATION_STORAGE_NAME": { "type": "string", - "value": "[variables('txtRegionValue')]" + "value": "[variables('storageAccountName')]" }, "TEXT_TRANSLATION_TOKEN_URL": { "type": "string", "value": "[variables('tokenURLValue')]" + }, + "TEXT_TRANSLATION_AAD_REGION": { + "type": "string", + "value": "[variables('txtRegionValue')]" + }, + "TEXT_TRANSLATION_AAD_RESOURCE_ID": { + "type": "string", + "value": "[resourceId('Microsoft.CognitiveServices/accounts', variables('txtUniqueSubDomainName'))]" } } }