Interactive Translation

One of the Lilt web app's core features is the interactive translation. You can build your own app with this technology using the API.

Interactive (or predictive) machine translation uses already translated parts of the sentence and predicts the remaining parts. This interplay between user input and prediction can be done word-by-word or phrase-by-phrase until the translation has finished. The translator and the machine are interacting with each other.

In order to implement this, you first need to know the ID of the memory you want to use for translation or create a new one. Before requesting a translation you will have to register the source segment first to get a source_hash.

# Python; Note: This is just a stub
def register_segment(source, srcLang, trgLang):
    payload = {"key": lilt_api_key, "source": source, "srclang": srcLang, "trglang": trgLang}
    res = requests.get(lilt_api_url + "/translate/register", params=payload, verify=False)
    return res.json()["source_hash"]

Then you can also provide a partial translation as prefix to your translation request. The following shows an example how to request a translation interactively providing a new, longer prefix in each request:

# Python; Note: This is just a stub
def translate_interactive(source, srcLang, trgLang, target):
    source_hash = register_segment(source, srcLang, trgLang)
    prefix = []
    for token in target:
        prefix.append(token)
        prefix_string = " ".join(prefix)
        payload = {"key": lilt_api_key, "memory_id": find_memory(memory_name), "source": source,
                "source_hash": source_hash, "prefix": prefix_string}
        res = requests.get(lilt_api_url + "/translate", params=payload, verify=False)
        print "translation for prefix - \"%s\" : %s" % (prefix_string, res.json()["translation"][0]["target"])

translate_interactive("Drücke Enter um zum nächsten Fenster zu gelangen", "de", "en", ["Press Enter", "to get", "to", "the next window"])

The German source segment "Drücke Enter um zum nächsten Fenster zu gelangen" is translated by the MT to "Press Enter to continue with the next window to reach" but we want to change it interactively to "Press Enter to get to the next window". The result will be

translation for prefix - "Press Enter" : Press Enter to continue with the next window to reach
translation for prefix - "Press Enter to get" : Press Enter to get to next window
translation for prefix - "Press Enter to get to" : Press Enter to get to the next window
translation for prefix - "Press Enter to get to the next window" : Press Enter to get to the next window

and you can see how the translation changes when more feedback is provided as prefix.

For full interactive and adaptive machine translation you should also add the new segments to the Memory so that the information can be used for future segments.


To learn more, see the full API reference.

Still need help? Get in touch!
Last updated on 19th April 2018