Class SentenceTupleImpl¶
Defined in File corpus_base.h
Class Documentation¶
-
class
SentenceTupleImpl
¶ A sentence tuple that stores all sources and target sentences for a specific “line” from a parallel corpus.
Sentence tuples store sentences from external files and a basis for construction of marian::data::CorpusBatch objects. They are not a part of marian::data::CorpusBatch.
Public Functions
-
SentenceTupleImpl
()¶ Creates an empty tuple with 0 id (default constructor).
-
SentenceTupleImpl
(size_t id)¶ Creates an empty tuple with the given Id.
-
~SentenceTupleImpl
()¶
-
size_t
getId
() const¶ Returns the sentence’s ID.
-
bool
isAltered
() const¶ Returns whether this Tuple was altered or augmented from what was provided to Marian in input.
-
void
markAltered
()¶ Mark that this Tuple was internally altered or augmented by Marian.
-
void
push_back
(const Words &words)¶ Adds a new sentence at the end of the tuple.
- Parameters
words
: A vector of word indices.
-
size_t
size
() const¶ The size of the tuple, e.g.
two for parallel data with a source and target sentences.
-
bool
empty
() const¶ Checks whether the tuple is empty.
-
auto
begin
() const¶
-
auto
end
() const¶
-
auto
rbegin
() const¶
-
auto
rend
() const¶
-
const std::vector<float> &
getWeights
() const¶ Get sentence weights.
For sentence-level weights the vector contains only one element.
-
void
setWeights
(const std::vector<float> &weights)¶ Set sentence weights.
For word weights (i.e. weights.size() > 1) it checks if there is as many weights as target tokens. If not, it aborts. Because of this, this function must becalled after adding source and target tokens.
-
const WordAlignment &
getAlignment
() const¶
-
void
setAlignment
(const WordAlignment &alignment)¶
-