This repository has been archived by the owner on Dec 14, 2023. It is now read-only.
forked from browsermt/bergamot-translator
-
Notifications
You must be signed in to change notification settings - Fork 10
Unified API Example
abhi-agg edited this page Mar 30, 2021
·
5 revisions
translate API input/output examples:
std::vector<TranslationResult> translate(std::vector<std::string> &&texts, TranslationRequest request)
For brevity and simplicity, all the tokens
are represented as strings
but they will be represented as ByteRange
structure and
Response
= std::vector<TranslationResult>
Case 1: texts
contains only 1 entry (i.e. texts.size() = 1
) and texts[0]
contains 2 sentences
texts : ["abc def. ghi jkl."] // Single entry in texts that contains 2 sentences
request : {
qualityScoreGranularity : QualityScoreGranularity::WORD
includeSentenceMapping : true;
includeAlignment : true;
}
Response: [
{// TranslationResult corresponding to `texts[0]`
originalText : "abc def. ghi jkl."
translatedText : "ABC DEF. GHI JKL."
qualityScores : [
{// Quality Score for 1st translated sentence ("ABC DEF.")
translatedSentenceTokens : ["AB", "C ", "DE", "F", "."]
translatedSentenceScores : [0.xx, 0.xx, 0.xx, 0.x, 0.x]
},
{// Quality Score for 2nd translated sentence ("GHI JKL.")
translatedSentenceTokens : ["GHI", "JKL", "."]
translatedSentenceScores : [0.xxx, 0.xxx, 0.x]
}
]
sentenceMappings : [
{"abc def.", "ABC DEF."},
{"ghi jkl.", "GHI JKL."}
]
alignments : [
{// Alignment b/w 1st original Sentence and corresponding translated sentence
originalSentenceViews : [ "abc", " de", "f", "."]
translatedSentenceViews : [ "AB", "C ", "DE", "F", "."]
alignmentsOriginalToTranslated : [
[0.xx, 0.xx, 0.xx, 0.x, 0.x],
[0.xx, 0.xx, 0.xx, 0.x, 0.x],
[0.xx, 0.xx, 0.xx, 0.x, 0.x],
[0.xx, 0.xx, 0.xx, 0.x, 0.x],
]
},
{// Alignment b/w 2nd original Sentence and corresponding translated sentence
originalSentenceViews : [ "ghi", "jkl", "."]
translatedSentenceViews : [ "GHI", "JKL", "."]
alignmentsOriginalToTranslated : [
[0.xx, 0.xx, 0.xx],
[0.xx, 0.xx, 0.xx],
[0.xx, 0.xx, 0.xx],
]
}
]
}
]