Skip to content

Commit faa9c44

Browse files
committed
another fix to ComposeCompactLatticeDeterministic(), and a fix (plus cleanup) to word-align-lattice.cc, that affects the --test=true option of lattice-align-words for some topologies including chain models.
1 parent 0e284f3 commit faa9c44

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

src/lat/lattice-functions.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1586,7 +1586,7 @@ void ComposeCompactLatticeDeterministic(
15861586
// Adds arc to <composed_clat>.
15871587
if (arc1.olabel == 0) {
15881588
composed_clat->AddArc(state_map[s],
1589-
CompactLatticeArc(0, 0,
1589+
CompactLatticeArc(arc1.ilabel, 0,
15901590
arc1.weight, next_state));
15911591
} else {
15921592
Weight2 composed_weight(

src/lat/word-align-lattice.cc

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -429,14 +429,17 @@ bool LatticeWordAligner::ComputationState::OutputOnePhoneWordArc(
429429
}
430430

431431
// interpret i as the number of transition-ids to consume.
432-
std::vector<int32> tids_out(transition_ids_.begin(), transition_ids_.begin()+i);
432+
std::vector<int32> tids_out(transition_ids_.begin(),
433+
transition_ids_.begin() + i);
433434

434435
// consumed transition ids from our internal state.
435436
int32 word = word_labels_[0];
436437
*arc_out = CompactLatticeArc(word, word,
437438
CompactLatticeWeight(weight_, tids_out), fst::kNoStateId);
438-
transition_ids_.erase(transition_ids_.begin(), transition_ids_.begin()+i); // delete these
439-
word_labels_.erase(word_labels_.begin(), word_labels_.begin()+1); // remove the word we output.
439+
transition_ids_.erase(transition_ids_.begin(),
440+
transition_ids_.begin() + i); // delete these
441+
// Remove the word that we just output.
442+
word_labels_.erase(word_labels_.begin(), word_labels_.begin() + 1);
440443
weight_ = LatticeWeight::One(); // we just output the weight.
441444
return true;
442445
}
@@ -518,15 +521,19 @@ bool LatticeWordAligner::ComputationState::OutputNormalWordArc(
518521

519522
// OK, we're ready to output the word.
520523
// Interpret i as the number of transition-ids to consume.
521-
std::vector<int32> tids_out(transition_ids_.begin(), transition_ids_.begin()+i);
524+
std::vector<int32> tids_out(transition_ids_.begin(),
525+
transition_ids_.begin() + i);
522526

523527
// consumed transition ids from our internal state.
524528
int32 word = word_labels_[0];
525529
*arc_out = CompactLatticeArc(word, word,
526530
CompactLatticeWeight(weight_, tids_out),
527531
fst::kNoStateId);
528-
transition_ids_.erase(transition_ids_.begin(), transition_ids_.begin()+i); // delete these
529-
word_labels_.erase(word_labels_.begin(), word_labels_.begin()+1); // remove the word we output.
532+
transition_ids_.erase(transition_ids_.begin(),
533+
transition_ids_.begin() + i); // delete these
534+
// Remove the word that we just output.
535+
word_labels_.erase(word_labels_.begin(),
536+
word_labels_.begin() + 1);
530537
weight_ = LatticeWeight::One(); // we just output the weight.
531538
return true;
532539
}
@@ -829,8 +836,8 @@ class WordAlignedLatticeTester {
829836
{ // first phone.
830837
int num_final = 0;
831838
for (i = 0; i < tids.size(); i++) {
832-
if (tmodel_.IsFinal(tids[i])) num_final++;
833839
if (tmodel_.TransitionIdToPhone(tids[i]) != first_phone) break;
840+
if (tmodel_.IsFinal(tids[i])) num_final++;
834841
}
835842
if (num_final != 1)
836843
return false; // Something went wrong-- perhaps we
@@ -857,7 +864,7 @@ class WordAlignedLatticeTester {
857864
else {
858865
// Make sure the only thing that follows this is self-loops
859866
// of the final transition-state.
860-
for (size_t k=j+1; k<tids.size(); k++)
867+
for (size_t k = j + 1; k < tids.size(); k++)
861868
if (tmodel_.TransitionIdToTransitionState(tids[k])
862869
!= tmodel_.TransitionIdToTransitionState(tids[j])
863870
|| !tmodel_.IsSelfLoop(tids[k]))

0 commit comments

Comments
 (0)