public class LanguageTranslation extends WatsonService
VERSION
Constructor and Description |
---|
LanguageTranslation()
Instantiates a new Language Translation service.
|
Modifier and Type | Method and Description |
---|---|
TranslationModel |
createModel(CreateModelOptions options)
Creates a translation models.
|
void |
deleteModel(String modelId)
Deletes a translation models.
|
List<IdentifiableLanguage> |
getIdentifiableLanguages()
Retrieves the list of identifiable languages.
|
TranslationModel |
getModel(String modelId)
Retrieves a translation models.
|
List<TranslationModel> |
getModels()
Retrieves the list of translation models.
|
List<TranslationModel> |
getModels(Boolean showDefault,
String source,
String target)
Retrieves the list of models.
|
List<IdentifiedLanguage> |
identify(String text)
Identify language in which text is written.
|
TranslationResult |
translate(String text,
String modelId)
Translate text using a model.
|
TranslationResult |
translate(String text,
String source,
String target)
Translate text using source and target languages.
Here is an example of how to translate "hello" from English to Spanish: |
configureHttpClient, execute, executeRequest, executeWithoutResponse, getApiKey, getEndPoint, getName, getToken, setApiKey, setAuthentication, setDefaultHeaders, setEndPoint, setUsernameAndPassword, toString
public LanguageTranslation()
public TranslationModel createModel(CreateModelOptions options)
options
- the create model optionspublic void deleteModel(String modelId)
modelId
- the model identifierpublic List<IdentifiableLanguage> getIdentifiableLanguages()
TranslationModel
public TranslationModel getModel(String modelId)
modelId
- the model identifierTranslationModel
public List<TranslationModel> getModels()
TranslationModel
public List<TranslationModel> getModels(Boolean showDefault, String source, String target)
showDefault
- show default modelssource
- the sourcetarget
- the targetTranslationModel
public List<IdentifiedLanguage> identify(String text)
text
- the text to identifypublic TranslationResult translate(String text, String modelId)
text
- The submitted paragraphs to translatemodelId
- the model idTranslationResult
public TranslationResult translate(String text, String source, String target)
LanguageTranslation service = new LanguageTranslation(); service.setUsernameAndPassword("USERNAME", "PASSWORD"); TranslationResult translationResult = service.translate("hello", "en", "es"); System.out.println(translationResult);
text
- The submitted paragraphs to translatesource
- The source languagetarget
- The target languageTranslationResult
Copyright © 2015–2016. All rights reserved.