Struct Response

Nested Relationships

Nested Types

Struct Documentation

struct Response

Response holds AnnotatedText(s) of source-text and translated text, alignment information between source and target sub-words and sentences.

AnnotatedText provides an API to access markings of (sub)-word and sentences boundaries, which are required to interpret Quality and Alignment (s) at the moment.

Public Functions

const size_t size() const

Convenience function to obtain number of units translated.

Same as .source.numSentences() and .target.numSentences(). The processing of a text of into sentences are handled internally, and this information can be used to iterate through meaningful units of translation for which alignment and quality information are available.

ByteRange getSourceSentenceAsByteRange(size_t sentenceIdx) const

Returns the source sentence (in terms of byte range) corresponding to sentenceIdx.

Parameters
  • [in] sentenceIdx: The index representing the sentence where 0 <= sentenceIdx < Response::size()

ByteRange getTargetSentenceAsByteRange(size_t sentenceIdx) const

Returns the translated sentence (in terms of byte range) corresponding to sentenceIdx.

Parameters
  • [in] sentenceIdx: The index representing the sentence where 0 <= sentenceIdx < Response::size()

const std::string &getOriginalText() const
const std::string &getTranslatedText() const

Public Members

AnnotatedText source

source text and annotations of (sub-)words and sentences.

AnnotatedText target

translated text and annotations of (sub-)words and sentences.

std::vector<SentenceQualityScore> qualityScores

logprob of each word and the total sequence (sentence) normalized by length, for each sentence processed by the translator.

Indices correspond to ranges accessible through respective Annotation on source or target.

std::vector<std::vector<std::vector<float>>> alignments

Alignments between source and target.

This is a collection of dense matrices providing P[t][s] = p(source-token s | target token t) with an alignment matrix for each sentence.

struct SentenceQualityScore

SentenceQualityScore contains the quality data of a given translated sentence.

It includes the confidence (proxied by log probabilities) of each decoded word (higher logprobs imply better-translated words), the ByteRanges of each term, and logprobs of the whole sentence, represented as the mean word scores.

Public Members

std::vector<float> wordScores

Quality score of each translated word.

std::vector<SubwordRange> wordRanges

Position of start and end token of each word in the translated text.

float sentenceScore = 0.0

Whole sentence quality score (it is composed by the mean of its words)