mindmeld.components.translators module

This module contains translator clients used by the MultiLingual Annotator.

class mindmeld.components.translators.GoogleTranslator[source]

Bases: mindmeld.components.translators.Translator

Class for translation using the Google Translate API.

detect_language(text)[source]
Parameters:text (str) -- Input text
Returns:Detected Language Code
Return type:language_code (str)
static get_translate_client()[source]

Creates a translation client after finding the credential path. Attempts to import the Google Cloud Translation library.

Returns:Google Translation Client
Return type:translate_client (translate_v2.Client)
Raises:ModuleNotFoundError
translate(text, target_language)[source]
Parameters:
  • text (str) -- Input text
  • target_language (str) -- Language code for language to translate the given text to.
Returns:

Translated text

Return type:

translated_text (str)

class mindmeld.components.translators.NoOpTranslator[source]

Bases: mindmeld.components.translators.Translator

No-Ops translator to be used when a Translator is not selected or available.

detect_language(text)[source]
Parameters:text (str) -- Input text
Returns:Detected Language Code
Return type:language_code (str)
translate(text, target_language)[source]
Parameters:
  • text (str) -- Input text
  • destination_language (str) -- Language code for target language.
Returns:

Translated text

Return type:

translated_text (str)

class mindmeld.components.translators.Translator[source]

Bases: object

Abstract Translator Base Class for Translators to be used by Mindmeld.

detect_language(text)[source]
Parameters:text (str) -- Input text
Returns:Detected Language Code
Return type:language_code (str)
translate(text, target_language)[source]
Parameters:
  • text (str) -- Input text
  • destination_language (str) -- Language code for target language.
Returns:

Translated text

Return type:

translated_text (str)

class mindmeld.components.translators.TranslatorFactory[source]

Bases: object

Translator Factory Class

static get_translator(translator)[source]

A static method to get a translator

Parameters:translator (str) -- Name of the desired translator class
Returns:Translator Class
Return type:(Translator)