Skip to content
Andrea Rossi edited this page Nov 14, 2017 · 7 revisions

Quick example

curl -X GET http://localhost:8045/translate \
     -d "source=en" \
     -d "target=it" \
     -d "q=This is an <b>example</b>" \
     -d "context=Mr President" \
     | python -mjson.tool

{
    "data": {
        "contextVector": {
            "entries": [
                {"memory": {"id": 1, "name": "europarl"}, "score": 0.20658109},
                {"memory": {"id": 2, "name": "ibm"}, "score": 0.0017772929}
            ]
        },
        "decodingTime": 54,
        "sourceWordCount": 4,
        "targetWordCount": 5,
        "translation": "Si tratta di un <b>esempio</b>"
    },
    "status": 200
}

Description

This method returns the translation of the provided text. The text is XML encoded and can contain XML Tags. Since one ModernMT Engine may supports multiple language pairs and directions, you need to specify the source and target languages.

Resource URL

http://localhost:8045/translate

Parameters

source The language tag of the source language

Example: en
target The language tag of the target language

Example: it
q The text to translate in XML format (XML tags accepted, text must be XML-encoded)

Example: This is an <b>example</b>
context
optional
The context text to use to translate the sentence.

Example: Mr President
context_limit
optional
The maximum number of domains in the Context Vector used for the translation. Default is 10.

Example: 3
context_vector
optional
The context vector to use in the translation, as a series of comma-separated key-value pairs `id1:score1,id2:score2,..`.

Example: 1:0.34,3:0.045
nbest
optional
If greater than zero, a list of the top n-best translations is returned. Default is 0.

Example: 10
verbose
optional
If true, the response will be more detailed. Default is false.

Response Fields

translation The translation of the input sentence.
decodingTime The decoding time expressed in milliseconds
contextVector The Context Vector object calculated by analyzing the context text provided. For more details on the object format, please have a look at API Get Context Vector.
sourceWordCount Source sentence word count.
targetWordCount Translation word count.