public class LanguageTranslator
extends com.ibm.cloud.sdk.core.service.BaseService
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_SERVICE_NAME |
static String |
DEFAULT_SERVICE_URL |
Constructor and Description |
---|
LanguageTranslator(String version)
Constructs an instance of the `LanguageTranslator` client.
|
LanguageTranslator(String version,
com.ibm.cloud.sdk.core.security.Authenticator authenticator)
Constructs an instance of the `LanguageTranslator` client.
|
LanguageTranslator(String version,
String serviceName)
Constructs an instance of the `LanguageTranslator` client.
|
LanguageTranslator(String version,
String serviceName,
com.ibm.cloud.sdk.core.security.Authenticator authenticator)
Constructs an instance of the `LanguageTranslator` client.
|
Modifier and Type | Method and Description |
---|---|
com.ibm.cloud.sdk.core.http.ServiceCall<TranslationModel> |
createModel(CreateModelOptions createModelOptions)
Create model.
|
com.ibm.cloud.sdk.core.http.ServiceCall<Void> |
deleteDocument(DeleteDocumentOptions deleteDocumentOptions)
Delete document.
|
com.ibm.cloud.sdk.core.http.ServiceCall<DeleteModelResult> |
deleteModel(DeleteModelOptions deleteModelOptions)
Delete model.
|
com.ibm.cloud.sdk.core.http.ServiceCall<DocumentStatus> |
getDocumentStatus(GetDocumentStatusOptions getDocumentStatusOptions)
Get document status.
|
com.ibm.cloud.sdk.core.http.ServiceCall<TranslationModel> |
getModel(GetModelOptions getModelOptions)
Get model details.
|
com.ibm.cloud.sdk.core.http.ServiceCall<InputStream> |
getTranslatedDocument(GetTranslatedDocumentOptions getTranslatedDocumentOptions)
Get translated document.
|
String |
getVersion()
Gets the version.
|
com.ibm.cloud.sdk.core.http.ServiceCall<IdentifiedLanguages> |
identify(IdentifyOptions identifyOptions)
Identify language.
|
com.ibm.cloud.sdk.core.http.ServiceCall<DocumentList> |
listDocuments()
List documents.
|
com.ibm.cloud.sdk.core.http.ServiceCall<DocumentList> |
listDocuments(ListDocumentsOptions listDocumentsOptions)
List documents.
|
com.ibm.cloud.sdk.core.http.ServiceCall<IdentifiableLanguages> |
listIdentifiableLanguages()
List identifiable languages.
|
com.ibm.cloud.sdk.core.http.ServiceCall<IdentifiableLanguages> |
listIdentifiableLanguages(ListIdentifiableLanguagesOptions listIdentifiableLanguagesOptions)
List identifiable languages.
|
com.ibm.cloud.sdk.core.http.ServiceCall<Languages> |
listLanguages()
List supported languages.
|
com.ibm.cloud.sdk.core.http.ServiceCall<Languages> |
listLanguages(ListLanguagesOptions listLanguagesOptions)
List supported languages.
|
com.ibm.cloud.sdk.core.http.ServiceCall<TranslationModels> |
listModels()
List models.
|
com.ibm.cloud.sdk.core.http.ServiceCall<TranslationModels> |
listModels(ListModelsOptions listModelsOptions)
List models.
|
void |
setVersion(String version)
Sets the version.
|
com.ibm.cloud.sdk.core.http.ServiceCall<TranslationResult> |
translate(TranslateOptions translateOptions)
Translate.
|
com.ibm.cloud.sdk.core.http.ServiceCall<DocumentStatus> |
translateDocument(TranslateDocumentOptions translateDocumentOptions)
Translate document.
|
public static final String DEFAULT_SERVICE_NAME
public static final String DEFAULT_SERVICE_URL
public LanguageTranslator(String version)
version
- Release date of the version of the API you want to use. Specify dates in
YYYY-MM-DD format. The current version is `2018-05-01`.public LanguageTranslator(String version, com.ibm.cloud.sdk.core.security.Authenticator authenticator)
version
- Release date of the version of the API you want to use. Specify dates in
YYYY-MM-DD format. The current version is `2018-05-01`.authenticator
- the Authenticator
instance to be configured for this clientpublic LanguageTranslator(String version, String serviceName)
version
- Release date of the version of the API you want to use. Specify dates in
YYYY-MM-DD format. The current version is `2018-05-01`.serviceName
- the service name to be used when configuring the client instancepublic LanguageTranslator(String version, String serviceName, com.ibm.cloud.sdk.core.security.Authenticator authenticator)
version
- Release date of the version of the API you want to use. Specify dates in
YYYY-MM-DD format. The current version is `2018-05-01`.serviceName
- the service name to be used when configuring the client instanceauthenticator
- the Authenticator
instance to be configured for this clientpublic String getVersion()
Release date of the version of the API you want to use. Specify dates in YYYY-MM-DD format. The current version is `2018-05-01`.
public void setVersion(String version)
version
- the new versionpublic com.ibm.cloud.sdk.core.http.ServiceCall<Languages> listLanguages(ListLanguagesOptions listLanguagesOptions)
Lists all supported languages for translation. The method returns an array of supported languages with information about each language. Languages are listed in alphabetical order by language code (for example, `af`, `ar`). In addition to basic information about each language, the response indicates whether the language is `supported_as_source` for translation and `supported_as_target` for translation. It also lists whether the language is `identifiable`.
listLanguagesOptions
- the ListLanguagesOptions
containing the options for the
callServiceCall
with a result of type Languages
public com.ibm.cloud.sdk.core.http.ServiceCall<Languages> listLanguages()
Lists all supported languages for translation. The method returns an array of supported languages with information about each language. Languages are listed in alphabetical order by language code (for example, `af`, `ar`). In addition to basic information about each language, the response indicates whether the language is `supported_as_source` for translation and `supported_as_target` for translation. It also lists whether the language is `identifiable`.
ServiceCall
with a result of type Languages
public com.ibm.cloud.sdk.core.http.ServiceCall<TranslationResult> translate(TranslateOptions translateOptions)
Translates the input text from the source language to the target language. Specify a model ID that indicates the source and target languages, or specify the source and target languages individually. You can omit the source language to have the service attempt to detect the language from the input text. If you omit the source language, the request must contain sufficient input text for the service to identify the source language.
You can translate a maximum of 50 KB (51,200 bytes) of text with a single request. All input text must be encoded in UTF-8 format.
translateOptions
- the TranslateOptions
containing the options for the callServiceCall
with a result of type TranslationResult
public com.ibm.cloud.sdk.core.http.ServiceCall<IdentifiableLanguages> listIdentifiableLanguages(ListIdentifiableLanguagesOptions listIdentifiableLanguagesOptions)
Lists the languages that the service can identify. Returns the language code (for example, `en` for English or `es` for Spanish) and name of each language.
listIdentifiableLanguagesOptions
- the ListIdentifiableLanguagesOptions
containing
the options for the callServiceCall
with a result of type IdentifiableLanguages
public com.ibm.cloud.sdk.core.http.ServiceCall<IdentifiableLanguages> listIdentifiableLanguages()
Lists the languages that the service can identify. Returns the language code (for example, `en` for English or `es` for Spanish) and name of each language.
ServiceCall
with a result of type IdentifiableLanguages
public com.ibm.cloud.sdk.core.http.ServiceCall<IdentifiedLanguages> identify(IdentifyOptions identifyOptions)
Identifies the language of the input text.
identifyOptions
- the IdentifyOptions
containing the options for the callServiceCall
with a result of type IdentifiedLanguages
public com.ibm.cloud.sdk.core.http.ServiceCall<TranslationModels> listModels(ListModelsOptions listModelsOptions)
Lists available translation models.
listModelsOptions
- the ListModelsOptions
containing the options for the callServiceCall
with a result of type TranslationModels
public com.ibm.cloud.sdk.core.http.ServiceCall<TranslationModels> listModels()
Lists available translation models.
ServiceCall
with a result of type TranslationModels
public com.ibm.cloud.sdk.core.http.ServiceCall<TranslationModel> createModel(CreateModelOptions createModelOptions)
Uploads training files to customize a translation model. You can customize a model with a forced glossary or with a parallel corpus: * Use a *forced glossary* to force certain terms and phrases to be translated in a specific way. You can upload only a single forced glossary file for a model. The size of a forced glossary file for a custom model is limited to 10 MB. * Use a *parallel corpus* when you want your custom model to learn from general translation patterns in parallel sentences in your samples. What your model learns from a parallel corpus can improve translation results for input text that the model has not been trained on. You can upload multiple parallel corpora files with a request. To successfully train with parallel corpora, the corpora files must contain a cumulative total of at least 5000 parallel sentences. The cumulative size of all uploaded corpus files for a custom model is limited to 250 MB.
Depending on the type of customization and the size of the uploaded files, training time can range from minutes for a glossary to several hours for a large parallel corpus. To create a model that is customized with a parallel corpus and a forced glossary, customize the model with a parallel corpus first and then customize the resulting model with a forced glossary.
You can create a maximum of 10 custom models per language pair. For more information about customizing a translation model, including the formatting and character restrictions for data files, see [Customizing your model](https://cloud.ibm.com/docs/language-translator?topic=language-translator-customizing).
#### Supported file formats
You can provide your training data for customization in the following document formats: * **TMX** (`.tmx`) - Translation Memory eXchange (TMX) is an XML specification for the exchange of translation memories. * **XLIFF** (`.xliff`) - XML Localization Interchange File Format (XLIFF) is an XML specification for the exchange of translation memories. * **CSV** (`.csv`) - Comma-separated values (CSV) file with two columns for aligned sentences and phrases. The first row must have two language codes. The first column is for the source language code, and the second column is for the target language code. * **TSV** (`.tsv` or `.tab`) - Tab-separated values (TSV) file with two columns for aligned sentences and phrases. The first row must have two language codes. The first column is for the source language code, and the second column is for the target language code. * **JSON** (`.json`) - Custom JSON format for specifying aligned sentences and phrases. * **Microsoft Excel** (`.xls` or `.xlsx`) - Excel file with the first two columns for aligned sentences and phrases. The first row contains the language code.
You must encode all text data in UTF-8 format. For more information, see [Supported document formats for training data](https://cloud.ibm.com/docs/language-translator?topic=language-translator-customizing#supported-document-formats-for-training-data).
#### Specifying file formats
You can indicate the format of a file by including the file extension with the file name. Use the file extensions shown in **Supported file formats**.
Alternatively, you can omit the file extension and specify one of the following `content-type` specifications for the file: * **TMX** - `application/x-tmx+xml` * **XLIFF** - `application/xliff+xml` * **CSV** - `text/csv` * **TSV** - `text/tab-separated-values` * **JSON** - `application/json` * **Microsoft Excel** - `application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`
For example, with `curl`, use the following `content-type` specification to indicate the format of a CSV file named **glossary**:
`--form "forced_glossary=@glossary;type=text/csv"`.
createModelOptions
- the CreateModelOptions
containing the options for the callServiceCall
with a result of type TranslationModel
public com.ibm.cloud.sdk.core.http.ServiceCall<DeleteModelResult> deleteModel(DeleteModelOptions deleteModelOptions)
Deletes a custom translation model.
deleteModelOptions
- the DeleteModelOptions
containing the options for the callServiceCall
with a result of type DeleteModelResult
public com.ibm.cloud.sdk.core.http.ServiceCall<TranslationModel> getModel(GetModelOptions getModelOptions)
Gets information about a translation model, including training status for custom models. Use this API call to poll the status of your customization request. A successfully completed training has a status of `available`.
getModelOptions
- the GetModelOptions
containing the options for the callServiceCall
with a result of type TranslationModel
public com.ibm.cloud.sdk.core.http.ServiceCall<DocumentList> listDocuments(ListDocumentsOptions listDocumentsOptions)
Lists documents that have been submitted for translation.
listDocumentsOptions
- the ListDocumentsOptions
containing the options for the
callServiceCall
with a result of type DocumentList
public com.ibm.cloud.sdk.core.http.ServiceCall<DocumentList> listDocuments()
Lists documents that have been submitted for translation.
ServiceCall
with a result of type DocumentList
public com.ibm.cloud.sdk.core.http.ServiceCall<DocumentStatus> translateDocument(TranslateDocumentOptions translateDocumentOptions)
Submit a document for translation. You can submit the document contents in the `file` parameter, or you can reference a previously submitted document by document ID. The maximum file size for document translation is * 20 MB for service instances on the Standard, Advanced, and Premium plans * 2 MB for service instances on the Lite plan.
translateDocumentOptions
- the TranslateDocumentOptions
containing the options for
the callServiceCall
with a result of type DocumentStatus
public com.ibm.cloud.sdk.core.http.ServiceCall<DocumentStatus> getDocumentStatus(GetDocumentStatusOptions getDocumentStatusOptions)
Gets the translation status of a document.
getDocumentStatusOptions
- the GetDocumentStatusOptions
containing the options for
the callServiceCall
with a result of type DocumentStatus
public com.ibm.cloud.sdk.core.http.ServiceCall<Void> deleteDocument(DeleteDocumentOptions deleteDocumentOptions)
Deletes a document.
deleteDocumentOptions
- the DeleteDocumentOptions
containing the options for the
callServiceCall
with a void resultpublic com.ibm.cloud.sdk.core.http.ServiceCall<InputStream> getTranslatedDocument(GetTranslatedDocumentOptions getTranslatedDocumentOptions)
Gets the translated document associated with the given document ID.
getTranslatedDocumentOptions
- the GetTranslatedDocumentOptions
containing the
options for the callServiceCall
with a result of type InputStream
Copyright © 2021 IBM Cloud. All rights reserved.