diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/TranslatorTextClient.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/TranslatorTextClient.java new file mode 100644 index 0000000000000..852b9a5cc2af7 --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/TranslatorTextClient.java @@ -0,0 +1,111 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext; + +import com.microsoft.azure.AzureClient; +import com.microsoft.rest.RestClient; + +/** + * The interface for TranslatorTextClient class. + */ +public interface TranslatorTextClient { + /** + * Gets the REST client. + * + * @return the {@link RestClient} object. + */ + RestClient restClient(); + + /** + * Gets the {@link AzureClient} used for long running operations. + * @return the azure client; + */ + AzureClient getAzureClient(); + + /** + * Gets the User-Agent header for the client. + * + * @return the user agent string. + */ + String userAgent(); + + /** + * Gets Supported Cognitive Services endpoints. + * + * @return the endpoint value. + */ + String endpoint(); + + /** + * Sets Supported Cognitive Services endpoints. + * + * @param endpoint the endpoint value. + * @return the service client itself + */ + TranslatorTextClient withEndpoint(String endpoint); + + /** + * Gets Version of the API requested by the client. Value must be **3.0**.. + * + * @return the apiVersion value. + */ + String apiVersion(); + + /** + * Gets The preferred language for the response.. + * + * @return the acceptLanguage value. + */ + String acceptLanguage(); + + /** + * Sets The preferred language for the response.. + * + * @param acceptLanguage the acceptLanguage value. + * @return the service client itself + */ + TranslatorTextClient withAcceptLanguage(String acceptLanguage); + + /** + * Gets The retry timeout in seconds for Long Running Operations. Default value is 30.. + * + * @return the longRunningOperationRetryTimeout value. + */ + int longRunningOperationRetryTimeout(); + + /** + * Sets The retry timeout in seconds for Long Running Operations. Default value is 30.. + * + * @param longRunningOperationRetryTimeout the longRunningOperationRetryTimeout value. + * @return the service client itself + */ + TranslatorTextClient withLongRunningOperationRetryTimeout(int longRunningOperationRetryTimeout); + + /** + * Gets Whether a unique x-ms-client-request-id should be generated. When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true.. + * + * @return the generateClientRequestId value. + */ + boolean generateClientRequestId(); + + /** + * Sets Whether a unique x-ms-client-request-id should be generated. When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true.. + * + * @param generateClientRequestId the generateClientRequestId value. + * @return the service client itself + */ + TranslatorTextClient withGenerateClientRequestId(boolean generateClientRequestId); + + /** + * Gets the Translators object to access its operations. + * @return the Translators object. + */ + Translators translators(); + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/Translators.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/Translators.java new file mode 100644 index 0000000000000..367694de0a436 --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/Translators.java @@ -0,0 +1,2632 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext; + +import com.microsoft.azure.cognitiveservices.translatortext.models.BreakSentenceResultItem; +import com.microsoft.azure.cognitiveservices.translatortext.models.BreakSentenceTextInput; +import com.microsoft.azure.cognitiveservices.translatortext.models.DetectResultItem; +import com.microsoft.azure.cognitiveservices.translatortext.models.DetectTextInput; +import com.microsoft.azure.cognitiveservices.translatortext.models.DictionaryExampleResultItem; +import com.microsoft.azure.cognitiveservices.translatortext.models.DictionaryExampleTextInput; +import com.microsoft.azure.cognitiveservices.translatortext.models.DictionaryLookupResultItem; +import com.microsoft.azure.cognitiveservices.translatortext.models.DictionaryLookupTextInput; +import com.microsoft.azure.cognitiveservices.translatortext.models.ErrorMessageException; +import com.microsoft.azure.cognitiveservices.translatortext.models.LanguagesResult; +import com.microsoft.azure.cognitiveservices.translatortext.models.TranslateResultAllItem; +import com.microsoft.azure.cognitiveservices.translatortext.models.TranslateTextInput; +import com.microsoft.azure.cognitiveservices.translatortext.models.TransliterateResultItem; +import com.microsoft.azure.cognitiveservices.translatortext.models.TransliterateTextInput; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; +import java.util.List; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in Translators. + */ +public interface Translators { + /** + * Identifies the position of sentence boundaries in a piece of text. + * + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named Text. Sentence boundaries are computed for the value of the Text property. + The following limitations apply: + * The array can have at most 100 elements. + * The text value of an array element cannot exceed 10,000 characters including spaces. + * The entire text included in the request cannot exceed 50,000 characters including spaces. + * If the `language` query parameter is specified, then all array elements must be in the same language. Otherwise, language auto-detection is applied to each array element independently. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `sentLen`- An array of integers representing the lengths of the sentences in the text element. The length of the array is the number of sentences, and the values are the length of each sentence. + * `detectedLanguage`- An object describing the detected language through the following properties + * `language`- Code of the detected 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. + * Note that the `detectedLanguage` property is only present in the result object when language auto-detection is requested. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorMessageException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<BreakSentenceResultItem> object if successful. + */ + List breakSentence(List text); + + /** + * Identifies the position of sentence boundaries in a piece of text. + * + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named Text. Sentence boundaries are computed for the value of the Text property. + The following limitations apply: + * The array can have at most 100 elements. + * The text value of an array element cannot exceed 10,000 characters including spaces. + * The entire text included in the request cannot exceed 50,000 characters including spaces. + * If the `language` query parameter is specified, then all array elements must be in the same language. Otherwise, language auto-detection is applied to each array element independently. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `sentLen`- An array of integers representing the lengths of the sentences in the text element. The length of the array is the number of sentences, and the values are the length of each sentence. + * `detectedLanguage`- An object describing the detected language through the following properties + * `language`- Code of the detected 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. + * Note that the `detectedLanguage` property is only present in the result object when language auto-detection is requested. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> breakSentenceAsync(List text, final ServiceCallback> serviceCallback); + + /** + * Identifies the position of sentence boundaries in a piece of text. + * + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named Text. Sentence boundaries are computed for the value of the Text property. + The following limitations apply: + * The array can have at most 100 elements. + * The text value of an array element cannot exceed 10,000 characters including spaces. + * The entire text included in the request cannot exceed 50,000 characters including spaces. + * If the `language` query parameter is specified, then all array elements must be in the same language. Otherwise, language auto-detection is applied to each array element independently. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `sentLen`- An array of integers representing the lengths of the sentences in the text element. The length of the array is the number of sentences, and the values are the length of each sentence. + * `detectedLanguage`- An object describing the detected language through the following properties + * `language`- Code of the detected 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. + * Note that the `detectedLanguage` property is only present in the result object when language auto-detection is requested. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<BreakSentenceResultItem> object + */ + Observable> breakSentenceAsync(List text); + + /** + * Identifies the position of sentence boundaries in a piece of text. + * + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named Text. Sentence boundaries are computed for the value of the Text property. + The following limitations apply: + * The array can have at most 100 elements. + * The text value of an array element cannot exceed 10,000 characters including spaces. + * The entire text included in the request cannot exceed 50,000 characters including spaces. + * If the `language` query parameter is specified, then all array elements must be in the same language. Otherwise, language auto-detection is applied to each array element independently. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `sentLen`- An array of integers representing the lengths of the sentences in the text element. The length of the array is the number of sentences, and the values are the length of each sentence. + * `detectedLanguage`- An object describing the detected language through the following properties + * `language`- Code of the detected 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. + * Note that the `detectedLanguage` property is only present in the result object when language auto-detection is requested. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<BreakSentenceResultItem> object + */ + Observable>> breakSentenceWithServiceResponseAsync(List text); + /** + * Identifies the position of sentence boundaries in a piece of text. + * + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named Text. Sentence boundaries are computed for the value of the Text property. + The following limitations apply: + * The array can have at most 100 elements. + * The text value of an array element cannot exceed 10,000 characters including spaces. + * The entire text included in the request cannot exceed 50,000 characters including spaces. + * If the `language` query parameter is specified, then all array elements must be in the same language. Otherwise, language auto-detection is applied to each array element independently. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `sentLen`- An array of integers representing the lengths of the sentences in the text element. The length of the array is the number of sentences, and the values are the length of each sentence. + * `detectedLanguage`- An object describing the detected language through the following properties + * `language`- Code of the detected 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. + * Note that the `detectedLanguage` property is only present in the result object when language auto-detection is requested. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @param language Language tag of the language of the input text. If not specified, Translator will apply automatic language detection. + * @param script Script identifier of the script used by the input text. If a script is not specified, the default script of the language will be assumed. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorMessageException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<BreakSentenceResultItem> object if successful. + */ + List breakSentence(List text, String language, String script, String xClientTraceId); + + /** + * Identifies the position of sentence boundaries in a piece of text. + * + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named Text. Sentence boundaries are computed for the value of the Text property. + The following limitations apply: + * The array can have at most 100 elements. + * The text value of an array element cannot exceed 10,000 characters including spaces. + * The entire text included in the request cannot exceed 50,000 characters including spaces. + * If the `language` query parameter is specified, then all array elements must be in the same language. Otherwise, language auto-detection is applied to each array element independently. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `sentLen`- An array of integers representing the lengths of the sentences in the text element. The length of the array is the number of sentences, and the values are the length of each sentence. + * `detectedLanguage`- An object describing the detected language through the following properties + * `language`- Code of the detected 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. + * Note that the `detectedLanguage` property is only present in the result object when language auto-detection is requested. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @param language Language tag of the language of the input text. If not specified, Translator will apply automatic language detection. + * @param script Script identifier of the script used by the input text. If a script is not specified, the default script of the language will be assumed. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> breakSentenceAsync(List text, String language, String script, String xClientTraceId, final ServiceCallback> serviceCallback); + + /** + * Identifies the position of sentence boundaries in a piece of text. + * + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named Text. Sentence boundaries are computed for the value of the Text property. + The following limitations apply: + * The array can have at most 100 elements. + * The text value of an array element cannot exceed 10,000 characters including spaces. + * The entire text included in the request cannot exceed 50,000 characters including spaces. + * If the `language` query parameter is specified, then all array elements must be in the same language. Otherwise, language auto-detection is applied to each array element independently. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `sentLen`- An array of integers representing the lengths of the sentences in the text element. The length of the array is the number of sentences, and the values are the length of each sentence. + * `detectedLanguage`- An object describing the detected language through the following properties + * `language`- Code of the detected 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. + * Note that the `detectedLanguage` property is only present in the result object when language auto-detection is requested. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @param language Language tag of the language of the input text. If not specified, Translator will apply automatic language detection. + * @param script Script identifier of the script used by the input text. If a script is not specified, the default script of the language will be assumed. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<BreakSentenceResultItem> object + */ + Observable> breakSentenceAsync(List text, String language, String script, String xClientTraceId); + + /** + * Identifies the position of sentence boundaries in a piece of text. + * + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named Text. Sentence boundaries are computed for the value of the Text property. + The following limitations apply: + * The array can have at most 100 elements. + * The text value of an array element cannot exceed 10,000 characters including spaces. + * The entire text included in the request cannot exceed 50,000 characters including spaces. + * If the `language` query parameter is specified, then all array elements must be in the same language. Otherwise, language auto-detection is applied to each array element independently. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `sentLen`- An array of integers representing the lengths of the sentences in the text element. The length of the array is the number of sentences, and the values are the length of each sentence. + * `detectedLanguage`- An object describing the detected language through the following properties + * `language`- Code of the detected 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. + * Note that the `detectedLanguage` property is only present in the result object when language auto-detection is requested. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @param language Language tag of the language of the input text. If not specified, Translator will apply automatic language detection. + * @param script Script identifier of the script used by the input text. If a script is not specified, the default script of the language will be assumed. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<BreakSentenceResultItem> object + */ + Observable>> breakSentenceWithServiceResponseAsync(List text, String language, String script, String xClientTraceId); + + /** + * Identifies the language of a string of text. + * + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named Text. Language detection is applied to the value of the Text property. + The following limitations apply: + * The array can have at most 100 elements. + * The text value of an array element cannot exceed 10,000 characters including spaces. + * The entire text included in the request cannot exceed 50,000 characters including spaces. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * language- Code of the detected 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. + * isTranslationSupported- A boolean value which is true if the detected language is one of the languages supported for text translation. Not all detected languages can be translated by the API. + * isTransliterationSupported- A boolean value which is true if the detected language is one of the languages supported for transliteration. + * alternatives- An array of other possible languages. Each element of the array is another object with the same properties listed above- language, score, isTranslationSupported and isTransliterationSupported. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorMessageException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<DetectResultItem> object if successful. + */ + List detect(List text); + + /** + * Identifies the language of a string of text. + * + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named Text. Language detection is applied to the value of the Text property. + The following limitations apply: + * The array can have at most 100 elements. + * The text value of an array element cannot exceed 10,000 characters including spaces. + * The entire text included in the request cannot exceed 50,000 characters including spaces. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * language- Code of the detected 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. + * isTranslationSupported- A boolean value which is true if the detected language is one of the languages supported for text translation. Not all detected languages can be translated by the API. + * isTransliterationSupported- A boolean value which is true if the detected language is one of the languages supported for transliteration. + * alternatives- An array of other possible languages. Each element of the array is another object with the same properties listed above- language, score, isTranslationSupported and isTransliterationSupported. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> detectAsync(List text, final ServiceCallback> serviceCallback); + + /** + * Identifies the language of a string of text. + * + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named Text. Language detection is applied to the value of the Text property. + The following limitations apply: + * The array can have at most 100 elements. + * The text value of an array element cannot exceed 10,000 characters including spaces. + * The entire text included in the request cannot exceed 50,000 characters including spaces. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * language- Code of the detected 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. + * isTranslationSupported- A boolean value which is true if the detected language is one of the languages supported for text translation. Not all detected languages can be translated by the API. + * isTransliterationSupported- A boolean value which is true if the detected language is one of the languages supported for transliteration. + * alternatives- An array of other possible languages. Each element of the array is another object with the same properties listed above- language, score, isTranslationSupported and isTransliterationSupported. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DetectResultItem> object + */ + Observable> detectAsync(List text); + + /** + * Identifies the language of a string of text. + * + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named Text. Language detection is applied to the value of the Text property. + The following limitations apply: + * The array can have at most 100 elements. + * The text value of an array element cannot exceed 10,000 characters including spaces. + * The entire text included in the request cannot exceed 50,000 characters including spaces. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * language- Code of the detected 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. + * isTranslationSupported- A boolean value which is true if the detected language is one of the languages supported for text translation. Not all detected languages can be translated by the API. + * isTransliterationSupported- A boolean value which is true if the detected language is one of the languages supported for transliteration. + * alternatives- An array of other possible languages. Each element of the array is another object with the same properties listed above- language, score, isTranslationSupported and isTransliterationSupported. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DetectResultItem> object + */ + Observable>> detectWithServiceResponseAsync(List text); + /** + * Identifies the language of a string of text. + * + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named Text. Language detection is applied to the value of the Text property. + The following limitations apply: + * The array can have at most 100 elements. + * The text value of an array element cannot exceed 10,000 characters including spaces. + * The entire text included in the request cannot exceed 50,000 characters including spaces. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * language- Code of the detected 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. + * isTranslationSupported- A boolean value which is true if the detected language is one of the languages supported for text translation. Not all detected languages can be translated by the API. + * isTransliterationSupported- A boolean value which is true if the detected language is one of the languages supported for transliteration. + * alternatives- An array of other possible languages. Each element of the array is another object with the same properties listed above- language, score, isTranslationSupported and isTransliterationSupported. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorMessageException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<DetectResultItem> object if successful. + */ + List detect(List text, String xClientTraceId); + + /** + * Identifies the language of a string of text. + * + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named Text. Language detection is applied to the value of the Text property. + The following limitations apply: + * The array can have at most 100 elements. + * The text value of an array element cannot exceed 10,000 characters including spaces. + * The entire text included in the request cannot exceed 50,000 characters including spaces. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * language- Code of the detected 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. + * isTranslationSupported- A boolean value which is true if the detected language is one of the languages supported for text translation. Not all detected languages can be translated by the API. + * isTransliterationSupported- A boolean value which is true if the detected language is one of the languages supported for transliteration. + * alternatives- An array of other possible languages. Each element of the array is another object with the same properties listed above- language, score, isTranslationSupported and isTransliterationSupported. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> detectAsync(List text, String xClientTraceId, final ServiceCallback> serviceCallback); + + /** + * Identifies the language of a string of text. + * + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named Text. Language detection is applied to the value of the Text property. + The following limitations apply: + * The array can have at most 100 elements. + * The text value of an array element cannot exceed 10,000 characters including spaces. + * The entire text included in the request cannot exceed 50,000 characters including spaces. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * language- Code of the detected 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. + * isTranslationSupported- A boolean value which is true if the detected language is one of the languages supported for text translation. Not all detected languages can be translated by the API. + * isTransliterationSupported- A boolean value which is true if the detected language is one of the languages supported for transliteration. + * alternatives- An array of other possible languages. Each element of the array is another object with the same properties listed above- language, score, isTranslationSupported and isTransliterationSupported. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DetectResultItem> object + */ + Observable> detectAsync(List text, String xClientTraceId); + + /** + * Identifies the language of a string of text. + * + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named Text. Language detection is applied to the value of the Text property. + The following limitations apply: + * The array can have at most 100 elements. + * The text value of an array element cannot exceed 10,000 characters including spaces. + * The entire text included in the request cannot exceed 50,000 characters including spaces. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * language- Code of the detected 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. + * isTranslationSupported- A boolean value which is true if the detected language is one of the languages supported for text translation. Not all detected languages can be translated by the API. + * isTransliterationSupported- A boolean value which is true if the detected language is one of the languages supported for transliteration. + * alternatives- An array of other possible languages. Each element of the array is another object with the same properties listed above- language, score, isTranslationSupported and isTransliterationSupported. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DetectResultItem> object + */ + Observable>> detectWithServiceResponseAsync(List text, String xClientTraceId); + + /** + * Provides alternative translations for a word and a small number of idiomatic phrases. Each translation has a `part-of-speech` and a list of `back-translations`. The back-translations enable a user to understand the translation in context. The Dictionary Example operation allows further drill down to see example uses of each translation pair. + * + * @param from Specifies the language of the input text. The source language must be one of the supported languages included in the `dictionary` scope. + * @param to Specifies the language of the output text. The target language must be one of the supported languages included in the `dictionary` scope of the Languages resource. + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the term to lookup. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 100 characters including spaces. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `normalizedSource`- 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. + * `displaySource`- 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". + * `translations`- A list of translations for the source term. Each element of the list is an object with the following properties: + * `normalizedTarget`- A string giving the normalized form of this term in the target language. This value should be used as input to lookup examples. + * `displayTarget`- 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"`. + * `posTag`- A string associating this term with a part-of-speech tag. + | Tag name | Description | + | --------- | ---------------- | + | ADJ | Adjectives | + | ADV | Adverbs | + | CONJ | Conjunctions | + | DET | Determiners | + | MODAL | Verbs | + | NOUN | Nouns | + | PREP | Prepositions | + | PRON | Pronouns | + | VERB | Verbs | + | OTHER | Other | + As an implementation note, these tags were determined by part-of-speech tagging the English side, and then taking the most frequent tag for each source/target pair. So if people frequently translate a Spanish word to a different part-of-speech tag in English, tags may end up being wrong (with respect to the Spanish word). + * `confidence`- 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. + * `prefixWord-` A string giving the 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. + * `backTranslations-` 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. Each element of the `backTranslations` list is an object described by the following properties- + * `normalizedText-` 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. + * `displayText-` A string giving the source term that is a back-translation of the target in a form best suited for end-user display. + * `numExamples-` 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. + * `frequencyCount-` 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. + Note - If the term being looked up does not exist in the dictionary, the response is 200 (OK) but the `translations` list is an empty list. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorMessageException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<DictionaryLookupResultItem> object if successful. + */ + List dictionaryLookup(String from, String to, List text); + + /** + * Provides alternative translations for a word and a small number of idiomatic phrases. Each translation has a `part-of-speech` and a list of `back-translations`. The back-translations enable a user to understand the translation in context. The Dictionary Example operation allows further drill down to see example uses of each translation pair. + * + * @param from Specifies the language of the input text. The source language must be one of the supported languages included in the `dictionary` scope. + * @param to Specifies the language of the output text. The target language must be one of the supported languages included in the `dictionary` scope of the Languages resource. + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the term to lookup. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 100 characters including spaces. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `normalizedSource`- 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. + * `displaySource`- 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". + * `translations`- A list of translations for the source term. Each element of the list is an object with the following properties: + * `normalizedTarget`- A string giving the normalized form of this term in the target language. This value should be used as input to lookup examples. + * `displayTarget`- 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"`. + * `posTag`- A string associating this term with a part-of-speech tag. + | Tag name | Description | + | --------- | ---------------- | + | ADJ | Adjectives | + | ADV | Adverbs | + | CONJ | Conjunctions | + | DET | Determiners | + | MODAL | Verbs | + | NOUN | Nouns | + | PREP | Prepositions | + | PRON | Pronouns | + | VERB | Verbs | + | OTHER | Other | + As an implementation note, these tags were determined by part-of-speech tagging the English side, and then taking the most frequent tag for each source/target pair. So if people frequently translate a Spanish word to a different part-of-speech tag in English, tags may end up being wrong (with respect to the Spanish word). + * `confidence`- 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. + * `prefixWord-` A string giving the 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. + * `backTranslations-` 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. Each element of the `backTranslations` list is an object described by the following properties- + * `normalizedText-` 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. + * `displayText-` A string giving the source term that is a back-translation of the target in a form best suited for end-user display. + * `numExamples-` 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. + * `frequencyCount-` 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. + Note - If the term being looked up does not exist in the dictionary, the response is 200 (OK) but the `translations` list is an empty list. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> dictionaryLookupAsync(String from, String to, List text, final ServiceCallback> serviceCallback); + + /** + * Provides alternative translations for a word and a small number of idiomatic phrases. Each translation has a `part-of-speech` and a list of `back-translations`. The back-translations enable a user to understand the translation in context. The Dictionary Example operation allows further drill down to see example uses of each translation pair. + * + * @param from Specifies the language of the input text. The source language must be one of the supported languages included in the `dictionary` scope. + * @param to Specifies the language of the output text. The target language must be one of the supported languages included in the `dictionary` scope of the Languages resource. + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the term to lookup. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 100 characters including spaces. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `normalizedSource`- 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. + * `displaySource`- 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". + * `translations`- A list of translations for the source term. Each element of the list is an object with the following properties: + * `normalizedTarget`- A string giving the normalized form of this term in the target language. This value should be used as input to lookup examples. + * `displayTarget`- 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"`. + * `posTag`- A string associating this term with a part-of-speech tag. + | Tag name | Description | + | --------- | ---------------- | + | ADJ | Adjectives | + | ADV | Adverbs | + | CONJ | Conjunctions | + | DET | Determiners | + | MODAL | Verbs | + | NOUN | Nouns | + | PREP | Prepositions | + | PRON | Pronouns | + | VERB | Verbs | + | OTHER | Other | + As an implementation note, these tags were determined by part-of-speech tagging the English side, and then taking the most frequent tag for each source/target pair. So if people frequently translate a Spanish word to a different part-of-speech tag in English, tags may end up being wrong (with respect to the Spanish word). + * `confidence`- 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. + * `prefixWord-` A string giving the 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. + * `backTranslations-` 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. Each element of the `backTranslations` list is an object described by the following properties- + * `normalizedText-` 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. + * `displayText-` A string giving the source term that is a back-translation of the target in a form best suited for end-user display. + * `numExamples-` 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. + * `frequencyCount-` 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. + Note - If the term being looked up does not exist in the dictionary, the response is 200 (OK) but the `translations` list is an empty list. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DictionaryLookupResultItem> object + */ + Observable> dictionaryLookupAsync(String from, String to, List text); + + /** + * Provides alternative translations for a word and a small number of idiomatic phrases. Each translation has a `part-of-speech` and a list of `back-translations`. The back-translations enable a user to understand the translation in context. The Dictionary Example operation allows further drill down to see example uses of each translation pair. + * + * @param from Specifies the language of the input text. The source language must be one of the supported languages included in the `dictionary` scope. + * @param to Specifies the language of the output text. The target language must be one of the supported languages included in the `dictionary` scope of the Languages resource. + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the term to lookup. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 100 characters including spaces. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `normalizedSource`- 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. + * `displaySource`- 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". + * `translations`- A list of translations for the source term. Each element of the list is an object with the following properties: + * `normalizedTarget`- A string giving the normalized form of this term in the target language. This value should be used as input to lookup examples. + * `displayTarget`- 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"`. + * `posTag`- A string associating this term with a part-of-speech tag. + | Tag name | Description | + | --------- | ---------------- | + | ADJ | Adjectives | + | ADV | Adverbs | + | CONJ | Conjunctions | + | DET | Determiners | + | MODAL | Verbs | + | NOUN | Nouns | + | PREP | Prepositions | + | PRON | Pronouns | + | VERB | Verbs | + | OTHER | Other | + As an implementation note, these tags were determined by part-of-speech tagging the English side, and then taking the most frequent tag for each source/target pair. So if people frequently translate a Spanish word to a different part-of-speech tag in English, tags may end up being wrong (with respect to the Spanish word). + * `confidence`- 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. + * `prefixWord-` A string giving the 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. + * `backTranslations-` 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. Each element of the `backTranslations` list is an object described by the following properties- + * `normalizedText-` 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. + * `displayText-` A string giving the source term that is a back-translation of the target in a form best suited for end-user display. + * `numExamples-` 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. + * `frequencyCount-` 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. + Note - If the term being looked up does not exist in the dictionary, the response is 200 (OK) but the `translations` list is an empty list. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DictionaryLookupResultItem> object + */ + Observable>> dictionaryLookupWithServiceResponseAsync(String from, String to, List text); + /** + * Provides alternative translations for a word and a small number of idiomatic phrases. Each translation has a `part-of-speech` and a list of `back-translations`. The back-translations enable a user to understand the translation in context. The Dictionary Example operation allows further drill down to see example uses of each translation pair. + * + * @param from Specifies the language of the input text. The source language must be one of the supported languages included in the `dictionary` scope. + * @param to Specifies the language of the output text. The target language must be one of the supported languages included in the `dictionary` scope of the Languages resource. + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the term to lookup. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 100 characters including spaces. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `normalizedSource`- 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. + * `displaySource`- 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". + * `translations`- A list of translations for the source term. Each element of the list is an object with the following properties: + * `normalizedTarget`- A string giving the normalized form of this term in the target language. This value should be used as input to lookup examples. + * `displayTarget`- 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"`. + * `posTag`- A string associating this term with a part-of-speech tag. + | Tag name | Description | + | --------- | ---------------- | + | ADJ | Adjectives | + | ADV | Adverbs | + | CONJ | Conjunctions | + | DET | Determiners | + | MODAL | Verbs | + | NOUN | Nouns | + | PREP | Prepositions | + | PRON | Pronouns | + | VERB | Verbs | + | OTHER | Other | + As an implementation note, these tags were determined by part-of-speech tagging the English side, and then taking the most frequent tag for each source/target pair. So if people frequently translate a Spanish word to a different part-of-speech tag in English, tags may end up being wrong (with respect to the Spanish word). + * `confidence`- 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. + * `prefixWord-` A string giving the 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. + * `backTranslations-` 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. Each element of the `backTranslations` list is an object described by the following properties- + * `normalizedText-` 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. + * `displayText-` A string giving the source term that is a back-translation of the target in a form best suited for end-user display. + * `numExamples-` 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. + * `frequencyCount-` 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. + Note - If the term being looked up does not exist in the dictionary, the response is 200 (OK) but the `translations` list is an empty list. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorMessageException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<DictionaryLookupResultItem> object if successful. + */ + List dictionaryLookup(String from, String to, List text, String xClientTraceId); + + /** + * Provides alternative translations for a word and a small number of idiomatic phrases. Each translation has a `part-of-speech` and a list of `back-translations`. The back-translations enable a user to understand the translation in context. The Dictionary Example operation allows further drill down to see example uses of each translation pair. + * + * @param from Specifies the language of the input text. The source language must be one of the supported languages included in the `dictionary` scope. + * @param to Specifies the language of the output text. The target language must be one of the supported languages included in the `dictionary` scope of the Languages resource. + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the term to lookup. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 100 characters including spaces. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `normalizedSource`- 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. + * `displaySource`- 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". + * `translations`- A list of translations for the source term. Each element of the list is an object with the following properties: + * `normalizedTarget`- A string giving the normalized form of this term in the target language. This value should be used as input to lookup examples. + * `displayTarget`- 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"`. + * `posTag`- A string associating this term with a part-of-speech tag. + | Tag name | Description | + | --------- | ---------------- | + | ADJ | Adjectives | + | ADV | Adverbs | + | CONJ | Conjunctions | + | DET | Determiners | + | MODAL | Verbs | + | NOUN | Nouns | + | PREP | Prepositions | + | PRON | Pronouns | + | VERB | Verbs | + | OTHER | Other | + As an implementation note, these tags were determined by part-of-speech tagging the English side, and then taking the most frequent tag for each source/target pair. So if people frequently translate a Spanish word to a different part-of-speech tag in English, tags may end up being wrong (with respect to the Spanish word). + * `confidence`- 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. + * `prefixWord-` A string giving the 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. + * `backTranslations-` 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. Each element of the `backTranslations` list is an object described by the following properties- + * `normalizedText-` 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. + * `displayText-` A string giving the source term that is a back-translation of the target in a form best suited for end-user display. + * `numExamples-` 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. + * `frequencyCount-` 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. + Note - If the term being looked up does not exist in the dictionary, the response is 200 (OK) but the `translations` list is an empty list. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> dictionaryLookupAsync(String from, String to, List text, String xClientTraceId, final ServiceCallback> serviceCallback); + + /** + * Provides alternative translations for a word and a small number of idiomatic phrases. Each translation has a `part-of-speech` and a list of `back-translations`. The back-translations enable a user to understand the translation in context. The Dictionary Example operation allows further drill down to see example uses of each translation pair. + * + * @param from Specifies the language of the input text. The source language must be one of the supported languages included in the `dictionary` scope. + * @param to Specifies the language of the output text. The target language must be one of the supported languages included in the `dictionary` scope of the Languages resource. + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the term to lookup. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 100 characters including spaces. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `normalizedSource`- 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. + * `displaySource`- 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". + * `translations`- A list of translations for the source term. Each element of the list is an object with the following properties: + * `normalizedTarget`- A string giving the normalized form of this term in the target language. This value should be used as input to lookup examples. + * `displayTarget`- 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"`. + * `posTag`- A string associating this term with a part-of-speech tag. + | Tag name | Description | + | --------- | ---------------- | + | ADJ | Adjectives | + | ADV | Adverbs | + | CONJ | Conjunctions | + | DET | Determiners | + | MODAL | Verbs | + | NOUN | Nouns | + | PREP | Prepositions | + | PRON | Pronouns | + | VERB | Verbs | + | OTHER | Other | + As an implementation note, these tags were determined by part-of-speech tagging the English side, and then taking the most frequent tag for each source/target pair. So if people frequently translate a Spanish word to a different part-of-speech tag in English, tags may end up being wrong (with respect to the Spanish word). + * `confidence`- 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. + * `prefixWord-` A string giving the 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. + * `backTranslations-` 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. Each element of the `backTranslations` list is an object described by the following properties- + * `normalizedText-` 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. + * `displayText-` A string giving the source term that is a back-translation of the target in a form best suited for end-user display. + * `numExamples-` 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. + * `frequencyCount-` 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. + Note - If the term being looked up does not exist in the dictionary, the response is 200 (OK) but the `translations` list is an empty list. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DictionaryLookupResultItem> object + */ + Observable> dictionaryLookupAsync(String from, String to, List text, String xClientTraceId); + + /** + * Provides alternative translations for a word and a small number of idiomatic phrases. Each translation has a `part-of-speech` and a list of `back-translations`. The back-translations enable a user to understand the translation in context. The Dictionary Example operation allows further drill down to see example uses of each translation pair. + * + * @param from Specifies the language of the input text. The source language must be one of the supported languages included in the `dictionary` scope. + * @param to Specifies the language of the output text. The target language must be one of the supported languages included in the `dictionary` scope of the Languages resource. + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the term to lookup. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 100 characters including spaces. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `normalizedSource`- 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. + * `displaySource`- 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". + * `translations`- A list of translations for the source term. Each element of the list is an object with the following properties: + * `normalizedTarget`- A string giving the normalized form of this term in the target language. This value should be used as input to lookup examples. + * `displayTarget`- 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"`. + * `posTag`- A string associating this term with a part-of-speech tag. + | Tag name | Description | + | --------- | ---------------- | + | ADJ | Adjectives | + | ADV | Adverbs | + | CONJ | Conjunctions | + | DET | Determiners | + | MODAL | Verbs | + | NOUN | Nouns | + | PREP | Prepositions | + | PRON | Pronouns | + | VERB | Verbs | + | OTHER | Other | + As an implementation note, these tags were determined by part-of-speech tagging the English side, and then taking the most frequent tag for each source/target pair. So if people frequently translate a Spanish word to a different part-of-speech tag in English, tags may end up being wrong (with respect to the Spanish word). + * `confidence`- 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. + * `prefixWord-` A string giving the 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. + * `backTranslations-` 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. Each element of the `backTranslations` list is an object described by the following properties- + * `normalizedText-` 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. + * `displayText-` A string giving the source term that is a back-translation of the target in a form best suited for end-user display. + * `numExamples-` 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. + * `frequencyCount-` 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. + Note - If the term being looked up does not exist in the dictionary, the response is 200 (OK) but the `translations` list is an empty list. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DictionaryLookupResultItem> object + */ + Observable>> dictionaryLookupWithServiceResponseAsync(String from, String to, List text, String xClientTraceId); + + /** + * Provides examples that show how terms in the dictionary are used in context. This operation is used in tandem with `Dictionary lookup`. + * + * @param from Specifies the language of the input text. The source language must be one of the supported languages included in the `dictionary` scope. + * @param to Specifies the language of the output text. The target language must be one of the supported languages included in the `dictionary` scope. + * @param text # Request body + The body of the request is a JSON array. Each array element is a JSON object with the following properties: + * `Text-` A string specifying the term to lookup. This should be the value of a `normalizedText` field from the back-translations of a previous Dictionary lookup request. It can also be the value of the `normalizedSource` field. + * `Translation-` 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. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 100 characters including spaces. + # Response body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `normalizedSource-` 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. + * `normalizedTarget-` 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. + * `examples-` A list of examples for the (source term, target term) pair. Each element of the list is an object with the following properties: + * `sourcePrefix-` 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. + * `sourceTerm-` 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. + * `sourceSuffix-` 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. + * `targetPrefix-` A string similar to `sourcePrefix` but for the target. + * `targetTerm-` A string similar to `sourceTerm` but for the target. + * `targetSuffix-` A string similar to `sourceSuffix` but for the target. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + NOTE - If there are no examples in the dictionary, the response is 200 (OK) but the `examples` list is an empty list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorMessageException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<DictionaryExampleResultItem> object if successful. + */ + List dictionaryExamples(String from, String to, List text); + + /** + * Provides examples that show how terms in the dictionary are used in context. This operation is used in tandem with `Dictionary lookup`. + * + * @param from Specifies the language of the input text. The source language must be one of the supported languages included in the `dictionary` scope. + * @param to Specifies the language of the output text. The target language must be one of the supported languages included in the `dictionary` scope. + * @param text # Request body + The body of the request is a JSON array. Each array element is a JSON object with the following properties: + * `Text-` A string specifying the term to lookup. This should be the value of a `normalizedText` field from the back-translations of a previous Dictionary lookup request. It can also be the value of the `normalizedSource` field. + * `Translation-` 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. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 100 characters including spaces. + # Response body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `normalizedSource-` 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. + * `normalizedTarget-` 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. + * `examples-` A list of examples for the (source term, target term) pair. Each element of the list is an object with the following properties: + * `sourcePrefix-` 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. + * `sourceTerm-` 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. + * `sourceSuffix-` 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. + * `targetPrefix-` A string similar to `sourcePrefix` but for the target. + * `targetTerm-` A string similar to `sourceTerm` but for the target. + * `targetSuffix-` A string similar to `sourceSuffix` but for the target. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + NOTE - If there are no examples in the dictionary, the response is 200 (OK) but the `examples` list is an empty list. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> dictionaryExamplesAsync(String from, String to, List text, final ServiceCallback> serviceCallback); + + /** + * Provides examples that show how terms in the dictionary are used in context. This operation is used in tandem with `Dictionary lookup`. + * + * @param from Specifies the language of the input text. The source language must be one of the supported languages included in the `dictionary` scope. + * @param to Specifies the language of the output text. The target language must be one of the supported languages included in the `dictionary` scope. + * @param text # Request body + The body of the request is a JSON array. Each array element is a JSON object with the following properties: + * `Text-` A string specifying the term to lookup. This should be the value of a `normalizedText` field from the back-translations of a previous Dictionary lookup request. It can also be the value of the `normalizedSource` field. + * `Translation-` 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. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 100 characters including spaces. + # Response body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `normalizedSource-` 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. + * `normalizedTarget-` 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. + * `examples-` A list of examples for the (source term, target term) pair. Each element of the list is an object with the following properties: + * `sourcePrefix-` 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. + * `sourceTerm-` 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. + * `sourceSuffix-` 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. + * `targetPrefix-` A string similar to `sourcePrefix` but for the target. + * `targetTerm-` A string similar to `sourceTerm` but for the target. + * `targetSuffix-` A string similar to `sourceSuffix` but for the target. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + NOTE - If there are no examples in the dictionary, the response is 200 (OK) but the `examples` list is an empty list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DictionaryExampleResultItem> object + */ + Observable> dictionaryExamplesAsync(String from, String to, List text); + + /** + * Provides examples that show how terms in the dictionary are used in context. This operation is used in tandem with `Dictionary lookup`. + * + * @param from Specifies the language of the input text. The source language must be one of the supported languages included in the `dictionary` scope. + * @param to Specifies the language of the output text. The target language must be one of the supported languages included in the `dictionary` scope. + * @param text # Request body + The body of the request is a JSON array. Each array element is a JSON object with the following properties: + * `Text-` A string specifying the term to lookup. This should be the value of a `normalizedText` field from the back-translations of a previous Dictionary lookup request. It can also be the value of the `normalizedSource` field. + * `Translation-` 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. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 100 characters including spaces. + # Response body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `normalizedSource-` 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. + * `normalizedTarget-` 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. + * `examples-` A list of examples for the (source term, target term) pair. Each element of the list is an object with the following properties: + * `sourcePrefix-` 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. + * `sourceTerm-` 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. + * `sourceSuffix-` 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. + * `targetPrefix-` A string similar to `sourcePrefix` but for the target. + * `targetTerm-` A string similar to `sourceTerm` but for the target. + * `targetSuffix-` A string similar to `sourceSuffix` but for the target. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + NOTE - If there are no examples in the dictionary, the response is 200 (OK) but the `examples` list is an empty list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DictionaryExampleResultItem> object + */ + Observable>> dictionaryExamplesWithServiceResponseAsync(String from, String to, List text); + /** + * Provides examples that show how terms in the dictionary are used in context. This operation is used in tandem with `Dictionary lookup`. + * + * @param from Specifies the language of the input text. The source language must be one of the supported languages included in the `dictionary` scope. + * @param to Specifies the language of the output text. The target language must be one of the supported languages included in the `dictionary` scope. + * @param text # Request body + The body of the request is a JSON array. Each array element is a JSON object with the following properties: + * `Text-` A string specifying the term to lookup. This should be the value of a `normalizedText` field from the back-translations of a previous Dictionary lookup request. It can also be the value of the `normalizedSource` field. + * `Translation-` 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. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 100 characters including spaces. + # Response body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `normalizedSource-` 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. + * `normalizedTarget-` 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. + * `examples-` A list of examples for the (source term, target term) pair. Each element of the list is an object with the following properties: + * `sourcePrefix-` 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. + * `sourceTerm-` 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. + * `sourceSuffix-` 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. + * `targetPrefix-` A string similar to `sourcePrefix` but for the target. + * `targetTerm-` A string similar to `sourceTerm` but for the target. + * `targetSuffix-` A string similar to `sourceSuffix` but for the target. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + NOTE - If there are no examples in the dictionary, the response is 200 (OK) but the `examples` list is an empty list. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorMessageException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<DictionaryExampleResultItem> object if successful. + */ + List dictionaryExamples(String from, String to, List text, String xClientTraceId); + + /** + * Provides examples that show how terms in the dictionary are used in context. This operation is used in tandem with `Dictionary lookup`. + * + * @param from Specifies the language of the input text. The source language must be one of the supported languages included in the `dictionary` scope. + * @param to Specifies the language of the output text. The target language must be one of the supported languages included in the `dictionary` scope. + * @param text # Request body + The body of the request is a JSON array. Each array element is a JSON object with the following properties: + * `Text-` A string specifying the term to lookup. This should be the value of a `normalizedText` field from the back-translations of a previous Dictionary lookup request. It can also be the value of the `normalizedSource` field. + * `Translation-` 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. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 100 characters including spaces. + # Response body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `normalizedSource-` 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. + * `normalizedTarget-` 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. + * `examples-` A list of examples for the (source term, target term) pair. Each element of the list is an object with the following properties: + * `sourcePrefix-` 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. + * `sourceTerm-` 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. + * `sourceSuffix-` 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. + * `targetPrefix-` A string similar to `sourcePrefix` but for the target. + * `targetTerm-` A string similar to `sourceTerm` but for the target. + * `targetSuffix-` A string similar to `sourceSuffix` but for the target. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + NOTE - If there are no examples in the dictionary, the response is 200 (OK) but the `examples` list is an empty list. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> dictionaryExamplesAsync(String from, String to, List text, String xClientTraceId, final ServiceCallback> serviceCallback); + + /** + * Provides examples that show how terms in the dictionary are used in context. This operation is used in tandem with `Dictionary lookup`. + * + * @param from Specifies the language of the input text. The source language must be one of the supported languages included in the `dictionary` scope. + * @param to Specifies the language of the output text. The target language must be one of the supported languages included in the `dictionary` scope. + * @param text # Request body + The body of the request is a JSON array. Each array element is a JSON object with the following properties: + * `Text-` A string specifying the term to lookup. This should be the value of a `normalizedText` field from the back-translations of a previous Dictionary lookup request. It can also be the value of the `normalizedSource` field. + * `Translation-` 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. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 100 characters including spaces. + # Response body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `normalizedSource-` 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. + * `normalizedTarget-` 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. + * `examples-` A list of examples for the (source term, target term) pair. Each element of the list is an object with the following properties: + * `sourcePrefix-` 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. + * `sourceTerm-` 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. + * `sourceSuffix-` 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. + * `targetPrefix-` A string similar to `sourcePrefix` but for the target. + * `targetTerm-` A string similar to `sourceTerm` but for the target. + * `targetSuffix-` A string similar to `sourceSuffix` but for the target. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + NOTE - If there are no examples in the dictionary, the response is 200 (OK) but the `examples` list is an empty list. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DictionaryExampleResultItem> object + */ + Observable> dictionaryExamplesAsync(String from, String to, List text, String xClientTraceId); + + /** + * Provides examples that show how terms in the dictionary are used in context. This operation is used in tandem with `Dictionary lookup`. + * + * @param from Specifies the language of the input text. The source language must be one of the supported languages included in the `dictionary` scope. + * @param to Specifies the language of the output text. The target language must be one of the supported languages included in the `dictionary` scope. + * @param text # Request body + The body of the request is a JSON array. Each array element is a JSON object with the following properties: + * `Text-` A string specifying the term to lookup. This should be the value of a `normalizedText` field from the back-translations of a previous Dictionary lookup request. It can also be the value of the `normalizedSource` field. + * `Translation-` 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. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 100 characters including spaces. + # Response body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `normalizedSource-` 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. + * `normalizedTarget-` 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. + * `examples-` A list of examples for the (source term, target term) pair. Each element of the list is an object with the following properties: + * `sourcePrefix-` 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. + * `sourceTerm-` 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. + * `sourceSuffix-` 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. + * `targetPrefix-` A string similar to `sourcePrefix` but for the target. + * `targetTerm-` A string similar to `sourceTerm` but for the target. + * `targetSuffix-` A string similar to `sourceSuffix` but for the target. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + NOTE - If there are no examples in the dictionary, the response is 200 (OK) but the `examples` list is an empty list. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DictionaryExampleResultItem> object + */ + Observable>> dictionaryExamplesWithServiceResponseAsync(String from, String to, List text, String xClientTraceId); + + /** + * Gets the set of languages currently supported by other operations of the Translator Text API. + **Authentication is not required to get language resources.** + # Response Body + A client uses the `scope` query parameter to define which groups of languages it is interested in. + * `scope=translation` provides languages supported to translate text from one language to another language. + * `scope=transliteration` provides capabilities for converting text in one language from one script to another script. + * `scope=dictionary` provides language pairs for which `Dictionary` operations return data. + A client may retrieve several groups simultaneously by specifying a comma-separated list of names. For example, `scope=translation,transliteration,dictionary` would return supported languages for all groups. + A successful response is a JSON object with one property for each requested group. + The value for each property is as follows. + * `translation` property + The value of the `translation` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. A key identifies a language for which text can be translated to or translated from. The value associated with the key is a JSON object with properties that describe the language + * `name-` Display name of the language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + ```json + { + "translation": { + ... + "fr": { + "name": "French", + "nativeName": "Français", + "dir": "ltr" + }, + ... + } + } + ``` + * `transliteration` property + The value of the `transliteration` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. A key identifies a language for which text can be converted from one script to another script. The value associated with the key is a JSON object with properties that describe the language and its supported scripts + * `name-` Display name of the language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `scripts-` List of scripts to convert from. Each element of the `scripts` list has properties- + * `code-` Code identifying the script. + * `name-` Display name of the script in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for the language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `toScripts-` List of scripts available to convert text to. Each element of the `toScripts` list has properties `code`, `name`, `nativeName`, and `dir` as described earlier. + ```json + { + "transliteration": { + ... + "ja": { + "name": "Japanese", + "nativeName": "日本語", + "scripts": [ + { + "code": "Jpan", + "name": "Japanese", + "nativeName": "日本語", + "dir": "ltr", + "toScripts": [ + { + "code": "Latn", + "name": "Latin", + "nativeName": "ラテン語", + "dir": "ltr" + } + ] + }, + { + "code": "Latn", + "name": "Latin", + "nativeName": "ラテン語", + "dir": "ltr", + "toScripts": [ + { + "code": "Jpan", + "name": "Japanese", + "nativeName": "日本語", + "dir": "ltr" + } + ] + } + ] + }, + ... + } + } + ``` + * `dictionary` property + The value of the `dictionary` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. The key identifies a language for which alternative translations and back-translations are available. The value is a JSON object that describes the source language and the target languages with available translations. + * `name-` Display name of the source language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `translations-` List of languages with alterative translations and examples for the query expressed in the source language. Each element of the `translations` list has properties + * `name-` Display name of the target language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the target language in the locale native for the target language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `code-` Language code identifying the target language. + ```json + "es": { + "name": "Spanish", + "nativeName": "Español", + "dir": "ltr", + "translations": [ + { + "name": "English", + "nativeName": "English", + "dir": "ltr", + "code": "en" + } + ] + }, + ``` + The structure of the response object will not change without a change in the version of the API. For the same version of the API, the list of available languages may change over time because Microsoft Translator continually extends the list of languages supported by its services. + The list of supported languages will not change frequently. To save network bandwidth and improve responsiveness, a client application should consider caching language resources and the corresponding entity tag (`ETag`). Then, the client application can periodically (for example, once every 24 hours) query the service to fetch the latest set of supported languages. Passing the current `ETag` value in an `If-None-Match` header 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. + # Response Header + ETag - Current value of the entity tag for the requested groups of supported languages. To make subsequent requests more efficient, the client may send the `ETag` value in an `If-None-Match` header field. + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorMessageException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the LanguagesResult object if successful. + */ + LanguagesResult languages(); + + /** + * Gets the set of languages currently supported by other operations of the Translator Text API. + **Authentication is not required to get language resources.** + # Response Body + A client uses the `scope` query parameter to define which groups of languages it is interested in. + * `scope=translation` provides languages supported to translate text from one language to another language. + * `scope=transliteration` provides capabilities for converting text in one language from one script to another script. + * `scope=dictionary` provides language pairs for which `Dictionary` operations return data. + A client may retrieve several groups simultaneously by specifying a comma-separated list of names. For example, `scope=translation,transliteration,dictionary` would return supported languages for all groups. + A successful response is a JSON object with one property for each requested group. + The value for each property is as follows. + * `translation` property + The value of the `translation` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. A key identifies a language for which text can be translated to or translated from. The value associated with the key is a JSON object with properties that describe the language + * `name-` Display name of the language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + ```json + { + "translation": { + ... + "fr": { + "name": "French", + "nativeName": "Français", + "dir": "ltr" + }, + ... + } + } + ``` + * `transliteration` property + The value of the `transliteration` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. A key identifies a language for which text can be converted from one script to another script. The value associated with the key is a JSON object with properties that describe the language and its supported scripts + * `name-` Display name of the language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `scripts-` List of scripts to convert from. Each element of the `scripts` list has properties- + * `code-` Code identifying the script. + * `name-` Display name of the script in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for the language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `toScripts-` List of scripts available to convert text to. Each element of the `toScripts` list has properties `code`, `name`, `nativeName`, and `dir` as described earlier. + ```json + { + "transliteration": { + ... + "ja": { + "name": "Japanese", + "nativeName": "日本語", + "scripts": [ + { + "code": "Jpan", + "name": "Japanese", + "nativeName": "日本語", + "dir": "ltr", + "toScripts": [ + { + "code": "Latn", + "name": "Latin", + "nativeName": "ラテン語", + "dir": "ltr" + } + ] + }, + { + "code": "Latn", + "name": "Latin", + "nativeName": "ラテン語", + "dir": "ltr", + "toScripts": [ + { + "code": "Jpan", + "name": "Japanese", + "nativeName": "日本語", + "dir": "ltr" + } + ] + } + ] + }, + ... + } + } + ``` + * `dictionary` property + The value of the `dictionary` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. The key identifies a language for which alternative translations and back-translations are available. The value is a JSON object that describes the source language and the target languages with available translations. + * `name-` Display name of the source language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `translations-` List of languages with alterative translations and examples for the query expressed in the source language. Each element of the `translations` list has properties + * `name-` Display name of the target language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the target language in the locale native for the target language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `code-` Language code identifying the target language. + ```json + "es": { + "name": "Spanish", + "nativeName": "Español", + "dir": "ltr", + "translations": [ + { + "name": "English", + "nativeName": "English", + "dir": "ltr", + "code": "en" + } + ] + }, + ``` + The structure of the response object will not change without a change in the version of the API. For the same version of the API, the list of available languages may change over time because Microsoft Translator continually extends the list of languages supported by its services. + The list of supported languages will not change frequently. To save network bandwidth and improve responsiveness, a client application should consider caching language resources and the corresponding entity tag (`ETag`). Then, the client application can periodically (for example, once every 24 hours) query the service to fetch the latest set of supported languages. Passing the current `ETag` value in an `If-None-Match` header 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. + # Response Header + ETag - Current value of the entity tag for the requested groups of supported languages. To make subsequent requests more efficient, the client may send the `ETag` value in an `If-None-Match` header field. + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture languagesAsync(final ServiceCallback serviceCallback); + + /** + * Gets the set of languages currently supported by other operations of the Translator Text API. + **Authentication is not required to get language resources.** + # Response Body + A client uses the `scope` query parameter to define which groups of languages it is interested in. + * `scope=translation` provides languages supported to translate text from one language to another language. + * `scope=transliteration` provides capabilities for converting text in one language from one script to another script. + * `scope=dictionary` provides language pairs for which `Dictionary` operations return data. + A client may retrieve several groups simultaneously by specifying a comma-separated list of names. For example, `scope=translation,transliteration,dictionary` would return supported languages for all groups. + A successful response is a JSON object with one property for each requested group. + The value for each property is as follows. + * `translation` property + The value of the `translation` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. A key identifies a language for which text can be translated to or translated from. The value associated with the key is a JSON object with properties that describe the language + * `name-` Display name of the language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + ```json + { + "translation": { + ... + "fr": { + "name": "French", + "nativeName": "Français", + "dir": "ltr" + }, + ... + } + } + ``` + * `transliteration` property + The value of the `transliteration` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. A key identifies a language for which text can be converted from one script to another script. The value associated with the key is a JSON object with properties that describe the language and its supported scripts + * `name-` Display name of the language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `scripts-` List of scripts to convert from. Each element of the `scripts` list has properties- + * `code-` Code identifying the script. + * `name-` Display name of the script in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for the language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `toScripts-` List of scripts available to convert text to. Each element of the `toScripts` list has properties `code`, `name`, `nativeName`, and `dir` as described earlier. + ```json + { + "transliteration": { + ... + "ja": { + "name": "Japanese", + "nativeName": "日本語", + "scripts": [ + { + "code": "Jpan", + "name": "Japanese", + "nativeName": "日本語", + "dir": "ltr", + "toScripts": [ + { + "code": "Latn", + "name": "Latin", + "nativeName": "ラテン語", + "dir": "ltr" + } + ] + }, + { + "code": "Latn", + "name": "Latin", + "nativeName": "ラテン語", + "dir": "ltr", + "toScripts": [ + { + "code": "Jpan", + "name": "Japanese", + "nativeName": "日本語", + "dir": "ltr" + } + ] + } + ] + }, + ... + } + } + ``` + * `dictionary` property + The value of the `dictionary` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. The key identifies a language for which alternative translations and back-translations are available. The value is a JSON object that describes the source language and the target languages with available translations. + * `name-` Display name of the source language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `translations-` List of languages with alterative translations and examples for the query expressed in the source language. Each element of the `translations` list has properties + * `name-` Display name of the target language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the target language in the locale native for the target language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `code-` Language code identifying the target language. + ```json + "es": { + "name": "Spanish", + "nativeName": "Español", + "dir": "ltr", + "translations": [ + { + "name": "English", + "nativeName": "English", + "dir": "ltr", + "code": "en" + } + ] + }, + ``` + The structure of the response object will not change without a change in the version of the API. For the same version of the API, the list of available languages may change over time because Microsoft Translator continually extends the list of languages supported by its services. + The list of supported languages will not change frequently. To save network bandwidth and improve responsiveness, a client application should consider caching language resources and the corresponding entity tag (`ETag`). Then, the client application can periodically (for example, once every 24 hours) query the service to fetch the latest set of supported languages. Passing the current `ETag` value in an `If-None-Match` header 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. + # Response Header + ETag - Current value of the entity tag for the requested groups of supported languages. To make subsequent requests more efficient, the client may send the `ETag` value in an `If-None-Match` header field. + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the LanguagesResult object + */ + Observable languagesAsync(); + + /** + * Gets the set of languages currently supported by other operations of the Translator Text API. + **Authentication is not required to get language resources.** + # Response Body + A client uses the `scope` query parameter to define which groups of languages it is interested in. + * `scope=translation` provides languages supported to translate text from one language to another language. + * `scope=transliteration` provides capabilities for converting text in one language from one script to another script. + * `scope=dictionary` provides language pairs for which `Dictionary` operations return data. + A client may retrieve several groups simultaneously by specifying a comma-separated list of names. For example, `scope=translation,transliteration,dictionary` would return supported languages for all groups. + A successful response is a JSON object with one property for each requested group. + The value for each property is as follows. + * `translation` property + The value of the `translation` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. A key identifies a language for which text can be translated to or translated from. The value associated with the key is a JSON object with properties that describe the language + * `name-` Display name of the language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + ```json + { + "translation": { + ... + "fr": { + "name": "French", + "nativeName": "Français", + "dir": "ltr" + }, + ... + } + } + ``` + * `transliteration` property + The value of the `transliteration` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. A key identifies a language for which text can be converted from one script to another script. The value associated with the key is a JSON object with properties that describe the language and its supported scripts + * `name-` Display name of the language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `scripts-` List of scripts to convert from. Each element of the `scripts` list has properties- + * `code-` Code identifying the script. + * `name-` Display name of the script in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for the language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `toScripts-` List of scripts available to convert text to. Each element of the `toScripts` list has properties `code`, `name`, `nativeName`, and `dir` as described earlier. + ```json + { + "transliteration": { + ... + "ja": { + "name": "Japanese", + "nativeName": "日本語", + "scripts": [ + { + "code": "Jpan", + "name": "Japanese", + "nativeName": "日本語", + "dir": "ltr", + "toScripts": [ + { + "code": "Latn", + "name": "Latin", + "nativeName": "ラテン語", + "dir": "ltr" + } + ] + }, + { + "code": "Latn", + "name": "Latin", + "nativeName": "ラテン語", + "dir": "ltr", + "toScripts": [ + { + "code": "Jpan", + "name": "Japanese", + "nativeName": "日本語", + "dir": "ltr" + } + ] + } + ] + }, + ... + } + } + ``` + * `dictionary` property + The value of the `dictionary` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. The key identifies a language for which alternative translations and back-translations are available. The value is a JSON object that describes the source language and the target languages with available translations. + * `name-` Display name of the source language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `translations-` List of languages with alterative translations and examples for the query expressed in the source language. Each element of the `translations` list has properties + * `name-` Display name of the target language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the target language in the locale native for the target language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `code-` Language code identifying the target language. + ```json + "es": { + "name": "Spanish", + "nativeName": "Español", + "dir": "ltr", + "translations": [ + { + "name": "English", + "nativeName": "English", + "dir": "ltr", + "code": "en" + } + ] + }, + ``` + The structure of the response object will not change without a change in the version of the API. For the same version of the API, the list of available languages may change over time because Microsoft Translator continually extends the list of languages supported by its services. + The list of supported languages will not change frequently. To save network bandwidth and improve responsiveness, a client application should consider caching language resources and the corresponding entity tag (`ETag`). Then, the client application can periodically (for example, once every 24 hours) query the service to fetch the latest set of supported languages. Passing the current `ETag` value in an `If-None-Match` header 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. + # Response Header + ETag - Current value of the entity tag for the requested groups of supported languages. To make subsequent requests more efficient, the client may send the `ETag` value in an `If-None-Match` header field. + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the LanguagesResult object + */ + Observable> languagesWithServiceResponseAsync(); + /** + * Gets the set of languages currently supported by other operations of the Translator Text API. + **Authentication is not required to get language resources.** + # Response Body + A client uses the `scope` query parameter to define which groups of languages it is interested in. + * `scope=translation` provides languages supported to translate text from one language to another language. + * `scope=transliteration` provides capabilities for converting text in one language from one script to another script. + * `scope=dictionary` provides language pairs for which `Dictionary` operations return data. + A client may retrieve several groups simultaneously by specifying a comma-separated list of names. For example, `scope=translation,transliteration,dictionary` would return supported languages for all groups. + A successful response is a JSON object with one property for each requested group. + The value for each property is as follows. + * `translation` property + The value of the `translation` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. A key identifies a language for which text can be translated to or translated from. The value associated with the key is a JSON object with properties that describe the language + * `name-` Display name of the language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + ```json + { + "translation": { + ... + "fr": { + "name": "French", + "nativeName": "Français", + "dir": "ltr" + }, + ... + } + } + ``` + * `transliteration` property + The value of the `transliteration` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. A key identifies a language for which text can be converted from one script to another script. The value associated with the key is a JSON object with properties that describe the language and its supported scripts + * `name-` Display name of the language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `scripts-` List of scripts to convert from. Each element of the `scripts` list has properties- + * `code-` Code identifying the script. + * `name-` Display name of the script in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for the language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `toScripts-` List of scripts available to convert text to. Each element of the `toScripts` list has properties `code`, `name`, `nativeName`, and `dir` as described earlier. + ```json + { + "transliteration": { + ... + "ja": { + "name": "Japanese", + "nativeName": "日本語", + "scripts": [ + { + "code": "Jpan", + "name": "Japanese", + "nativeName": "日本語", + "dir": "ltr", + "toScripts": [ + { + "code": "Latn", + "name": "Latin", + "nativeName": "ラテン語", + "dir": "ltr" + } + ] + }, + { + "code": "Latn", + "name": "Latin", + "nativeName": "ラテン語", + "dir": "ltr", + "toScripts": [ + { + "code": "Jpan", + "name": "Japanese", + "nativeName": "日本語", + "dir": "ltr" + } + ] + } + ] + }, + ... + } + } + ``` + * `dictionary` property + The value of the `dictionary` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. The key identifies a language for which alternative translations and back-translations are available. The value is a JSON object that describes the source language and the target languages with available translations. + * `name-` Display name of the source language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `translations-` List of languages with alterative translations and examples for the query expressed in the source language. Each element of the `translations` list has properties + * `name-` Display name of the target language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the target language in the locale native for the target language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `code-` Language code identifying the target language. + ```json + "es": { + "name": "Spanish", + "nativeName": "Español", + "dir": "ltr", + "translations": [ + { + "name": "English", + "nativeName": "English", + "dir": "ltr", + "code": "en" + } + ] + }, + ``` + The structure of the response object will not change without a change in the version of the API. For the same version of the API, the list of available languages may change over time because Microsoft Translator continually extends the list of languages supported by its services. + The list of supported languages will not change frequently. To save network bandwidth and improve responsiveness, a client application should consider caching language resources and the corresponding entity tag (`ETag`). Then, the client application can periodically (for example, once every 24 hours) query the service to fetch the latest set of supported languages. Passing the current `ETag` value in an `If-None-Match` header 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. + # Response Header + ETag - Current value of the entity tag for the requested groups of supported languages. To make subsequent requests more efficient, the client may send the `ETag` value in an `If-None-Match` header field. + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * + * @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. + * @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 xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorMessageException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the LanguagesResult object if successful. + */ + LanguagesResult languages(List scope, String acceptLanguage, String xClientTraceId); + + /** + * Gets the set of languages currently supported by other operations of the Translator Text API. + **Authentication is not required to get language resources.** + # Response Body + A client uses the `scope` query parameter to define which groups of languages it is interested in. + * `scope=translation` provides languages supported to translate text from one language to another language. + * `scope=transliteration` provides capabilities for converting text in one language from one script to another script. + * `scope=dictionary` provides language pairs for which `Dictionary` operations return data. + A client may retrieve several groups simultaneously by specifying a comma-separated list of names. For example, `scope=translation,transliteration,dictionary` would return supported languages for all groups. + A successful response is a JSON object with one property for each requested group. + The value for each property is as follows. + * `translation` property + The value of the `translation` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. A key identifies a language for which text can be translated to or translated from. The value associated with the key is a JSON object with properties that describe the language + * `name-` Display name of the language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + ```json + { + "translation": { + ... + "fr": { + "name": "French", + "nativeName": "Français", + "dir": "ltr" + }, + ... + } + } + ``` + * `transliteration` property + The value of the `transliteration` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. A key identifies a language for which text can be converted from one script to another script. The value associated with the key is a JSON object with properties that describe the language and its supported scripts + * `name-` Display name of the language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `scripts-` List of scripts to convert from. Each element of the `scripts` list has properties- + * `code-` Code identifying the script. + * `name-` Display name of the script in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for the language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `toScripts-` List of scripts available to convert text to. Each element of the `toScripts` list has properties `code`, `name`, `nativeName`, and `dir` as described earlier. + ```json + { + "transliteration": { + ... + "ja": { + "name": "Japanese", + "nativeName": "日本語", + "scripts": [ + { + "code": "Jpan", + "name": "Japanese", + "nativeName": "日本語", + "dir": "ltr", + "toScripts": [ + { + "code": "Latn", + "name": "Latin", + "nativeName": "ラテン語", + "dir": "ltr" + } + ] + }, + { + "code": "Latn", + "name": "Latin", + "nativeName": "ラテン語", + "dir": "ltr", + "toScripts": [ + { + "code": "Jpan", + "name": "Japanese", + "nativeName": "日本語", + "dir": "ltr" + } + ] + } + ] + }, + ... + } + } + ``` + * `dictionary` property + The value of the `dictionary` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. The key identifies a language for which alternative translations and back-translations are available. The value is a JSON object that describes the source language and the target languages with available translations. + * `name-` Display name of the source language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `translations-` List of languages with alterative translations and examples for the query expressed in the source language. Each element of the `translations` list has properties + * `name-` Display name of the target language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the target language in the locale native for the target language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `code-` Language code identifying the target language. + ```json + "es": { + "name": "Spanish", + "nativeName": "Español", + "dir": "ltr", + "translations": [ + { + "name": "English", + "nativeName": "English", + "dir": "ltr", + "code": "en" + } + ] + }, + ``` + The structure of the response object will not change without a change in the version of the API. For the same version of the API, the list of available languages may change over time because Microsoft Translator continually extends the list of languages supported by its services. + The list of supported languages will not change frequently. To save network bandwidth and improve responsiveness, a client application should consider caching language resources and the corresponding entity tag (`ETag`). Then, the client application can periodically (for example, once every 24 hours) query the service to fetch the latest set of supported languages. Passing the current `ETag` value in an `If-None-Match` header 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. + # Response Header + ETag - Current value of the entity tag for the requested groups of supported languages. To make subsequent requests more efficient, the client may send the `ETag` value in an `If-None-Match` header field. + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * + * @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. + * @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 xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture languagesAsync(List scope, String acceptLanguage, String xClientTraceId, final ServiceCallback serviceCallback); + + /** + * Gets the set of languages currently supported by other operations of the Translator Text API. + **Authentication is not required to get language resources.** + # Response Body + A client uses the `scope` query parameter to define which groups of languages it is interested in. + * `scope=translation` provides languages supported to translate text from one language to another language. + * `scope=transliteration` provides capabilities for converting text in one language from one script to another script. + * `scope=dictionary` provides language pairs for which `Dictionary` operations return data. + A client may retrieve several groups simultaneously by specifying a comma-separated list of names. For example, `scope=translation,transliteration,dictionary` would return supported languages for all groups. + A successful response is a JSON object with one property for each requested group. + The value for each property is as follows. + * `translation` property + The value of the `translation` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. A key identifies a language for which text can be translated to or translated from. The value associated with the key is a JSON object with properties that describe the language + * `name-` Display name of the language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + ```json + { + "translation": { + ... + "fr": { + "name": "French", + "nativeName": "Français", + "dir": "ltr" + }, + ... + } + } + ``` + * `transliteration` property + The value of the `transliteration` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. A key identifies a language for which text can be converted from one script to another script. The value associated with the key is a JSON object with properties that describe the language and its supported scripts + * `name-` Display name of the language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `scripts-` List of scripts to convert from. Each element of the `scripts` list has properties- + * `code-` Code identifying the script. + * `name-` Display name of the script in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for the language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `toScripts-` List of scripts available to convert text to. Each element of the `toScripts` list has properties `code`, `name`, `nativeName`, and `dir` as described earlier. + ```json + { + "transliteration": { + ... + "ja": { + "name": "Japanese", + "nativeName": "日本語", + "scripts": [ + { + "code": "Jpan", + "name": "Japanese", + "nativeName": "日本語", + "dir": "ltr", + "toScripts": [ + { + "code": "Latn", + "name": "Latin", + "nativeName": "ラテン語", + "dir": "ltr" + } + ] + }, + { + "code": "Latn", + "name": "Latin", + "nativeName": "ラテン語", + "dir": "ltr", + "toScripts": [ + { + "code": "Jpan", + "name": "Japanese", + "nativeName": "日本語", + "dir": "ltr" + } + ] + } + ] + }, + ... + } + } + ``` + * `dictionary` property + The value of the `dictionary` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. The key identifies a language for which alternative translations and back-translations are available. The value is a JSON object that describes the source language and the target languages with available translations. + * `name-` Display name of the source language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `translations-` List of languages with alterative translations and examples for the query expressed in the source language. Each element of the `translations` list has properties + * `name-` Display name of the target language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the target language in the locale native for the target language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `code-` Language code identifying the target language. + ```json + "es": { + "name": "Spanish", + "nativeName": "Español", + "dir": "ltr", + "translations": [ + { + "name": "English", + "nativeName": "English", + "dir": "ltr", + "code": "en" + } + ] + }, + ``` + The structure of the response object will not change without a change in the version of the API. For the same version of the API, the list of available languages may change over time because Microsoft Translator continually extends the list of languages supported by its services. + The list of supported languages will not change frequently. To save network bandwidth and improve responsiveness, a client application should consider caching language resources and the corresponding entity tag (`ETag`). Then, the client application can periodically (for example, once every 24 hours) query the service to fetch the latest set of supported languages. Passing the current `ETag` value in an `If-None-Match` header 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. + # Response Header + ETag - Current value of the entity tag for the requested groups of supported languages. To make subsequent requests more efficient, the client may send the `ETag` value in an `If-None-Match` header field. + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * + * @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. + * @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 xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the LanguagesResult object + */ + Observable languagesAsync(List scope, String acceptLanguage, String xClientTraceId); + + /** + * Gets the set of languages currently supported by other operations of the Translator Text API. + **Authentication is not required to get language resources.** + # Response Body + A client uses the `scope` query parameter to define which groups of languages it is interested in. + * `scope=translation` provides languages supported to translate text from one language to another language. + * `scope=transliteration` provides capabilities for converting text in one language from one script to another script. + * `scope=dictionary` provides language pairs for which `Dictionary` operations return data. + A client may retrieve several groups simultaneously by specifying a comma-separated list of names. For example, `scope=translation,transliteration,dictionary` would return supported languages for all groups. + A successful response is a JSON object with one property for each requested group. + The value for each property is as follows. + * `translation` property + The value of the `translation` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. A key identifies a language for which text can be translated to or translated from. The value associated with the key is a JSON object with properties that describe the language + * `name-` Display name of the language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + ```json + { + "translation": { + ... + "fr": { + "name": "French", + "nativeName": "Français", + "dir": "ltr" + }, + ... + } + } + ``` + * `transliteration` property + The value of the `transliteration` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. A key identifies a language for which text can be converted from one script to another script. The value associated with the key is a JSON object with properties that describe the language and its supported scripts + * `name-` Display name of the language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `scripts-` List of scripts to convert from. Each element of the `scripts` list has properties- + * `code-` Code identifying the script. + * `name-` Display name of the script in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for the language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `toScripts-` List of scripts available to convert text to. Each element of the `toScripts` list has properties `code`, `name`, `nativeName`, and `dir` as described earlier. + ```json + { + "transliteration": { + ... + "ja": { + "name": "Japanese", + "nativeName": "日本語", + "scripts": [ + { + "code": "Jpan", + "name": "Japanese", + "nativeName": "日本語", + "dir": "ltr", + "toScripts": [ + { + "code": "Latn", + "name": "Latin", + "nativeName": "ラテン語", + "dir": "ltr" + } + ] + }, + { + "code": "Latn", + "name": "Latin", + "nativeName": "ラテン語", + "dir": "ltr", + "toScripts": [ + { + "code": "Jpan", + "name": "Japanese", + "nativeName": "日本語", + "dir": "ltr" + } + ] + } + ] + }, + ... + } + } + ``` + * `dictionary` property + The value of the `dictionary` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. The key identifies a language for which alternative translations and back-translations are available. The value is a JSON object that describes the source language and the target languages with available translations. + * `name-` Display name of the source language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `translations-` List of languages with alterative translations and examples for the query expressed in the source language. Each element of the `translations` list has properties + * `name-` Display name of the target language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the target language in the locale native for the target language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `code-` Language code identifying the target language. + ```json + "es": { + "name": "Spanish", + "nativeName": "Español", + "dir": "ltr", + "translations": [ + { + "name": "English", + "nativeName": "English", + "dir": "ltr", + "code": "en" + } + ] + }, + ``` + The structure of the response object will not change without a change in the version of the API. For the same version of the API, the list of available languages may change over time because Microsoft Translator continually extends the list of languages supported by its services. + The list of supported languages will not change frequently. To save network bandwidth and improve responsiveness, a client application should consider caching language resources and the corresponding entity tag (`ETag`). Then, the client application can periodically (for example, once every 24 hours) query the service to fetch the latest set of supported languages. Passing the current `ETag` value in an `If-None-Match` header 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. + # Response Header + ETag - Current value of the entity tag for the requested groups of supported languages. To make subsequent requests more efficient, the client may send the `ETag` value in an `If-None-Match` header field. + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * + * @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. + * @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 xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the LanguagesResult object + */ + Observable> languagesWithServiceResponseAsync(List scope, String acceptLanguage, String xClientTraceId); + + /** + * Translates text into one or more languages. + * + * @param to Specifies the language of the output text. Find which languages are available to translate to by using the languages method. For example, use `to=de` to translate to German. + It's possible to translate to multiple languages simultaneously by repeating the `to` parameter in the query string. For example, use `to=de&to=it` to translate to German and Italian in the same request. + * @param text # Request body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the string to translate. + The following limitations apply: + * The array can have at most 25 elements. + * The entire text included in the request cannot exceed 5,000 characters including spaces. + # Response body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties- + * `detectedLanguage`- An object describing the detected language through the following properties. + * `language`- A string representing the code of the detected 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. + The `detectedLanguage` property is only present in the result object when language auto-detection is requested. + * `translations`- An array of translation results. The size of the array matches the number of target languages specified in the `to` query parameter. Each element in the array includes. + * `to` A string representing the language code of the target language. + * `text`- A string giving the translated text. + * `transliteration`- An object giving the translated text in the script specified by the `toScript` parameter. + * `script`- A string specifying the target script. + * `text`- A string giving the translated text in the target script. + The `transliteration` object is not included if transliteration does not take place. + *`alignment`- An object with a single string property named `proj`, which 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. See Obtain alignment information for an example and restrictions. + * `sentLen`- An object returning sentence boundaries in the input and output texts. + * `srcSentLen`- 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. + * `transSentLen`- 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. + Sentence boundaries are only included when the request parameter `includeSentenceLength` is `true`. + * `sourceText`- An object with a single string property named `text`, which gives the 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. + Example of JSON responses are provided in the examples section. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorMessageException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<TranslateResultAllItem> object if successful. + */ + List translate(List to, List text); + + /** + * Translates text into one or more languages. + * + * @param to Specifies the language of the output text. Find which languages are available to translate to by using the languages method. For example, use `to=de` to translate to German. + It's possible to translate to multiple languages simultaneously by repeating the `to` parameter in the query string. For example, use `to=de&to=it` to translate to German and Italian in the same request. + * @param text # Request body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the string to translate. + The following limitations apply: + * The array can have at most 25 elements. + * The entire text included in the request cannot exceed 5,000 characters including spaces. + # Response body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties- + * `detectedLanguage`- An object describing the detected language through the following properties. + * `language`- A string representing the code of the detected 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. + The `detectedLanguage` property is only present in the result object when language auto-detection is requested. + * `translations`- An array of translation results. The size of the array matches the number of target languages specified in the `to` query parameter. Each element in the array includes. + * `to` A string representing the language code of the target language. + * `text`- A string giving the translated text. + * `transliteration`- An object giving the translated text in the script specified by the `toScript` parameter. + * `script`- A string specifying the target script. + * `text`- A string giving the translated text in the target script. + The `transliteration` object is not included if transliteration does not take place. + *`alignment`- An object with a single string property named `proj`, which 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. See Obtain alignment information for an example and restrictions. + * `sentLen`- An object returning sentence boundaries in the input and output texts. + * `srcSentLen`- 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. + * `transSentLen`- 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. + Sentence boundaries are only included when the request parameter `includeSentenceLength` is `true`. + * `sourceText`- An object with a single string property named `text`, which gives the 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. + Example of JSON responses are provided in the examples section. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> translateAsync(List to, List text, final ServiceCallback> serviceCallback); + + /** + * Translates text into one or more languages. + * + * @param to Specifies the language of the output text. Find which languages are available to translate to by using the languages method. For example, use `to=de` to translate to German. + It's possible to translate to multiple languages simultaneously by repeating the `to` parameter in the query string. For example, use `to=de&to=it` to translate to German and Italian in the same request. + * @param text # Request body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the string to translate. + The following limitations apply: + * The array can have at most 25 elements. + * The entire text included in the request cannot exceed 5,000 characters including spaces. + # Response body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties- + * `detectedLanguage`- An object describing the detected language through the following properties. + * `language`- A string representing the code of the detected 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. + The `detectedLanguage` property is only present in the result object when language auto-detection is requested. + * `translations`- An array of translation results. The size of the array matches the number of target languages specified in the `to` query parameter. Each element in the array includes. + * `to` A string representing the language code of the target language. + * `text`- A string giving the translated text. + * `transliteration`- An object giving the translated text in the script specified by the `toScript` parameter. + * `script`- A string specifying the target script. + * `text`- A string giving the translated text in the target script. + The `transliteration` object is not included if transliteration does not take place. + *`alignment`- An object with a single string property named `proj`, which 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. See Obtain alignment information for an example and restrictions. + * `sentLen`- An object returning sentence boundaries in the input and output texts. + * `srcSentLen`- 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. + * `transSentLen`- 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. + Sentence boundaries are only included when the request parameter `includeSentenceLength` is `true`. + * `sourceText`- An object with a single string property named `text`, which gives the 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. + Example of JSON responses are provided in the examples section. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<TranslateResultAllItem> object + */ + Observable> translateAsync(List to, List text); + + /** + * Translates text into one or more languages. + * + * @param to Specifies the language of the output text. Find which languages are available to translate to by using the languages method. For example, use `to=de` to translate to German. + It's possible to translate to multiple languages simultaneously by repeating the `to` parameter in the query string. For example, use `to=de&to=it` to translate to German and Italian in the same request. + * @param text # Request body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the string to translate. + The following limitations apply: + * The array can have at most 25 elements. + * The entire text included in the request cannot exceed 5,000 characters including spaces. + # Response body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties- + * `detectedLanguage`- An object describing the detected language through the following properties. + * `language`- A string representing the code of the detected 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. + The `detectedLanguage` property is only present in the result object when language auto-detection is requested. + * `translations`- An array of translation results. The size of the array matches the number of target languages specified in the `to` query parameter. Each element in the array includes. + * `to` A string representing the language code of the target language. + * `text`- A string giving the translated text. + * `transliteration`- An object giving the translated text in the script specified by the `toScript` parameter. + * `script`- A string specifying the target script. + * `text`- A string giving the translated text in the target script. + The `transliteration` object is not included if transliteration does not take place. + *`alignment`- An object with a single string property named `proj`, which 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. See Obtain alignment information for an example and restrictions. + * `sentLen`- An object returning sentence boundaries in the input and output texts. + * `srcSentLen`- 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. + * `transSentLen`- 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. + Sentence boundaries are only included when the request parameter `includeSentenceLength` is `true`. + * `sourceText`- An object with a single string property named `text`, which gives the 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. + Example of JSON responses are provided in the examples section. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<TranslateResultAllItem> object + */ + Observable>> translateWithServiceResponseAsync(List to, List text); + /** + * Translates text into one or more languages. + * + * @param to Specifies the language of the output text. Find which languages are available to translate to by using the languages method. For example, use `to=de` to translate to German. + It's possible to translate to multiple languages simultaneously by repeating the `to` parameter in the query string. For example, use `to=de&to=it` to translate to German and Italian in the same request. + * @param text # Request body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the string to translate. + The following limitations apply: + * The array can have at most 25 elements. + * The entire text included in the request cannot exceed 5,000 characters including spaces. + # Response body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties- + * `detectedLanguage`- An object describing the detected language through the following properties. + * `language`- A string representing the code of the detected 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. + The `detectedLanguage` property is only present in the result object when language auto-detection is requested. + * `translations`- An array of translation results. The size of the array matches the number of target languages specified in the `to` query parameter. Each element in the array includes. + * `to` A string representing the language code of the target language. + * `text`- A string giving the translated text. + * `transliteration`- An object giving the translated text in the script specified by the `toScript` parameter. + * `script`- A string specifying the target script. + * `text`- A string giving the translated text in the target script. + The `transliteration` object is not included if transliteration does not take place. + *`alignment`- An object with a single string property named `proj`, which 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. See Obtain alignment information for an example and restrictions. + * `sentLen`- An object returning sentence boundaries in the input and output texts. + * `srcSentLen`- 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. + * `transSentLen`- 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. + Sentence boundaries are only included when the request parameter `includeSentenceLength` is `true`. + * `sourceText`- An object with a single string property named `text`, which gives the 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. + Example of JSON responses are provided in the examples section. + * @param from Specifies the language of the input text. Find which languages are available to translate from by using the languages method. If the `from` parameter is not specified, automatic language detection is applied to determine the source language. + * @param textType Defines whether the text being translated is plain text or HTML text. Any HTML needs to be a well-formed, complete HTML element. Possible values are `plain` (default) or `html` + . Possible values include: 'plain', 'html' + * @param category A string specifying the category (domain) of the translation. This parameter retrieves translations from a customized system built with Custom Translator. Default value is `general`. + * @param profanityAction Specifies how profanities should be treated in translations. Possible values are: `NoAction` (default), `Marked` or `Deleted`. + ### Handling Profanity + Normally the Translator service will retain profanity that is present in the source in the translation. The degree of profanity and the context that makes words profane differ between cultures, and as a result the degree of profanity in the target language may be amplified or reduced. + If you want to avoid getting profanity in the translation, regardless of the presence of profanity in the source text, you can use the profanity filtering option. The option allows you to choose whether you want to see profanity deleted, whether you want to mark profanities with appropriate tags (giving you the option to add your own post-processing), or you want no action taken. The accepted values of `ProfanityAction` are `Deleted`, `Marked` and `NoAction` (default). + | ProfanityAction | Action | + | ---------- | ---------- | + | `NoAction` | This is the default behavior. Profanity will pass from source to target. | + | | Example Source (Japanese)- 彼はジャッカスです。 | + | | Example Translation (English)- He is a jackass. | + | | | + | `Deleted` | Profane words will be removed from the output without replacement. | + | | Example Source (Japanese)- 彼はジャッカスです。 | + | | Example Translation (English)- He is a. | + | `Marked` | Profane words are replaced by a marker in the output. The marker depends on the `ProfanityMarker` parameter. + | | For `ProfanityMarker=Asterisk`, profane words are replaced with `***` | + | | Example Source (Japanese)- 彼はジャッカスです。 | + | | Example Translation (English)- He is a ***. | + | | For `ProfanityMarker=Tag`, profane words are surrounded by XML tags <profanity> and </profanity> + | | Example Source (Japanese)- 彼はジャッカスです。 | + | | Example Translation (English)- He is a <profanity>jackass</profanity>. + . Possible values include: 'NoAction', 'Marked', '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 suggestedFrom Specifies a fallback language if the language of the input text can't be identified. Language auto-detection is applied when the `from` parameter is omitted. If detection fails, the `suggestedFrom` language will be assumed. + * @param fromScript Specifies the script of the input text. Supported scripts are available from the languages method + * @param toScript Specifies the script of the translated text. Supported scripts are available from the languages method + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorMessageException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<TranslateResultAllItem> object if successful. + */ + List translate(List to, List text, String from, String textType, String category, String profanityAction, String profanityMarker, Boolean includeAlignment, Boolean includeSentenceLength, String suggestedFrom, String fromScript, List toScript, String xClientTraceId); + + /** + * Translates text into one or more languages. + * + * @param to Specifies the language of the output text. Find which languages are available to translate to by using the languages method. For example, use `to=de` to translate to German. + It's possible to translate to multiple languages simultaneously by repeating the `to` parameter in the query string. For example, use `to=de&to=it` to translate to German and Italian in the same request. + * @param text # Request body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the string to translate. + The following limitations apply: + * The array can have at most 25 elements. + * The entire text included in the request cannot exceed 5,000 characters including spaces. + # Response body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties- + * `detectedLanguage`- An object describing the detected language through the following properties. + * `language`- A string representing the code of the detected 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. + The `detectedLanguage` property is only present in the result object when language auto-detection is requested. + * `translations`- An array of translation results. The size of the array matches the number of target languages specified in the `to` query parameter. Each element in the array includes. + * `to` A string representing the language code of the target language. + * `text`- A string giving the translated text. + * `transliteration`- An object giving the translated text in the script specified by the `toScript` parameter. + * `script`- A string specifying the target script. + * `text`- A string giving the translated text in the target script. + The `transliteration` object is not included if transliteration does not take place. + *`alignment`- An object with a single string property named `proj`, which 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. See Obtain alignment information for an example and restrictions. + * `sentLen`- An object returning sentence boundaries in the input and output texts. + * `srcSentLen`- 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. + * `transSentLen`- 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. + Sentence boundaries are only included when the request parameter `includeSentenceLength` is `true`. + * `sourceText`- An object with a single string property named `text`, which gives the 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. + Example of JSON responses are provided in the examples section. + * @param from Specifies the language of the input text. Find which languages are available to translate from by using the languages method. If the `from` parameter is not specified, automatic language detection is applied to determine the source language. + * @param textType Defines whether the text being translated is plain text or HTML text. Any HTML needs to be a well-formed, complete HTML element. Possible values are `plain` (default) or `html` + . Possible values include: 'plain', 'html' + * @param category A string specifying the category (domain) of the translation. This parameter retrieves translations from a customized system built with Custom Translator. Default value is `general`. + * @param profanityAction Specifies how profanities should be treated in translations. Possible values are: `NoAction` (default), `Marked` or `Deleted`. + ### Handling Profanity + Normally the Translator service will retain profanity that is present in the source in the translation. The degree of profanity and the context that makes words profane differ between cultures, and as a result the degree of profanity in the target language may be amplified or reduced. + If you want to avoid getting profanity in the translation, regardless of the presence of profanity in the source text, you can use the profanity filtering option. The option allows you to choose whether you want to see profanity deleted, whether you want to mark profanities with appropriate tags (giving you the option to add your own post-processing), or you want no action taken. The accepted values of `ProfanityAction` are `Deleted`, `Marked` and `NoAction` (default). + | ProfanityAction | Action | + | ---------- | ---------- | + | `NoAction` | This is the default behavior. Profanity will pass from source to target. | + | | Example Source (Japanese)- 彼はジャッカスです。 | + | | Example Translation (English)- He is a jackass. | + | | | + | `Deleted` | Profane words will be removed from the output without replacement. | + | | Example Source (Japanese)- 彼はジャッカスです。 | + | | Example Translation (English)- He is a. | + | `Marked` | Profane words are replaced by a marker in the output. The marker depends on the `ProfanityMarker` parameter. + | | For `ProfanityMarker=Asterisk`, profane words are replaced with `***` | + | | Example Source (Japanese)- 彼はジャッカスです。 | + | | Example Translation (English)- He is a ***. | + | | For `ProfanityMarker=Tag`, profane words are surrounded by XML tags <profanity> and </profanity> + | | Example Source (Japanese)- 彼はジャッカスです。 | + | | Example Translation (English)- He is a <profanity>jackass</profanity>. + . Possible values include: 'NoAction', 'Marked', '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 suggestedFrom Specifies a fallback language if the language of the input text can't be identified. Language auto-detection is applied when the `from` parameter is omitted. If detection fails, the `suggestedFrom` language will be assumed. + * @param fromScript Specifies the script of the input text. Supported scripts are available from the languages method + * @param toScript Specifies the script of the translated text. Supported scripts are available from the languages method + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> translateAsync(List to, List text, String from, String textType, String category, String profanityAction, String profanityMarker, Boolean includeAlignment, Boolean includeSentenceLength, String suggestedFrom, String fromScript, List toScript, String xClientTraceId, final ServiceCallback> serviceCallback); + + /** + * Translates text into one or more languages. + * + * @param to Specifies the language of the output text. Find which languages are available to translate to by using the languages method. For example, use `to=de` to translate to German. + It's possible to translate to multiple languages simultaneously by repeating the `to` parameter in the query string. For example, use `to=de&to=it` to translate to German and Italian in the same request. + * @param text # Request body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the string to translate. + The following limitations apply: + * The array can have at most 25 elements. + * The entire text included in the request cannot exceed 5,000 characters including spaces. + # Response body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties- + * `detectedLanguage`- An object describing the detected language through the following properties. + * `language`- A string representing the code of the detected 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. + The `detectedLanguage` property is only present in the result object when language auto-detection is requested. + * `translations`- An array of translation results. The size of the array matches the number of target languages specified in the `to` query parameter. Each element in the array includes. + * `to` A string representing the language code of the target language. + * `text`- A string giving the translated text. + * `transliteration`- An object giving the translated text in the script specified by the `toScript` parameter. + * `script`- A string specifying the target script. + * `text`- A string giving the translated text in the target script. + The `transliteration` object is not included if transliteration does not take place. + *`alignment`- An object with a single string property named `proj`, which 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. See Obtain alignment information for an example and restrictions. + * `sentLen`- An object returning sentence boundaries in the input and output texts. + * `srcSentLen`- 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. + * `transSentLen`- 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. + Sentence boundaries are only included when the request parameter `includeSentenceLength` is `true`. + * `sourceText`- An object with a single string property named `text`, which gives the 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. + Example of JSON responses are provided in the examples section. + * @param from Specifies the language of the input text. Find which languages are available to translate from by using the languages method. If the `from` parameter is not specified, automatic language detection is applied to determine the source language. + * @param textType Defines whether the text being translated is plain text or HTML text. Any HTML needs to be a well-formed, complete HTML element. Possible values are `plain` (default) or `html` + . Possible values include: 'plain', 'html' + * @param category A string specifying the category (domain) of the translation. This parameter retrieves translations from a customized system built with Custom Translator. Default value is `general`. + * @param profanityAction Specifies how profanities should be treated in translations. Possible values are: `NoAction` (default), `Marked` or `Deleted`. + ### Handling Profanity + Normally the Translator service will retain profanity that is present in the source in the translation. The degree of profanity and the context that makes words profane differ between cultures, and as a result the degree of profanity in the target language may be amplified or reduced. + If you want to avoid getting profanity in the translation, regardless of the presence of profanity in the source text, you can use the profanity filtering option. The option allows you to choose whether you want to see profanity deleted, whether you want to mark profanities with appropriate tags (giving you the option to add your own post-processing), or you want no action taken. The accepted values of `ProfanityAction` are `Deleted`, `Marked` and `NoAction` (default). + | ProfanityAction | Action | + | ---------- | ---------- | + | `NoAction` | This is the default behavior. Profanity will pass from source to target. | + | | Example Source (Japanese)- 彼はジャッカスです。 | + | | Example Translation (English)- He is a jackass. | + | | | + | `Deleted` | Profane words will be removed from the output without replacement. | + | | Example Source (Japanese)- 彼はジャッカスです。 | + | | Example Translation (English)- He is a. | + | `Marked` | Profane words are replaced by a marker in the output. The marker depends on the `ProfanityMarker` parameter. + | | For `ProfanityMarker=Asterisk`, profane words are replaced with `***` | + | | Example Source (Japanese)- 彼はジャッカスです。 | + | | Example Translation (English)- He is a ***. | + | | For `ProfanityMarker=Tag`, profane words are surrounded by XML tags <profanity> and </profanity> + | | Example Source (Japanese)- 彼はジャッカスです。 | + | | Example Translation (English)- He is a <profanity>jackass</profanity>. + . Possible values include: 'NoAction', 'Marked', '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 suggestedFrom Specifies a fallback language if the language of the input text can't be identified. Language auto-detection is applied when the `from` parameter is omitted. If detection fails, the `suggestedFrom` language will be assumed. + * @param fromScript Specifies the script of the input text. Supported scripts are available from the languages method + * @param toScript Specifies the script of the translated text. Supported scripts are available from the languages method + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<TranslateResultAllItem> object + */ + Observable> translateAsync(List to, List text, String from, String textType, String category, String profanityAction, String profanityMarker, Boolean includeAlignment, Boolean includeSentenceLength, String suggestedFrom, String fromScript, List toScript, String xClientTraceId); + + /** + * Translates text into one or more languages. + * + * @param to Specifies the language of the output text. Find which languages are available to translate to by using the languages method. For example, use `to=de` to translate to German. + It's possible to translate to multiple languages simultaneously by repeating the `to` parameter in the query string. For example, use `to=de&to=it` to translate to German and Italian in the same request. + * @param text # Request body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the string to translate. + The following limitations apply: + * The array can have at most 25 elements. + * The entire text included in the request cannot exceed 5,000 characters including spaces. + # Response body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties- + * `detectedLanguage`- An object describing the detected language through the following properties. + * `language`- A string representing the code of the detected 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. + The `detectedLanguage` property is only present in the result object when language auto-detection is requested. + * `translations`- An array of translation results. The size of the array matches the number of target languages specified in the `to` query parameter. Each element in the array includes. + * `to` A string representing the language code of the target language. + * `text`- A string giving the translated text. + * `transliteration`- An object giving the translated text in the script specified by the `toScript` parameter. + * `script`- A string specifying the target script. + * `text`- A string giving the translated text in the target script. + The `transliteration` object is not included if transliteration does not take place. + *`alignment`- An object with a single string property named `proj`, which 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. See Obtain alignment information for an example and restrictions. + * `sentLen`- An object returning sentence boundaries in the input and output texts. + * `srcSentLen`- 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. + * `transSentLen`- 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. + Sentence boundaries are only included when the request parameter `includeSentenceLength` is `true`. + * `sourceText`- An object with a single string property named `text`, which gives the 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. + Example of JSON responses are provided in the examples section. + * @param from Specifies the language of the input text. Find which languages are available to translate from by using the languages method. If the `from` parameter is not specified, automatic language detection is applied to determine the source language. + * @param textType Defines whether the text being translated is plain text or HTML text. Any HTML needs to be a well-formed, complete HTML element. Possible values are `plain` (default) or `html` + . Possible values include: 'plain', 'html' + * @param category A string specifying the category (domain) of the translation. This parameter retrieves translations from a customized system built with Custom Translator. Default value is `general`. + * @param profanityAction Specifies how profanities should be treated in translations. Possible values are: `NoAction` (default), `Marked` or `Deleted`. + ### Handling Profanity + Normally the Translator service will retain profanity that is present in the source in the translation. The degree of profanity and the context that makes words profane differ between cultures, and as a result the degree of profanity in the target language may be amplified or reduced. + If you want to avoid getting profanity in the translation, regardless of the presence of profanity in the source text, you can use the profanity filtering option. The option allows you to choose whether you want to see profanity deleted, whether you want to mark profanities with appropriate tags (giving you the option to add your own post-processing), or you want no action taken. The accepted values of `ProfanityAction` are `Deleted`, `Marked` and `NoAction` (default). + | ProfanityAction | Action | + | ---------- | ---------- | + | `NoAction` | This is the default behavior. Profanity will pass from source to target. | + | | Example Source (Japanese)- 彼はジャッカスです。 | + | | Example Translation (English)- He is a jackass. | + | | | + | `Deleted` | Profane words will be removed from the output without replacement. | + | | Example Source (Japanese)- 彼はジャッカスです。 | + | | Example Translation (English)- He is a. | + | `Marked` | Profane words are replaced by a marker in the output. The marker depends on the `ProfanityMarker` parameter. + | | For `ProfanityMarker=Asterisk`, profane words are replaced with `***` | + | | Example Source (Japanese)- 彼はジャッカスです。 | + | | Example Translation (English)- He is a ***. | + | | For `ProfanityMarker=Tag`, profane words are surrounded by XML tags <profanity> and </profanity> + | | Example Source (Japanese)- 彼はジャッカスです。 | + | | Example Translation (English)- He is a <profanity>jackass</profanity>. + . Possible values include: 'NoAction', 'Marked', '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 suggestedFrom Specifies a fallback language if the language of the input text can't be identified. Language auto-detection is applied when the `from` parameter is omitted. If detection fails, the `suggestedFrom` language will be assumed. + * @param fromScript Specifies the script of the input text. Supported scripts are available from the languages method + * @param toScript Specifies the script of the translated text. Supported scripts are available from the languages method + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<TranslateResultAllItem> object + */ + Observable>> translateWithServiceResponseAsync(List to, List text, String from, String textType, String category, String profanityAction, String profanityMarker, Boolean includeAlignment, Boolean includeSentenceLength, String suggestedFrom, String fromScript, List toScript, String xClientTraceId); + + /** + * Converts the text of a language in one script into another type of script. Example- + Japanese script "こんにちは" + Same word in Latin script "konnichiha". + * + * @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. Lookup supported languages using the `transliteration` scope, to find input scripts available for the selected language. + * @param toScript Specifies the output script. Lookup supported languages using the `transliteration` scope, to find output scripts available for the selected combination of input language and input script. + * @param texts # Request body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the string to convert. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 1,000 characters including spaces. + * The entire text included in the request cannot exceed 5,000 characters including spaces. + # Response body + A successful response is a JSON array with one result for each element in the input array. A result object includes the following properties: + * `text`- A string which is the result of converting the input string to the output script. + * `script`- A string specifying the script used in the output. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorMessageException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<TransliterateResultItem> object if successful. + */ + List transliterate(String language, String fromScript, String toScript, List texts); + + /** + * Converts the text of a language in one script into another type of script. Example- + Japanese script "こんにちは" + Same word in Latin script "konnichiha". + * + * @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. Lookup supported languages using the `transliteration` scope, to find input scripts available for the selected language. + * @param toScript Specifies the output script. Lookup supported languages using the `transliteration` scope, to find output scripts available for the selected combination of input language and input script. + * @param texts # Request body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the string to convert. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 1,000 characters including spaces. + * The entire text included in the request cannot exceed 5,000 characters including spaces. + # Response body + A successful response is a JSON array with one result for each element in the input array. A result object includes the following properties: + * `text`- A string which is the result of converting the input string to the output script. + * `script`- A string specifying the script used in the output. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> transliterateAsync(String language, String fromScript, String toScript, List texts, final ServiceCallback> serviceCallback); + + /** + * Converts the text of a language in one script into another type of script. Example- + Japanese script "こんにちは" + Same word in Latin script "konnichiha". + * + * @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. Lookup supported languages using the `transliteration` scope, to find input scripts available for the selected language. + * @param toScript Specifies the output script. Lookup supported languages using the `transliteration` scope, to find output scripts available for the selected combination of input language and input script. + * @param texts # Request body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the string to convert. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 1,000 characters including spaces. + * The entire text included in the request cannot exceed 5,000 characters including spaces. + # Response body + A successful response is a JSON array with one result for each element in the input array. A result object includes the following properties: + * `text`- A string which is the result of converting the input string to the output script. + * `script`- A string specifying the script used in the output. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<TransliterateResultItem> object + */ + Observable> transliterateAsync(String language, String fromScript, String toScript, List texts); + + /** + * Converts the text of a language in one script into another type of script. Example- + Japanese script "こんにちは" + Same word in Latin script "konnichiha". + * + * @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. Lookup supported languages using the `transliteration` scope, to find input scripts available for the selected language. + * @param toScript Specifies the output script. Lookup supported languages using the `transliteration` scope, to find output scripts available for the selected combination of input language and input script. + * @param texts # Request body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the string to convert. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 1,000 characters including spaces. + * The entire text included in the request cannot exceed 5,000 characters including spaces. + # Response body + A successful response is a JSON array with one result for each element in the input array. A result object includes the following properties: + * `text`- A string which is the result of converting the input string to the output script. + * `script`- A string specifying the script used in the output. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<TransliterateResultItem> object + */ + Observable>> transliterateWithServiceResponseAsync(String language, String fromScript, String toScript, List texts); + /** + * Converts the text of a language in one script into another type of script. Example- + Japanese script "こんにちは" + Same word in Latin script "konnichiha". + * + * @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. Lookup supported languages using the `transliteration` scope, to find input scripts available for the selected language. + * @param toScript Specifies the output script. Lookup supported languages using the `transliteration` scope, to find output scripts available for the selected combination of input language and input script. + * @param texts # Request body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the string to convert. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 1,000 characters including spaces. + * The entire text included in the request cannot exceed 5,000 characters including spaces. + # Response body + A successful response is a JSON array with one result for each element in the input array. A result object includes the following properties: + * `text`- A string which is the result of converting the input string to the output script. + * `script`- A string specifying the script used in the output. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorMessageException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<TransliterateResultItem> object if successful. + */ + List transliterate(String language, String fromScript, String toScript, List texts, String xClientTraceId); + + /** + * Converts the text of a language in one script into another type of script. Example- + Japanese script "こんにちは" + Same word in Latin script "konnichiha". + * + * @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. Lookup supported languages using the `transliteration` scope, to find input scripts available for the selected language. + * @param toScript Specifies the output script. Lookup supported languages using the `transliteration` scope, to find output scripts available for the selected combination of input language and input script. + * @param texts # Request body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the string to convert. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 1,000 characters including spaces. + * The entire text included in the request cannot exceed 5,000 characters including spaces. + # Response body + A successful response is a JSON array with one result for each element in the input array. A result object includes the following properties: + * `text`- A string which is the result of converting the input string to the output script. + * `script`- A string specifying the script used in the output. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> transliterateAsync(String language, String fromScript, String toScript, List texts, String xClientTraceId, final ServiceCallback> serviceCallback); + + /** + * Converts the text of a language in one script into another type of script. Example- + Japanese script "こんにちは" + Same word in Latin script "konnichiha". + * + * @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. Lookup supported languages using the `transliteration` scope, to find input scripts available for the selected language. + * @param toScript Specifies the output script. Lookup supported languages using the `transliteration` scope, to find output scripts available for the selected combination of input language and input script. + * @param texts # Request body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the string to convert. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 1,000 characters including spaces. + * The entire text included in the request cannot exceed 5,000 characters including spaces. + # Response body + A successful response is a JSON array with one result for each element in the input array. A result object includes the following properties: + * `text`- A string which is the result of converting the input string to the output script. + * `script`- A string specifying the script used in the output. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<TransliterateResultItem> object + */ + Observable> transliterateAsync(String language, String fromScript, String toScript, List texts, String xClientTraceId); + + /** + * Converts the text of a language in one script into another type of script. Example- + Japanese script "こんにちは" + Same word in Latin script "konnichiha". + * + * @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. Lookup supported languages using the `transliteration` scope, to find input scripts available for the selected language. + * @param toScript Specifies the output script. Lookup supported languages using the `transliteration` scope, to find output scripts available for the selected combination of input language and input script. + * @param texts # Request body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the string to convert. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 1,000 characters including spaces. + * The entire text included in the request cannot exceed 5,000 characters including spaces. + # Response body + A successful response is a JSON array with one result for each element in the input array. A result object includes the following properties: + * `text`- A string which is the result of converting the input string to the output script. + * `script`- A string specifying the script used in the output. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<TransliterateResultItem> object + */ + Observable>> transliterateWithServiceResponseAsync(String language, String fromScript, String toScript, List texts, String xClientTraceId); + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/implementation/TranslatorTextClientImpl.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/implementation/TranslatorTextClientImpl.java new file mode 100644 index 0000000000000..0adbee1539a41 --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/implementation/TranslatorTextClientImpl.java @@ -0,0 +1,198 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.implementation; + +import com.microsoft.azure.AzureClient; +import com.microsoft.azure.AzureServiceClient; +import com.microsoft.azure.cognitiveservices.translatortext.Translators; +import com.microsoft.azure.cognitiveservices.translatortext.TranslatorTextClient; +import com.microsoft.rest.credentials.ServiceClientCredentials; +import com.microsoft.rest.RestClient; + +/** + * Initializes a new instance of the TranslatorTextClientImpl class. + */ +public class TranslatorTextClientImpl extends AzureServiceClient implements TranslatorTextClient { + /** the {@link AzureClient} used for long running operations. */ + private AzureClient azureClient; + + /** + * Gets the {@link AzureClient} used for long running operations. + * @return the azure client; + */ + public AzureClient getAzureClient() { + return this.azureClient; + } + + /** Supported Cognitive Services endpoints. */ + private String endpoint; + + /** + * Gets Supported Cognitive Services endpoints. + * + * @return the endpoint value. + */ + public String endpoint() { + return this.endpoint; + } + + /** + * Sets Supported Cognitive Services endpoints. + * + * @param endpoint the endpoint value. + * @return the service client itself + */ + public TranslatorTextClientImpl withEndpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** Version of the API requested by the client. Value must be **3.0**. */ + private String apiVersion; + + /** + * Gets Version of the API requested by the client. Value must be **3.0**. + * + * @return the apiVersion value. + */ + public String apiVersion() { + return this.apiVersion; + } + + /** The preferred language for the response. */ + private String acceptLanguage; + + /** + * Gets The preferred language for the response. + * + * @return the acceptLanguage value. + */ + public String acceptLanguage() { + return this.acceptLanguage; + } + + /** + * Sets The preferred language for the response. + * + * @param acceptLanguage the acceptLanguage value. + * @return the service client itself + */ + public TranslatorTextClientImpl withAcceptLanguage(String acceptLanguage) { + this.acceptLanguage = acceptLanguage; + return this; + } + + /** The retry timeout in seconds for Long Running Operations. Default value is 30. */ + private int longRunningOperationRetryTimeout; + + /** + * Gets The retry timeout in seconds for Long Running Operations. Default value is 30. + * + * @return the longRunningOperationRetryTimeout value. + */ + public int longRunningOperationRetryTimeout() { + return this.longRunningOperationRetryTimeout; + } + + /** + * Sets The retry timeout in seconds for Long Running Operations. Default value is 30. + * + * @param longRunningOperationRetryTimeout the longRunningOperationRetryTimeout value. + * @return the service client itself + */ + public TranslatorTextClientImpl withLongRunningOperationRetryTimeout(int longRunningOperationRetryTimeout) { + this.longRunningOperationRetryTimeout = longRunningOperationRetryTimeout; + return this; + } + + /** Whether a unique x-ms-client-request-id should be generated. When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. */ + private boolean generateClientRequestId; + + /** + * Gets Whether a unique x-ms-client-request-id should be generated. When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + * + * @return the generateClientRequestId value. + */ + public boolean generateClientRequestId() { + return this.generateClientRequestId; + } + + /** + * Sets Whether a unique x-ms-client-request-id should be generated. When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + * + * @param generateClientRequestId the generateClientRequestId value. + * @return the service client itself + */ + public TranslatorTextClientImpl withGenerateClientRequestId(boolean generateClientRequestId) { + this.generateClientRequestId = generateClientRequestId; + return this; + } + + /** + * The Translators object to access its operations. + */ + private Translators translators; + + /** + * Gets the Translators object to access its operations. + * @return the Translators object. + */ + public Translators translators() { + return this.translators; + } + + /** + * Initializes an instance of TranslatorTextClient client. + * + * @param credentials the management credentials for Azure + */ + public TranslatorTextClientImpl(ServiceClientCredentials credentials) { + this("https://{Endpoint}", credentials); + } + + /** + * Initializes an instance of TranslatorTextClient client. + * + * @param baseUrl the base URL of the host + * @param credentials the management credentials for Azure + */ + private TranslatorTextClientImpl(String baseUrl, ServiceClientCredentials credentials) { + super(baseUrl, credentials); + initialize(); + } + + /** + * Initializes an instance of TranslatorTextClient client. + * + * @param restClient the REST client to connect to Azure. + */ + public TranslatorTextClientImpl(RestClient restClient) { + super(restClient); + initialize(); + } + + protected void initialize() { + this.apiVersion = "3.0"; + this.acceptLanguage = "en-US"; + this.longRunningOperationRetryTimeout = 30; + this.generateClientRequestId = true; + this.translators = new TranslatorsImpl(restClient().retrofit(), this); + this.azureClient = new AzureClient(this); + } + + /** + * Gets the User-Agent header for the client. + * + * @return the user agent string. + */ + @Override + public String userAgent() { + return String.format("%s (%s, %s)", super.userAgent(), "TranslatorTextClient", "3.0"); + } +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/implementation/TranslatorsImpl.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/implementation/TranslatorsImpl.java new file mode 100644 index 0000000000000..bfa03801c1402 --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/implementation/TranslatorsImpl.java @@ -0,0 +1,3313 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.implementation; + +import retrofit2.Retrofit; +import com.microsoft.azure.cognitiveservices.translatortext.Translators; +import com.google.common.base.Joiner; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.cognitiveservices.translatortext.models.BreakSentenceResultItem; +import com.microsoft.azure.cognitiveservices.translatortext.models.BreakSentenceTextInput; +import com.microsoft.azure.cognitiveservices.translatortext.models.DetectResultItem; +import com.microsoft.azure.cognitiveservices.translatortext.models.DetectTextInput; +import com.microsoft.azure.cognitiveservices.translatortext.models.DictionaryExampleResultItem; +import com.microsoft.azure.cognitiveservices.translatortext.models.DictionaryExampleTextInput; +import com.microsoft.azure.cognitiveservices.translatortext.models.DictionaryLookupResultItem; +import com.microsoft.azure.cognitiveservices.translatortext.models.DictionaryLookupTextInput; +import com.microsoft.azure.cognitiveservices.translatortext.models.ErrorMessageException; +import com.microsoft.azure.cognitiveservices.translatortext.models.LanguagesResult; +import com.microsoft.azure.cognitiveservices.translatortext.models.TranslateResultAllItem; +import com.microsoft.azure.cognitiveservices.translatortext.models.TranslateTextInput; +import com.microsoft.azure.cognitiveservices.translatortext.models.TransliterateResultItem; +import com.microsoft.azure.cognitiveservices.translatortext.models.TransliterateTextInput; +import com.microsoft.rest.CollectionFormat; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.Validator; +import java.io.IOException; +import java.util.List; +import okhttp3.ResponseBody; +import retrofit2.http.Body; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.POST; +import retrofit2.http.Query; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in Translators. + */ +public class TranslatorsImpl implements Translators { + /** The Retrofit service to perform REST calls. */ + private TranslatorsService service; + /** The service client containing this operation class. */ + private TranslatorTextClientImpl client; + + /** + * Initializes an instance of TranslatorsImpl. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public TranslatorsImpl(Retrofit retrofit, TranslatorTextClientImpl client) { + this.service = retrofit.create(TranslatorsService.class); + this.client = client; + } + + /** + * The interface defining all the services for Translators to be + * used by Retrofit to perform actually REST calls. + */ + interface TranslatorsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.translatortext.Translators breakSentence" }) + @POST("BreakSentence") + Observable> breakSentence(@Query("api-version") String apiVersion, @Query("Language") String language, @Query("Script") String script, @Header("X-ClientTraceId") String xClientTraceId, @Body List text, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.translatortext.Translators detect" }) + @POST("Detect") + Observable> detect(@Query("api-version") String apiVersion, @Header("X-ClientTraceId") String xClientTraceId, @Body List text, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.translatortext.Translators dictionaryLookup" }) + @POST("Dictionary/Lookup") + Observable> dictionaryLookup(@Query("api-version") String apiVersion, @Query("from") String from, @Query("to") String to, @Header("X-ClientTraceId") String xClientTraceId, @Body List text, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.translatortext.Translators dictionaryExamples" }) + @POST("Dictionary/Examples") + Observable> dictionaryExamples(@Query("api-version") String apiVersion, @Query("from") String from, @Query("to") String to, @Header("X-ClientTraceId") String xClientTraceId, @Body List text, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.translatortext.Translators languages" }) + @GET("Languages") + Observable> languages(@Query("api-version") String apiVersion, @Query("scope") String scope, @Header("Accept-Language") String acceptLanguage, @Header("X-ClientTraceId") String xClientTraceId, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.translatortext.Translators translate" }) + @POST("translate") + Observable> translate(@Query("api-version") String apiVersion, @Query("from") String from, @Query("to") String to, @Query("textType") String textType, @Query("category") String category, @Query("profanityAction") String profanityAction, @Query("profanityMarker") String profanityMarker, @Query("includeAlignment") Boolean includeAlignment, @Query("includeSentenceLength") Boolean includeSentenceLength, @Query("suggestedFrom") String suggestedFrom, @Query("fromScript") String fromScript, @Query("toScript") String toScript, @Header("X-ClientTraceId") String xClientTraceId, @Body List text, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.translatortext.Translators transliterate" }) + @POST("transliterate") + Observable> transliterate(@Query("api-version") String apiVersion, @Query("language") String language, @Query("fromScript") String fromScript, @Query("toScript") String toScript, @Header("X-ClientTraceId") String xClientTraceId, @Body List texts, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + } + + /** + * Identifies the position of sentence boundaries in a piece of text. + * + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named Text. Sentence boundaries are computed for the value of the Text property. + The following limitations apply: + * The array can have at most 100 elements. + * The text value of an array element cannot exceed 10,000 characters including spaces. + * The entire text included in the request cannot exceed 50,000 characters including spaces. + * If the `language` query parameter is specified, then all array elements must be in the same language. Otherwise, language auto-detection is applied to each array element independently. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `sentLen`- An array of integers representing the lengths of the sentences in the text element. The length of the array is the number of sentences, and the values are the length of each sentence. + * `detectedLanguage`- An object describing the detected language through the following properties + * `language`- Code of the detected 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. + * Note that the `detectedLanguage` property is only present in the result object when language auto-detection is requested. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorMessageException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<BreakSentenceResultItem> object if successful. + */ + public List breakSentence(List text) { + return breakSentenceWithServiceResponseAsync(text).toBlocking().single().body(); + } + + /** + * Identifies the position of sentence boundaries in a piece of text. + * + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named Text. Sentence boundaries are computed for the value of the Text property. + The following limitations apply: + * The array can have at most 100 elements. + * The text value of an array element cannot exceed 10,000 characters including spaces. + * The entire text included in the request cannot exceed 50,000 characters including spaces. + * If the `language` query parameter is specified, then all array elements must be in the same language. Otherwise, language auto-detection is applied to each array element independently. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `sentLen`- An array of integers representing the lengths of the sentences in the text element. The length of the array is the number of sentences, and the values are the length of each sentence. + * `detectedLanguage`- An object describing the detected language through the following properties + * `language`- Code of the detected 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. + * Note that the `detectedLanguage` property is only present in the result object when language auto-detection is requested. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> breakSentenceAsync(List text, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(breakSentenceWithServiceResponseAsync(text), serviceCallback); + } + + /** + * Identifies the position of sentence boundaries in a piece of text. + * + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named Text. Sentence boundaries are computed for the value of the Text property. + The following limitations apply: + * The array can have at most 100 elements. + * The text value of an array element cannot exceed 10,000 characters including spaces. + * The entire text included in the request cannot exceed 50,000 characters including spaces. + * If the `language` query parameter is specified, then all array elements must be in the same language. Otherwise, language auto-detection is applied to each array element independently. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `sentLen`- An array of integers representing the lengths of the sentences in the text element. The length of the array is the number of sentences, and the values are the length of each sentence. + * `detectedLanguage`- An object describing the detected language through the following properties + * `language`- Code of the detected 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. + * Note that the `detectedLanguage` property is only present in the result object when language auto-detection is requested. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<BreakSentenceResultItem> object + */ + public Observable> breakSentenceAsync(List text) { + return breakSentenceWithServiceResponseAsync(text).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Identifies the position of sentence boundaries in a piece of text. + * + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named Text. Sentence boundaries are computed for the value of the Text property. + The following limitations apply: + * The array can have at most 100 elements. + * The text value of an array element cannot exceed 10,000 characters including spaces. + * The entire text included in the request cannot exceed 50,000 characters including spaces. + * If the `language` query parameter is specified, then all array elements must be in the same language. Otherwise, language auto-detection is applied to each array element independently. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `sentLen`- An array of integers representing the lengths of the sentences in the text element. The length of the array is the number of sentences, and the values are the length of each sentence. + * `detectedLanguage`- An object describing the detected language through the following properties + * `language`- Code of the detected 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. + * Note that the `detectedLanguage` property is only present in the result object when language auto-detection is requested. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<BreakSentenceResultItem> object + */ + public Observable>> breakSentenceWithServiceResponseAsync(List text) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + if (text == null) { + throw new IllegalArgumentException("Parameter text is required and cannot be null."); + } + Validator.validate(text); + final String language = null; + final String script = null; + final String xClientTraceId = null; + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.breakSentence(this.client.apiVersion(), language, script, xClientTraceId, text, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = breakSentenceDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Identifies the position of sentence boundaries in a piece of text. + * + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named Text. Sentence boundaries are computed for the value of the Text property. + The following limitations apply: + * The array can have at most 100 elements. + * The text value of an array element cannot exceed 10,000 characters including spaces. + * The entire text included in the request cannot exceed 50,000 characters including spaces. + * If the `language` query parameter is specified, then all array elements must be in the same language. Otherwise, language auto-detection is applied to each array element independently. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `sentLen`- An array of integers representing the lengths of the sentences in the text element. The length of the array is the number of sentences, and the values are the length of each sentence. + * `detectedLanguage`- An object describing the detected language through the following properties + * `language`- Code of the detected 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. + * Note that the `detectedLanguage` property is only present in the result object when language auto-detection is requested. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @param language Language tag of the language of the input text. If not specified, Translator will apply automatic language detection. + * @param script Script identifier of the script used by the input text. If a script is not specified, the default script of the language will be assumed. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorMessageException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<BreakSentenceResultItem> object if successful. + */ + public List breakSentence(List text, String language, String script, String xClientTraceId) { + return breakSentenceWithServiceResponseAsync(text, language, script, xClientTraceId).toBlocking().single().body(); + } + + /** + * Identifies the position of sentence boundaries in a piece of text. + * + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named Text. Sentence boundaries are computed for the value of the Text property. + The following limitations apply: + * The array can have at most 100 elements. + * The text value of an array element cannot exceed 10,000 characters including spaces. + * The entire text included in the request cannot exceed 50,000 characters including spaces. + * If the `language` query parameter is specified, then all array elements must be in the same language. Otherwise, language auto-detection is applied to each array element independently. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `sentLen`- An array of integers representing the lengths of the sentences in the text element. The length of the array is the number of sentences, and the values are the length of each sentence. + * `detectedLanguage`- An object describing the detected language through the following properties + * `language`- Code of the detected 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. + * Note that the `detectedLanguage` property is only present in the result object when language auto-detection is requested. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @param language Language tag of the language of the input text. If not specified, Translator will apply automatic language detection. + * @param script Script identifier of the script used by the input text. If a script is not specified, the default script of the language will be assumed. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> breakSentenceAsync(List text, String language, String script, String xClientTraceId, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(breakSentenceWithServiceResponseAsync(text, language, script, xClientTraceId), serviceCallback); + } + + /** + * Identifies the position of sentence boundaries in a piece of text. + * + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named Text. Sentence boundaries are computed for the value of the Text property. + The following limitations apply: + * The array can have at most 100 elements. + * The text value of an array element cannot exceed 10,000 characters including spaces. + * The entire text included in the request cannot exceed 50,000 characters including spaces. + * If the `language` query parameter is specified, then all array elements must be in the same language. Otherwise, language auto-detection is applied to each array element independently. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `sentLen`- An array of integers representing the lengths of the sentences in the text element. The length of the array is the number of sentences, and the values are the length of each sentence. + * `detectedLanguage`- An object describing the detected language through the following properties + * `language`- Code of the detected 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. + * Note that the `detectedLanguage` property is only present in the result object when language auto-detection is requested. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @param language Language tag of the language of the input text. If not specified, Translator will apply automatic language detection. + * @param script Script identifier of the script used by the input text. If a script is not specified, the default script of the language will be assumed. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<BreakSentenceResultItem> object + */ + public Observable> breakSentenceAsync(List text, String language, String script, String xClientTraceId) { + return breakSentenceWithServiceResponseAsync(text, language, script, xClientTraceId).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Identifies the position of sentence boundaries in a piece of text. + * + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named Text. Sentence boundaries are computed for the value of the Text property. + The following limitations apply: + * The array can have at most 100 elements. + * The text value of an array element cannot exceed 10,000 characters including spaces. + * The entire text included in the request cannot exceed 50,000 characters including spaces. + * If the `language` query parameter is specified, then all array elements must be in the same language. Otherwise, language auto-detection is applied to each array element independently. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `sentLen`- An array of integers representing the lengths of the sentences in the text element. The length of the array is the number of sentences, and the values are the length of each sentence. + * `detectedLanguage`- An object describing the detected language through the following properties + * `language`- Code of the detected 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. + * Note that the `detectedLanguage` property is only present in the result object when language auto-detection is requested. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @param language Language tag of the language of the input text. If not specified, Translator will apply automatic language detection. + * @param script Script identifier of the script used by the input text. If a script is not specified, the default script of the language will be assumed. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<BreakSentenceResultItem> object + */ + public Observable>> breakSentenceWithServiceResponseAsync(List text, String language, String script, String xClientTraceId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + if (text == null) { + throw new IllegalArgumentException("Parameter text is required and cannot be null."); + } + Validator.validate(text); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.breakSentence(this.client.apiVersion(), language, script, xClientTraceId, text, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = breakSentenceDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> breakSentenceDelegate(Response response) throws ErrorMessageException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorMessageException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorMessageException.class) + .build(response); + } + + /** + * Identifies the language of a string of text. + * + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named Text. Language detection is applied to the value of the Text property. + The following limitations apply: + * The array can have at most 100 elements. + * The text value of an array element cannot exceed 10,000 characters including spaces. + * The entire text included in the request cannot exceed 50,000 characters including spaces. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * language- Code of the detected 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. + * isTranslationSupported- A boolean value which is true if the detected language is one of the languages supported for text translation. Not all detected languages can be translated by the API. + * isTransliterationSupported- A boolean value which is true if the detected language is one of the languages supported for transliteration. + * alternatives- An array of other possible languages. Each element of the array is another object with the same properties listed above- language, score, isTranslationSupported and isTransliterationSupported. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorMessageException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<DetectResultItem> object if successful. + */ + public List detect(List text) { + return detectWithServiceResponseAsync(text).toBlocking().single().body(); + } + + /** + * Identifies the language of a string of text. + * + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named Text. Language detection is applied to the value of the Text property. + The following limitations apply: + * The array can have at most 100 elements. + * The text value of an array element cannot exceed 10,000 characters including spaces. + * The entire text included in the request cannot exceed 50,000 characters including spaces. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * language- Code of the detected 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. + * isTranslationSupported- A boolean value which is true if the detected language is one of the languages supported for text translation. Not all detected languages can be translated by the API. + * isTransliterationSupported- A boolean value which is true if the detected language is one of the languages supported for transliteration. + * alternatives- An array of other possible languages. Each element of the array is another object with the same properties listed above- language, score, isTranslationSupported and isTransliterationSupported. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> detectAsync(List text, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(detectWithServiceResponseAsync(text), serviceCallback); + } + + /** + * Identifies the language of a string of text. + * + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named Text. Language detection is applied to the value of the Text property. + The following limitations apply: + * The array can have at most 100 elements. + * The text value of an array element cannot exceed 10,000 characters including spaces. + * The entire text included in the request cannot exceed 50,000 characters including spaces. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * language- Code of the detected 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. + * isTranslationSupported- A boolean value which is true if the detected language is one of the languages supported for text translation. Not all detected languages can be translated by the API. + * isTransliterationSupported- A boolean value which is true if the detected language is one of the languages supported for transliteration. + * alternatives- An array of other possible languages. Each element of the array is another object with the same properties listed above- language, score, isTranslationSupported and isTransliterationSupported. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DetectResultItem> object + */ + public Observable> detectAsync(List text) { + return detectWithServiceResponseAsync(text).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Identifies the language of a string of text. + * + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named Text. Language detection is applied to the value of the Text property. + The following limitations apply: + * The array can have at most 100 elements. + * The text value of an array element cannot exceed 10,000 characters including spaces. + * The entire text included in the request cannot exceed 50,000 characters including spaces. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * language- Code of the detected 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. + * isTranslationSupported- A boolean value which is true if the detected language is one of the languages supported for text translation. Not all detected languages can be translated by the API. + * isTransliterationSupported- A boolean value which is true if the detected language is one of the languages supported for transliteration. + * alternatives- An array of other possible languages. Each element of the array is another object with the same properties listed above- language, score, isTranslationSupported and isTransliterationSupported. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DetectResultItem> object + */ + public Observable>> detectWithServiceResponseAsync(List text) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + if (text == null) { + throw new IllegalArgumentException("Parameter text is required and cannot be null."); + } + Validator.validate(text); + final String xClientTraceId = null; + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.detect(this.client.apiVersion(), xClientTraceId, text, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = detectDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Identifies the language of a string of text. + * + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named Text. Language detection is applied to the value of the Text property. + The following limitations apply: + * The array can have at most 100 elements. + * The text value of an array element cannot exceed 10,000 characters including spaces. + * The entire text included in the request cannot exceed 50,000 characters including spaces. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * language- Code of the detected 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. + * isTranslationSupported- A boolean value which is true if the detected language is one of the languages supported for text translation. Not all detected languages can be translated by the API. + * isTransliterationSupported- A boolean value which is true if the detected language is one of the languages supported for transliteration. + * alternatives- An array of other possible languages. Each element of the array is another object with the same properties listed above- language, score, isTranslationSupported and isTransliterationSupported. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorMessageException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<DetectResultItem> object if successful. + */ + public List detect(List text, String xClientTraceId) { + return detectWithServiceResponseAsync(text, xClientTraceId).toBlocking().single().body(); + } + + /** + * Identifies the language of a string of text. + * + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named Text. Language detection is applied to the value of the Text property. + The following limitations apply: + * The array can have at most 100 elements. + * The text value of an array element cannot exceed 10,000 characters including spaces. + * The entire text included in the request cannot exceed 50,000 characters including spaces. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * language- Code of the detected 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. + * isTranslationSupported- A boolean value which is true if the detected language is one of the languages supported for text translation. Not all detected languages can be translated by the API. + * isTransliterationSupported- A boolean value which is true if the detected language is one of the languages supported for transliteration. + * alternatives- An array of other possible languages. Each element of the array is another object with the same properties listed above- language, score, isTranslationSupported and isTransliterationSupported. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> detectAsync(List text, String xClientTraceId, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(detectWithServiceResponseAsync(text, xClientTraceId), serviceCallback); + } + + /** + * Identifies the language of a string of text. + * + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named Text. Language detection is applied to the value of the Text property. + The following limitations apply: + * The array can have at most 100 elements. + * The text value of an array element cannot exceed 10,000 characters including spaces. + * The entire text included in the request cannot exceed 50,000 characters including spaces. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * language- Code of the detected 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. + * isTranslationSupported- A boolean value which is true if the detected language is one of the languages supported for text translation. Not all detected languages can be translated by the API. + * isTransliterationSupported- A boolean value which is true if the detected language is one of the languages supported for transliteration. + * alternatives- An array of other possible languages. Each element of the array is another object with the same properties listed above- language, score, isTranslationSupported and isTransliterationSupported. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DetectResultItem> object + */ + public Observable> detectAsync(List text, String xClientTraceId) { + return detectWithServiceResponseAsync(text, xClientTraceId).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Identifies the language of a string of text. + * + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named Text. Language detection is applied to the value of the Text property. + The following limitations apply: + * The array can have at most 100 elements. + * The text value of an array element cannot exceed 10,000 characters including spaces. + * The entire text included in the request cannot exceed 50,000 characters including spaces. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * language- Code of the detected 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. + * isTranslationSupported- A boolean value which is true if the detected language is one of the languages supported for text translation. Not all detected languages can be translated by the API. + * isTransliterationSupported- A boolean value which is true if the detected language is one of the languages supported for transliteration. + * alternatives- An array of other possible languages. Each element of the array is another object with the same properties listed above- language, score, isTranslationSupported and isTransliterationSupported. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DetectResultItem> object + */ + public Observable>> detectWithServiceResponseAsync(List text, String xClientTraceId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + if (text == null) { + throw new IllegalArgumentException("Parameter text is required and cannot be null."); + } + Validator.validate(text); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.detect(this.client.apiVersion(), xClientTraceId, text, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = detectDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> detectDelegate(Response response) throws ErrorMessageException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorMessageException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorMessageException.class) + .build(response); + } + + /** + * Provides alternative translations for a word and a small number of idiomatic phrases. Each translation has a `part-of-speech` and a list of `back-translations`. The back-translations enable a user to understand the translation in context. The Dictionary Example operation allows further drill down to see example uses of each translation pair. + * + * @param from Specifies the language of the input text. The source language must be one of the supported languages included in the `dictionary` scope. + * @param to Specifies the language of the output text. The target language must be one of the supported languages included in the `dictionary` scope of the Languages resource. + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the term to lookup. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 100 characters including spaces. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `normalizedSource`- 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. + * `displaySource`- 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". + * `translations`- A list of translations for the source term. Each element of the list is an object with the following properties: + * `normalizedTarget`- A string giving the normalized form of this term in the target language. This value should be used as input to lookup examples. + * `displayTarget`- 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"`. + * `posTag`- A string associating this term with a part-of-speech tag. + | Tag name | Description | + | --------- | ---------------- | + | ADJ | Adjectives | + | ADV | Adverbs | + | CONJ | Conjunctions | + | DET | Determiners | + | MODAL | Verbs | + | NOUN | Nouns | + | PREP | Prepositions | + | PRON | Pronouns | + | VERB | Verbs | + | OTHER | Other | + As an implementation note, these tags were determined by part-of-speech tagging the English side, and then taking the most frequent tag for each source/target pair. So if people frequently translate a Spanish word to a different part-of-speech tag in English, tags may end up being wrong (with respect to the Spanish word). + * `confidence`- 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. + * `prefixWord-` A string giving the 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. + * `backTranslations-` 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. Each element of the `backTranslations` list is an object described by the following properties- + * `normalizedText-` 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. + * `displayText-` A string giving the source term that is a back-translation of the target in a form best suited for end-user display. + * `numExamples-` 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. + * `frequencyCount-` 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. + Note - If the term being looked up does not exist in the dictionary, the response is 200 (OK) but the `translations` list is an empty list. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorMessageException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<DictionaryLookupResultItem> object if successful. + */ + public List dictionaryLookup(String from, String to, List text) { + return dictionaryLookupWithServiceResponseAsync(from, to, text).toBlocking().single().body(); + } + + /** + * Provides alternative translations for a word and a small number of idiomatic phrases. Each translation has a `part-of-speech` and a list of `back-translations`. The back-translations enable a user to understand the translation in context. The Dictionary Example operation allows further drill down to see example uses of each translation pair. + * + * @param from Specifies the language of the input text. The source language must be one of the supported languages included in the `dictionary` scope. + * @param to Specifies the language of the output text. The target language must be one of the supported languages included in the `dictionary` scope of the Languages resource. + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the term to lookup. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 100 characters including spaces. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `normalizedSource`- 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. + * `displaySource`- 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". + * `translations`- A list of translations for the source term. Each element of the list is an object with the following properties: + * `normalizedTarget`- A string giving the normalized form of this term in the target language. This value should be used as input to lookup examples. + * `displayTarget`- 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"`. + * `posTag`- A string associating this term with a part-of-speech tag. + | Tag name | Description | + | --------- | ---------------- | + | ADJ | Adjectives | + | ADV | Adverbs | + | CONJ | Conjunctions | + | DET | Determiners | + | MODAL | Verbs | + | NOUN | Nouns | + | PREP | Prepositions | + | PRON | Pronouns | + | VERB | Verbs | + | OTHER | Other | + As an implementation note, these tags were determined by part-of-speech tagging the English side, and then taking the most frequent tag for each source/target pair. So if people frequently translate a Spanish word to a different part-of-speech tag in English, tags may end up being wrong (with respect to the Spanish word). + * `confidence`- 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. + * `prefixWord-` A string giving the 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. + * `backTranslations-` 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. Each element of the `backTranslations` list is an object described by the following properties- + * `normalizedText-` 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. + * `displayText-` A string giving the source term that is a back-translation of the target in a form best suited for end-user display. + * `numExamples-` 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. + * `frequencyCount-` 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. + Note - If the term being looked up does not exist in the dictionary, the response is 200 (OK) but the `translations` list is an empty list. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> dictionaryLookupAsync(String from, String to, List text, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(dictionaryLookupWithServiceResponseAsync(from, to, text), serviceCallback); + } + + /** + * Provides alternative translations for a word and a small number of idiomatic phrases. Each translation has a `part-of-speech` and a list of `back-translations`. The back-translations enable a user to understand the translation in context. The Dictionary Example operation allows further drill down to see example uses of each translation pair. + * + * @param from Specifies the language of the input text. The source language must be one of the supported languages included in the `dictionary` scope. + * @param to Specifies the language of the output text. The target language must be one of the supported languages included in the `dictionary` scope of the Languages resource. + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the term to lookup. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 100 characters including spaces. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `normalizedSource`- 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. + * `displaySource`- 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". + * `translations`- A list of translations for the source term. Each element of the list is an object with the following properties: + * `normalizedTarget`- A string giving the normalized form of this term in the target language. This value should be used as input to lookup examples. + * `displayTarget`- 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"`. + * `posTag`- A string associating this term with a part-of-speech tag. + | Tag name | Description | + | --------- | ---------------- | + | ADJ | Adjectives | + | ADV | Adverbs | + | CONJ | Conjunctions | + | DET | Determiners | + | MODAL | Verbs | + | NOUN | Nouns | + | PREP | Prepositions | + | PRON | Pronouns | + | VERB | Verbs | + | OTHER | Other | + As an implementation note, these tags were determined by part-of-speech tagging the English side, and then taking the most frequent tag for each source/target pair. So if people frequently translate a Spanish word to a different part-of-speech tag in English, tags may end up being wrong (with respect to the Spanish word). + * `confidence`- 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. + * `prefixWord-` A string giving the 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. + * `backTranslations-` 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. Each element of the `backTranslations` list is an object described by the following properties- + * `normalizedText-` 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. + * `displayText-` A string giving the source term that is a back-translation of the target in a form best suited for end-user display. + * `numExamples-` 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. + * `frequencyCount-` 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. + Note - If the term being looked up does not exist in the dictionary, the response is 200 (OK) but the `translations` list is an empty list. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DictionaryLookupResultItem> object + */ + public Observable> dictionaryLookupAsync(String from, String to, List text) { + return dictionaryLookupWithServiceResponseAsync(from, to, text).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Provides alternative translations for a word and a small number of idiomatic phrases. Each translation has a `part-of-speech` and a list of `back-translations`. The back-translations enable a user to understand the translation in context. The Dictionary Example operation allows further drill down to see example uses of each translation pair. + * + * @param from Specifies the language of the input text. The source language must be one of the supported languages included in the `dictionary` scope. + * @param to Specifies the language of the output text. The target language must be one of the supported languages included in the `dictionary` scope of the Languages resource. + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the term to lookup. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 100 characters including spaces. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `normalizedSource`- 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. + * `displaySource`- 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". + * `translations`- A list of translations for the source term. Each element of the list is an object with the following properties: + * `normalizedTarget`- A string giving the normalized form of this term in the target language. This value should be used as input to lookup examples. + * `displayTarget`- 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"`. + * `posTag`- A string associating this term with a part-of-speech tag. + | Tag name | Description | + | --------- | ---------------- | + | ADJ | Adjectives | + | ADV | Adverbs | + | CONJ | Conjunctions | + | DET | Determiners | + | MODAL | Verbs | + | NOUN | Nouns | + | PREP | Prepositions | + | PRON | Pronouns | + | VERB | Verbs | + | OTHER | Other | + As an implementation note, these tags were determined by part-of-speech tagging the English side, and then taking the most frequent tag for each source/target pair. So if people frequently translate a Spanish word to a different part-of-speech tag in English, tags may end up being wrong (with respect to the Spanish word). + * `confidence`- 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. + * `prefixWord-` A string giving the 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. + * `backTranslations-` 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. Each element of the `backTranslations` list is an object described by the following properties- + * `normalizedText-` 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. + * `displayText-` A string giving the source term that is a back-translation of the target in a form best suited for end-user display. + * `numExamples-` 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. + * `frequencyCount-` 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. + Note - If the term being looked up does not exist in the dictionary, the response is 200 (OK) but the `translations` list is an empty list. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DictionaryLookupResultItem> object + */ + public Observable>> dictionaryLookupWithServiceResponseAsync(String from, String to, List text) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + if (from == null) { + throw new IllegalArgumentException("Parameter from is required and cannot be null."); + } + if (to == null) { + throw new IllegalArgumentException("Parameter to is required and cannot be null."); + } + if (text == null) { + throw new IllegalArgumentException("Parameter text is required and cannot be null."); + } + Validator.validate(text); + final String xClientTraceId = null; + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.dictionaryLookup(this.client.apiVersion(), from, to, xClientTraceId, text, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = dictionaryLookupDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Provides alternative translations for a word and a small number of idiomatic phrases. Each translation has a `part-of-speech` and a list of `back-translations`. The back-translations enable a user to understand the translation in context. The Dictionary Example operation allows further drill down to see example uses of each translation pair. + * + * @param from Specifies the language of the input text. The source language must be one of the supported languages included in the `dictionary` scope. + * @param to Specifies the language of the output text. The target language must be one of the supported languages included in the `dictionary` scope of the Languages resource. + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the term to lookup. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 100 characters including spaces. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `normalizedSource`- 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. + * `displaySource`- 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". + * `translations`- A list of translations for the source term. Each element of the list is an object with the following properties: + * `normalizedTarget`- A string giving the normalized form of this term in the target language. This value should be used as input to lookup examples. + * `displayTarget`- 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"`. + * `posTag`- A string associating this term with a part-of-speech tag. + | Tag name | Description | + | --------- | ---------------- | + | ADJ | Adjectives | + | ADV | Adverbs | + | CONJ | Conjunctions | + | DET | Determiners | + | MODAL | Verbs | + | NOUN | Nouns | + | PREP | Prepositions | + | PRON | Pronouns | + | VERB | Verbs | + | OTHER | Other | + As an implementation note, these tags were determined by part-of-speech tagging the English side, and then taking the most frequent tag for each source/target pair. So if people frequently translate a Spanish word to a different part-of-speech tag in English, tags may end up being wrong (with respect to the Spanish word). + * `confidence`- 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. + * `prefixWord-` A string giving the 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. + * `backTranslations-` 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. Each element of the `backTranslations` list is an object described by the following properties- + * `normalizedText-` 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. + * `displayText-` A string giving the source term that is a back-translation of the target in a form best suited for end-user display. + * `numExamples-` 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. + * `frequencyCount-` 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. + Note - If the term being looked up does not exist in the dictionary, the response is 200 (OK) but the `translations` list is an empty list. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorMessageException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<DictionaryLookupResultItem> object if successful. + */ + public List dictionaryLookup(String from, String to, List text, String xClientTraceId) { + return dictionaryLookupWithServiceResponseAsync(from, to, text, xClientTraceId).toBlocking().single().body(); + } + + /** + * Provides alternative translations for a word and a small number of idiomatic phrases. Each translation has a `part-of-speech` and a list of `back-translations`. The back-translations enable a user to understand the translation in context. The Dictionary Example operation allows further drill down to see example uses of each translation pair. + * + * @param from Specifies the language of the input text. The source language must be one of the supported languages included in the `dictionary` scope. + * @param to Specifies the language of the output text. The target language must be one of the supported languages included in the `dictionary` scope of the Languages resource. + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the term to lookup. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 100 characters including spaces. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `normalizedSource`- 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. + * `displaySource`- 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". + * `translations`- A list of translations for the source term. Each element of the list is an object with the following properties: + * `normalizedTarget`- A string giving the normalized form of this term in the target language. This value should be used as input to lookup examples. + * `displayTarget`- 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"`. + * `posTag`- A string associating this term with a part-of-speech tag. + | Tag name | Description | + | --------- | ---------------- | + | ADJ | Adjectives | + | ADV | Adverbs | + | CONJ | Conjunctions | + | DET | Determiners | + | MODAL | Verbs | + | NOUN | Nouns | + | PREP | Prepositions | + | PRON | Pronouns | + | VERB | Verbs | + | OTHER | Other | + As an implementation note, these tags were determined by part-of-speech tagging the English side, and then taking the most frequent tag for each source/target pair. So if people frequently translate a Spanish word to a different part-of-speech tag in English, tags may end up being wrong (with respect to the Spanish word). + * `confidence`- 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. + * `prefixWord-` A string giving the 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. + * `backTranslations-` 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. Each element of the `backTranslations` list is an object described by the following properties- + * `normalizedText-` 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. + * `displayText-` A string giving the source term that is a back-translation of the target in a form best suited for end-user display. + * `numExamples-` 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. + * `frequencyCount-` 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. + Note - If the term being looked up does not exist in the dictionary, the response is 200 (OK) but the `translations` list is an empty list. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> dictionaryLookupAsync(String from, String to, List text, String xClientTraceId, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(dictionaryLookupWithServiceResponseAsync(from, to, text, xClientTraceId), serviceCallback); + } + + /** + * Provides alternative translations for a word and a small number of idiomatic phrases. Each translation has a `part-of-speech` and a list of `back-translations`. The back-translations enable a user to understand the translation in context. The Dictionary Example operation allows further drill down to see example uses of each translation pair. + * + * @param from Specifies the language of the input text. The source language must be one of the supported languages included in the `dictionary` scope. + * @param to Specifies the language of the output text. The target language must be one of the supported languages included in the `dictionary` scope of the Languages resource. + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the term to lookup. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 100 characters including spaces. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `normalizedSource`- 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. + * `displaySource`- 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". + * `translations`- A list of translations for the source term. Each element of the list is an object with the following properties: + * `normalizedTarget`- A string giving the normalized form of this term in the target language. This value should be used as input to lookup examples. + * `displayTarget`- 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"`. + * `posTag`- A string associating this term with a part-of-speech tag. + | Tag name | Description | + | --------- | ---------------- | + | ADJ | Adjectives | + | ADV | Adverbs | + | CONJ | Conjunctions | + | DET | Determiners | + | MODAL | Verbs | + | NOUN | Nouns | + | PREP | Prepositions | + | PRON | Pronouns | + | VERB | Verbs | + | OTHER | Other | + As an implementation note, these tags were determined by part-of-speech tagging the English side, and then taking the most frequent tag for each source/target pair. So if people frequently translate a Spanish word to a different part-of-speech tag in English, tags may end up being wrong (with respect to the Spanish word). + * `confidence`- 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. + * `prefixWord-` A string giving the 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. + * `backTranslations-` 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. Each element of the `backTranslations` list is an object described by the following properties- + * `normalizedText-` 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. + * `displayText-` A string giving the source term that is a back-translation of the target in a form best suited for end-user display. + * `numExamples-` 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. + * `frequencyCount-` 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. + Note - If the term being looked up does not exist in the dictionary, the response is 200 (OK) but the `translations` list is an empty list. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DictionaryLookupResultItem> object + */ + public Observable> dictionaryLookupAsync(String from, String to, List text, String xClientTraceId) { + return dictionaryLookupWithServiceResponseAsync(from, to, text, xClientTraceId).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Provides alternative translations for a word and a small number of idiomatic phrases. Each translation has a `part-of-speech` and a list of `back-translations`. The back-translations enable a user to understand the translation in context. The Dictionary Example operation allows further drill down to see example uses of each translation pair. + * + * @param from Specifies the language of the input text. The source language must be one of the supported languages included in the `dictionary` scope. + * @param to Specifies the language of the output text. The target language must be one of the supported languages included in the `dictionary` scope of the Languages resource. + * @param text # Request Body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the term to lookup. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 100 characters including spaces. + # Response Body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `normalizedSource`- 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. + * `displaySource`- 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". + * `translations`- A list of translations for the source term. Each element of the list is an object with the following properties: + * `normalizedTarget`- A string giving the normalized form of this term in the target language. This value should be used as input to lookup examples. + * `displayTarget`- 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"`. + * `posTag`- A string associating this term with a part-of-speech tag. + | Tag name | Description | + | --------- | ---------------- | + | ADJ | Adjectives | + | ADV | Adverbs | + | CONJ | Conjunctions | + | DET | Determiners | + | MODAL | Verbs | + | NOUN | Nouns | + | PREP | Prepositions | + | PRON | Pronouns | + | VERB | Verbs | + | OTHER | Other | + As an implementation note, these tags were determined by part-of-speech tagging the English side, and then taking the most frequent tag for each source/target pair. So if people frequently translate a Spanish word to a different part-of-speech tag in English, tags may end up being wrong (with respect to the Spanish word). + * `confidence`- 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. + * `prefixWord-` A string giving the 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. + * `backTranslations-` 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. Each element of the `backTranslations` list is an object described by the following properties- + * `normalizedText-` 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. + * `displayText-` A string giving the source term that is a back-translation of the target in a form best suited for end-user display. + * `numExamples-` 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. + * `frequencyCount-` 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. + Note - If the term being looked up does not exist in the dictionary, the response is 200 (OK) but the `translations` list is an empty list. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DictionaryLookupResultItem> object + */ + public Observable>> dictionaryLookupWithServiceResponseAsync(String from, String to, List text, String xClientTraceId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + if (from == null) { + throw new IllegalArgumentException("Parameter from is required and cannot be null."); + } + if (to == null) { + throw new IllegalArgumentException("Parameter to is required and cannot be null."); + } + if (text == null) { + throw new IllegalArgumentException("Parameter text is required and cannot be null."); + } + Validator.validate(text); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.dictionaryLookup(this.client.apiVersion(), from, to, xClientTraceId, text, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = dictionaryLookupDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> dictionaryLookupDelegate(Response response) throws ErrorMessageException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorMessageException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorMessageException.class) + .build(response); + } + + /** + * Provides examples that show how terms in the dictionary are used in context. This operation is used in tandem with `Dictionary lookup`. + * + * @param from Specifies the language of the input text. The source language must be one of the supported languages included in the `dictionary` scope. + * @param to Specifies the language of the output text. The target language must be one of the supported languages included in the `dictionary` scope. + * @param text # Request body + The body of the request is a JSON array. Each array element is a JSON object with the following properties: + * `Text-` A string specifying the term to lookup. This should be the value of a `normalizedText` field from the back-translations of a previous Dictionary lookup request. It can also be the value of the `normalizedSource` field. + * `Translation-` 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. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 100 characters including spaces. + # Response body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `normalizedSource-` 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. + * `normalizedTarget-` 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. + * `examples-` A list of examples for the (source term, target term) pair. Each element of the list is an object with the following properties: + * `sourcePrefix-` 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. + * `sourceTerm-` 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. + * `sourceSuffix-` 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. + * `targetPrefix-` A string similar to `sourcePrefix` but for the target. + * `targetTerm-` A string similar to `sourceTerm` but for the target. + * `targetSuffix-` A string similar to `sourceSuffix` but for the target. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + NOTE - If there are no examples in the dictionary, the response is 200 (OK) but the `examples` list is an empty list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorMessageException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<DictionaryExampleResultItem> object if successful. + */ + public List dictionaryExamples(String from, String to, List text) { + return dictionaryExamplesWithServiceResponseAsync(from, to, text).toBlocking().single().body(); + } + + /** + * Provides examples that show how terms in the dictionary are used in context. This operation is used in tandem with `Dictionary lookup`. + * + * @param from Specifies the language of the input text. The source language must be one of the supported languages included in the `dictionary` scope. + * @param to Specifies the language of the output text. The target language must be one of the supported languages included in the `dictionary` scope. + * @param text # Request body + The body of the request is a JSON array. Each array element is a JSON object with the following properties: + * `Text-` A string specifying the term to lookup. This should be the value of a `normalizedText` field from the back-translations of a previous Dictionary lookup request. It can also be the value of the `normalizedSource` field. + * `Translation-` 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. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 100 characters including spaces. + # Response body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `normalizedSource-` 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. + * `normalizedTarget-` 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. + * `examples-` A list of examples for the (source term, target term) pair. Each element of the list is an object with the following properties: + * `sourcePrefix-` 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. + * `sourceTerm-` 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. + * `sourceSuffix-` 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. + * `targetPrefix-` A string similar to `sourcePrefix` but for the target. + * `targetTerm-` A string similar to `sourceTerm` but for the target. + * `targetSuffix-` A string similar to `sourceSuffix` but for the target. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + NOTE - If there are no examples in the dictionary, the response is 200 (OK) but the `examples` list is an empty list. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> dictionaryExamplesAsync(String from, String to, List text, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(dictionaryExamplesWithServiceResponseAsync(from, to, text), serviceCallback); + } + + /** + * Provides examples that show how terms in the dictionary are used in context. This operation is used in tandem with `Dictionary lookup`. + * + * @param from Specifies the language of the input text. The source language must be one of the supported languages included in the `dictionary` scope. + * @param to Specifies the language of the output text. The target language must be one of the supported languages included in the `dictionary` scope. + * @param text # Request body + The body of the request is a JSON array. Each array element is a JSON object with the following properties: + * `Text-` A string specifying the term to lookup. This should be the value of a `normalizedText` field from the back-translations of a previous Dictionary lookup request. It can also be the value of the `normalizedSource` field. + * `Translation-` 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. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 100 characters including spaces. + # Response body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `normalizedSource-` 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. + * `normalizedTarget-` 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. + * `examples-` A list of examples for the (source term, target term) pair. Each element of the list is an object with the following properties: + * `sourcePrefix-` 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. + * `sourceTerm-` 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. + * `sourceSuffix-` 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. + * `targetPrefix-` A string similar to `sourcePrefix` but for the target. + * `targetTerm-` A string similar to `sourceTerm` but for the target. + * `targetSuffix-` A string similar to `sourceSuffix` but for the target. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + NOTE - If there are no examples in the dictionary, the response is 200 (OK) but the `examples` list is an empty list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DictionaryExampleResultItem> object + */ + public Observable> dictionaryExamplesAsync(String from, String to, List text) { + return dictionaryExamplesWithServiceResponseAsync(from, to, text).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Provides examples that show how terms in the dictionary are used in context. This operation is used in tandem with `Dictionary lookup`. + * + * @param from Specifies the language of the input text. The source language must be one of the supported languages included in the `dictionary` scope. + * @param to Specifies the language of the output text. The target language must be one of the supported languages included in the `dictionary` scope. + * @param text # Request body + The body of the request is a JSON array. Each array element is a JSON object with the following properties: + * `Text-` A string specifying the term to lookup. This should be the value of a `normalizedText` field from the back-translations of a previous Dictionary lookup request. It can also be the value of the `normalizedSource` field. + * `Translation-` 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. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 100 characters including spaces. + # Response body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `normalizedSource-` 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. + * `normalizedTarget-` 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. + * `examples-` A list of examples for the (source term, target term) pair. Each element of the list is an object with the following properties: + * `sourcePrefix-` 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. + * `sourceTerm-` 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. + * `sourceSuffix-` 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. + * `targetPrefix-` A string similar to `sourcePrefix` but for the target. + * `targetTerm-` A string similar to `sourceTerm` but for the target. + * `targetSuffix-` A string similar to `sourceSuffix` but for the target. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + NOTE - If there are no examples in the dictionary, the response is 200 (OK) but the `examples` list is an empty list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DictionaryExampleResultItem> object + */ + public Observable>> dictionaryExamplesWithServiceResponseAsync(String from, String to, List text) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + if (from == null) { + throw new IllegalArgumentException("Parameter from is required and cannot be null."); + } + if (to == null) { + throw new IllegalArgumentException("Parameter to is required and cannot be null."); + } + if (text == null) { + throw new IllegalArgumentException("Parameter text is required and cannot be null."); + } + Validator.validate(text); + final String xClientTraceId = null; + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.dictionaryExamples(this.client.apiVersion(), from, to, xClientTraceId, text, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = dictionaryExamplesDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Provides examples that show how terms in the dictionary are used in context. This operation is used in tandem with `Dictionary lookup`. + * + * @param from Specifies the language of the input text. The source language must be one of the supported languages included in the `dictionary` scope. + * @param to Specifies the language of the output text. The target language must be one of the supported languages included in the `dictionary` scope. + * @param text # Request body + The body of the request is a JSON array. Each array element is a JSON object with the following properties: + * `Text-` A string specifying the term to lookup. This should be the value of a `normalizedText` field from the back-translations of a previous Dictionary lookup request. It can also be the value of the `normalizedSource` field. + * `Translation-` 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. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 100 characters including spaces. + # Response body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `normalizedSource-` 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. + * `normalizedTarget-` 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. + * `examples-` A list of examples for the (source term, target term) pair. Each element of the list is an object with the following properties: + * `sourcePrefix-` 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. + * `sourceTerm-` 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. + * `sourceSuffix-` 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. + * `targetPrefix-` A string similar to `sourcePrefix` but for the target. + * `targetTerm-` A string similar to `sourceTerm` but for the target. + * `targetSuffix-` A string similar to `sourceSuffix` but for the target. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + NOTE - If there are no examples in the dictionary, the response is 200 (OK) but the `examples` list is an empty list. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorMessageException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<DictionaryExampleResultItem> object if successful. + */ + public List dictionaryExamples(String from, String to, List text, String xClientTraceId) { + return dictionaryExamplesWithServiceResponseAsync(from, to, text, xClientTraceId).toBlocking().single().body(); + } + + /** + * Provides examples that show how terms in the dictionary are used in context. This operation is used in tandem with `Dictionary lookup`. + * + * @param from Specifies the language of the input text. The source language must be one of the supported languages included in the `dictionary` scope. + * @param to Specifies the language of the output text. The target language must be one of the supported languages included in the `dictionary` scope. + * @param text # Request body + The body of the request is a JSON array. Each array element is a JSON object with the following properties: + * `Text-` A string specifying the term to lookup. This should be the value of a `normalizedText` field from the back-translations of a previous Dictionary lookup request. It can also be the value of the `normalizedSource` field. + * `Translation-` 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. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 100 characters including spaces. + # Response body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `normalizedSource-` 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. + * `normalizedTarget-` 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. + * `examples-` A list of examples for the (source term, target term) pair. Each element of the list is an object with the following properties: + * `sourcePrefix-` 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. + * `sourceTerm-` 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. + * `sourceSuffix-` 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. + * `targetPrefix-` A string similar to `sourcePrefix` but for the target. + * `targetTerm-` A string similar to `sourceTerm` but for the target. + * `targetSuffix-` A string similar to `sourceSuffix` but for the target. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + NOTE - If there are no examples in the dictionary, the response is 200 (OK) but the `examples` list is an empty list. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> dictionaryExamplesAsync(String from, String to, List text, String xClientTraceId, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(dictionaryExamplesWithServiceResponseAsync(from, to, text, xClientTraceId), serviceCallback); + } + + /** + * Provides examples that show how terms in the dictionary are used in context. This operation is used in tandem with `Dictionary lookup`. + * + * @param from Specifies the language of the input text. The source language must be one of the supported languages included in the `dictionary` scope. + * @param to Specifies the language of the output text. The target language must be one of the supported languages included in the `dictionary` scope. + * @param text # Request body + The body of the request is a JSON array. Each array element is a JSON object with the following properties: + * `Text-` A string specifying the term to lookup. This should be the value of a `normalizedText` field from the back-translations of a previous Dictionary lookup request. It can also be the value of the `normalizedSource` field. + * `Translation-` 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. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 100 characters including spaces. + # Response body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `normalizedSource-` 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. + * `normalizedTarget-` 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. + * `examples-` A list of examples for the (source term, target term) pair. Each element of the list is an object with the following properties: + * `sourcePrefix-` 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. + * `sourceTerm-` 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. + * `sourceSuffix-` 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. + * `targetPrefix-` A string similar to `sourcePrefix` but for the target. + * `targetTerm-` A string similar to `sourceTerm` but for the target. + * `targetSuffix-` A string similar to `sourceSuffix` but for the target. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + NOTE - If there are no examples in the dictionary, the response is 200 (OK) but the `examples` list is an empty list. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DictionaryExampleResultItem> object + */ + public Observable> dictionaryExamplesAsync(String from, String to, List text, String xClientTraceId) { + return dictionaryExamplesWithServiceResponseAsync(from, to, text, xClientTraceId).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Provides examples that show how terms in the dictionary are used in context. This operation is used in tandem with `Dictionary lookup`. + * + * @param from Specifies the language of the input text. The source language must be one of the supported languages included in the `dictionary` scope. + * @param to Specifies the language of the output text. The target language must be one of the supported languages included in the `dictionary` scope. + * @param text # Request body + The body of the request is a JSON array. Each array element is a JSON object with the following properties: + * `Text-` A string specifying the term to lookup. This should be the value of a `normalizedText` field from the back-translations of a previous Dictionary lookup request. It can also be the value of the `normalizedSource` field. + * `Translation-` 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. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 100 characters including spaces. + # Response body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties: + * `normalizedSource-` 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. + * `normalizedTarget-` 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. + * `examples-` A list of examples for the (source term, target term) pair. Each element of the list is an object with the following properties: + * `sourcePrefix-` 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. + * `sourceTerm-` 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. + * `sourceSuffix-` 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. + * `targetPrefix-` A string similar to `sourcePrefix` but for the target. + * `targetTerm-` A string similar to `sourceTerm` but for the target. + * `targetSuffix-` A string similar to `sourceSuffix` but for the target. + # Response Header + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + NOTE - If there are no examples in the dictionary, the response is 200 (OK) but the `examples` list is an empty list. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DictionaryExampleResultItem> object + */ + public Observable>> dictionaryExamplesWithServiceResponseAsync(String from, String to, List text, String xClientTraceId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + if (from == null) { + throw new IllegalArgumentException("Parameter from is required and cannot be null."); + } + if (to == null) { + throw new IllegalArgumentException("Parameter to is required and cannot be null."); + } + if (text == null) { + throw new IllegalArgumentException("Parameter text is required and cannot be null."); + } + Validator.validate(text); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.dictionaryExamples(this.client.apiVersion(), from, to, xClientTraceId, text, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = dictionaryExamplesDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> dictionaryExamplesDelegate(Response response) throws ErrorMessageException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorMessageException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorMessageException.class) + .build(response); + } + + /** + * Gets the set of languages currently supported by other operations of the Translator Text API. + **Authentication is not required to get language resources.** + # Response Body + A client uses the `scope` query parameter to define which groups of languages it is interested in. + * `scope=translation` provides languages supported to translate text from one language to another language. + * `scope=transliteration` provides capabilities for converting text in one language from one script to another script. + * `scope=dictionary` provides language pairs for which `Dictionary` operations return data. + A client may retrieve several groups simultaneously by specifying a comma-separated list of names. For example, `scope=translation,transliteration,dictionary` would return supported languages for all groups. + A successful response is a JSON object with one property for each requested group. + The value for each property is as follows. + * `translation` property + The value of the `translation` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. A key identifies a language for which text can be translated to or translated from. The value associated with the key is a JSON object with properties that describe the language + * `name-` Display name of the language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + ```json + { + "translation": { + ... + "fr": { + "name": "French", + "nativeName": "Français", + "dir": "ltr" + }, + ... + } + } + ``` + * `transliteration` property + The value of the `transliteration` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. A key identifies a language for which text can be converted from one script to another script. The value associated with the key is a JSON object with properties that describe the language and its supported scripts + * `name-` Display name of the language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `scripts-` List of scripts to convert from. Each element of the `scripts` list has properties- + * `code-` Code identifying the script. + * `name-` Display name of the script in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for the language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `toScripts-` List of scripts available to convert text to. Each element of the `toScripts` list has properties `code`, `name`, `nativeName`, and `dir` as described earlier. + ```json + { + "transliteration": { + ... + "ja": { + "name": "Japanese", + "nativeName": "日本語", + "scripts": [ + { + "code": "Jpan", + "name": "Japanese", + "nativeName": "日本語", + "dir": "ltr", + "toScripts": [ + { + "code": "Latn", + "name": "Latin", + "nativeName": "ラテン語", + "dir": "ltr" + } + ] + }, + { + "code": "Latn", + "name": "Latin", + "nativeName": "ラテン語", + "dir": "ltr", + "toScripts": [ + { + "code": "Jpan", + "name": "Japanese", + "nativeName": "日本語", + "dir": "ltr" + } + ] + } + ] + }, + ... + } + } + ``` + * `dictionary` property + The value of the `dictionary` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. The key identifies a language for which alternative translations and back-translations are available. The value is a JSON object that describes the source language and the target languages with available translations. + * `name-` Display name of the source language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `translations-` List of languages with alterative translations and examples for the query expressed in the source language. Each element of the `translations` list has properties + * `name-` Display name of the target language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the target language in the locale native for the target language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `code-` Language code identifying the target language. + ```json + "es": { + "name": "Spanish", + "nativeName": "Español", + "dir": "ltr", + "translations": [ + { + "name": "English", + "nativeName": "English", + "dir": "ltr", + "code": "en" + } + ] + }, + ``` + The structure of the response object will not change without a change in the version of the API. For the same version of the API, the list of available languages may change over time because Microsoft Translator continually extends the list of languages supported by its services. + The list of supported languages will not change frequently. To save network bandwidth and improve responsiveness, a client application should consider caching language resources and the corresponding entity tag (`ETag`). Then, the client application can periodically (for example, once every 24 hours) query the service to fetch the latest set of supported languages. Passing the current `ETag` value in an `If-None-Match` header 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. + # Response Header + ETag - Current value of the entity tag for the requested groups of supported languages. To make subsequent requests more efficient, the client may send the `ETag` value in an `If-None-Match` header field. + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorMessageException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the LanguagesResult object if successful. + */ + public LanguagesResult languages() { + return languagesWithServiceResponseAsync().toBlocking().single().body(); + } + + /** + * Gets the set of languages currently supported by other operations of the Translator Text API. + **Authentication is not required to get language resources.** + # Response Body + A client uses the `scope` query parameter to define which groups of languages it is interested in. + * `scope=translation` provides languages supported to translate text from one language to another language. + * `scope=transliteration` provides capabilities for converting text in one language from one script to another script. + * `scope=dictionary` provides language pairs for which `Dictionary` operations return data. + A client may retrieve several groups simultaneously by specifying a comma-separated list of names. For example, `scope=translation,transliteration,dictionary` would return supported languages for all groups. + A successful response is a JSON object with one property for each requested group. + The value for each property is as follows. + * `translation` property + The value of the `translation` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. A key identifies a language for which text can be translated to or translated from. The value associated with the key is a JSON object with properties that describe the language + * `name-` Display name of the language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + ```json + { + "translation": { + ... + "fr": { + "name": "French", + "nativeName": "Français", + "dir": "ltr" + }, + ... + } + } + ``` + * `transliteration` property + The value of the `transliteration` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. A key identifies a language for which text can be converted from one script to another script. The value associated with the key is a JSON object with properties that describe the language and its supported scripts + * `name-` Display name of the language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `scripts-` List of scripts to convert from. Each element of the `scripts` list has properties- + * `code-` Code identifying the script. + * `name-` Display name of the script in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for the language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `toScripts-` List of scripts available to convert text to. Each element of the `toScripts` list has properties `code`, `name`, `nativeName`, and `dir` as described earlier. + ```json + { + "transliteration": { + ... + "ja": { + "name": "Japanese", + "nativeName": "日本語", + "scripts": [ + { + "code": "Jpan", + "name": "Japanese", + "nativeName": "日本語", + "dir": "ltr", + "toScripts": [ + { + "code": "Latn", + "name": "Latin", + "nativeName": "ラテン語", + "dir": "ltr" + } + ] + }, + { + "code": "Latn", + "name": "Latin", + "nativeName": "ラテン語", + "dir": "ltr", + "toScripts": [ + { + "code": "Jpan", + "name": "Japanese", + "nativeName": "日本語", + "dir": "ltr" + } + ] + } + ] + }, + ... + } + } + ``` + * `dictionary` property + The value of the `dictionary` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. The key identifies a language for which alternative translations and back-translations are available. The value is a JSON object that describes the source language and the target languages with available translations. + * `name-` Display name of the source language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `translations-` List of languages with alterative translations and examples for the query expressed in the source language. Each element of the `translations` list has properties + * `name-` Display name of the target language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the target language in the locale native for the target language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `code-` Language code identifying the target language. + ```json + "es": { + "name": "Spanish", + "nativeName": "Español", + "dir": "ltr", + "translations": [ + { + "name": "English", + "nativeName": "English", + "dir": "ltr", + "code": "en" + } + ] + }, + ``` + The structure of the response object will not change without a change in the version of the API. For the same version of the API, the list of available languages may change over time because Microsoft Translator continually extends the list of languages supported by its services. + The list of supported languages will not change frequently. To save network bandwidth and improve responsiveness, a client application should consider caching language resources and the corresponding entity tag (`ETag`). Then, the client application can periodically (for example, once every 24 hours) query the service to fetch the latest set of supported languages. Passing the current `ETag` value in an `If-None-Match` header 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. + # Response Header + ETag - Current value of the entity tag for the requested groups of supported languages. To make subsequent requests more efficient, the client may send the `ETag` value in an `If-None-Match` header field. + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture languagesAsync(final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(languagesWithServiceResponseAsync(), serviceCallback); + } + + /** + * Gets the set of languages currently supported by other operations of the Translator Text API. + **Authentication is not required to get language resources.** + # Response Body + A client uses the `scope` query parameter to define which groups of languages it is interested in. + * `scope=translation` provides languages supported to translate text from one language to another language. + * `scope=transliteration` provides capabilities for converting text in one language from one script to another script. + * `scope=dictionary` provides language pairs for which `Dictionary` operations return data. + A client may retrieve several groups simultaneously by specifying a comma-separated list of names. For example, `scope=translation,transliteration,dictionary` would return supported languages for all groups. + A successful response is a JSON object with one property for each requested group. + The value for each property is as follows. + * `translation` property + The value of the `translation` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. A key identifies a language for which text can be translated to or translated from. The value associated with the key is a JSON object with properties that describe the language + * `name-` Display name of the language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + ```json + { + "translation": { + ... + "fr": { + "name": "French", + "nativeName": "Français", + "dir": "ltr" + }, + ... + } + } + ``` + * `transliteration` property + The value of the `transliteration` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. A key identifies a language for which text can be converted from one script to another script. The value associated with the key is a JSON object with properties that describe the language and its supported scripts + * `name-` Display name of the language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `scripts-` List of scripts to convert from. Each element of the `scripts` list has properties- + * `code-` Code identifying the script. + * `name-` Display name of the script in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for the language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `toScripts-` List of scripts available to convert text to. Each element of the `toScripts` list has properties `code`, `name`, `nativeName`, and `dir` as described earlier. + ```json + { + "transliteration": { + ... + "ja": { + "name": "Japanese", + "nativeName": "日本語", + "scripts": [ + { + "code": "Jpan", + "name": "Japanese", + "nativeName": "日本語", + "dir": "ltr", + "toScripts": [ + { + "code": "Latn", + "name": "Latin", + "nativeName": "ラテン語", + "dir": "ltr" + } + ] + }, + { + "code": "Latn", + "name": "Latin", + "nativeName": "ラテン語", + "dir": "ltr", + "toScripts": [ + { + "code": "Jpan", + "name": "Japanese", + "nativeName": "日本語", + "dir": "ltr" + } + ] + } + ] + }, + ... + } + } + ``` + * `dictionary` property + The value of the `dictionary` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. The key identifies a language for which alternative translations and back-translations are available. The value is a JSON object that describes the source language and the target languages with available translations. + * `name-` Display name of the source language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `translations-` List of languages with alterative translations and examples for the query expressed in the source language. Each element of the `translations` list has properties + * `name-` Display name of the target language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the target language in the locale native for the target language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `code-` Language code identifying the target language. + ```json + "es": { + "name": "Spanish", + "nativeName": "Español", + "dir": "ltr", + "translations": [ + { + "name": "English", + "nativeName": "English", + "dir": "ltr", + "code": "en" + } + ] + }, + ``` + The structure of the response object will not change without a change in the version of the API. For the same version of the API, the list of available languages may change over time because Microsoft Translator continually extends the list of languages supported by its services. + The list of supported languages will not change frequently. To save network bandwidth and improve responsiveness, a client application should consider caching language resources and the corresponding entity tag (`ETag`). Then, the client application can periodically (for example, once every 24 hours) query the service to fetch the latest set of supported languages. Passing the current `ETag` value in an `If-None-Match` header 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. + # Response Header + ETag - Current value of the entity tag for the requested groups of supported languages. To make subsequent requests more efficient, the client may send the `ETag` value in an `If-None-Match` header field. + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the LanguagesResult object + */ + public Observable languagesAsync() { + return languagesWithServiceResponseAsync().map(new Func1, LanguagesResult>() { + @Override + public LanguagesResult call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Gets the set of languages currently supported by other operations of the Translator Text API. + **Authentication is not required to get language resources.** + # Response Body + A client uses the `scope` query parameter to define which groups of languages it is interested in. + * `scope=translation` provides languages supported to translate text from one language to another language. + * `scope=transliteration` provides capabilities for converting text in one language from one script to another script. + * `scope=dictionary` provides language pairs for which `Dictionary` operations return data. + A client may retrieve several groups simultaneously by specifying a comma-separated list of names. For example, `scope=translation,transliteration,dictionary` would return supported languages for all groups. + A successful response is a JSON object with one property for each requested group. + The value for each property is as follows. + * `translation` property + The value of the `translation` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. A key identifies a language for which text can be translated to or translated from. The value associated with the key is a JSON object with properties that describe the language + * `name-` Display name of the language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + ```json + { + "translation": { + ... + "fr": { + "name": "French", + "nativeName": "Français", + "dir": "ltr" + }, + ... + } + } + ``` + * `transliteration` property + The value of the `transliteration` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. A key identifies a language for which text can be converted from one script to another script. The value associated with the key is a JSON object with properties that describe the language and its supported scripts + * `name-` Display name of the language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `scripts-` List of scripts to convert from. Each element of the `scripts` list has properties- + * `code-` Code identifying the script. + * `name-` Display name of the script in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for the language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `toScripts-` List of scripts available to convert text to. Each element of the `toScripts` list has properties `code`, `name`, `nativeName`, and `dir` as described earlier. + ```json + { + "transliteration": { + ... + "ja": { + "name": "Japanese", + "nativeName": "日本語", + "scripts": [ + { + "code": "Jpan", + "name": "Japanese", + "nativeName": "日本語", + "dir": "ltr", + "toScripts": [ + { + "code": "Latn", + "name": "Latin", + "nativeName": "ラテン語", + "dir": "ltr" + } + ] + }, + { + "code": "Latn", + "name": "Latin", + "nativeName": "ラテン語", + "dir": "ltr", + "toScripts": [ + { + "code": "Jpan", + "name": "Japanese", + "nativeName": "日本語", + "dir": "ltr" + } + ] + } + ] + }, + ... + } + } + ``` + * `dictionary` property + The value of the `dictionary` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. The key identifies a language for which alternative translations and back-translations are available. The value is a JSON object that describes the source language and the target languages with available translations. + * `name-` Display name of the source language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `translations-` List of languages with alterative translations and examples for the query expressed in the source language. Each element of the `translations` list has properties + * `name-` Display name of the target language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the target language in the locale native for the target language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `code-` Language code identifying the target language. + ```json + "es": { + "name": "Spanish", + "nativeName": "Español", + "dir": "ltr", + "translations": [ + { + "name": "English", + "nativeName": "English", + "dir": "ltr", + "code": "en" + } + ] + }, + ``` + The structure of the response object will not change without a change in the version of the API. For the same version of the API, the list of available languages may change over time because Microsoft Translator continually extends the list of languages supported by its services. + The list of supported languages will not change frequently. To save network bandwidth and improve responsiveness, a client application should consider caching language resources and the corresponding entity tag (`ETag`). Then, the client application can periodically (for example, once every 24 hours) query the service to fetch the latest set of supported languages. Passing the current `ETag` value in an `If-None-Match` header 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. + # Response Header + ETag - Current value of the entity tag for the requested groups of supported languages. To make subsequent requests more efficient, the client may send the `ETag` value in an `If-None-Match` header field. + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the LanguagesResult object + */ + public Observable> languagesWithServiceResponseAsync() { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + final List scope = null; + final String acceptLanguage = null; + final String xClientTraceId = null; + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + String scopeConverted = this.client.serializerAdapter().serializeList(scope, CollectionFormat.CSV); + return service.languages(this.client.apiVersion(), scopeConverted, acceptLanguage, xClientTraceId, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = languagesDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Gets the set of languages currently supported by other operations of the Translator Text API. + **Authentication is not required to get language resources.** + # Response Body + A client uses the `scope` query parameter to define which groups of languages it is interested in. + * `scope=translation` provides languages supported to translate text from one language to another language. + * `scope=transliteration` provides capabilities for converting text in one language from one script to another script. + * `scope=dictionary` provides language pairs for which `Dictionary` operations return data. + A client may retrieve several groups simultaneously by specifying a comma-separated list of names. For example, `scope=translation,transliteration,dictionary` would return supported languages for all groups. + A successful response is a JSON object with one property for each requested group. + The value for each property is as follows. + * `translation` property + The value of the `translation` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. A key identifies a language for which text can be translated to or translated from. The value associated with the key is a JSON object with properties that describe the language + * `name-` Display name of the language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + ```json + { + "translation": { + ... + "fr": { + "name": "French", + "nativeName": "Français", + "dir": "ltr" + }, + ... + } + } + ``` + * `transliteration` property + The value of the `transliteration` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. A key identifies a language for which text can be converted from one script to another script. The value associated with the key is a JSON object with properties that describe the language and its supported scripts + * `name-` Display name of the language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `scripts-` List of scripts to convert from. Each element of the `scripts` list has properties- + * `code-` Code identifying the script. + * `name-` Display name of the script in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for the language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `toScripts-` List of scripts available to convert text to. Each element of the `toScripts` list has properties `code`, `name`, `nativeName`, and `dir` as described earlier. + ```json + { + "transliteration": { + ... + "ja": { + "name": "Japanese", + "nativeName": "日本語", + "scripts": [ + { + "code": "Jpan", + "name": "Japanese", + "nativeName": "日本語", + "dir": "ltr", + "toScripts": [ + { + "code": "Latn", + "name": "Latin", + "nativeName": "ラテン語", + "dir": "ltr" + } + ] + }, + { + "code": "Latn", + "name": "Latin", + "nativeName": "ラテン語", + "dir": "ltr", + "toScripts": [ + { + "code": "Jpan", + "name": "Japanese", + "nativeName": "日本語", + "dir": "ltr" + } + ] + } + ] + }, + ... + } + } + ``` + * `dictionary` property + The value of the `dictionary` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. The key identifies a language for which alternative translations and back-translations are available. The value is a JSON object that describes the source language and the target languages with available translations. + * `name-` Display name of the source language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `translations-` List of languages with alterative translations and examples for the query expressed in the source language. Each element of the `translations` list has properties + * `name-` Display name of the target language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the target language in the locale native for the target language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `code-` Language code identifying the target language. + ```json + "es": { + "name": "Spanish", + "nativeName": "Español", + "dir": "ltr", + "translations": [ + { + "name": "English", + "nativeName": "English", + "dir": "ltr", + "code": "en" + } + ] + }, + ``` + The structure of the response object will not change without a change in the version of the API. For the same version of the API, the list of available languages may change over time because Microsoft Translator continually extends the list of languages supported by its services. + The list of supported languages will not change frequently. To save network bandwidth and improve responsiveness, a client application should consider caching language resources and the corresponding entity tag (`ETag`). Then, the client application can periodically (for example, once every 24 hours) query the service to fetch the latest set of supported languages. Passing the current `ETag` value in an `If-None-Match` header 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. + # Response Header + ETag - Current value of the entity tag for the requested groups of supported languages. To make subsequent requests more efficient, the client may send the `ETag` value in an `If-None-Match` header field. + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * + * @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. + * @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 xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorMessageException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the LanguagesResult object if successful. + */ + public LanguagesResult languages(List scope, String acceptLanguage, String xClientTraceId) { + return languagesWithServiceResponseAsync(scope, acceptLanguage, xClientTraceId).toBlocking().single().body(); + } + + /** + * Gets the set of languages currently supported by other operations of the Translator Text API. + **Authentication is not required to get language resources.** + # Response Body + A client uses the `scope` query parameter to define which groups of languages it is interested in. + * `scope=translation` provides languages supported to translate text from one language to another language. + * `scope=transliteration` provides capabilities for converting text in one language from one script to another script. + * `scope=dictionary` provides language pairs for which `Dictionary` operations return data. + A client may retrieve several groups simultaneously by specifying a comma-separated list of names. For example, `scope=translation,transliteration,dictionary` would return supported languages for all groups. + A successful response is a JSON object with one property for each requested group. + The value for each property is as follows. + * `translation` property + The value of the `translation` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. A key identifies a language for which text can be translated to or translated from. The value associated with the key is a JSON object with properties that describe the language + * `name-` Display name of the language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + ```json + { + "translation": { + ... + "fr": { + "name": "French", + "nativeName": "Français", + "dir": "ltr" + }, + ... + } + } + ``` + * `transliteration` property + The value of the `transliteration` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. A key identifies a language for which text can be converted from one script to another script. The value associated with the key is a JSON object with properties that describe the language and its supported scripts + * `name-` Display name of the language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `scripts-` List of scripts to convert from. Each element of the `scripts` list has properties- + * `code-` Code identifying the script. + * `name-` Display name of the script in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for the language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `toScripts-` List of scripts available to convert text to. Each element of the `toScripts` list has properties `code`, `name`, `nativeName`, and `dir` as described earlier. + ```json + { + "transliteration": { + ... + "ja": { + "name": "Japanese", + "nativeName": "日本語", + "scripts": [ + { + "code": "Jpan", + "name": "Japanese", + "nativeName": "日本語", + "dir": "ltr", + "toScripts": [ + { + "code": "Latn", + "name": "Latin", + "nativeName": "ラテン語", + "dir": "ltr" + } + ] + }, + { + "code": "Latn", + "name": "Latin", + "nativeName": "ラテン語", + "dir": "ltr", + "toScripts": [ + { + "code": "Jpan", + "name": "Japanese", + "nativeName": "日本語", + "dir": "ltr" + } + ] + } + ] + }, + ... + } + } + ``` + * `dictionary` property + The value of the `dictionary` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. The key identifies a language for which alternative translations and back-translations are available. The value is a JSON object that describes the source language and the target languages with available translations. + * `name-` Display name of the source language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `translations-` List of languages with alterative translations and examples for the query expressed in the source language. Each element of the `translations` list has properties + * `name-` Display name of the target language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the target language in the locale native for the target language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `code-` Language code identifying the target language. + ```json + "es": { + "name": "Spanish", + "nativeName": "Español", + "dir": "ltr", + "translations": [ + { + "name": "English", + "nativeName": "English", + "dir": "ltr", + "code": "en" + } + ] + }, + ``` + The structure of the response object will not change without a change in the version of the API. For the same version of the API, the list of available languages may change over time because Microsoft Translator continually extends the list of languages supported by its services. + The list of supported languages will not change frequently. To save network bandwidth and improve responsiveness, a client application should consider caching language resources and the corresponding entity tag (`ETag`). Then, the client application can periodically (for example, once every 24 hours) query the service to fetch the latest set of supported languages. Passing the current `ETag` value in an `If-None-Match` header 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. + # Response Header + ETag - Current value of the entity tag for the requested groups of supported languages. To make subsequent requests more efficient, the client may send the `ETag` value in an `If-None-Match` header field. + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * + * @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. + * @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 xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture languagesAsync(List scope, String acceptLanguage, String xClientTraceId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(languagesWithServiceResponseAsync(scope, acceptLanguage, xClientTraceId), serviceCallback); + } + + /** + * Gets the set of languages currently supported by other operations of the Translator Text API. + **Authentication is not required to get language resources.** + # Response Body + A client uses the `scope` query parameter to define which groups of languages it is interested in. + * `scope=translation` provides languages supported to translate text from one language to another language. + * `scope=transliteration` provides capabilities for converting text in one language from one script to another script. + * `scope=dictionary` provides language pairs for which `Dictionary` operations return data. + A client may retrieve several groups simultaneously by specifying a comma-separated list of names. For example, `scope=translation,transliteration,dictionary` would return supported languages for all groups. + A successful response is a JSON object with one property for each requested group. + The value for each property is as follows. + * `translation` property + The value of the `translation` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. A key identifies a language for which text can be translated to or translated from. The value associated with the key is a JSON object with properties that describe the language + * `name-` Display name of the language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + ```json + { + "translation": { + ... + "fr": { + "name": "French", + "nativeName": "Français", + "dir": "ltr" + }, + ... + } + } + ``` + * `transliteration` property + The value of the `transliteration` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. A key identifies a language for which text can be converted from one script to another script. The value associated with the key is a JSON object with properties that describe the language and its supported scripts + * `name-` Display name of the language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `scripts-` List of scripts to convert from. Each element of the `scripts` list has properties- + * `code-` Code identifying the script. + * `name-` Display name of the script in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for the language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `toScripts-` List of scripts available to convert text to. Each element of the `toScripts` list has properties `code`, `name`, `nativeName`, and `dir` as described earlier. + ```json + { + "transliteration": { + ... + "ja": { + "name": "Japanese", + "nativeName": "日本語", + "scripts": [ + { + "code": "Jpan", + "name": "Japanese", + "nativeName": "日本語", + "dir": "ltr", + "toScripts": [ + { + "code": "Latn", + "name": "Latin", + "nativeName": "ラテン語", + "dir": "ltr" + } + ] + }, + { + "code": "Latn", + "name": "Latin", + "nativeName": "ラテン語", + "dir": "ltr", + "toScripts": [ + { + "code": "Jpan", + "name": "Japanese", + "nativeName": "日本語", + "dir": "ltr" + } + ] + } + ] + }, + ... + } + } + ``` + * `dictionary` property + The value of the `dictionary` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. The key identifies a language for which alternative translations and back-translations are available. The value is a JSON object that describes the source language and the target languages with available translations. + * `name-` Display name of the source language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `translations-` List of languages with alterative translations and examples for the query expressed in the source language. Each element of the `translations` list has properties + * `name-` Display name of the target language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the target language in the locale native for the target language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `code-` Language code identifying the target language. + ```json + "es": { + "name": "Spanish", + "nativeName": "Español", + "dir": "ltr", + "translations": [ + { + "name": "English", + "nativeName": "English", + "dir": "ltr", + "code": "en" + } + ] + }, + ``` + The structure of the response object will not change without a change in the version of the API. For the same version of the API, the list of available languages may change over time because Microsoft Translator continually extends the list of languages supported by its services. + The list of supported languages will not change frequently. To save network bandwidth and improve responsiveness, a client application should consider caching language resources and the corresponding entity tag (`ETag`). Then, the client application can periodically (for example, once every 24 hours) query the service to fetch the latest set of supported languages. Passing the current `ETag` value in an `If-None-Match` header 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. + # Response Header + ETag - Current value of the entity tag for the requested groups of supported languages. To make subsequent requests more efficient, the client may send the `ETag` value in an `If-None-Match` header field. + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * + * @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. + * @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 xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the LanguagesResult object + */ + public Observable languagesAsync(List scope, String acceptLanguage, String xClientTraceId) { + return languagesWithServiceResponseAsync(scope, acceptLanguage, xClientTraceId).map(new Func1, LanguagesResult>() { + @Override + public LanguagesResult call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Gets the set of languages currently supported by other operations of the Translator Text API. + **Authentication is not required to get language resources.** + # Response Body + A client uses the `scope` query parameter to define which groups of languages it is interested in. + * `scope=translation` provides languages supported to translate text from one language to another language. + * `scope=transliteration` provides capabilities for converting text in one language from one script to another script. + * `scope=dictionary` provides language pairs for which `Dictionary` operations return data. + A client may retrieve several groups simultaneously by specifying a comma-separated list of names. For example, `scope=translation,transliteration,dictionary` would return supported languages for all groups. + A successful response is a JSON object with one property for each requested group. + The value for each property is as follows. + * `translation` property + The value of the `translation` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. A key identifies a language for which text can be translated to or translated from. The value associated with the key is a JSON object with properties that describe the language + * `name-` Display name of the language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + ```json + { + "translation": { + ... + "fr": { + "name": "French", + "nativeName": "Français", + "dir": "ltr" + }, + ... + } + } + ``` + * `transliteration` property + The value of the `transliteration` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. A key identifies a language for which text can be converted from one script to another script. The value associated with the key is a JSON object with properties that describe the language and its supported scripts + * `name-` Display name of the language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `scripts-` List of scripts to convert from. Each element of the `scripts` list has properties- + * `code-` Code identifying the script. + * `name-` Display name of the script in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for the language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `toScripts-` List of scripts available to convert text to. Each element of the `toScripts` list has properties `code`, `name`, `nativeName`, and `dir` as described earlier. + ```json + { + "transliteration": { + ... + "ja": { + "name": "Japanese", + "nativeName": "日本語", + "scripts": [ + { + "code": "Jpan", + "name": "Japanese", + "nativeName": "日本語", + "dir": "ltr", + "toScripts": [ + { + "code": "Latn", + "name": "Latin", + "nativeName": "ラテン語", + "dir": "ltr" + } + ] + }, + { + "code": "Latn", + "name": "Latin", + "nativeName": "ラテン語", + "dir": "ltr", + "toScripts": [ + { + "code": "Jpan", + "name": "Japanese", + "nativeName": "日本語", + "dir": "ltr" + } + ] + } + ] + }, + ... + } + } + ``` + * `dictionary` property + The value of the `dictionary` property is a dictionary of (key, value) pairs. Each key is a BCP 47 language tag. The key identifies a language for which alternative translations and back-translations are available. The value is a JSON object that describes the source language and the target languages with available translations. + * `name-` Display name of the source language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the language in the locale native for this language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `translations-` List of languages with alterative translations and examples for the query expressed in the source language. Each element of the `translations` list has properties + * `name-` Display name of the target language in the locale requested via `Accept-Language` header. + * `nativeName-` Display name of the target language in the locale native for the target language. + * `dir-` Directionality, which is `rtl` for right-to-left languages or `ltr` for left-to-right languages. + * `code-` Language code identifying the target language. + ```json + "es": { + "name": "Spanish", + "nativeName": "Español", + "dir": "ltr", + "translations": [ + { + "name": "English", + "nativeName": "English", + "dir": "ltr", + "code": "en" + } + ] + }, + ``` + The structure of the response object will not change without a change in the version of the API. For the same version of the API, the list of available languages may change over time because Microsoft Translator continually extends the list of languages supported by its services. + The list of supported languages will not change frequently. To save network bandwidth and improve responsiveness, a client application should consider caching language resources and the corresponding entity tag (`ETag`). Then, the client application can periodically (for example, once every 24 hours) query the service to fetch the latest set of supported languages. Passing the current `ETag` value in an `If-None-Match` header 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. + # Response Header + ETag - Current value of the entity tag for the requested groups of supported languages. To make subsequent requests more efficient, the client may send the `ETag` value in an `If-None-Match` header field. + X-RequestId - Value generated by the service to identify the request. It is used for troubleshooting purposes. + * + * @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. + * @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 xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the LanguagesResult object + */ + public Observable> languagesWithServiceResponseAsync(List scope, String acceptLanguage, String xClientTraceId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + Validator.validate(scope); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + String scopeConverted = this.client.serializerAdapter().serializeList(scope, CollectionFormat.CSV); + return service.languages(this.client.apiVersion(), scopeConverted, acceptLanguage, xClientTraceId, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = languagesDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse languagesDelegate(Response response) throws ErrorMessageException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorMessageException.class) + .build(response); + } + + /** + * Translates text into one or more languages. + * + * @param to Specifies the language of the output text. Find which languages are available to translate to by using the languages method. For example, use `to=de` to translate to German. + It's possible to translate to multiple languages simultaneously by repeating the `to` parameter in the query string. For example, use `to=de&to=it` to translate to German and Italian in the same request. + * @param text # Request body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the string to translate. + The following limitations apply: + * The array can have at most 25 elements. + * The entire text included in the request cannot exceed 5,000 characters including spaces. + # Response body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties- + * `detectedLanguage`- An object describing the detected language through the following properties. + * `language`- A string representing the code of the detected 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. + The `detectedLanguage` property is only present in the result object when language auto-detection is requested. + * `translations`- An array of translation results. The size of the array matches the number of target languages specified in the `to` query parameter. Each element in the array includes. + * `to` A string representing the language code of the target language. + * `text`- A string giving the translated text. + * `transliteration`- An object giving the translated text in the script specified by the `toScript` parameter. + * `script`- A string specifying the target script. + * `text`- A string giving the translated text in the target script. + The `transliteration` object is not included if transliteration does not take place. + *`alignment`- An object with a single string property named `proj`, which 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. See Obtain alignment information for an example and restrictions. + * `sentLen`- An object returning sentence boundaries in the input and output texts. + * `srcSentLen`- 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. + * `transSentLen`- 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. + Sentence boundaries are only included when the request parameter `includeSentenceLength` is `true`. + * `sourceText`- An object with a single string property named `text`, which gives the 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. + Example of JSON responses are provided in the examples section. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorMessageException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<TranslateResultAllItem> object if successful. + */ + public List translate(List to, List text) { + return translateWithServiceResponseAsync(to, text).toBlocking().single().body(); + } + + /** + * Translates text into one or more languages. + * + * @param to Specifies the language of the output text. Find which languages are available to translate to by using the languages method. For example, use `to=de` to translate to German. + It's possible to translate to multiple languages simultaneously by repeating the `to` parameter in the query string. For example, use `to=de&to=it` to translate to German and Italian in the same request. + * @param text # Request body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the string to translate. + The following limitations apply: + * The array can have at most 25 elements. + * The entire text included in the request cannot exceed 5,000 characters including spaces. + # Response body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties- + * `detectedLanguage`- An object describing the detected language through the following properties. + * `language`- A string representing the code of the detected 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. + The `detectedLanguage` property is only present in the result object when language auto-detection is requested. + * `translations`- An array of translation results. The size of the array matches the number of target languages specified in the `to` query parameter. Each element in the array includes. + * `to` A string representing the language code of the target language. + * `text`- A string giving the translated text. + * `transliteration`- An object giving the translated text in the script specified by the `toScript` parameter. + * `script`- A string specifying the target script. + * `text`- A string giving the translated text in the target script. + The `transliteration` object is not included if transliteration does not take place. + *`alignment`- An object with a single string property named `proj`, which 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. See Obtain alignment information for an example and restrictions. + * `sentLen`- An object returning sentence boundaries in the input and output texts. + * `srcSentLen`- 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. + * `transSentLen`- 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. + Sentence boundaries are only included when the request parameter `includeSentenceLength` is `true`. + * `sourceText`- An object with a single string property named `text`, which gives the 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. + Example of JSON responses are provided in the examples section. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> translateAsync(List to, List text, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(translateWithServiceResponseAsync(to, text), serviceCallback); + } + + /** + * Translates text into one or more languages. + * + * @param to Specifies the language of the output text. Find which languages are available to translate to by using the languages method. For example, use `to=de` to translate to German. + It's possible to translate to multiple languages simultaneously by repeating the `to` parameter in the query string. For example, use `to=de&to=it` to translate to German and Italian in the same request. + * @param text # Request body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the string to translate. + The following limitations apply: + * The array can have at most 25 elements. + * The entire text included in the request cannot exceed 5,000 characters including spaces. + # Response body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties- + * `detectedLanguage`- An object describing the detected language through the following properties. + * `language`- A string representing the code of the detected 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. + The `detectedLanguage` property is only present in the result object when language auto-detection is requested. + * `translations`- An array of translation results. The size of the array matches the number of target languages specified in the `to` query parameter. Each element in the array includes. + * `to` A string representing the language code of the target language. + * `text`- A string giving the translated text. + * `transliteration`- An object giving the translated text in the script specified by the `toScript` parameter. + * `script`- A string specifying the target script. + * `text`- A string giving the translated text in the target script. + The `transliteration` object is not included if transliteration does not take place. + *`alignment`- An object with a single string property named `proj`, which 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. See Obtain alignment information for an example and restrictions. + * `sentLen`- An object returning sentence boundaries in the input and output texts. + * `srcSentLen`- 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. + * `transSentLen`- 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. + Sentence boundaries are only included when the request parameter `includeSentenceLength` is `true`. + * `sourceText`- An object with a single string property named `text`, which gives the 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. + Example of JSON responses are provided in the examples section. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<TranslateResultAllItem> object + */ + public Observable> translateAsync(List to, List text) { + return translateWithServiceResponseAsync(to, text).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Translates text into one or more languages. + * + * @param to Specifies the language of the output text. Find which languages are available to translate to by using the languages method. For example, use `to=de` to translate to German. + It's possible to translate to multiple languages simultaneously by repeating the `to` parameter in the query string. For example, use `to=de&to=it` to translate to German and Italian in the same request. + * @param text # Request body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the string to translate. + The following limitations apply: + * The array can have at most 25 elements. + * The entire text included in the request cannot exceed 5,000 characters including spaces. + # Response body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties- + * `detectedLanguage`- An object describing the detected language through the following properties. + * `language`- A string representing the code of the detected 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. + The `detectedLanguage` property is only present in the result object when language auto-detection is requested. + * `translations`- An array of translation results. The size of the array matches the number of target languages specified in the `to` query parameter. Each element in the array includes. + * `to` A string representing the language code of the target language. + * `text`- A string giving the translated text. + * `transliteration`- An object giving the translated text in the script specified by the `toScript` parameter. + * `script`- A string specifying the target script. + * `text`- A string giving the translated text in the target script. + The `transliteration` object is not included if transliteration does not take place. + *`alignment`- An object with a single string property named `proj`, which 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. See Obtain alignment information for an example and restrictions. + * `sentLen`- An object returning sentence boundaries in the input and output texts. + * `srcSentLen`- 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. + * `transSentLen`- 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. + Sentence boundaries are only included when the request parameter `includeSentenceLength` is `true`. + * `sourceText`- An object with a single string property named `text`, which gives the 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. + Example of JSON responses are provided in the examples section. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<TranslateResultAllItem> object + */ + public Observable>> translateWithServiceResponseAsync(List to, List text) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + if (to == null) { + throw new IllegalArgumentException("Parameter to is required and cannot be null."); + } + if (text == null) { + throw new IllegalArgumentException("Parameter text is required and cannot be null."); + } + Validator.validate(to); + Validator.validate(text); + final String from = null; + final String textType = null; + final String category = null; + final String profanityAction = null; + final String profanityMarker = null; + final Boolean includeAlignment = null; + final Boolean includeSentenceLength = null; + final String suggestedFrom = null; + final String fromScript = null; + final List toScript = null; + final String xClientTraceId = null; + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + String toConverted = this.client.serializerAdapter().serializeList(to, CollectionFormat.CSV);String toScriptConverted = this.client.serializerAdapter().serializeList(toScript, CollectionFormat.CSV); + return service.translate(this.client.apiVersion(), from, toConverted, textType, category, profanityAction, profanityMarker, includeAlignment, includeSentenceLength, suggestedFrom, fromScript, toScriptConverted, xClientTraceId, text, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = translateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Translates text into one or more languages. + * + * @param to Specifies the language of the output text. Find which languages are available to translate to by using the languages method. For example, use `to=de` to translate to German. + It's possible to translate to multiple languages simultaneously by repeating the `to` parameter in the query string. For example, use `to=de&to=it` to translate to German and Italian in the same request. + * @param text # Request body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the string to translate. + The following limitations apply: + * The array can have at most 25 elements. + * The entire text included in the request cannot exceed 5,000 characters including spaces. + # Response body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties- + * `detectedLanguage`- An object describing the detected language through the following properties. + * `language`- A string representing the code of the detected 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. + The `detectedLanguage` property is only present in the result object when language auto-detection is requested. + * `translations`- An array of translation results. The size of the array matches the number of target languages specified in the `to` query parameter. Each element in the array includes. + * `to` A string representing the language code of the target language. + * `text`- A string giving the translated text. + * `transliteration`- An object giving the translated text in the script specified by the `toScript` parameter. + * `script`- A string specifying the target script. + * `text`- A string giving the translated text in the target script. + The `transliteration` object is not included if transliteration does not take place. + *`alignment`- An object with a single string property named `proj`, which 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. See Obtain alignment information for an example and restrictions. + * `sentLen`- An object returning sentence boundaries in the input and output texts. + * `srcSentLen`- 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. + * `transSentLen`- 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. + Sentence boundaries are only included when the request parameter `includeSentenceLength` is `true`. + * `sourceText`- An object with a single string property named `text`, which gives the 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. + Example of JSON responses are provided in the examples section. + * @param from Specifies the language of the input text. Find which languages are available to translate from by using the languages method. If the `from` parameter is not specified, automatic language detection is applied to determine the source language. + * @param textType Defines whether the text being translated is plain text or HTML text. Any HTML needs to be a well-formed, complete HTML element. Possible values are `plain` (default) or `html` + . Possible values include: 'plain', 'html' + * @param category A string specifying the category (domain) of the translation. This parameter retrieves translations from a customized system built with Custom Translator. Default value is `general`. + * @param profanityAction Specifies how profanities should be treated in translations. Possible values are: `NoAction` (default), `Marked` or `Deleted`. + ### Handling Profanity + Normally the Translator service will retain profanity that is present in the source in the translation. The degree of profanity and the context that makes words profane differ between cultures, and as a result the degree of profanity in the target language may be amplified or reduced. + If you want to avoid getting profanity in the translation, regardless of the presence of profanity in the source text, you can use the profanity filtering option. The option allows you to choose whether you want to see profanity deleted, whether you want to mark profanities with appropriate tags (giving you the option to add your own post-processing), or you want no action taken. The accepted values of `ProfanityAction` are `Deleted`, `Marked` and `NoAction` (default). + | ProfanityAction | Action | + | ---------- | ---------- | + | `NoAction` | This is the default behavior. Profanity will pass from source to target. | + | | Example Source (Japanese)- 彼はジャッカスです。 | + | | Example Translation (English)- He is a jackass. | + | | | + | `Deleted` | Profane words will be removed from the output without replacement. | + | | Example Source (Japanese)- 彼はジャッカスです。 | + | | Example Translation (English)- He is a. | + | `Marked` | Profane words are replaced by a marker in the output. The marker depends on the `ProfanityMarker` parameter. + | | For `ProfanityMarker=Asterisk`, profane words are replaced with `***` | + | | Example Source (Japanese)- 彼はジャッカスです。 | + | | Example Translation (English)- He is a ***. | + | | For `ProfanityMarker=Tag`, profane words are surrounded by XML tags <profanity> and </profanity> + | | Example Source (Japanese)- 彼はジャッカスです。 | + | | Example Translation (English)- He is a <profanity>jackass</profanity>. + . Possible values include: 'NoAction', 'Marked', '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 suggestedFrom Specifies a fallback language if the language of the input text can't be identified. Language auto-detection is applied when the `from` parameter is omitted. If detection fails, the `suggestedFrom` language will be assumed. + * @param fromScript Specifies the script of the input text. Supported scripts are available from the languages method + * @param toScript Specifies the script of the translated text. Supported scripts are available from the languages method + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorMessageException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<TranslateResultAllItem> object if successful. + */ + public List translate(List to, List text, String from, String textType, String category, String profanityAction, String profanityMarker, Boolean includeAlignment, Boolean includeSentenceLength, String suggestedFrom, String fromScript, List toScript, String xClientTraceId) { + return translateWithServiceResponseAsync(to, text, from, textType, category, profanityAction, profanityMarker, includeAlignment, includeSentenceLength, suggestedFrom, fromScript, toScript, xClientTraceId).toBlocking().single().body(); + } + + /** + * Translates text into one or more languages. + * + * @param to Specifies the language of the output text. Find which languages are available to translate to by using the languages method. For example, use `to=de` to translate to German. + It's possible to translate to multiple languages simultaneously by repeating the `to` parameter in the query string. For example, use `to=de&to=it` to translate to German and Italian in the same request. + * @param text # Request body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the string to translate. + The following limitations apply: + * The array can have at most 25 elements. + * The entire text included in the request cannot exceed 5,000 characters including spaces. + # Response body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties- + * `detectedLanguage`- An object describing the detected language through the following properties. + * `language`- A string representing the code of the detected 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. + The `detectedLanguage` property is only present in the result object when language auto-detection is requested. + * `translations`- An array of translation results. The size of the array matches the number of target languages specified in the `to` query parameter. Each element in the array includes. + * `to` A string representing the language code of the target language. + * `text`- A string giving the translated text. + * `transliteration`- An object giving the translated text in the script specified by the `toScript` parameter. + * `script`- A string specifying the target script. + * `text`- A string giving the translated text in the target script. + The `transliteration` object is not included if transliteration does not take place. + *`alignment`- An object with a single string property named `proj`, which 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. See Obtain alignment information for an example and restrictions. + * `sentLen`- An object returning sentence boundaries in the input and output texts. + * `srcSentLen`- 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. + * `transSentLen`- 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. + Sentence boundaries are only included when the request parameter `includeSentenceLength` is `true`. + * `sourceText`- An object with a single string property named `text`, which gives the 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. + Example of JSON responses are provided in the examples section. + * @param from Specifies the language of the input text. Find which languages are available to translate from by using the languages method. If the `from` parameter is not specified, automatic language detection is applied to determine the source language. + * @param textType Defines whether the text being translated is plain text or HTML text. Any HTML needs to be a well-formed, complete HTML element. Possible values are `plain` (default) or `html` + . Possible values include: 'plain', 'html' + * @param category A string specifying the category (domain) of the translation. This parameter retrieves translations from a customized system built with Custom Translator. Default value is `general`. + * @param profanityAction Specifies how profanities should be treated in translations. Possible values are: `NoAction` (default), `Marked` or `Deleted`. + ### Handling Profanity + Normally the Translator service will retain profanity that is present in the source in the translation. The degree of profanity and the context that makes words profane differ between cultures, and as a result the degree of profanity in the target language may be amplified or reduced. + If you want to avoid getting profanity in the translation, regardless of the presence of profanity in the source text, you can use the profanity filtering option. The option allows you to choose whether you want to see profanity deleted, whether you want to mark profanities with appropriate tags (giving you the option to add your own post-processing), or you want no action taken. The accepted values of `ProfanityAction` are `Deleted`, `Marked` and `NoAction` (default). + | ProfanityAction | Action | + | ---------- | ---------- | + | `NoAction` | This is the default behavior. Profanity will pass from source to target. | + | | Example Source (Japanese)- 彼はジャッカスです。 | + | | Example Translation (English)- He is a jackass. | + | | | + | `Deleted` | Profane words will be removed from the output without replacement. | + | | Example Source (Japanese)- 彼はジャッカスです。 | + | | Example Translation (English)- He is a. | + | `Marked` | Profane words are replaced by a marker in the output. The marker depends on the `ProfanityMarker` parameter. + | | For `ProfanityMarker=Asterisk`, profane words are replaced with `***` | + | | Example Source (Japanese)- 彼はジャッカスです。 | + | | Example Translation (English)- He is a ***. | + | | For `ProfanityMarker=Tag`, profane words are surrounded by XML tags <profanity> and </profanity> + | | Example Source (Japanese)- 彼はジャッカスです。 | + | | Example Translation (English)- He is a <profanity>jackass</profanity>. + . Possible values include: 'NoAction', 'Marked', '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 suggestedFrom Specifies a fallback language if the language of the input text can't be identified. Language auto-detection is applied when the `from` parameter is omitted. If detection fails, the `suggestedFrom` language will be assumed. + * @param fromScript Specifies the script of the input text. Supported scripts are available from the languages method + * @param toScript Specifies the script of the translated text. Supported scripts are available from the languages method + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> translateAsync(List to, List text, String from, String textType, String category, String profanityAction, String profanityMarker, Boolean includeAlignment, Boolean includeSentenceLength, String suggestedFrom, String fromScript, List toScript, String xClientTraceId, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(translateWithServiceResponseAsync(to, text, from, textType, category, profanityAction, profanityMarker, includeAlignment, includeSentenceLength, suggestedFrom, fromScript, toScript, xClientTraceId), serviceCallback); + } + + /** + * Translates text into one or more languages. + * + * @param to Specifies the language of the output text. Find which languages are available to translate to by using the languages method. For example, use `to=de` to translate to German. + It's possible to translate to multiple languages simultaneously by repeating the `to` parameter in the query string. For example, use `to=de&to=it` to translate to German and Italian in the same request. + * @param text # Request body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the string to translate. + The following limitations apply: + * The array can have at most 25 elements. + * The entire text included in the request cannot exceed 5,000 characters including spaces. + # Response body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties- + * `detectedLanguage`- An object describing the detected language through the following properties. + * `language`- A string representing the code of the detected 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. + The `detectedLanguage` property is only present in the result object when language auto-detection is requested. + * `translations`- An array of translation results. The size of the array matches the number of target languages specified in the `to` query parameter. Each element in the array includes. + * `to` A string representing the language code of the target language. + * `text`- A string giving the translated text. + * `transliteration`- An object giving the translated text in the script specified by the `toScript` parameter. + * `script`- A string specifying the target script. + * `text`- A string giving the translated text in the target script. + The `transliteration` object is not included if transliteration does not take place. + *`alignment`- An object with a single string property named `proj`, which 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. See Obtain alignment information for an example and restrictions. + * `sentLen`- An object returning sentence boundaries in the input and output texts. + * `srcSentLen`- 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. + * `transSentLen`- 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. + Sentence boundaries are only included when the request parameter `includeSentenceLength` is `true`. + * `sourceText`- An object with a single string property named `text`, which gives the 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. + Example of JSON responses are provided in the examples section. + * @param from Specifies the language of the input text. Find which languages are available to translate from by using the languages method. If the `from` parameter is not specified, automatic language detection is applied to determine the source language. + * @param textType Defines whether the text being translated is plain text or HTML text. Any HTML needs to be a well-formed, complete HTML element. Possible values are `plain` (default) or `html` + . Possible values include: 'plain', 'html' + * @param category A string specifying the category (domain) of the translation. This parameter retrieves translations from a customized system built with Custom Translator. Default value is `general`. + * @param profanityAction Specifies how profanities should be treated in translations. Possible values are: `NoAction` (default), `Marked` or `Deleted`. + ### Handling Profanity + Normally the Translator service will retain profanity that is present in the source in the translation. The degree of profanity and the context that makes words profane differ between cultures, and as a result the degree of profanity in the target language may be amplified or reduced. + If you want to avoid getting profanity in the translation, regardless of the presence of profanity in the source text, you can use the profanity filtering option. The option allows you to choose whether you want to see profanity deleted, whether you want to mark profanities with appropriate tags (giving you the option to add your own post-processing), or you want no action taken. The accepted values of `ProfanityAction` are `Deleted`, `Marked` and `NoAction` (default). + | ProfanityAction | Action | + | ---------- | ---------- | + | `NoAction` | This is the default behavior. Profanity will pass from source to target. | + | | Example Source (Japanese)- 彼はジャッカスです。 | + | | Example Translation (English)- He is a jackass. | + | | | + | `Deleted` | Profane words will be removed from the output without replacement. | + | | Example Source (Japanese)- 彼はジャッカスです。 | + | | Example Translation (English)- He is a. | + | `Marked` | Profane words are replaced by a marker in the output. The marker depends on the `ProfanityMarker` parameter. + | | For `ProfanityMarker=Asterisk`, profane words are replaced with `***` | + | | Example Source (Japanese)- 彼はジャッカスです。 | + | | Example Translation (English)- He is a ***. | + | | For `ProfanityMarker=Tag`, profane words are surrounded by XML tags <profanity> and </profanity> + | | Example Source (Japanese)- 彼はジャッカスです。 | + | | Example Translation (English)- He is a <profanity>jackass</profanity>. + . Possible values include: 'NoAction', 'Marked', '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 suggestedFrom Specifies a fallback language if the language of the input text can't be identified. Language auto-detection is applied when the `from` parameter is omitted. If detection fails, the `suggestedFrom` language will be assumed. + * @param fromScript Specifies the script of the input text. Supported scripts are available from the languages method + * @param toScript Specifies the script of the translated text. Supported scripts are available from the languages method + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<TranslateResultAllItem> object + */ + public Observable> translateAsync(List to, List text, String from, String textType, String category, String profanityAction, String profanityMarker, Boolean includeAlignment, Boolean includeSentenceLength, String suggestedFrom, String fromScript, List toScript, String xClientTraceId) { + return translateWithServiceResponseAsync(to, text, from, textType, category, profanityAction, profanityMarker, includeAlignment, includeSentenceLength, suggestedFrom, fromScript, toScript, xClientTraceId).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Translates text into one or more languages. + * + * @param to Specifies the language of the output text. Find which languages are available to translate to by using the languages method. For example, use `to=de` to translate to German. + It's possible to translate to multiple languages simultaneously by repeating the `to` parameter in the query string. For example, use `to=de&to=it` to translate to German and Italian in the same request. + * @param text # Request body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the string to translate. + The following limitations apply: + * The array can have at most 25 elements. + * The entire text included in the request cannot exceed 5,000 characters including spaces. + # Response body + A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties- + * `detectedLanguage`- An object describing the detected language through the following properties. + * `language`- A string representing the code of the detected 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. + The `detectedLanguage` property is only present in the result object when language auto-detection is requested. + * `translations`- An array of translation results. The size of the array matches the number of target languages specified in the `to` query parameter. Each element in the array includes. + * `to` A string representing the language code of the target language. + * `text`- A string giving the translated text. + * `transliteration`- An object giving the translated text in the script specified by the `toScript` parameter. + * `script`- A string specifying the target script. + * `text`- A string giving the translated text in the target script. + The `transliteration` object is not included if transliteration does not take place. + *`alignment`- An object with a single string property named `proj`, which 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. See Obtain alignment information for an example and restrictions. + * `sentLen`- An object returning sentence boundaries in the input and output texts. + * `srcSentLen`- 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. + * `transSentLen`- 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. + Sentence boundaries are only included when the request parameter `includeSentenceLength` is `true`. + * `sourceText`- An object with a single string property named `text`, which gives the 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. + Example of JSON responses are provided in the examples section. + * @param from Specifies the language of the input text. Find which languages are available to translate from by using the languages method. If the `from` parameter is not specified, automatic language detection is applied to determine the source language. + * @param textType Defines whether the text being translated is plain text or HTML text. Any HTML needs to be a well-formed, complete HTML element. Possible values are `plain` (default) or `html` + . Possible values include: 'plain', 'html' + * @param category A string specifying the category (domain) of the translation. This parameter retrieves translations from a customized system built with Custom Translator. Default value is `general`. + * @param profanityAction Specifies how profanities should be treated in translations. Possible values are: `NoAction` (default), `Marked` or `Deleted`. + ### Handling Profanity + Normally the Translator service will retain profanity that is present in the source in the translation. The degree of profanity and the context that makes words profane differ between cultures, and as a result the degree of profanity in the target language may be amplified or reduced. + If you want to avoid getting profanity in the translation, regardless of the presence of profanity in the source text, you can use the profanity filtering option. The option allows you to choose whether you want to see profanity deleted, whether you want to mark profanities with appropriate tags (giving you the option to add your own post-processing), or you want no action taken. The accepted values of `ProfanityAction` are `Deleted`, `Marked` and `NoAction` (default). + | ProfanityAction | Action | + | ---------- | ---------- | + | `NoAction` | This is the default behavior. Profanity will pass from source to target. | + | | Example Source (Japanese)- 彼はジャッカスです。 | + | | Example Translation (English)- He is a jackass. | + | | | + | `Deleted` | Profane words will be removed from the output without replacement. | + | | Example Source (Japanese)- 彼はジャッカスです。 | + | | Example Translation (English)- He is a. | + | `Marked` | Profane words are replaced by a marker in the output. The marker depends on the `ProfanityMarker` parameter. + | | For `ProfanityMarker=Asterisk`, profane words are replaced with `***` | + | | Example Source (Japanese)- 彼はジャッカスです。 | + | | Example Translation (English)- He is a ***. | + | | For `ProfanityMarker=Tag`, profane words are surrounded by XML tags <profanity> and </profanity> + | | Example Source (Japanese)- 彼はジャッカスです。 | + | | Example Translation (English)- He is a <profanity>jackass</profanity>. + . Possible values include: 'NoAction', 'Marked', '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 suggestedFrom Specifies a fallback language if the language of the input text can't be identified. Language auto-detection is applied when the `from` parameter is omitted. If detection fails, the `suggestedFrom` language will be assumed. + * @param fromScript Specifies the script of the input text. Supported scripts are available from the languages method + * @param toScript Specifies the script of the translated text. Supported scripts are available from the languages method + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<TranslateResultAllItem> object + */ + public Observable>> translateWithServiceResponseAsync(List to, List text, String from, String textType, String category, String profanityAction, String profanityMarker, Boolean includeAlignment, Boolean includeSentenceLength, String suggestedFrom, String fromScript, List toScript, String xClientTraceId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + if (to == null) { + throw new IllegalArgumentException("Parameter to is required and cannot be null."); + } + if (text == null) { + throw new IllegalArgumentException("Parameter text is required and cannot be null."); + } + Validator.validate(to); + Validator.validate(toScript); + Validator.validate(text); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + String toConverted = this.client.serializerAdapter().serializeList(to, CollectionFormat.CSV);String toScriptConverted = this.client.serializerAdapter().serializeList(toScript, CollectionFormat.CSV); + return service.translate(this.client.apiVersion(), from, toConverted, textType, category, profanityAction, profanityMarker, includeAlignment, includeSentenceLength, suggestedFrom, fromScript, toScriptConverted, xClientTraceId, text, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = translateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> translateDelegate(Response response) throws ErrorMessageException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorMessageException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorMessageException.class) + .build(response); + } + + /** + * Converts the text of a language in one script into another type of script. Example- + Japanese script "こんにちは" + Same word in Latin script "konnichiha". + * + * @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. Lookup supported languages using the `transliteration` scope, to find input scripts available for the selected language. + * @param toScript Specifies the output script. Lookup supported languages using the `transliteration` scope, to find output scripts available for the selected combination of input language and input script. + * @param texts # Request body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the string to convert. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 1,000 characters including spaces. + * The entire text included in the request cannot exceed 5,000 characters including spaces. + # Response body + A successful response is a JSON array with one result for each element in the input array. A result object includes the following properties: + * `text`- A string which is the result of converting the input string to the output script. + * `script`- A string specifying the script used in the output. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorMessageException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<TransliterateResultItem> object if successful. + */ + public List transliterate(String language, String fromScript, String toScript, List texts) { + return transliterateWithServiceResponseAsync(language, fromScript, toScript, texts).toBlocking().single().body(); + } + + /** + * Converts the text of a language in one script into another type of script. Example- + Japanese script "こんにちは" + Same word in Latin script "konnichiha". + * + * @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. Lookup supported languages using the `transliteration` scope, to find input scripts available for the selected language. + * @param toScript Specifies the output script. Lookup supported languages using the `transliteration` scope, to find output scripts available for the selected combination of input language and input script. + * @param texts # Request body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the string to convert. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 1,000 characters including spaces. + * The entire text included in the request cannot exceed 5,000 characters including spaces. + # Response body + A successful response is a JSON array with one result for each element in the input array. A result object includes the following properties: + * `text`- A string which is the result of converting the input string to the output script. + * `script`- A string specifying the script used in the output. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> transliterateAsync(String language, String fromScript, String toScript, List texts, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(transliterateWithServiceResponseAsync(language, fromScript, toScript, texts), serviceCallback); + } + + /** + * Converts the text of a language in one script into another type of script. Example- + Japanese script "こんにちは" + Same word in Latin script "konnichiha". + * + * @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. Lookup supported languages using the `transliteration` scope, to find input scripts available for the selected language. + * @param toScript Specifies the output script. Lookup supported languages using the `transliteration` scope, to find output scripts available for the selected combination of input language and input script. + * @param texts # Request body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the string to convert. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 1,000 characters including spaces. + * The entire text included in the request cannot exceed 5,000 characters including spaces. + # Response body + A successful response is a JSON array with one result for each element in the input array. A result object includes the following properties: + * `text`- A string which is the result of converting the input string to the output script. + * `script`- A string specifying the script used in the output. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<TransliterateResultItem> object + */ + public Observable> transliterateAsync(String language, String fromScript, String toScript, List texts) { + return transliterateWithServiceResponseAsync(language, fromScript, toScript, texts).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Converts the text of a language in one script into another type of script. Example- + Japanese script "こんにちは" + Same word in Latin script "konnichiha". + * + * @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. Lookup supported languages using the `transliteration` scope, to find input scripts available for the selected language. + * @param toScript Specifies the output script. Lookup supported languages using the `transliteration` scope, to find output scripts available for the selected combination of input language and input script. + * @param texts # Request body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the string to convert. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 1,000 characters including spaces. + * The entire text included in the request cannot exceed 5,000 characters including spaces. + # Response body + A successful response is a JSON array with one result for each element in the input array. A result object includes the following properties: + * `text`- A string which is the result of converting the input string to the output script. + * `script`- A string specifying the script used in the output. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<TransliterateResultItem> object + */ + public Observable>> transliterateWithServiceResponseAsync(String language, String fromScript, String toScript, List texts) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + if (language == null) { + throw new IllegalArgumentException("Parameter language is required and cannot be null."); + } + if (fromScript == null) { + throw new IllegalArgumentException("Parameter fromScript is required and cannot be null."); + } + if (toScript == null) { + throw new IllegalArgumentException("Parameter toScript is required and cannot be null."); + } + if (texts == null) { + throw new IllegalArgumentException("Parameter texts is required and cannot be null."); + } + Validator.validate(texts); + final String xClientTraceId = null; + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.transliterate(this.client.apiVersion(), language, fromScript, toScript, xClientTraceId, texts, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = transliterateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Converts the text of a language in one script into another type of script. Example- + Japanese script "こんにちは" + Same word in Latin script "konnichiha". + * + * @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. Lookup supported languages using the `transliteration` scope, to find input scripts available for the selected language. + * @param toScript Specifies the output script. Lookup supported languages using the `transliteration` scope, to find output scripts available for the selected combination of input language and input script. + * @param texts # Request body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the string to convert. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 1,000 characters including spaces. + * The entire text included in the request cannot exceed 5,000 characters including spaces. + # Response body + A successful response is a JSON array with one result for each element in the input array. A result object includes the following properties: + * `text`- A string which is the result of converting the input string to the output script. + * `script`- A string specifying the script used in the output. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorMessageException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<TransliterateResultItem> object if successful. + */ + public List transliterate(String language, String fromScript, String toScript, List texts, String xClientTraceId) { + return transliterateWithServiceResponseAsync(language, fromScript, toScript, texts, xClientTraceId).toBlocking().single().body(); + } + + /** + * Converts the text of a language in one script into another type of script. Example- + Japanese script "こんにちは" + Same word in Latin script "konnichiha". + * + * @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. Lookup supported languages using the `transliteration` scope, to find input scripts available for the selected language. + * @param toScript Specifies the output script. Lookup supported languages using the `transliteration` scope, to find output scripts available for the selected combination of input language and input script. + * @param texts # Request body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the string to convert. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 1,000 characters including spaces. + * The entire text included in the request cannot exceed 5,000 characters including spaces. + # Response body + A successful response is a JSON array with one result for each element in the input array. A result object includes the following properties: + * `text`- A string which is the result of converting the input string to the output script. + * `script`- A string specifying the script used in the output. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> transliterateAsync(String language, String fromScript, String toScript, List texts, String xClientTraceId, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(transliterateWithServiceResponseAsync(language, fromScript, toScript, texts, xClientTraceId), serviceCallback); + } + + /** + * Converts the text of a language in one script into another type of script. Example- + Japanese script "こんにちは" + Same word in Latin script "konnichiha". + * + * @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. Lookup supported languages using the `transliteration` scope, to find input scripts available for the selected language. + * @param toScript Specifies the output script. Lookup supported languages using the `transliteration` scope, to find output scripts available for the selected combination of input language and input script. + * @param texts # Request body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the string to convert. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 1,000 characters including spaces. + * The entire text included in the request cannot exceed 5,000 characters including spaces. + # Response body + A successful response is a JSON array with one result for each element in the input array. A result object includes the following properties: + * `text`- A string which is the result of converting the input string to the output script. + * `script`- A string specifying the script used in the output. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<TransliterateResultItem> object + */ + public Observable> transliterateAsync(String language, String fromScript, String toScript, List texts, String xClientTraceId) { + return transliterateWithServiceResponseAsync(language, fromScript, toScript, texts, xClientTraceId).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Converts the text of a language in one script into another type of script. Example- + Japanese script "こんにちは" + Same word in Latin script "konnichiha". + * + * @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. Lookup supported languages using the `transliteration` scope, to find input scripts available for the selected language. + * @param toScript Specifies the output script. Lookup supported languages using the `transliteration` scope, to find output scripts available for the selected combination of input language and input script. + * @param texts # Request body + The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`, which represents the string to convert. + The following limitations apply: + * The array can have at most 10 elements. + * The text value of an array element cannot exceed 1,000 characters including spaces. + * The entire text included in the request cannot exceed 5,000 characters including spaces. + # Response body + A successful response is a JSON array with one result for each element in the input array. A result object includes the following properties: + * `text`- A string which is the result of converting the input string to the output script. + * `script`- A string specifying the script used in the output. + * @param xClientTraceId A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<TransliterateResultItem> object + */ + public Observable>> transliterateWithServiceResponseAsync(String language, String fromScript, String toScript, List texts, String xClientTraceId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + if (language == null) { + throw new IllegalArgumentException("Parameter language is required and cannot be null."); + } + if (fromScript == null) { + throw new IllegalArgumentException("Parameter fromScript is required and cannot be null."); + } + if (toScript == null) { + throw new IllegalArgumentException("Parameter toScript is required and cannot be null."); + } + if (texts == null) { + throw new IllegalArgumentException("Parameter texts is required and cannot be null."); + } + Validator.validate(texts); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.transliterate(this.client.apiVersion(), language, fromScript, toScript, xClientTraceId, texts, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = transliterateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> transliterateDelegate(Response response) throws ErrorMessageException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorMessageException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorMessageException.class) + .build(response); + } + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/implementation/package-info.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/implementation/package-info.java new file mode 100644 index 0000000000000..efa384eaece1b --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/implementation/package-info.java @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * This package contains the implementation classes for TranslatorTextClient. + * # Introduction + The Microsoft Translator Text API provides a JSON-based Web API. It provides: + * Translation between any supported languages to any other supported language. + * Translation to multiple languages in one request. + * Transliteration to convert text from one script to another script of the same language. + * Language detection, translation, and transliteration in one request. + * Dictionary to lookup alternative translations of a term, to find back-translations and examples showing terms used in context. + * Rich language detection. + # Base URLs + The Translator Text API is available in the following clouds: + | Description | Region | Base URL | + | ------- | -------- | ------- | + | Azure | Global | api.cognitive.microsofttranslator.com | + | Azure | Europe | api-eur.cognitive.microsofttranslator.com | + # Authentication + Subscribe to the Translator Text API, part of Azure Cognitive Services, and use your subscription key from the Azure portal to authenticate. You can follow the steps in https://docs.microsoft.com/en-us/azure/cognitive-services/translator/translator-text-how-to-signup. + The simplest way is to pass your Azure secret key to the Translator service using the http request header `Ocp-Apim-Subscription-Key`. + If you prefer using a short-lived authentication, you may use your secret key to obtain an authorization token from the token service. In that case you pass the authorization token to the Translator service using the `Authorization` request header. To obtain an authorization token, make a `POST` request to the following URL: + | Environment | Authentication service URL | + | ---------- | ---------- | + | Azure | `https://api.cognitive.microsoft.com/sts/v1.0/issueToken` | + Here are example requests to obtain a token with a lifetime of 10 minutes, given a secret key: + ```python + // Pass secret key using header + curl --header 'Ocp-Apim-Subscription-Key: ' --data "" 'https://api.cognitive.microsoft.com/sts/v1.0/issueToken' + // Pass secret key using query string parameter + curl --data "" 'https://api.cognitive.microsoft.com/sts/v1.0/issueToken?Subscription-Key=' + ``` + A successful request returns the encoded access token as plain text in the response body. The valid token is passed to the Translator service as a bearer token in the Authorization. + ``` + Authorization: Bearer + ``` + An authentication token is valid for 10 minutes. The token should be re-used when making multiple calls to the Translator APIs. If you make requests to the Translator API over an extended period of time, you must request a new access token at regular intervals before the token expires, for instance every 9 minutes. + To summarize, a client request to the Translator API will include one authorization header taken from the following table: + | Headers | Description | + | ---------- | ---------- | + | Ocp-Apim-Subscription-key | Use with Cognitive Services subscription if you are passing your secret key. The value is the Azure secret key for your subscription to Translator Text API. | + | Authorization | Use with Cognitive Services subscription if you are passing an authentication token. The value is the Bearer token: `Bearer `. | + ## All-in-one subscription + The last authentication option is to use a Cognitive Service’s all-in-one subscription. This allows you to use a single secret key to authenticate requests for multiple services. + When you use an all-in-one secret key, you must include two authentication headers with your request. The first passes the secret key, the second specifies the region associated with your subscription. + `Ocp-Api-Subscription-Key` `Ocp-Apim-Subscription-Region` + If you pass the secret key in the query string with the parameter `Subscription-Key`, then you must specify the region with query parameter `Subscription-Region`. + If you use a bearer token, you must obtain the token from the region endpoint: + `https://.api.cognitive.microsoft.com/sts/v1.0/issueToken`. + Available regions are: `australiaeast`, `brazilsouth`, `canadacentral`, `centralindia`, `centraluseuap`, `eastasia`, `eastus`, `eastus2`, `japaneast`, `northeurope`, `southcentralus`, `southeastasia`, `uksouth`, `westcentralus`, `westeurope`, `westus`, and `westus2`. + Region is required for the all-in-one Text API subscription. + # Errors + A standard error response is a JSON object with name/value pair named `error`. The value is also a JSON object with properties: + * `code`: A server-defined error code. + * `message`: A string giving a human-readable representation of the error. + For example, a customer with a free trial subscription receives the following error once the free quota is exhausted: + ```json + { + "error": { + "code":403000, + "message":"The subscription has exceeded its free quota." + } + } + ``` + # Enter your subscription keys to try out Microsoft Translator. + Select the `Authorize` button and enter your Microsoft Translator subscription key, OR your `all in one Cognitive Services` subscription key. If you are using the all in one Cognitive Services key you will need to also enter your subscription region. + ## Available regions are: + `australiaeast`, `brazilsouth`, `canadacentral`, `centralindia`, `centraluseuap`, `eastasia`, `eastus`, `eastus2`, `japaneast`, `northeurope`, `southcentralus`, `southeastasia`, `uksouth`, `westcentralus`, `westeurope`, `westus`, `westus2`. + */ +package com.microsoft.azure.cognitiveservices.translatortext.implementation; diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/BreakSentenceResultItem.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/BreakSentenceResultItem.java new file mode 100644 index 0000000000000..c2880151e94a9 --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/BreakSentenceResultItem.java @@ -0,0 +1,44 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The BreakSentenceResultItem model. + */ +public class BreakSentenceResultItem { + /** + * The sentLen property. + */ + @JsonProperty(value = "sentLen") + private List sentLen; + + /** + * Get the sentLen value. + * + * @return the sentLen value + */ + public List sentLen() { + return this.sentLen; + } + + /** + * Set the sentLen value. + * + * @param sentLen the sentLen value to set + * @return the BreakSentenceResultItem object itself. + */ + public BreakSentenceResultItem withSentLen(List sentLen) { + this.sentLen = sentLen; + return this; + } + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/BreakSentenceTextInput.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/BreakSentenceTextInput.java new file mode 100644 index 0000000000000..bce08d617faa9 --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/BreakSentenceTextInput.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Text needed for break sentence request. + */ +public class BreakSentenceTextInput { + /** + * The text property. + */ + @JsonProperty(value = "text") + private String text; + + /** + * Get the text value. + * + * @return the text value + */ + public String text() { + return this.text; + } + + /** + * Set the text value. + * + * @param text the text value to set + * @return the BreakSentenceTextInput object itself. + */ + public BreakSentenceTextInput withText(String text) { + this.text = text; + return this; + } + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/DetectResultItem.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/DetectResultItem.java new file mode 100644 index 0000000000000..1ccb517d8485e --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/DetectResultItem.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The DetectResultItem model. + */ +public class DetectResultItem { + /** + * The text property. + */ + @JsonProperty(value = "text") + private String text; + + /** + * Get the text value. + * + * @return the text value + */ + public String text() { + return this.text; + } + + /** + * Set the text value. + * + * @param text the text value to set + * @return the DetectResultItem object itself. + */ + public DetectResultItem withText(String text) { + this.text = text; + return this; + } + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/DetectTextInput.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/DetectTextInput.java new file mode 100644 index 0000000000000..1cf367604148a --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/DetectTextInput.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Text needed for detect request. + */ +public class DetectTextInput { + /** + * The text property. + */ + @JsonProperty(value = "text") + private String text; + + /** + * Get the text value. + * + * @return the text value + */ + public String text() { + return this.text; + } + + /** + * Set the text value. + * + * @param text the text value to set + * @return the DetectTextInput object itself. + */ + public DetectTextInput withText(String text) { + this.text = text; + return this; + } + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/DictionaryExampleResultItem.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/DictionaryExampleResultItem.java new file mode 100644 index 0000000000000..8253dcdae2e41 --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/DictionaryExampleResultItem.java @@ -0,0 +1,96 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The DictionaryExampleResultItem model. + */ +public class DictionaryExampleResultItem { + /** + * The normalizedSource property. + */ + @JsonProperty(value = "normalizedSource") + private String normalizedSource; + + /** + * The normalizedTarget property. + */ + @JsonProperty(value = "normalizedTarget") + private String normalizedTarget; + + /** + * The examples property. + */ + @JsonProperty(value = "examples") + private List examples; + + /** + * Get the normalizedSource value. + * + * @return the normalizedSource value + */ + public String normalizedSource() { + return this.normalizedSource; + } + + /** + * Set the normalizedSource value. + * + * @param normalizedSource the normalizedSource value to set + * @return the DictionaryExampleResultItem object itself. + */ + public DictionaryExampleResultItem withNormalizedSource(String normalizedSource) { + this.normalizedSource = normalizedSource; + return this; + } + + /** + * Get the normalizedTarget value. + * + * @return the normalizedTarget value + */ + public String normalizedTarget() { + return this.normalizedTarget; + } + + /** + * Set the normalizedTarget value. + * + * @param normalizedTarget the normalizedTarget value to set + * @return the DictionaryExampleResultItem object itself. + */ + public DictionaryExampleResultItem withNormalizedTarget(String normalizedTarget) { + this.normalizedTarget = normalizedTarget; + return this; + } + + /** + * Get the examples value. + * + * @return the examples value + */ + public List examples() { + return this.examples; + } + + /** + * Set the examples value. + * + * @param examples the examples value to set + * @return the DictionaryExampleResultItem object itself. + */ + public DictionaryExampleResultItem withExamples(List examples) { + this.examples = examples; + return this; + } + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/DictionaryExampleResultItemExamplesItem.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/DictionaryExampleResultItemExamplesItem.java new file mode 100644 index 0000000000000..c619dc1db6dec --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/DictionaryExampleResultItemExamplesItem.java @@ -0,0 +1,173 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The DictionaryExampleResultItemExamplesItem model. + */ +public class DictionaryExampleResultItemExamplesItem { + /** + * The sourcePrefix property. + */ + @JsonProperty(value = "sourcePrefix") + private String sourcePrefix; + + /** + * The sourceTerm property. + */ + @JsonProperty(value = "sourceTerm") + private String sourceTerm; + + /** + * The sourceSuffix property. + */ + @JsonProperty(value = "sourceSuffix") + private String sourceSuffix; + + /** + * The targetPrefix property. + */ + @JsonProperty(value = "targetPrefix") + private String targetPrefix; + + /** + * The targetTerm property. + */ + @JsonProperty(value = "targetTerm") + private String targetTerm; + + /** + * The targetSuffix property. + */ + @JsonProperty(value = "targetSuffix") + private String targetSuffix; + + /** + * Get the sourcePrefix value. + * + * @return the sourcePrefix value + */ + public String sourcePrefix() { + return this.sourcePrefix; + } + + /** + * Set the sourcePrefix value. + * + * @param sourcePrefix the sourcePrefix value to set + * @return the DictionaryExampleResultItemExamplesItem object itself. + */ + public DictionaryExampleResultItemExamplesItem withSourcePrefix(String sourcePrefix) { + this.sourcePrefix = sourcePrefix; + return this; + } + + /** + * Get the sourceTerm value. + * + * @return the sourceTerm value + */ + public String sourceTerm() { + return this.sourceTerm; + } + + /** + * Set the sourceTerm value. + * + * @param sourceTerm the sourceTerm value to set + * @return the DictionaryExampleResultItemExamplesItem object itself. + */ + public DictionaryExampleResultItemExamplesItem withSourceTerm(String sourceTerm) { + this.sourceTerm = sourceTerm; + return this; + } + + /** + * Get the sourceSuffix value. + * + * @return the sourceSuffix value + */ + public String sourceSuffix() { + return this.sourceSuffix; + } + + /** + * Set the sourceSuffix value. + * + * @param sourceSuffix the sourceSuffix value to set + * @return the DictionaryExampleResultItemExamplesItem object itself. + */ + public DictionaryExampleResultItemExamplesItem withSourceSuffix(String sourceSuffix) { + this.sourceSuffix = sourceSuffix; + return this; + } + + /** + * Get the targetPrefix value. + * + * @return the targetPrefix value + */ + public String targetPrefix() { + return this.targetPrefix; + } + + /** + * Set the targetPrefix value. + * + * @param targetPrefix the targetPrefix value to set + * @return the DictionaryExampleResultItemExamplesItem object itself. + */ + public DictionaryExampleResultItemExamplesItem withTargetPrefix(String targetPrefix) { + this.targetPrefix = targetPrefix; + return this; + } + + /** + * Get the targetTerm value. + * + * @return the targetTerm value + */ + public String targetTerm() { + return this.targetTerm; + } + + /** + * Set the targetTerm value. + * + * @param targetTerm the targetTerm value to set + * @return the DictionaryExampleResultItemExamplesItem object itself. + */ + public DictionaryExampleResultItemExamplesItem withTargetTerm(String targetTerm) { + this.targetTerm = targetTerm; + return this; + } + + /** + * Get the targetSuffix value. + * + * @return the targetSuffix value + */ + public String targetSuffix() { + return this.targetSuffix; + } + + /** + * Set the targetSuffix value. + * + * @param targetSuffix the targetSuffix value to set + * @return the DictionaryExampleResultItemExamplesItem object itself. + */ + public DictionaryExampleResultItemExamplesItem withTargetSuffix(String targetSuffix) { + this.targetSuffix = targetSuffix; + return this; + } + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/DictionaryExampleTextInput.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/DictionaryExampleTextInput.java new file mode 100644 index 0000000000000..5a78229c982ab --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/DictionaryExampleTextInput.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Text needed for a dictionary example request. + */ +public class DictionaryExampleTextInput { + /** + * The text property. + */ + @JsonProperty(value = "text") + private String text; + + /** + * The translation property. + */ + @JsonProperty(value = "translation") + private String translation; + + /** + * Get the text value. + * + * @return the text value + */ + public String text() { + return this.text; + } + + /** + * Set the text value. + * + * @param text the text value to set + * @return the DictionaryExampleTextInput object itself. + */ + public DictionaryExampleTextInput withText(String text) { + this.text = text; + return this; + } + + /** + * Get the translation value. + * + * @return the translation value + */ + public String translation() { + return this.translation; + } + + /** + * Set the translation value. + * + * @param translation the translation value to set + * @return the DictionaryExampleTextInput object itself. + */ + public DictionaryExampleTextInput withTranslation(String translation) { + this.translation = translation; + return this; + } + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/DictionaryLookupResultItem.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/DictionaryLookupResultItem.java new file mode 100644 index 0000000000000..4336a6379200d --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/DictionaryLookupResultItem.java @@ -0,0 +1,96 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The DictionaryLookupResultItem model. + */ +public class DictionaryLookupResultItem { + /** + * The normalizedSource property. + */ + @JsonProperty(value = "normalizedSource") + private String normalizedSource; + + /** + * The displaySource property. + */ + @JsonProperty(value = "displaySource") + private String displaySource; + + /** + * The translations property. + */ + @JsonProperty(value = "translations") + private List translations; + + /** + * Get the normalizedSource value. + * + * @return the normalizedSource value + */ + public String normalizedSource() { + return this.normalizedSource; + } + + /** + * Set the normalizedSource value. + * + * @param normalizedSource the normalizedSource value to set + * @return the DictionaryLookupResultItem object itself. + */ + public DictionaryLookupResultItem withNormalizedSource(String normalizedSource) { + this.normalizedSource = normalizedSource; + return this; + } + + /** + * Get the displaySource value. + * + * @return the displaySource value + */ + public String displaySource() { + return this.displaySource; + } + + /** + * Set the displaySource value. + * + * @param displaySource the displaySource value to set + * @return the DictionaryLookupResultItem object itself. + */ + public DictionaryLookupResultItem withDisplaySource(String displaySource) { + this.displaySource = displaySource; + return this; + } + + /** + * Get the translations value. + * + * @return the translations value + */ + public List translations() { + return this.translations; + } + + /** + * Set the translations value. + * + * @param translations the translations value to set + * @return the DictionaryLookupResultItem object itself. + */ + public DictionaryLookupResultItem withTranslations(List translations) { + this.translations = translations; + return this; + } + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/DictionaryLookupResultItemTranslationsItem.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/DictionaryLookupResultItemTranslationsItem.java new file mode 100644 index 0000000000000..1423282971a73 --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/DictionaryLookupResultItemTranslationsItem.java @@ -0,0 +1,174 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The DictionaryLookupResultItemTranslationsItem model. + */ +public class DictionaryLookupResultItemTranslationsItem { + /** + * The normalizedTarget property. + */ + @JsonProperty(value = "normalizedTarget") + private String normalizedTarget; + + /** + * The displayTarget property. + */ + @JsonProperty(value = "displayTarget") + private String displayTarget; + + /** + * The posTag property. + */ + @JsonProperty(value = "posTag") + private String posTag; + + /** + * The confidence property. + */ + @JsonProperty(value = "confidence") + private Double confidence; + + /** + * The prefixWord property. + */ + @JsonProperty(value = "prefixWord") + private String prefixWord; + + /** + * The backTranslations property. + */ + @JsonProperty(value = "backTranslations") + private List backTranslations; + + /** + * Get the normalizedTarget value. + * + * @return the normalizedTarget value + */ + public String normalizedTarget() { + return this.normalizedTarget; + } + + /** + * Set the normalizedTarget value. + * + * @param normalizedTarget the normalizedTarget value to set + * @return the DictionaryLookupResultItemTranslationsItem object itself. + */ + public DictionaryLookupResultItemTranslationsItem withNormalizedTarget(String normalizedTarget) { + this.normalizedTarget = normalizedTarget; + return this; + } + + /** + * Get the displayTarget value. + * + * @return the displayTarget value + */ + public String displayTarget() { + return this.displayTarget; + } + + /** + * Set the displayTarget value. + * + * @param displayTarget the displayTarget value to set + * @return the DictionaryLookupResultItemTranslationsItem object itself. + */ + public DictionaryLookupResultItemTranslationsItem withDisplayTarget(String displayTarget) { + this.displayTarget = displayTarget; + return this; + } + + /** + * Get the posTag value. + * + * @return the posTag value + */ + public String posTag() { + return this.posTag; + } + + /** + * Set the posTag value. + * + * @param posTag the posTag value to set + * @return the DictionaryLookupResultItemTranslationsItem object itself. + */ + public DictionaryLookupResultItemTranslationsItem withPosTag(String posTag) { + this.posTag = posTag; + return this; + } + + /** + * Get the confidence value. + * + * @return the confidence value + */ + public Double confidence() { + return this.confidence; + } + + /** + * Set the confidence value. + * + * @param confidence the confidence value to set + * @return the DictionaryLookupResultItemTranslationsItem object itself. + */ + public DictionaryLookupResultItemTranslationsItem withConfidence(Double confidence) { + this.confidence = confidence; + return this; + } + + /** + * Get the prefixWord value. + * + * @return the prefixWord value + */ + public String prefixWord() { + return this.prefixWord; + } + + /** + * Set the prefixWord value. + * + * @param prefixWord the prefixWord value to set + * @return the DictionaryLookupResultItemTranslationsItem object itself. + */ + public DictionaryLookupResultItemTranslationsItem withPrefixWord(String prefixWord) { + this.prefixWord = prefixWord; + return this; + } + + /** + * Get the backTranslations value. + * + * @return the backTranslations value + */ + public List backTranslations() { + return this.backTranslations; + } + + /** + * Set the backTranslations value. + * + * @param backTranslations the backTranslations value to set + * @return the DictionaryLookupResultItemTranslationsItem object itself. + */ + public DictionaryLookupResultItemTranslationsItem withBackTranslations(List backTranslations) { + this.backTranslations = backTranslations; + return this; + } + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/DictionaryLookupResultItemTranslationsItemBackTranslationsItem.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/DictionaryLookupResultItemTranslationsItemBackTranslationsItem.java new file mode 100644 index 0000000000000..1fa0305945c48 --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/DictionaryLookupResultItemTranslationsItemBackTranslationsItem.java @@ -0,0 +1,121 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The DictionaryLookupResultItemTranslationsItemBackTranslationsItem model. + */ +public class DictionaryLookupResultItemTranslationsItemBackTranslationsItem { + /** + * The normalizedText property. + */ + @JsonProperty(value = "normalizedText") + private String normalizedText; + + /** + * The displayText property. + */ + @JsonProperty(value = "displayText") + private String displayText; + + /** + * The numExamples property. + */ + @JsonProperty(value = "numExamples") + private Integer numExamples; + + /** + * The frequencyCount property. + */ + @JsonProperty(value = "frequencyCount") + private Integer frequencyCount; + + /** + * Get the normalizedText value. + * + * @return the normalizedText value + */ + public String normalizedText() { + return this.normalizedText; + } + + /** + * Set the normalizedText value. + * + * @param normalizedText the normalizedText value to set + * @return the DictionaryLookupResultItemTranslationsItemBackTranslationsItem object itself. + */ + public DictionaryLookupResultItemTranslationsItemBackTranslationsItem withNormalizedText(String normalizedText) { + this.normalizedText = normalizedText; + return this; + } + + /** + * Get the displayText value. + * + * @return the displayText value + */ + public String displayText() { + return this.displayText; + } + + /** + * Set the displayText value. + * + * @param displayText the displayText value to set + * @return the DictionaryLookupResultItemTranslationsItemBackTranslationsItem object itself. + */ + public DictionaryLookupResultItemTranslationsItemBackTranslationsItem withDisplayText(String displayText) { + this.displayText = displayText; + return this; + } + + /** + * Get the numExamples value. + * + * @return the numExamples value + */ + public Integer numExamples() { + return this.numExamples; + } + + /** + * Set the numExamples value. + * + * @param numExamples the numExamples value to set + * @return the DictionaryLookupResultItemTranslationsItemBackTranslationsItem object itself. + */ + public DictionaryLookupResultItemTranslationsItemBackTranslationsItem withNumExamples(Integer numExamples) { + this.numExamples = numExamples; + return this; + } + + /** + * Get the frequencyCount value. + * + * @return the frequencyCount value + */ + public Integer frequencyCount() { + return this.frequencyCount; + } + + /** + * Set the frequencyCount value. + * + * @param frequencyCount the frequencyCount value to set + * @return the DictionaryLookupResultItemTranslationsItemBackTranslationsItem object itself. + */ + public DictionaryLookupResultItemTranslationsItemBackTranslationsItem withFrequencyCount(Integer frequencyCount) { + this.frequencyCount = frequencyCount; + return this; + } + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/DictionaryLookupTextInput.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/DictionaryLookupTextInput.java new file mode 100644 index 0000000000000..560fa749198ee --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/DictionaryLookupTextInput.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Text needed for a dictionary lookup request. + */ +public class DictionaryLookupTextInput { + /** + * The text property. + */ + @JsonProperty(value = "text") + private String text; + + /** + * Get the text value. + * + * @return the text value + */ + public String text() { + return this.text; + } + + /** + * Set the text value. + * + * @param text the text value to set + * @return the DictionaryLookupTextInput object itself. + */ + public DictionaryLookupTextInput withText(String text) { + this.text = text; + return this; + } + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/ErrorMessage.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/ErrorMessage.java new file mode 100644 index 0000000000000..1840fb65af57b --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/ErrorMessage.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The ErrorMessage model. + */ +public class ErrorMessage { + /** + * The error property. + */ + @JsonProperty(value = "error") + private ErrorMessageError error; + + /** + * Get the error value. + * + * @return the error value + */ + public ErrorMessageError error() { + return this.error; + } + + /** + * Set the error value. + * + * @param error the error value to set + * @return the ErrorMessage object itself. + */ + public ErrorMessage withError(ErrorMessageError error) { + this.error = error; + return this; + } + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/ErrorMessageError.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/ErrorMessageError.java new file mode 100644 index 0000000000000..d9db270314eab --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/ErrorMessageError.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The ErrorMessageError model. + */ +public class ErrorMessageError { + /** + * The code property. + */ + @JsonProperty(value = "code") + private String code; + + /** + * The message property. + */ + @JsonProperty(value = "message") + private String message; + + /** + * Get the code value. + * + * @return the code value + */ + public String code() { + return this.code; + } + + /** + * Set the code value. + * + * @param code the code value to set + * @return the ErrorMessageError object itself. + */ + public ErrorMessageError withCode(String code) { + this.code = code; + return this; + } + + /** + * Get the message value. + * + * @return the message value + */ + public String message() { + return this.message; + } + + /** + * Set the message value. + * + * @param message the message value to set + * @return the ErrorMessageError object itself. + */ + public ErrorMessageError withMessage(String message) { + this.message = message; + return this; + } + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/ErrorMessageException.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/ErrorMessageException.java new file mode 100644 index 0000000000000..2bd78d45f8672 --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/ErrorMessageException.java @@ -0,0 +1,44 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.models; + +import com.microsoft.rest.RestException; +import okhttp3.ResponseBody; +import retrofit2.Response; + +/** + * Exception thrown for an invalid response with ErrorMessage information. + */ +public class ErrorMessageException extends RestException { + /** + * Initializes a new instance of the ErrorMessageException class. + * + * @param message the exception message or the response content if a message is not available + * @param response the HTTP response + */ + public ErrorMessageException(final String message, final Response response) { + super(message, response); + } + + /** + * Initializes a new instance of the ErrorMessageException class. + * + * @param message the exception message or the response content if a message is not available + * @param response the HTTP response + * @param body the deserialized response body + */ + public ErrorMessageException(final String message, final Response response, final ErrorMessage body) { + super(message, response, body); + } + + @Override + public ErrorMessage body() { + return (ErrorMessage) super.body(); + } +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/LanguagesResult.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/LanguagesResult.java new file mode 100644 index 0000000000000..77b9c5b9373a4 --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/LanguagesResult.java @@ -0,0 +1,95 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Example of a successful languages request. + */ +public class LanguagesResult { + /** + * The translation property. + */ + @JsonProperty(value = "translation") + private LanguagesResultTranslation translation; + + /** + * The transliteration property. + */ + @JsonProperty(value = "transliteration") + private LanguagesResultTransliteration transliteration; + + /** + * The dictionary property. + */ + @JsonProperty(value = "dictionary") + private LanguagesResultDictionary dictionary; + + /** + * Get the translation value. + * + * @return the translation value + */ + public LanguagesResultTranslation translation() { + return this.translation; + } + + /** + * Set the translation value. + * + * @param translation the translation value to set + * @return the LanguagesResult object itself. + */ + public LanguagesResult withTranslation(LanguagesResultTranslation translation) { + this.translation = translation; + return this; + } + + /** + * Get the transliteration value. + * + * @return the transliteration value + */ + public LanguagesResultTransliteration transliteration() { + return this.transliteration; + } + + /** + * Set the transliteration value. + * + * @param transliteration the transliteration value to set + * @return the LanguagesResult object itself. + */ + public LanguagesResult withTransliteration(LanguagesResultTransliteration transliteration) { + this.transliteration = transliteration; + return this; + } + + /** + * Get the dictionary value. + * + * @return the dictionary value + */ + public LanguagesResultDictionary dictionary() { + return this.dictionary; + } + + /** + * Set the dictionary value. + * + * @param dictionary the dictionary value to set + * @return the LanguagesResult object itself. + */ + public LanguagesResult withDictionary(LanguagesResultDictionary dictionary) { + this.dictionary = dictionary; + return this; + } + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/LanguagesResultDictionary.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/LanguagesResultDictionary.java new file mode 100644 index 0000000000000..f7e847e93c7a7 --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/LanguagesResultDictionary.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The LanguagesResultDictionary model. + */ +public class LanguagesResultDictionary { + /** + * The languageCode property. + */ + @JsonProperty(value = "languageCode") + private LanguagesResultDictionaryLanguageCode languageCode; + + /** + * Get the languageCode value. + * + * @return the languageCode value + */ + public LanguagesResultDictionaryLanguageCode languageCode() { + return this.languageCode; + } + + /** + * Set the languageCode value. + * + * @param languageCode the languageCode value to set + * @return the LanguagesResultDictionary object itself. + */ + public LanguagesResultDictionary withLanguageCode(LanguagesResultDictionaryLanguageCode languageCode) { + this.languageCode = languageCode; + return this; + } + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/LanguagesResultDictionaryLanguageCode.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/LanguagesResultDictionaryLanguageCode.java new file mode 100644 index 0000000000000..ccc299936f288 --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/LanguagesResultDictionaryLanguageCode.java @@ -0,0 +1,122 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The LanguagesResultDictionaryLanguageCode model. + */ +public class LanguagesResultDictionaryLanguageCode { + /** + * The name property. + */ + @JsonProperty(value = "name") + private String name; + + /** + * The nativeName property. + */ + @JsonProperty(value = "nativeName") + private String nativeName; + + /** + * The dir property. + */ + @JsonProperty(value = "dir") + private String dir; + + /** + * The translations property. + */ + @JsonProperty(value = "translations") + private List translations; + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name value. + * + * @param name the name value to set + * @return the LanguagesResultDictionaryLanguageCode object itself. + */ + public LanguagesResultDictionaryLanguageCode withName(String name) { + this.name = name; + return this; + } + + /** + * Get the nativeName value. + * + * @return the nativeName value + */ + public String nativeName() { + return this.nativeName; + } + + /** + * Set the nativeName value. + * + * @param nativeName the nativeName value to set + * @return the LanguagesResultDictionaryLanguageCode object itself. + */ + public LanguagesResultDictionaryLanguageCode withNativeName(String nativeName) { + this.nativeName = nativeName; + return this; + } + + /** + * Get the dir value. + * + * @return the dir value + */ + public String dir() { + return this.dir; + } + + /** + * Set the dir value. + * + * @param dir the dir value to set + * @return the LanguagesResultDictionaryLanguageCode object itself. + */ + public LanguagesResultDictionaryLanguageCode withDir(String dir) { + this.dir = dir; + return this; + } + + /** + * Get the translations value. + * + * @return the translations value + */ + public List translations() { + return this.translations; + } + + /** + * Set the translations value. + * + * @param translations the translations value to set + * @return the LanguagesResultDictionaryLanguageCode object itself. + */ + public LanguagesResultDictionaryLanguageCode withTranslations(List translations) { + this.translations = translations; + return this; + } + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/LanguagesResultDictionaryLanguageCodeTranslationsItem.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/LanguagesResultDictionaryLanguageCodeTranslationsItem.java new file mode 100644 index 0000000000000..7af0a5cecc637 --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/LanguagesResultDictionaryLanguageCodeTranslationsItem.java @@ -0,0 +1,121 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The LanguagesResultDictionaryLanguageCodeTranslationsItem model. + */ +public class LanguagesResultDictionaryLanguageCodeTranslationsItem { + /** + * The name property. + */ + @JsonProperty(value = "name") + private String name; + + /** + * The nativeName property. + */ + @JsonProperty(value = "nativeName") + private String nativeName; + + /** + * The dir property. + */ + @JsonProperty(value = "dir") + private String dir; + + /** + * The code property. + */ + @JsonProperty(value = "code") + private String code; + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name value. + * + * @param name the name value to set + * @return the LanguagesResultDictionaryLanguageCodeTranslationsItem object itself. + */ + public LanguagesResultDictionaryLanguageCodeTranslationsItem withName(String name) { + this.name = name; + return this; + } + + /** + * Get the nativeName value. + * + * @return the nativeName value + */ + public String nativeName() { + return this.nativeName; + } + + /** + * Set the nativeName value. + * + * @param nativeName the nativeName value to set + * @return the LanguagesResultDictionaryLanguageCodeTranslationsItem object itself. + */ + public LanguagesResultDictionaryLanguageCodeTranslationsItem withNativeName(String nativeName) { + this.nativeName = nativeName; + return this; + } + + /** + * Get the dir value. + * + * @return the dir value + */ + public String dir() { + return this.dir; + } + + /** + * Set the dir value. + * + * @param dir the dir value to set + * @return the LanguagesResultDictionaryLanguageCodeTranslationsItem object itself. + */ + public LanguagesResultDictionaryLanguageCodeTranslationsItem withDir(String dir) { + this.dir = dir; + return this; + } + + /** + * Get the code value. + * + * @return the code value + */ + public String code() { + return this.code; + } + + /** + * Set the code value. + * + * @param code the code value to set + * @return the LanguagesResultDictionaryLanguageCodeTranslationsItem object itself. + */ + public LanguagesResultDictionaryLanguageCodeTranslationsItem withCode(String code) { + this.code = code; + return this; + } + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/LanguagesResultTranslation.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/LanguagesResultTranslation.java new file mode 100644 index 0000000000000..4afe829946ac2 --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/LanguagesResultTranslation.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The LanguagesResultTranslation model. + */ +public class LanguagesResultTranslation { + /** + * The languageCode property. + */ + @JsonProperty(value = "languageCode") + private LanguagesResultTranslationLanguageCode languageCode; + + /** + * Get the languageCode value. + * + * @return the languageCode value + */ + public LanguagesResultTranslationLanguageCode languageCode() { + return this.languageCode; + } + + /** + * Set the languageCode value. + * + * @param languageCode the languageCode value to set + * @return the LanguagesResultTranslation object itself. + */ + public LanguagesResultTranslation withLanguageCode(LanguagesResultTranslationLanguageCode languageCode) { + this.languageCode = languageCode; + return this; + } + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/LanguagesResultTranslationLanguageCode.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/LanguagesResultTranslationLanguageCode.java new file mode 100644 index 0000000000000..12b158efa0017 --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/LanguagesResultTranslationLanguageCode.java @@ -0,0 +1,95 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The LanguagesResultTranslationLanguageCode model. + */ +public class LanguagesResultTranslationLanguageCode { + /** + * The name property. + */ + @JsonProperty(value = "name") + private String name; + + /** + * The nativeName property. + */ + @JsonProperty(value = "nativeName") + private String nativeName; + + /** + * The dir property. + */ + @JsonProperty(value = "dir") + private String dir; + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name value. + * + * @param name the name value to set + * @return the LanguagesResultTranslationLanguageCode object itself. + */ + public LanguagesResultTranslationLanguageCode withName(String name) { + this.name = name; + return this; + } + + /** + * Get the nativeName value. + * + * @return the nativeName value + */ + public String nativeName() { + return this.nativeName; + } + + /** + * Set the nativeName value. + * + * @param nativeName the nativeName value to set + * @return the LanguagesResultTranslationLanguageCode object itself. + */ + public LanguagesResultTranslationLanguageCode withNativeName(String nativeName) { + this.nativeName = nativeName; + return this; + } + + /** + * Get the dir value. + * + * @return the dir value + */ + public String dir() { + return this.dir; + } + + /** + * Set the dir value. + * + * @param dir the dir value to set + * @return the LanguagesResultTranslationLanguageCode object itself. + */ + public LanguagesResultTranslationLanguageCode withDir(String dir) { + this.dir = dir; + return this; + } + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/LanguagesResultTransliteration.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/LanguagesResultTransliteration.java new file mode 100644 index 0000000000000..1db1fa47ccd3c --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/LanguagesResultTransliteration.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The LanguagesResultTransliteration model. + */ +public class LanguagesResultTransliteration { + /** + * The languageCode property. + */ + @JsonProperty(value = "languageCode") + private LanguagesResultTransliterationLanguageCode languageCode; + + /** + * Get the languageCode value. + * + * @return the languageCode value + */ + public LanguagesResultTransliterationLanguageCode languageCode() { + return this.languageCode; + } + + /** + * Set the languageCode value. + * + * @param languageCode the languageCode value to set + * @return the LanguagesResultTransliteration object itself. + */ + public LanguagesResultTransliteration withLanguageCode(LanguagesResultTransliterationLanguageCode languageCode) { + this.languageCode = languageCode; + return this; + } + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/LanguagesResultTransliterationLanguageCode.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/LanguagesResultTransliterationLanguageCode.java new file mode 100644 index 0000000000000..5df4deeb9ddfb --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/LanguagesResultTransliterationLanguageCode.java @@ -0,0 +1,96 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The LanguagesResultTransliterationLanguageCode model. + */ +public class LanguagesResultTransliterationLanguageCode { + /** + * The name property. + */ + @JsonProperty(value = "name") + private String name; + + /** + * The nativeName property. + */ + @JsonProperty(value = "nativeName") + private String nativeName; + + /** + * The scripts property. + */ + @JsonProperty(value = "scripts") + private List scripts; + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name value. + * + * @param name the name value to set + * @return the LanguagesResultTransliterationLanguageCode object itself. + */ + public LanguagesResultTransliterationLanguageCode withName(String name) { + this.name = name; + return this; + } + + /** + * Get the nativeName value. + * + * @return the nativeName value + */ + public String nativeName() { + return this.nativeName; + } + + /** + * Set the nativeName value. + * + * @param nativeName the nativeName value to set + * @return the LanguagesResultTransliterationLanguageCode object itself. + */ + public LanguagesResultTransliterationLanguageCode withNativeName(String nativeName) { + this.nativeName = nativeName; + return this; + } + + /** + * Get the scripts value. + * + * @return the scripts value + */ + public List scripts() { + return this.scripts; + } + + /** + * Set the scripts value. + * + * @param scripts the scripts value to set + * @return the LanguagesResultTransliterationLanguageCode object itself. + */ + public LanguagesResultTransliterationLanguageCode withScripts(List scripts) { + this.scripts = scripts; + return this; + } + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/LanguagesResultTransliterationLanguageCodeScriptsItem.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/LanguagesResultTransliterationLanguageCodeScriptsItem.java new file mode 100644 index 0000000000000..d8e2eb2a9a3fe --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/LanguagesResultTransliterationLanguageCodeScriptsItem.java @@ -0,0 +1,148 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The LanguagesResultTransliterationLanguageCodeScriptsItem model. + */ +public class LanguagesResultTransliterationLanguageCodeScriptsItem { + /** + * The code property. + */ + @JsonProperty(value = "code") + private String code; + + /** + * The name property. + */ + @JsonProperty(value = "name") + private String name; + + /** + * The nativeName property. + */ + @JsonProperty(value = "nativeName") + private String nativeName; + + /** + * The dir property. + */ + @JsonProperty(value = "dir") + private String dir; + + /** + * The toScripts property. + */ + @JsonProperty(value = "toScripts") + private List toScripts; + + /** + * Get the code value. + * + * @return the code value + */ + public String code() { + return this.code; + } + + /** + * Set the code value. + * + * @param code the code value to set + * @return the LanguagesResultTransliterationLanguageCodeScriptsItem object itself. + */ + public LanguagesResultTransliterationLanguageCodeScriptsItem withCode(String code) { + this.code = code; + return this; + } + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name value. + * + * @param name the name value to set + * @return the LanguagesResultTransliterationLanguageCodeScriptsItem object itself. + */ + public LanguagesResultTransliterationLanguageCodeScriptsItem withName(String name) { + this.name = name; + return this; + } + + /** + * Get the nativeName value. + * + * @return the nativeName value + */ + public String nativeName() { + return this.nativeName; + } + + /** + * Set the nativeName value. + * + * @param nativeName the nativeName value to set + * @return the LanguagesResultTransliterationLanguageCodeScriptsItem object itself. + */ + public LanguagesResultTransliterationLanguageCodeScriptsItem withNativeName(String nativeName) { + this.nativeName = nativeName; + return this; + } + + /** + * Get the dir value. + * + * @return the dir value + */ + public String dir() { + return this.dir; + } + + /** + * Set the dir value. + * + * @param dir the dir value to set + * @return the LanguagesResultTransliterationLanguageCodeScriptsItem object itself. + */ + public LanguagesResultTransliterationLanguageCodeScriptsItem withDir(String dir) { + this.dir = dir; + return this; + } + + /** + * Get the toScripts value. + * + * @return the toScripts value + */ + public List toScripts() { + return this.toScripts; + } + + /** + * Set the toScripts value. + * + * @param toScripts the toScripts value to set + * @return the LanguagesResultTransliterationLanguageCodeScriptsItem object itself. + */ + public LanguagesResultTransliterationLanguageCodeScriptsItem withToScripts(List toScripts) { + this.toScripts = toScripts; + return this; + } + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/LanguagesResultTransliterationLanguageCodeScriptsItemToScriptsItem.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/LanguagesResultTransliterationLanguageCodeScriptsItemToScriptsItem.java new file mode 100644 index 0000000000000..39c413bcced44 --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/LanguagesResultTransliterationLanguageCodeScriptsItemToScriptsItem.java @@ -0,0 +1,122 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The LanguagesResultTransliterationLanguageCodeScriptsItemToScriptsItem + * model. + */ +public class LanguagesResultTransliterationLanguageCodeScriptsItemToScriptsItem { + /** + * The code property. + */ + @JsonProperty(value = "code") + private String code; + + /** + * The name property. + */ + @JsonProperty(value = "name") + private String name; + + /** + * The nativeName property. + */ + @JsonProperty(value = "nativeName") + private String nativeName; + + /** + * The dir property. + */ + @JsonProperty(value = "dir") + private String dir; + + /** + * Get the code value. + * + * @return the code value + */ + public String code() { + return this.code; + } + + /** + * Set the code value. + * + * @param code the code value to set + * @return the LanguagesResultTransliterationLanguageCodeScriptsItemToScriptsItem object itself. + */ + public LanguagesResultTransliterationLanguageCodeScriptsItemToScriptsItem withCode(String code) { + this.code = code; + return this; + } + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name value. + * + * @param name the name value to set + * @return the LanguagesResultTransliterationLanguageCodeScriptsItemToScriptsItem object itself. + */ + public LanguagesResultTransliterationLanguageCodeScriptsItemToScriptsItem withName(String name) { + this.name = name; + return this; + } + + /** + * Get the nativeName value. + * + * @return the nativeName value + */ + public String nativeName() { + return this.nativeName; + } + + /** + * Set the nativeName value. + * + * @param nativeName the nativeName value to set + * @return the LanguagesResultTransliterationLanguageCodeScriptsItemToScriptsItem object itself. + */ + public LanguagesResultTransliterationLanguageCodeScriptsItemToScriptsItem withNativeName(String nativeName) { + this.nativeName = nativeName; + return this; + } + + /** + * Get the dir value. + * + * @return the dir value + */ + public String dir() { + return this.dir; + } + + /** + * Set the dir value. + * + * @param dir the dir value to set + * @return the LanguagesResultTransliterationLanguageCodeScriptsItemToScriptsItem object itself. + */ + public LanguagesResultTransliterationLanguageCodeScriptsItemToScriptsItem withDir(String dir) { + this.dir = dir; + return this; + } + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TranslateResultAllItem.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TranslateResultAllItem.java new file mode 100644 index 0000000000000..d77b0f0182160 --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TranslateResultAllItem.java @@ -0,0 +1,70 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The TranslateResultAllItem model. + */ +public class TranslateResultAllItem { + /** + * The detectedLanguage property. + */ + @JsonProperty(value = "detectedLanguage") + private TranslateResultAllItemDetectedLanguage detectedLanguage; + + /** + * The translations property. + */ + @JsonProperty(value = "translations") + private List translations; + + /** + * Get the detectedLanguage value. + * + * @return the detectedLanguage value + */ + public TranslateResultAllItemDetectedLanguage detectedLanguage() { + return this.detectedLanguage; + } + + /** + * Set the detectedLanguage value. + * + * @param detectedLanguage the detectedLanguage value to set + * @return the TranslateResultAllItem object itself. + */ + public TranslateResultAllItem withDetectedLanguage(TranslateResultAllItemDetectedLanguage detectedLanguage) { + this.detectedLanguage = detectedLanguage; + return this; + } + + /** + * Get the translations value. + * + * @return the translations value + */ + public List translations() { + return this.translations; + } + + /** + * Set the translations value. + * + * @param translations the translations value to set + * @return the TranslateResultAllItem object itself. + */ + public TranslateResultAllItem withTranslations(List translations) { + this.translations = translations; + return this; + } + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TranslateResultAllItemDetectedLanguage.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TranslateResultAllItemDetectedLanguage.java new file mode 100644 index 0000000000000..85cf3365aaa5a --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TranslateResultAllItemDetectedLanguage.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The TranslateResultAllItemDetectedLanguage model. + */ +public class TranslateResultAllItemDetectedLanguage { + /** + * The language property. + */ + @JsonProperty(value = "language") + private String language; + + /** + * The score property. + */ + @JsonProperty(value = "score") + private Integer score; + + /** + * Get the language value. + * + * @return the language value + */ + public String language() { + return this.language; + } + + /** + * Set the language value. + * + * @param language the language value to set + * @return the TranslateResultAllItemDetectedLanguage object itself. + */ + public TranslateResultAllItemDetectedLanguage withLanguage(String language) { + this.language = language; + return this; + } + + /** + * Get the score value. + * + * @return the score value + */ + public Integer score() { + return this.score; + } + + /** + * Set the score value. + * + * @param score the score value to set + * @return the TranslateResultAllItemDetectedLanguage object itself. + */ + public TranslateResultAllItemDetectedLanguage withScore(Integer score) { + this.score = score; + return this; + } + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TranslateResultAllItemTranslationsItem.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TranslateResultAllItemTranslationsItem.java new file mode 100644 index 0000000000000..2d6a805a1cbdb --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TranslateResultAllItemTranslationsItem.java @@ -0,0 +1,147 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The TranslateResultAllItemTranslationsItem model. + */ +public class TranslateResultAllItemTranslationsItem { + /** + * The text property. + */ + @JsonProperty(value = "text") + private String text; + + /** + * The transliteration property. + */ + @JsonProperty(value = "transliteration") + private TranslateResultAllItemTranslationsItemTransliteration transliteration; + + /** + * The to property. + */ + @JsonProperty(value = "to") + private String to; + + /** + * The alignment property. + */ + @JsonProperty(value = "alignment") + private TranslateResultAllItemTranslationsItemAlignment alignment; + + /** + * The sentLen property. + */ + @JsonProperty(value = "sentLen") + private TranslateResultAllItemTranslationsItemSentLen sentLen; + + /** + * Get the text value. + * + * @return the text value + */ + public String text() { + return this.text; + } + + /** + * Set the text value. + * + * @param text the text value to set + * @return the TranslateResultAllItemTranslationsItem object itself. + */ + public TranslateResultAllItemTranslationsItem withText(String text) { + this.text = text; + return this; + } + + /** + * Get the transliteration value. + * + * @return the transliteration value + */ + public TranslateResultAllItemTranslationsItemTransliteration transliteration() { + return this.transliteration; + } + + /** + * Set the transliteration value. + * + * @param transliteration the transliteration value to set + * @return the TranslateResultAllItemTranslationsItem object itself. + */ + public TranslateResultAllItemTranslationsItem withTransliteration(TranslateResultAllItemTranslationsItemTransliteration transliteration) { + this.transliteration = transliteration; + return this; + } + + /** + * Get the to value. + * + * @return the to value + */ + public String to() { + return this.to; + } + + /** + * Set the to value. + * + * @param to the to value to set + * @return the TranslateResultAllItemTranslationsItem object itself. + */ + public TranslateResultAllItemTranslationsItem withTo(String to) { + this.to = to; + return this; + } + + /** + * Get the alignment value. + * + * @return the alignment value + */ + public TranslateResultAllItemTranslationsItemAlignment alignment() { + return this.alignment; + } + + /** + * Set the alignment value. + * + * @param alignment the alignment value to set + * @return the TranslateResultAllItemTranslationsItem object itself. + */ + public TranslateResultAllItemTranslationsItem withAlignment(TranslateResultAllItemTranslationsItemAlignment alignment) { + this.alignment = alignment; + return this; + } + + /** + * Get the sentLen value. + * + * @return the sentLen value + */ + public TranslateResultAllItemTranslationsItemSentLen sentLen() { + return this.sentLen; + } + + /** + * Set the sentLen value. + * + * @param sentLen the sentLen value to set + * @return the TranslateResultAllItemTranslationsItem object itself. + */ + public TranslateResultAllItemTranslationsItem withSentLen(TranslateResultAllItemTranslationsItemSentLen sentLen) { + this.sentLen = sentLen; + return this; + } + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TranslateResultAllItemTranslationsItemAlignment.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TranslateResultAllItemTranslationsItemAlignment.java new file mode 100644 index 0000000000000..71af6bb17b1f1 --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TranslateResultAllItemTranslationsItemAlignment.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The TranslateResultAllItemTranslationsItemAlignment model. + */ +public class TranslateResultAllItemTranslationsItemAlignment { + /** + * The proj property. + */ + @JsonProperty(value = "proj") + private String proj; + + /** + * Get the proj value. + * + * @return the proj value + */ + public String proj() { + return this.proj; + } + + /** + * Set the proj value. + * + * @param proj the proj value to set + * @return the TranslateResultAllItemTranslationsItemAlignment object itself. + */ + public TranslateResultAllItemTranslationsItemAlignment withProj(String proj) { + this.proj = proj; + return this; + } + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TranslateResultAllItemTranslationsItemSentLen.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TranslateResultAllItemTranslationsItemSentLen.java new file mode 100644 index 0000000000000..28736d23db396 --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TranslateResultAllItemTranslationsItemSentLen.java @@ -0,0 +1,70 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The TranslateResultAllItemTranslationsItemSentLen model. + */ +public class TranslateResultAllItemTranslationsItemSentLen { + /** + * The srcSentLen property. + */ + @JsonProperty(value = "srcSentLen") + private List srcSentLen; + + /** + * The transSentLen property. + */ + @JsonProperty(value = "transSentLen") + private List transSentLen; + + /** + * Get the srcSentLen value. + * + * @return the srcSentLen value + */ + public List srcSentLen() { + return this.srcSentLen; + } + + /** + * Set the srcSentLen value. + * + * @param srcSentLen the srcSentLen value to set + * @return the TranslateResultAllItemTranslationsItemSentLen object itself. + */ + public TranslateResultAllItemTranslationsItemSentLen withSrcSentLen(List srcSentLen) { + this.srcSentLen = srcSentLen; + return this; + } + + /** + * Get the transSentLen value. + * + * @return the transSentLen value + */ + public List transSentLen() { + return this.transSentLen; + } + + /** + * Set the transSentLen value. + * + * @param transSentLen the transSentLen value to set + * @return the TranslateResultAllItemTranslationsItemSentLen object itself. + */ + public TranslateResultAllItemTranslationsItemSentLen withTransSentLen(List transSentLen) { + this.transSentLen = transSentLen; + return this; + } + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TranslateResultAllItemTranslationsItemSentLenSrcSentLenItem.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TranslateResultAllItemTranslationsItemSentLenSrcSentLenItem.java new file mode 100644 index 0000000000000..84af03cd3b31b --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TranslateResultAllItemTranslationsItemSentLenSrcSentLenItem.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The TranslateResultAllItemTranslationsItemSentLenSrcSentLenItem model. + */ +public class TranslateResultAllItemTranslationsItemSentLenSrcSentLenItem { + /** + * The integer property. + */ + @JsonProperty(value = "integer") + private Integer integer; + + /** + * Get the integer value. + * + * @return the integer value + */ + public Integer integer() { + return this.integer; + } + + /** + * Set the integer value. + * + * @param integer the integer value to set + * @return the TranslateResultAllItemTranslationsItemSentLenSrcSentLenItem object itself. + */ + public TranslateResultAllItemTranslationsItemSentLenSrcSentLenItem withInteger(Integer integer) { + this.integer = integer; + return this; + } + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TranslateResultAllItemTranslationsItemSentLenTransSentLenItem.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TranslateResultAllItemTranslationsItemSentLenTransSentLenItem.java new file mode 100644 index 0000000000000..a31372364c312 --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TranslateResultAllItemTranslationsItemSentLenTransSentLenItem.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The TranslateResultAllItemTranslationsItemSentLenTransSentLenItem model. + */ +public class TranslateResultAllItemTranslationsItemSentLenTransSentLenItem { + /** + * The integer property. + */ + @JsonProperty(value = "integer") + private Integer integer; + + /** + * Get the integer value. + * + * @return the integer value + */ + public Integer integer() { + return this.integer; + } + + /** + * Set the integer value. + * + * @param integer the integer value to set + * @return the TranslateResultAllItemTranslationsItemSentLenTransSentLenItem object itself. + */ + public TranslateResultAllItemTranslationsItemSentLenTransSentLenItem withInteger(Integer integer) { + this.integer = integer; + return this; + } + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TranslateResultAllItemTranslationsItemTransliteration.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TranslateResultAllItemTranslationsItemTransliteration.java new file mode 100644 index 0000000000000..4833031bb994f --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TranslateResultAllItemTranslationsItemTransliteration.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The TranslateResultAllItemTranslationsItemTransliteration model. + */ +public class TranslateResultAllItemTranslationsItemTransliteration { + /** + * The text property. + */ + @JsonProperty(value = "text") + private String text; + + /** + * The script property. + */ + @JsonProperty(value = "script") + private String script; + + /** + * Get the text value. + * + * @return the text value + */ + public String text() { + return this.text; + } + + /** + * Set the text value. + * + * @param text the text value to set + * @return the TranslateResultAllItemTranslationsItemTransliteration object itself. + */ + public TranslateResultAllItemTranslationsItemTransliteration withText(String text) { + this.text = text; + return this; + } + + /** + * Get the script value. + * + * @return the script value + */ + public String script() { + return this.script; + } + + /** + * Set the script value. + * + * @param script the script value to set + * @return the TranslateResultAllItemTranslationsItemTransliteration object itself. + */ + public TranslateResultAllItemTranslationsItemTransliteration withScript(String script) { + this.script = script; + return this; + } + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TranslateResultItem.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TranslateResultItem.java new file mode 100644 index 0000000000000..90857e3473b0a --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TranslateResultItem.java @@ -0,0 +1,44 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The TranslateResultItem model. + */ +public class TranslateResultItem { + /** + * The translation property. + */ + @JsonProperty(value = "translation") + private List translation; + + /** + * Get the translation value. + * + * @return the translation value + */ + public List translation() { + return this.translation; + } + + /** + * Set the translation value. + * + * @param translation the translation value to set + * @return the TranslateResultItem object itself. + */ + public TranslateResultItem withTranslation(List translation) { + this.translation = translation; + return this; + } + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TranslateResultItemTranslationItem.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TranslateResultItemTranslationItem.java new file mode 100644 index 0000000000000..aef9c72d19179 --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TranslateResultItemTranslationItem.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The TranslateResultItemTranslationItem model. + */ +public class TranslateResultItemTranslationItem { + /** + * The text property. + */ + @JsonProperty(value = "text") + private String text; + + /** + * The to property. + */ + @JsonProperty(value = "to") + private String to; + + /** + * Get the text value. + * + * @return the text value + */ + public String text() { + return this.text; + } + + /** + * Set the text value. + * + * @param text the text value to set + * @return the TranslateResultItemTranslationItem object itself. + */ + public TranslateResultItemTranslationItem withText(String text) { + this.text = text; + return this; + } + + /** + * Get the to value. + * + * @return the to value + */ + public String to() { + return this.to; + } + + /** + * Set the to value. + * + * @param to the to value to set + * @return the TranslateResultItemTranslationItem object itself. + */ + public TranslateResultItemTranslationItem withTo(String to) { + this.to = to; + return this; + } + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TranslateTextInput.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TranslateTextInput.java new file mode 100644 index 0000000000000..917b054aba0c5 --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TranslateTextInput.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Text needed for a translate request. + */ +public class TranslateTextInput { + /** + * The text property. + */ + @JsonProperty(value = "text") + private String text; + + /** + * Get the text value. + * + * @return the text value + */ + public String text() { + return this.text; + } + + /** + * Set the text value. + * + * @param text the text value to set + * @return the TranslateTextInput object itself. + */ + public TranslateTextInput withText(String text) { + this.text = text; + return this; + } + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TransliterateResultItem.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TransliterateResultItem.java new file mode 100644 index 0000000000000..93371fbe260bd --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TransliterateResultItem.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The TransliterateResultItem model. + */ +public class TransliterateResultItem { + /** + * The text property. + */ + @JsonProperty(value = "text") + private String text; + + /** + * The script property. + */ + @JsonProperty(value = "script") + private String script; + + /** + * Get the text value. + * + * @return the text value + */ + public String text() { + return this.text; + } + + /** + * Set the text value. + * + * @param text the text value to set + * @return the TransliterateResultItem object itself. + */ + public TransliterateResultItem withText(String text) { + this.text = text; + return this; + } + + /** + * Get the script value. + * + * @return the script value + */ + public String script() { + return this.script; + } + + /** + * Set the script value. + * + * @param script the script value to set + * @return the TransliterateResultItem object itself. + */ + public TransliterateResultItem withScript(String script) { + this.script = script; + return this; + } + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TransliterateTextInput.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TransliterateTextInput.java new file mode 100644 index 0000000000000..406e74f032ede --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/TransliterateTextInput.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.translatortext.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Text needed for a transliterate request. + */ +public class TransliterateTextInput { + /** + * The text property. + */ + @JsonProperty(value = "text") + private String text; + + /** + * Get the text value. + * + * @return the text value + */ + public String text() { + return this.text; + } + + /** + * Set the text value. + * + * @param text the text value to set + * @return the TransliterateTextInput object itself. + */ + public TransliterateTextInput withText(String text) { + this.text = text; + return this; + } + +} diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/package-info.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/package-info.java new file mode 100644 index 0000000000000..9461756a26c27 --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/models/package-info.java @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * This package contains the models classes for TranslatorTextClient. + * # Introduction + The Microsoft Translator Text API provides a JSON-based Web API. It provides: + * Translation between any supported languages to any other supported language. + * Translation to multiple languages in one request. + * Transliteration to convert text from one script to another script of the same language. + * Language detection, translation, and transliteration in one request. + * Dictionary to lookup alternative translations of a term, to find back-translations and examples showing terms used in context. + * Rich language detection. + # Base URLs + The Translator Text API is available in the following clouds: + | Description | Region | Base URL | + | ------- | -------- | ------- | + | Azure | Global | api.cognitive.microsofttranslator.com | + | Azure | Europe | api-eur.cognitive.microsofttranslator.com | + # Authentication + Subscribe to the Translator Text API, part of Azure Cognitive Services, and use your subscription key from the Azure portal to authenticate. You can follow the steps in https://docs.microsoft.com/en-us/azure/cognitive-services/translator/translator-text-how-to-signup. + The simplest way is to pass your Azure secret key to the Translator service using the http request header `Ocp-Apim-Subscription-Key`. + If you prefer using a short-lived authentication, you may use your secret key to obtain an authorization token from the token service. In that case you pass the authorization token to the Translator service using the `Authorization` request header. To obtain an authorization token, make a `POST` request to the following URL: + | Environment | Authentication service URL | + | ---------- | ---------- | + | Azure | `https://api.cognitive.microsoft.com/sts/v1.0/issueToken` | + Here are example requests to obtain a token with a lifetime of 10 minutes, given a secret key: + ```python + // Pass secret key using header + curl --header 'Ocp-Apim-Subscription-Key: ' --data "" 'https://api.cognitive.microsoft.com/sts/v1.0/issueToken' + // Pass secret key using query string parameter + curl --data "" 'https://api.cognitive.microsoft.com/sts/v1.0/issueToken?Subscription-Key=' + ``` + A successful request returns the encoded access token as plain text in the response body. The valid token is passed to the Translator service as a bearer token in the Authorization. + ``` + Authorization: Bearer + ``` + An authentication token is valid for 10 minutes. The token should be re-used when making multiple calls to the Translator APIs. If you make requests to the Translator API over an extended period of time, you must request a new access token at regular intervals before the token expires, for instance every 9 minutes. + To summarize, a client request to the Translator API will include one authorization header taken from the following table: + | Headers | Description | + | ---------- | ---------- | + | Ocp-Apim-Subscription-key | Use with Cognitive Services subscription if you are passing your secret key. The value is the Azure secret key for your subscription to Translator Text API. | + | Authorization | Use with Cognitive Services subscription if you are passing an authentication token. The value is the Bearer token: `Bearer `. | + ## All-in-one subscription + The last authentication option is to use a Cognitive Service’s all-in-one subscription. This allows you to use a single secret key to authenticate requests for multiple services. + When you use an all-in-one secret key, you must include two authentication headers with your request. The first passes the secret key, the second specifies the region associated with your subscription. + `Ocp-Api-Subscription-Key` `Ocp-Apim-Subscription-Region` + If you pass the secret key in the query string with the parameter `Subscription-Key`, then you must specify the region with query parameter `Subscription-Region`. + If you use a bearer token, you must obtain the token from the region endpoint: + `https://.api.cognitive.microsoft.com/sts/v1.0/issueToken`. + Available regions are: `australiaeast`, `brazilsouth`, `canadacentral`, `centralindia`, `centraluseuap`, `eastasia`, `eastus`, `eastus2`, `japaneast`, `northeurope`, `southcentralus`, `southeastasia`, `uksouth`, `westcentralus`, `westeurope`, `westus`, and `westus2`. + Region is required for the all-in-one Text API subscription. + # Errors + A standard error response is a JSON object with name/value pair named `error`. The value is also a JSON object with properties: + * `code`: A server-defined error code. + * `message`: A string giving a human-readable representation of the error. + For example, a customer with a free trial subscription receives the following error once the free quota is exhausted: + ```json + { + "error": { + "code":403000, + "message":"The subscription has exceeded its free quota." + } + } + ``` + # Enter your subscription keys to try out Microsoft Translator. + Select the `Authorize` button and enter your Microsoft Translator subscription key, OR your `all in one Cognitive Services` subscription key. If you are using the all in one Cognitive Services key you will need to also enter your subscription region. + ## Available regions are: + `australiaeast`, `brazilsouth`, `canadacentral`, `centralindia`, `centraluseuap`, `eastasia`, `eastus`, `eastus2`, `japaneast`, `northeurope`, `southcentralus`, `southeastasia`, `uksouth`, `westcentralus`, `westeurope`, `westus`, `westus2`. + */ +package com.microsoft.azure.cognitiveservices.translatortext.models; diff --git a/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/package-info.java b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/package-info.java new file mode 100644 index 0000000000000..9ef8d49e82344 --- /dev/null +++ b/cognitiveservices/data-plane/translatortext/src/main/java/com/microsoft/azure/cognitiveservices/translatortext/package-info.java @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * This package contains the classes for TranslatorTextClient. + * # Introduction + The Microsoft Translator Text API provides a JSON-based Web API. It provides: + * Translation between any supported languages to any other supported language. + * Translation to multiple languages in one request. + * Transliteration to convert text from one script to another script of the same language. + * Language detection, translation, and transliteration in one request. + * Dictionary to lookup alternative translations of a term, to find back-translations and examples showing terms used in context. + * Rich language detection. + # Base URLs + The Translator Text API is available in the following clouds: + | Description | Region | Base URL | + | ------- | -------- | ------- | + | Azure | Global | api.cognitive.microsofttranslator.com | + | Azure | Europe | api-eur.cognitive.microsofttranslator.com | + # Authentication + Subscribe to the Translator Text API, part of Azure Cognitive Services, and use your subscription key from the Azure portal to authenticate. You can follow the steps in https://docs.microsoft.com/en-us/azure/cognitive-services/translator/translator-text-how-to-signup. + The simplest way is to pass your Azure secret key to the Translator service using the http request header `Ocp-Apim-Subscription-Key`. + If you prefer using a short-lived authentication, you may use your secret key to obtain an authorization token from the token service. In that case you pass the authorization token to the Translator service using the `Authorization` request header. To obtain an authorization token, make a `POST` request to the following URL: + | Environment | Authentication service URL | + | ---------- | ---------- | + | Azure | `https://api.cognitive.microsoft.com/sts/v1.0/issueToken` | + Here are example requests to obtain a token with a lifetime of 10 minutes, given a secret key: + ```python + // Pass secret key using header + curl --header 'Ocp-Apim-Subscription-Key: ' --data "" 'https://api.cognitive.microsoft.com/sts/v1.0/issueToken' + // Pass secret key using query string parameter + curl --data "" 'https://api.cognitive.microsoft.com/sts/v1.0/issueToken?Subscription-Key=' + ``` + A successful request returns the encoded access token as plain text in the response body. The valid token is passed to the Translator service as a bearer token in the Authorization. + ``` + Authorization: Bearer + ``` + An authentication token is valid for 10 minutes. The token should be re-used when making multiple calls to the Translator APIs. If you make requests to the Translator API over an extended period of time, you must request a new access token at regular intervals before the token expires, for instance every 9 minutes. + To summarize, a client request to the Translator API will include one authorization header taken from the following table: + | Headers | Description | + | ---------- | ---------- | + | Ocp-Apim-Subscription-key | Use with Cognitive Services subscription if you are passing your secret key. The value is the Azure secret key for your subscription to Translator Text API. | + | Authorization | Use with Cognitive Services subscription if you are passing an authentication token. The value is the Bearer token: `Bearer `. | + ## All-in-one subscription + The last authentication option is to use a Cognitive Service’s all-in-one subscription. This allows you to use a single secret key to authenticate requests for multiple services. + When you use an all-in-one secret key, you must include two authentication headers with your request. The first passes the secret key, the second specifies the region associated with your subscription. + `Ocp-Api-Subscription-Key` `Ocp-Apim-Subscription-Region` + If you pass the secret key in the query string with the parameter `Subscription-Key`, then you must specify the region with query parameter `Subscription-Region`. + If you use a bearer token, you must obtain the token from the region endpoint: + `https://.api.cognitive.microsoft.com/sts/v1.0/issueToken`. + Available regions are: `australiaeast`, `brazilsouth`, `canadacentral`, `centralindia`, `centraluseuap`, `eastasia`, `eastus`, `eastus2`, `japaneast`, `northeurope`, `southcentralus`, `southeastasia`, `uksouth`, `westcentralus`, `westeurope`, `westus`, and `westus2`. + Region is required for the all-in-one Text API subscription. + # Errors + A standard error response is a JSON object with name/value pair named `error`. The value is also a JSON object with properties: + * `code`: A server-defined error code. + * `message`: A string giving a human-readable representation of the error. + For example, a customer with a free trial subscription receives the following error once the free quota is exhausted: + ```json + { + "error": { + "code":403000, + "message":"The subscription has exceeded its free quota." + } + } + ``` + # Enter your subscription keys to try out Microsoft Translator. + Select the `Authorize` button and enter your Microsoft Translator subscription key, OR your `all in one Cognitive Services` subscription key. If you are using the all in one Cognitive Services key you will need to also enter your subscription region. + ## Available regions are: + `australiaeast`, `brazilsouth`, `canadacentral`, `centralindia`, `centraluseuap`, `eastasia`, `eastus`, `eastus2`, `japaneast`, `northeurope`, `southcentralus`, `southeastasia`, `uksouth`, `westcentralus`, `westeurope`, `westus`, `westus2`. + */ +package com.microsoft.azure.cognitiveservices.translatortext;