ibm_watson.language_translator_v3 module

IBM Watson™ Language Translator translates text from one language to another. The service offers multiple IBM-provided translation models that you can customize based on your unique terminology and language. Use Language Translator to take news from across the globe and present it in your language, communicate with your customers in their own language, and more.

class LanguageTranslatorV3(version: str, authenticator: ibm_cloud_sdk_core.authenticators.authenticator.Authenticator = None, service_name: str = 'language_translator')[source]

Bases: ibm_cloud_sdk_core.base_service.BaseService

The Language Translator V3 service.

DEFAULT_SERVICE_URL = 'https://api.us-south.language-translator.watson.cloud.ibm.com'
DEFAULT_SERVICE_NAME = 'language_translator'
list_languages(**kwargs) → ibm_cloud_sdk_core.detailed_response.DetailedResponse[source]

List supported languages.

Lists all supported languages. 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).

Parameters

headers (dict) – A dict containing the request headers

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse

translate(text: List[str], *, model_id: str = None, source: str = None, target: str = None, **kwargs) → ibm_cloud_sdk_core.detailed_response.DetailedResponse[source]

Translate.

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.

Parameters
  • text (List[str]) – Input text in UTF-8 encoding. Multiple entries result in multiple translations in the response.

  • model_id (str) – (optional) The model to use for translation. For example, en-de selects the IBM-provided base model for English-to-German translation. A model ID overrides the source and target parameters and is required if you use a custom model. If no model ID is specified, you must specify at least a target language.

  • source (str) – (optional) Language code that specifies the language of the input text. If omitted, the service derives the source language from the input text. The input must contain sufficient text for the service to identify the language reliably.

  • target (str) – (optional) Language code that specifies the target language for translation. Required if model ID is not specified.

  • headers (dict) – A dict containing the request headers

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse

list_identifiable_languages(**kwargs) → ibm_cloud_sdk_core.detailed_response.DetailedResponse[source]

List identifiable languages.

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.

Parameters

headers (dict) – A dict containing the request headers

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse

identify(text: str, **kwargs) → ibm_cloud_sdk_core.detailed_response.DetailedResponse[source]

Identify language.

Identifies the language of the input text.

Parameters
  • text (str) – Input text in UTF-8 format.

  • headers (dict) – A dict containing the request headers

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse

list_models(*, source: str = None, target: str = None, default: bool = None, **kwargs) → ibm_cloud_sdk_core.detailed_response.DetailedResponse[source]

List models.

Lists available translation models.

Parameters
  • source (str) – (optional) Specify a language code to filter results by source language.

  • target (str) – (optional) Specify a language code to filter results by target language.

  • default (bool) – (optional) If the default parameter isn’t specified, the service returns all models (default and non-default) for each language pair. To return only default models, set this parameter to true. To return only non-default models, set this parameter to false. There is exactly one default model, the IBM-provided base model, per language pair.

  • headers (dict) – A dict containing the request headers

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse

create_model(base_model_id: str, *, forced_glossary: BinaryIO = None, parallel_corpus: BinaryIO = None, name: str = None, **kwargs) → ibm_cloud_sdk_core.detailed_response.DetailedResponse[source]

Create model.

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 contains the language code. * TSV (.tsv or .tab) - Tab-separated values (TSV) file with two columns for aligned sentences and phrases. The first row contains the 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”.

Parameters
  • base_model_id (str) – The ID of the translation model to use as the base for customization. To see available models and IDs, use the List models method. Most models that are provided with the service are customizable. In addition, all models that you create with parallel corpora customization can be further customized with a forced glossary.

  • forced_glossary (TextIO) – (optional) A file with forced glossary terms for the source and target languages. The customizations in the file completely overwrite the domain translation data, including high frequency or high confidence phrase translations. You can upload only one glossary file for a custom model, and the glossary can have a maximum size of 10 MB. A forced glossary must contain single words or short phrases. For more information, see Supported file formats in the method description. With `curl`, use `–form forced_glossary=@{filename}`..

  • parallel_corpus (TextIO) – (optional) A file with parallel sentences for the source and target languages. You can upload multiple parallel corpus files in one request by repeating the parameter. All uploaded parallel corpus files combined must contain at least 5000 parallel sentences to train successfully. You can provide a maximum of 500,000 parallel sentences across all corpora. A single entry in a corpus file can contain a maximum of 80 words. All corpora files for a custom model can have a cumulative maximum size of 250 MB. For more information, see Supported file formats in the method description. With `curl`, use `–form parallel_corpus=@{filename}`..

  • name (str) – (optional) An optional model name that you can use to identify the model. Valid characters are letters, numbers, dashes, underscores, spaces, and apostrophes. The maximum length of the name is 32 characters.

  • headers (dict) – A dict containing the request headers

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse

delete_model(model_id: str, **kwargs) → ibm_cloud_sdk_core.detailed_response.DetailedResponse[source]

Delete model.

Deletes a custom translation model.

Parameters
  • model_id (str) – Model ID of the model to delete.

  • headers (dict) – A dict containing the request headers

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse

get_model(model_id: str, **kwargs) → ibm_cloud_sdk_core.detailed_response.DetailedResponse[source]

Get model details.

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.

Parameters
  • model_id (str) – Model ID of the model to get.

  • headers (dict) – A dict containing the request headers

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse

list_documents(**kwargs) → ibm_cloud_sdk_core.detailed_response.DetailedResponse[source]

List documents.

Lists documents that have been submitted for translation.

Parameters

headers (dict) – A dict containing the request headers

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse

translate_document(file: BinaryIO, *, filename: str = None, file_content_type: str = None, model_id: str = None, source: str = None, target: str = None, document_id: str = None, **kwargs) → ibm_cloud_sdk_core.detailed_response.DetailedResponse[source]

Translate document.

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.

Parameters
  • file (TextIO) – The contents of the source file to translate. [Supported file types](https://cloud.ibm.com/docs/language-translator?topic=language-translator-document-translator-tutorial#supported-file-formats) Maximum file size: 20 MB.

  • filename (str) – (optional) The filename for file.

  • file_content_type (str) – (optional) The content type of file.

  • model_id (str) – (optional) The model to use for translation. For example, en-de selects the IBM-provided base model for English-to-German translation. A model ID overrides the source and target parameters and is required if you use a custom model. If no model ID is specified, you must specify at least a target language.

  • source (str) – (optional) Language code that specifies the language of the source document. If omitted, the service derives the source language from the input text. The input must contain sufficient text for the service to identify the language reliably.

  • target (str) – (optional) Language code that specifies the target language for translation. Required if model ID is not specified.

  • document_id (str) – (optional) To use a previously submitted document as the source for a new translation, enter the document_id of the document.

  • headers (dict) – A dict containing the request headers

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse

get_document_status(document_id: str, **kwargs) → ibm_cloud_sdk_core.detailed_response.DetailedResponse[source]

Get document status.

Gets the translation status of a document.

Parameters
  • document_id (str) – The document ID of the document.

  • headers (dict) – A dict containing the request headers

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse

delete_document(document_id: str, **kwargs) → ibm_cloud_sdk_core.detailed_response.DetailedResponse[source]

Delete document.

Deletes a document.

Parameters
  • document_id (str) – Document ID of the document to delete.

  • headers (dict) – A dict containing the request headers

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse

get_translated_document(document_id: str, *, accept: str = None, **kwargs) → ibm_cloud_sdk_core.detailed_response.DetailedResponse[source]

Get translated document.

Gets the translated document associated with the given document ID.

Parameters
  • document_id (str) – The document ID of the document that was submitted for translation.

  • accept (str) – (optional) The type of the response: application/powerpoint, application/mspowerpoint, application/x-rtf, application/json, application/xml, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-powerpoint, application/vnd.openxmlformats-officedocument.presentationml.presentation, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/vnd.oasis.opendocument.spreadsheet, application/vnd.oasis.opendocument.presentation, application/vnd.oasis.opendocument.text, application/pdf, application/rtf, text/html, text/json, text/plain, text/richtext, text/rtf, or text/xml. A character encoding can be specified by including a charset parameter. For example, ‘text/html;charset=utf-8’.

  • headers (dict) – A dict containing the request headers

Returns

A DetailedResponse containing the result, headers and HTTP status code.

Return type

DetailedResponse

class TranslateDocumentEnums[source]

Bases: object

class FileContentType(value)[source]

Bases: enum.Enum

The content type of file.

APPLICATION_POWERPOINT = 'application/powerpoint'
APPLICATION_MSPOWERPOINT = 'application/mspowerpoint'
APPLICATION_X_RTF = 'application/x-rtf'
APPLICATION_JSON = 'application/json'
APPLICATION_XML = 'application/xml'
APPLICATION_VND_MS_EXCEL = 'application/vnd.ms-excel'
APPLICATION_VND_OPENXMLFORMATS_OFFICEDOCUMENT_SPREADSHEETML_SHEET = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
APPLICATION_VND_MS_POWERPOINT = 'application/vnd.ms-powerpoint'
APPLICATION_VND_OPENXMLFORMATS_OFFICEDOCUMENT_PRESENTATIONML_PRESENTATION = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'
APPLICATION_MSWORD = 'application/msword'
APPLICATION_VND_OPENXMLFORMATS_OFFICEDOCUMENT_WORDPROCESSINGML_DOCUMENT = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
APPLICATION_VND_OASIS_OPENDOCUMENT_SPREADSHEET = 'application/vnd.oasis.opendocument.spreadsheet'
APPLICATION_VND_OASIS_OPENDOCUMENT_PRESENTATION = 'application/vnd.oasis.opendocument.presentation'
APPLICATION_VND_OASIS_OPENDOCUMENT_TEXT = 'application/vnd.oasis.opendocument.text'
APPLICATION_PDF = 'application/pdf'
APPLICATION_RTF = 'application/rtf'
TEXT_HTML = 'text/html'
TEXT_JSON = 'text/json'
TEXT_PLAIN = 'text/plain'
TEXT_RICHTEXT = 'text/richtext'
TEXT_RTF = 'text/rtf'
TEXT_XML = 'text/xml'
class GetTranslatedDocumentEnums[source]

Bases: object

class Accept(value)[source]

Bases: enum.Enum

The type of the response: application/powerpoint, application/mspowerpoint, application/x-rtf, application/json, application/xml, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-powerpoint, application/vnd.openxmlformats-officedocument.presentationml.presentation, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/vnd.oasis.opendocument.spreadsheet, application/vnd.oasis.opendocument.presentation, application/vnd.oasis.opendocument.text, application/pdf, application/rtf, text/html, text/json, text/plain, text/richtext, text/rtf, or text/xml. A character encoding can be specified by including a charset parameter. For example, ‘text/html;charset=utf-8’.

APPLICATION_POWERPOINT = 'application/powerpoint'
APPLICATION_MSPOWERPOINT = 'application/mspowerpoint'
APPLICATION_X_RTF = 'application/x-rtf'
APPLICATION_JSON = 'application/json'
APPLICATION_XML = 'application/xml'
APPLICATION_VND_MS_EXCEL = 'application/vnd.ms-excel'
APPLICATION_VND_OPENXMLFORMATS_OFFICEDOCUMENT_SPREADSHEETML_SHEET = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
APPLICATION_VND_MS_POWERPOINT = 'application/vnd.ms-powerpoint'
APPLICATION_VND_OPENXMLFORMATS_OFFICEDOCUMENT_PRESENTATIONML_PRESENTATION = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'
APPLICATION_MSWORD = 'application/msword'
APPLICATION_VND_OPENXMLFORMATS_OFFICEDOCUMENT_WORDPROCESSINGML_DOCUMENT = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
APPLICATION_VND_OASIS_OPENDOCUMENT_SPREADSHEET = 'application/vnd.oasis.opendocument.spreadsheet'
APPLICATION_VND_OASIS_OPENDOCUMENT_PRESENTATION = 'application/vnd.oasis.opendocument.presentation'
APPLICATION_VND_OASIS_OPENDOCUMENT_TEXT = 'application/vnd.oasis.opendocument.text'
APPLICATION_PDF = 'application/pdf'
APPLICATION_RTF = 'application/rtf'
TEXT_HTML = 'text/html'
TEXT_JSON = 'text/json'
TEXT_PLAIN = 'text/plain'
TEXT_RICHTEXT = 'text/richtext'
TEXT_RTF = 'text/rtf'
TEXT_XML = 'text/xml'
class DeleteModelResult(status: str)[source]

Bases: object

DeleteModelResult.

Attr str status

“OK” indicates that the model was successfully deleted.

classmethod from_dict(_dict: Dict)ibm_watson.language_translator_v3.DeleteModelResult[source]

Initialize a DeleteModelResult object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class DocumentList(documents: List[DocumentStatus])[source]

Bases: object

DocumentList.

Attr List[DocumentStatus] documents

An array of all previously submitted documents.

classmethod from_dict(_dict: Dict)ibm_watson.language_translator_v3.DocumentList[source]

Initialize a DocumentList object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class DocumentStatus(document_id: str, filename: str, status: str, model_id: str, source: str, target: str, created: datetime.datetime, *, base_model_id: str = None, detected_language_confidence: float = None, completed: datetime.datetime = None, word_count: int = None, character_count: int = None)[source]

Bases: object

Document information, including translation status.

Attr str document_id

System generated ID identifying a document being translated using one specific translation model.

Attr str filename

filename from the submission (if it was missing in the multipart-form, ‘noname.<ext matching content type>’ is used.

Attr str status

The status of the translation job associated with a submitted document.

Attr str model_id

A globally unique string that identifies the underlying model that is used for translation.

Attr str base_model_id

(optional) Model ID of the base model that was used to customize the model. If the model is not a custom model, this will be absent or an empty string.

Attr str source

Translation source language code.

Attr float detected_language_confidence

(optional) A score between 0 and 1 indicating the confidence of source language detection. A higher value indicates greater confidence. This is returned only when the service automatically detects the source language.

Attr str target

Translation target language code.

Attr datetime created

The time when the document was submitted.

Attr datetime completed

(optional) The time when the translation completed.

Attr int word_count

(optional) An estimate of the number of words in the source document. Returned only if status is available.

Attr int character_count

(optional) The number of characters in the source document, present only if status=available.

classmethod from_dict(_dict: Dict)ibm_watson.language_translator_v3.DocumentStatus[source]

Initialize a DocumentStatus object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class StatusEnum(value)[source]

Bases: enum.Enum

The status of the translation job associated with a submitted document.

PROCESSING = 'processing'
AVAILABLE = 'available'
FAILED = 'failed'
class IdentifiableLanguage(language: str, name: str)[source]

Bases: object

IdentifiableLanguage.

Attr str language

The language code for an identifiable language.

Attr str name

The name of the identifiable language.

classmethod from_dict(_dict: Dict)ibm_watson.language_translator_v3.IdentifiableLanguage[source]

Initialize a IdentifiableLanguage object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class IdentifiableLanguages(languages: List[IdentifiableLanguage])[source]

Bases: object

IdentifiableLanguages.

Attr List[IdentifiableLanguage] languages

A list of all languages that the service can identify.

classmethod from_dict(_dict: Dict)ibm_watson.language_translator_v3.IdentifiableLanguages[source]

Initialize a IdentifiableLanguages object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class IdentifiedLanguage(language: str, confidence: float)[source]

Bases: object

IdentifiedLanguage.

Attr str language

The language code for an identified language.

Attr float confidence

The confidence score for the identified language.

classmethod from_dict(_dict: Dict)ibm_watson.language_translator_v3.IdentifiedLanguage[source]

Initialize a IdentifiedLanguage object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class IdentifiedLanguages(languages: List[IdentifiedLanguage])[source]

Bases: object

IdentifiedLanguages.

Attr List[IdentifiedLanguage] languages

A ranking of identified languages with confidence scores.

classmethod from_dict(_dict: Dict)ibm_watson.language_translator_v3.IdentifiedLanguages[source]

Initialize a IdentifiedLanguages object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class Language(*, language: str = None, language_name: str = None, native_language_name: str = None, country_code: str = None, words_separated: bool = None, direction: str = None, supported_as_source: bool = None, supported_as_target: bool = None, identifiable: bool = None)[source]

Bases: object

Response payload for languages.

Attr str language

(optional) The language code for the language (for example, af).

Attr str language_name

(optional) The name of the language in English (for example, Afrikaans).

Attr str native_language_name

(optional) The native name of the language (for example, Afrikaans).

Attr str country_code

(optional) The country code for the language (for example, ZA for South Africa).

Attr bool words_separated

(optional) Indicates whether words of the language are separated by whitespace: true if the words are separated; false otherwise.

Attr str direction

(optional) Indicates the direction of the language: right_to_left or left_to_right.

Attr bool supported_as_source

(optional) Indicates whether the language can be used as the source for translation: true if the language can be used as the source; false otherwise.

Attr bool supported_as_target

(optional) Indicates whether the language can be used as the target for translation: true if the language can be used as the target; false otherwise.

Attr bool identifiable

(optional) Indicates whether the language supports automatic detection: true if the language can be detected automatically; false otherwise.

classmethod from_dict(_dict: Dict)ibm_watson.language_translator_v3.Language[source]

Initialize a Language object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class Languages(languages: List[Language])[source]

Bases: object

The response type for listing supported languages.

Attr List[Language] languages

An array of supported languages with information about each language.

classmethod from_dict(_dict: Dict)ibm_watson.language_translator_v3.Languages[source]

Initialize a Languages object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class Translation(translation: str)[source]

Bases: object

Translation.

Attr str translation

Translation output in UTF-8.

classmethod from_dict(_dict: Dict)ibm_watson.language_translator_v3.Translation[source]

Initialize a Translation object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class TranslationModel(model_id: str, *, name: str = None, source: str = None, target: str = None, base_model_id: str = None, domain: str = None, customizable: bool = None, default_model: bool = None, owner: str = None, status: str = None)[source]

Bases: object

Response payload for models.

Attr str model_id

A globally unique string that identifies the underlying model that is used for translation.

Attr str name

(optional) Optional name that can be specified when the model is created.

Attr str source

(optional) Translation source language code.

Attr str target

(optional) Translation target language code.

Attr str base_model_id

(optional) Model ID of the base model that was used to customize the model. If the model is not a custom model, this will be an empty string.

Attr str domain

(optional) The domain of the translation model.

Attr bool customizable

(optional) Whether this model can be used as a base for customization. Customized models are not further customizable, and some base models are not customizable.

Attr bool default_model

(optional) Whether or not the model is a default model. A default model is the model for a given language pair that will be used when that language pair is specified in the source and target parameters.

Attr str owner

(optional) Either an empty string, indicating the model is not a custom model, or the ID of the service instance that created the model.

Attr str status

(optional) Availability of a model.

classmethod from_dict(_dict: Dict)ibm_watson.language_translator_v3.TranslationModel[source]

Initialize a TranslationModel object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class StatusEnum(value)[source]

Bases: enum.Enum

Availability of a model.

UPLOADING = 'uploading'
UPLOADED = 'uploaded'
DISPATCHING = 'dispatching'
QUEUED = 'queued'
TRAINING = 'training'
TRAINED = 'trained'
PUBLISHING = 'publishing'
AVAILABLE = 'available'
DELETED = 'deleted'
ERROR = 'error'
class TranslationModels(models: List[TranslationModel])[source]

Bases: object

The response type for listing existing translation models.

Attr List[TranslationModel] models

An array of available models.

classmethod from_dict(_dict: Dict)ibm_watson.language_translator_v3.TranslationModels[source]

Initialize a TranslationModels object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.

class TranslationResult(word_count: int, character_count: int, translations: List[Translation], *, detected_language: str = None, detected_language_confidence: float = None)[source]

Bases: object

TranslationResult.

Attr int word_count

An estimate of the number of words in the input text.

Attr int character_count

Number of characters in the input text.

Attr str detected_language

(optional) The language code of the source text if the source language was automatically detected.

Attr float detected_language_confidence

(optional) A score between 0 and 1 indicating the confidence of source language detection. A higher value indicates greater confidence. This is returned only when the service automatically detects the source language.

Attr List[Translation] translations

List of translation output in UTF-8, corresponding to the input text entries.

classmethod from_dict(_dict: Dict)ibm_watson.language_translator_v3.TranslationResult[source]

Initialize a TranslationResult object from a json dictionary.

to_dict() → Dict[source]

Return a json dictionary representing this model.