Skip to content

BergamotAPI

Ulrich Germann edited this page May 4, 2020 · 3 revisions

Bergamot API

The Bergamot API is provided at http://<host>:<port>/api/bergamot/v1/ and supports the POST method only. You POST and receive MIME type application/json.

Requests (property names in square brackets indicate optional elements; all others are mandatory)

{ "[options]": { "[inputFormat]": "sentence|paragraph|wrappedText",
                 "[nBest]: <integer>,
                 "[returnWordAlignment]": true|false,
                 "[returnSentenceScore]": true|false,
                 "[returnSoftAlignment]": true|false,
                 "[returnWordScores]": true|false,
                 "[returnTokenization]": true|false,
                 "[returnOriginal]": true|false },
  "text": <string>|<array>|<object>
}

Response format

The response replicates the input structure but replaces the value of "text" as follows:

  • if "text" is a string, it replaces the value with the Translation Output (see below)
  • if "text" is an array, it replaces each element in the array with the respective Translation Output
  • if "text" is an object, it replaces the value of the "text" property in that object with the respective Translation Output. A local "options" property overrides the settings of the parent (works, but not recommended)

Translation Output

  • if nBest is empty (defaults to 1) or 1, and none of the returnX properties are true, the translation output is a string with:
    • one sentence per line if inputFormat was sentence
    • one paragraph per line if inputFormat was paragraph
    • empty-line separated paragraphs with one sentence per line each if inputFormat was wrappedText (default)
  • otherwise, the response is a list of Paragraphs, where each Paragraph is a list of Sentence Translations, and each Sentence Translation is as

an n-best list of translations (it's a list even if nBest is 1, to make client side processing easier, because the response structure is the same irrespective of the value of nBest.

Clone this wiki locally