Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/marian-nmt/marian.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/data/corpus_base.cpp')
-rw-r--r--src/data/corpus_base.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/data/corpus_base.cpp b/src/data/corpus_base.cpp
index 5be4298b..5f9a9ee3 100644
--- a/src/data/corpus_base.cpp
+++ b/src/data/corpus_base.cpp
@@ -447,9 +447,15 @@ void CorpusBase::addAlignmentsToBatch(Ptr<CorpusBatch> batch,
std::vector<float> aligns(srcWords * dimBatch * trgWords, 0.f);
for(int b = 0; b < dimBatch; ++b) {
- for(auto p : batchVector[b].getAlignment()) {
- size_t idx = p.srcPos * dimBatch * trgWords + b * trgWords + p.tgtPos;
- aligns[idx] = 1.f;
+
+ // If the batch vector is altered within marian by, for example, case augmentation,
+ // the guided alignments we received for this tuple cease to be valid.
+ // Hence skip setting alignments for that sentence tuple..
+ if (!batchVector[b].isAltered()) {
+ for(auto p : batchVector[b].getAlignment()) {
+ size_t idx = p.srcPos * dimBatch * trgWords + b * trgWords + p.tgtPos;
+ aligns[idx] = 1.f;
+ }
}
}
batch->setGuidedAlignment(std::move(aligns));