modernmt

Library to use ModernMT machine translation services

source

modernmttranslate

 modernmttranslate (adaptive=False, adaptation_tm=None,
                    reference_tms=None)

Class to get translations from the ModernMT API


source

modernmttranslate.create_adaptation_tm

 modernmttranslate.create_adaptation_tm ()

Function to create empty translation memory (TM) for adaptative MT.


source

modernmttranslate.add_reference_translation

 modernmttranslate.add_reference_translation (tuid, sourcelang,
                                              targetlang, source,
                                              reference)

Function to submit a new reference translation (most often post-edited translation) to the adaptation TM.

Type Details
tuid Unique ID of the translation segment - if it exists, the segment gets overwritten
sourcelang str Source language identifier (BCP-47 format).
targetlang str Target language identifier (BCP-47 format).
source str Source text.
reference str Reference translation, possibly post-edited from machine translation.

source

modernmttranslate.check_langpair

 modernmttranslate.check_langpair (sourcelang, targetlang)

Function to verify if a language pair identified by language ids is supported

Type Details
sourcelang str Source language identifier (BCP-47 format).
targetlang str Target language identifier (BCP-47 format).
Returns bool Returns True if language pair is supported, otherwise False.

source

modernmttranslate.translate_text

 modernmttranslate.translate_text (sourcelang, targetlang, text,
                                   timeout=5)

Function to translate text into the target language

Type Default Details
sourcelang str Source language identifier (BCP-47 format).
targetlang str Target language identifier (BCP-47 format).
text str Source text that is to be translated.
timeout int 5 Timeout for translation request in seconds.
Returns str Translated text.