public class LanguageTranslation extends WatsonService
MESSAGE_CODE, MESSAGE_ERROR, VERSION| Constructor and Description |
|---|
LanguageTranslation()
Instantiates a new Language Translator service.
|
LanguageTranslation(String username,
String password)
Instantiates a new language translation service by username and password.
|
| Modifier and Type | Method and Description |
|---|---|
ServiceCall<TranslationModel> |
createModel(CreateModelOptions options)
Creates a translation models.
|
ServiceCall<Void> |
deleteModel(String modelId)
Deletes a translation models.
|
ServiceCall<List<IdentifiableLanguage>> |
getIdentifiableLanguages()
Gets the The identifiable languages.
|
ServiceCall<TranslationModel> |
getModel(String modelId)
Gets a translation models.
|
ServiceCall<List<TranslationModel>> |
getModels()
Gets the translation models.
|
ServiceCall<List<TranslationModel>> |
getModels(Boolean showDefault,
String source,
String target)
Retrieves the list of models.
|
ServiceCall<List<IdentifiedLanguage>> |
identify(String text)
Identify language in which text is written.
|
ServiceCall<TranslationResult> |
translate(List<String> texts,
Language source,
Language target)
Translate multiple texts using source and target languages.
|
ServiceCall<TranslationResult> |
translate(List<String> texts,
String modelId)
Translate multiple texts using a given model.
|
ServiceCall<TranslationResult> |
translate(String text,
Language source,
Language target)
Translate text using source and target languages.
Here is an example of how to translate "hello" from English to Spanish: |
ServiceCall<TranslationResult> |
translate(String text,
String modelId)
Translate text using a given model.
|
configureHttpClient, createServiceCall, getApiKey, getEndPoint, getName, getToken, processServiceCall, setApiKey, setAuthentication, setDefaultHeaders, setEndPoint, setSkipAuthentication, setUsernameAndPassword, toStringpublic LanguageTranslation()
public ServiceCall<TranslationModel> createModel(CreateModelOptions options)
options - the create model optionspublic ServiceCall<Void> deleteModel(String modelId)
modelId - the model identifierpublic ServiceCall<List<IdentifiableLanguage>> getIdentifiableLanguages()
See {@link IdentifiableLanguage}public ServiceCall<TranslationModel> getModel(String modelId)
modelId - the model identifierTranslationModelpublic ServiceCall<List<TranslationModel>> getModels()
TranslationModelpublic ServiceCall<List<TranslationModel>> getModels(Boolean showDefault, String source, String target)
showDefault - show default modelssource - the sourcetarget - the targetTranslationModelpublic ServiceCall<List<IdentifiedLanguage>> identify(String text)
text - the text to identifypublic ServiceCall<TranslationResult> translate(String text, String modelId)
text - The submitted paragraphs to translatemodelId - the model idTranslationResultpublic ServiceCall<TranslationResult> translate(String text, Language source, Language target)
LanguageTranslation service = new LanguageTranslation();
service.setUsernameAndPassword("USERNAME", "PASSWORD");
TranslationResult translationResult = service.translate("hello", Language.SPANISH, Language.ENGLISH).execute();
System.out.println(translationResult);
text - The paragraphs to translatesource - The source languagetarget - The target languageTranslationResultpublic ServiceCall<TranslationResult> translate(List<String> texts, String modelId)
texts - The submitted texts to translatemodelId - the model idTranslationResult with translations in the same order as the supplied texts.public ServiceCall<TranslationResult> translate(List<String> texts, Language source, Language target)
texts - The texts to translatesource - The source languagetarget - The target languageTranslationResult with translations in the same order as the supplied texts.Copyright © 2015–2016. All rights reserved.