TranslationTarget Class

  • java.lang.Object
    • com.azure.ai.translation.text.models.TranslationTarget

Implements

public final class TranslationTarget
implements JsonSerializable<TranslationTarget>

Target language and translation configuration parameters.

Constructor Summary

Constructor Description
TranslationTarget(String language)

Creates an instance of TranslationTarget class.

Method Summary

Modifier and Type Method and Description
static TranslationTarget fromJson(JsonReader jsonReader)

Reads an instance of TranslationTarget from the JsonReader.

String getAdaptiveDatasetId()

Get the adaptiveDatasetId property: Reference dataset ID having sentence pair to generate adaptive customized translation.

String getDeploymentName()

Get the deploymentName property: Default is 'general', which uses NMT system.

TranslationGender getGender()

Get the gender property: Desired gender of target translation.

String getLanguage()

Get the language property: Specifies the language of the output text.

ProfanityAction getProfanityAction()

Get the profanityAction property: Specifies how profanities should be treated in translations.

ProfanityMarker getProfanityMarker()

Get the profanityMarker property: Specifies how profanities should be marked in translations.

List<ReferenceTextPair> getReferenceTextPairs()

Get the referenceTextPairs property: Reference text pairs to generate adaptive customized translation.

String getScript()

Get the script property: Specifies the script of the translated text.

TranslationTone getTone()

Get the tone property: Desired tone of target translation.

Boolean isAllowFallback()

Get the allowFallback property: In the case where a custom system is being used, specifies that the service is allowed to fall back to a general system when a custom system doesn't exist.

TranslationTarget setAdaptiveDatasetId(String adaptiveDatasetId)

Set the adaptiveDatasetId property: Reference dataset ID having sentence pair to generate adaptive customized translation.

TranslationTarget setAllowFallback(Boolean allowFallback)

Set the allowFallback property: In the case where a custom system is being used, specifies that the service is allowed to fall back to a general system when a custom system doesn't exist.

TranslationTarget setDeploymentName(String deploymentName)

Set the deploymentName property: Default is 'general', which uses NMT system.

TranslationTarget setGender(TranslationGender gender)

Set the gender property: Desired gender of target translation.

TranslationTarget setProfanityAction(ProfanityAction profanityAction)

Set the profanityAction property: Specifies how profanities should be treated in translations.

TranslationTarget setProfanityMarker(ProfanityMarker profanityMarker)

Set the profanityMarker property: Specifies how profanities should be marked in translations.

TranslationTarget setReferenceTextPairs(List<ReferenceTextPair> referenceTextPairs)

Set the referenceTextPairs property: Reference text pairs to generate adaptive customized translation.

TranslationTarget setScript(String script)

Set the script property: Specifies the script of the translated text.

TranslationTarget setTone(TranslationTone tone)

Set the tone property: Desired tone of target translation.

JsonWriter toJson(JsonWriter jsonWriter)

Methods inherited from java.lang.Object

Constructor Details

TranslationTarget

public TranslationTarget(String language)

Creates an instance of TranslationTarget class.

Parameters:

language - the language value to set.

Method Details

fromJson

public static TranslationTarget fromJson(JsonReader jsonReader)

Reads an instance of TranslationTarget from the JsonReader.

Parameters:

jsonReader - The JsonReader being read.

Returns:

An instance of TranslationTarget if the JsonReader was pointing to an instance of it, or null if it was pointing to JSON null.

Throws:

IOException

- If the deserialized JSON object was missing any required properties.

getAdaptiveDatasetId

public String getAdaptiveDatasetId()

Get the adaptiveDatasetId property: Reference dataset ID having sentence pair to generate adaptive customized translation.

Returns:

the adaptiveDatasetId value.

getDeploymentName

public String getDeploymentName()

Get the deploymentName property: Default is 'general', which uses NMT system. 'abc-inc-gpt-4o', and 'abc-inc-gpt-4o-mini' are examples of deployment names which use GPT-4o uses or GPT-4o-mini model. 'gpt-4o' uses GPT-4o model. '<custom model id>' uses the custom NMT model tuned by customer. 'best' system determines which is the best model to use for the request. This intelligence could be introduced in future. Customer should have deployed it in their resource.

Returns:

the deploymentName value.

getGender

public TranslationGender getGender()

Get the gender property: Desired gender of target translation. Accepted values are female, male, or neutral.

Returns:

the gender value.

getLanguage

public String getLanguage()

Get the language property: Specifies the language of the output text. The target language must be one of the supported languages included in the translation scope. It's possible to translate to multiple languages simultaneously by including multiple string values in the targetsLanguage array.

Returns:

the language value.

getProfanityAction

public ProfanityAction getProfanityAction()

Get the profanityAction property: Specifies how profanities should be treated in translations. Possible values are: NoAction (default), Marked or Deleted.

Returns:

the profanityAction value.

getProfanityMarker

public ProfanityMarker getProfanityMarker()

Get the profanityMarker property: Specifies how profanities should be marked in translations. Possible values are: Asterisk (default) or Tag.

Returns:

the profanityMarker value.

getReferenceTextPairs

public List<ReferenceTextPair> getReferenceTextPairs()

Get the referenceTextPairs property: Reference text pairs to generate adaptive customized translation.

Returns:

the referenceTextPairs value.

getScript

public String getScript()

Get the script property: Specifies the script of the translated text.

Returns:

the script value.

getTone

public TranslationTone getTone()

Get the tone property: Desired tone of target translation. Accepted values are formal, informal, or neutral.

Returns:

the tone value.

isAllowFallback

public Boolean isAllowFallback()

Get the allowFallback property: In the case where a custom system is being used, specifies that the service is allowed to fall back to a general system when a custom system doesn't exist. In the case where a Large Language Model is being used, specifies that the service is allowed to fall back to a Small Language Model if an error occurs. Possible values are: true (default) or false. allowFallback=false specifies that the translation should only use systems trained for the category specified by the request. If a translation for language X to language Y requires chaining through a pivot language E, then all the systems in the chain (X → E and E → Y) will need to be custom and have the same category. If no system is found with the specific category, the request will return a 400 status code. allowFallback=true specifies that the service is allowed to fall back to a general system when a custom system doesn't exist.

Returns:

the allowFallback value.

setAdaptiveDatasetId

public TranslationTarget setAdaptiveDatasetId(String adaptiveDatasetId)

Set the adaptiveDatasetId property: Reference dataset ID having sentence pair to generate adaptive customized translation.

Parameters:

adaptiveDatasetId - the adaptiveDatasetId value to set.

Returns:

the TranslationTarget object itself.

setAllowFallback

public TranslationTarget setAllowFallback(Boolean allowFallback)

Set the allowFallback property: In the case where a custom system is being used, specifies that the service is allowed to fall back to a general system when a custom system doesn't exist. In the case where a Large Language Model is being used, specifies that the service is allowed to fall back to a Small Language Model if an error occurs. Possible values are: true (default) or false. allowFallback=false specifies that the translation should only use systems trained for the category specified by the request. If a translation for language X to language Y requires chaining through a pivot language E, then all the systems in the chain (X → E and E → Y) will need to be custom and have the same category. If no system is found with the specific category, the request will return a 400 status code. allowFallback=true specifies that the service is allowed to fall back to a general system when a custom system doesn't exist.

Parameters:

allowFallback - the allowFallback value to set.

Returns:

the TranslationTarget object itself.

setDeploymentName

public TranslationTarget setDeploymentName(String deploymentName)

Set the deploymentName property: Default is 'general', which uses NMT system. 'abc-inc-gpt-4o', and 'abc-inc-gpt-4o-mini' are examples of deployment names which use GPT-4o uses or GPT-4o-mini model. 'gpt-4o' uses GPT-4o model. '<custom model id>' uses the custom NMT model tuned by customer. 'best' system determines which is the best model to use for the request. This intelligence could be introduced in future. Customer should have deployed it in their resource.

Parameters:

deploymentName - the deploymentName value to set.

Returns:

the TranslationTarget object itself.

setGender

public TranslationTarget setGender(TranslationGender gender)

Set the gender property: Desired gender of target translation. Accepted values are female, male, or neutral.

Parameters:

gender - the gender value to set.

Returns:

the TranslationTarget object itself.

setProfanityAction

public TranslationTarget setProfanityAction(ProfanityAction profanityAction)

Set the profanityAction property: Specifies how profanities should be treated in translations. Possible values are: NoAction (default), Marked or Deleted.

Parameters:

profanityAction - the profanityAction value to set.

Returns:

the TranslationTarget object itself.

setProfanityMarker

public TranslationTarget setProfanityMarker(ProfanityMarker profanityMarker)

Set the profanityMarker property: Specifies how profanities should be marked in translations. Possible values are: Asterisk (default) or Tag.

Parameters:

profanityMarker - the profanityMarker value to set.

Returns:

the TranslationTarget object itself.

setReferenceTextPairs

public TranslationTarget setReferenceTextPairs(List<ReferenceTextPair> referenceTextPairs)

Set the referenceTextPairs property: Reference text pairs to generate adaptive customized translation.

Parameters:

referenceTextPairs - the referenceTextPairs value to set.

Returns:

the TranslationTarget object itself.

setScript

public TranslationTarget setScript(String script)

Set the script property: Specifies the script of the translated text.

Parameters:

script - the script value to set.

Returns:

the TranslationTarget object itself.

setTone

public TranslationTarget setTone(TranslationTone tone)

Set the tone property: Desired tone of target translation. Accepted values are formal, informal, or neutral.

Parameters:

tone - the tone value to set.

Returns:

the TranslationTarget object itself.

toJson

public JsonWriter toJson(JsonWriter jsonWriter)

Parameters:

jsonWriter

Throws:

Applies to