Skip to content

Commit 85da998

Browse files
committed
change recvoer—â_map to token_orig_cost and document
1 parent a758ba4 commit 85da998

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

src/decoder/lattice-faster-decoder-combine.cc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@ bool LatticeFasterDecoderCombineTpl<FST, Token>::GetRawLattice(
126126
KALDI_ERR << "You cannot call FinalizeDecoding() and then call "
127127
<< "GetRawLattice() with use_final_probs == false";
128128

129-
std::unordered_map<Token*, BaseFloat> recover_map;
129+
std::unordered_map<Token*, BaseFloat> token_orig_cost;
130130
if (!decoding_finalized_) {
131131
// Process the non-emitting arcs for the unfinished last frame.
132-
ProcessNonemitting(&recover_map);
132+
ProcessNonemitting(&token_orig_cost);
133133
}
134134

135135

@@ -202,7 +202,7 @@ bool LatticeFasterDecoderCombineTpl<FST, Token>::GetRawLattice(
202202
}
203203

204204
if (!decoding_finalized_) { // recover last token list
205-
RecoverLastTokenList(recover_map);
205+
RecoverLastTokenList(token_orig_cost);
206206
}
207207
return (ofst->NumStates() > 0);
208208
}
@@ -215,13 +215,13 @@ bool LatticeFasterDecoderCombineTpl<FST, Token>::GetRawLattice(
215215
// will not be affacted.
216216
template<typename FST, typename Token>
217217
void LatticeFasterDecoderCombineTpl<FST, Token>::RecoverLastTokenList(
218-
const std::unordered_map<Token*, BaseFloat> &recover_map) {
219-
if (!recover_map.empty()) {
218+
const std::unordered_map<Token*, BaseFloat> &token_orig_cost) {
219+
if (!token_orig_cost.empty()) {
220220
for (Token* tok = active_toks_[active_toks_.size() - 1].toks;
221221
tok != NULL;) {
222-
if (recover_map.find(tok) != recover_map.end()) {
222+
if (token_orig_cost.find(tok) != token_orig_cost.end()) {
223223
DeleteForwardLinks(tok);
224-
tok->tot_cost = recover_map.find(tok)->second;
224+
tok->tot_cost = token_orig_cost.find(tok)->second;
225225
tok->in_current_queue = false;
226226
tok = tok->next;
227227
} else {
@@ -897,10 +897,10 @@ void LatticeFasterDecoderCombineTpl<FST, Token>::ProcessForFrame(
897897

898898
template <typename FST, typename Token>
899899
void LatticeFasterDecoderCombineTpl<FST, Token>::ProcessNonemitting(
900-
std::unordered_map<Token*, BaseFloat> *recover_map) {
901-
if (recover_map) { // Build the elements which are used to recover
900+
std::unordered_map<Token*, BaseFloat> *token_orig_cost) {
901+
if (token_orig_cost) { // Build the elements which are used to recover
902902
for (IterType iter = cur_toks_.begin(); iter != cur_toks_.end(); iter++) {
903-
(*recover_map)[iter->second] = iter->second->tot_cost;
903+
(*token_orig_cost)[iter->second] = iter->second->tot_cost;
904904
}
905905
}
906906

src/decoder/lattice-faster-decoder-combine.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -463,17 +463,23 @@ class LatticeFasterDecoderCombineTpl {
463463
/// Or calls it in GetRawLattice() to generate the complete token list for
464464
/// the last frame. [Deal With the tokens in map "cur_toks_" which would
465465
/// only contains emittion tokens from previous frame.]
466-
/// If "recover_map" isn't NULL, we build the recover_map which will be used
467-
/// to recover "active_toks_[last_frame]" token list for the last frame.
468-
void ProcessNonemitting(std::unordered_map<Token*, BaseFloat> *recover_map);
466+
/// If the map, "token_orig_cost", isn't NULL, we build the map which will
467+
/// be used to recover "active_toks_[last_frame]" token list for the last
468+
/// frame.
469+
void ProcessNonemitting(std::unordered_map<Token*, BaseFloat> *token_orig_cost);
469470

470471
/// When GetRawLattice() is called during decoding, the
471472
/// active_toks_[last_frame] is changed. To keep the consistency of function
472473
/// ProcessForFrame(), recover it.
473474
/// Notice: as new token will be added to the head of TokenList, tok->next
474475
/// will not be affacted.
476+
/// "token_orig_cost" is a mapping from token pointer to the tot_cost of the
477+
/// token before propagating non-emitting arcs. It is used to recover the
478+
/// change of original tokens in the last frame and remove the new tokens
479+
/// which come from propagating non-emitting arcs, so that we can guarantee
480+
/// the consistency of function ProcessForFrame().
475481
void RecoverLastTokenList(
476-
const std::unordered_map<Token*, BaseFloat> &recover_map);
482+
const std::unordered_map<Token*, BaseFloat> &token_orig_cost);
477483

478484

479485
/// The "prev_toks_" and "cur_toks_" actually allow us to maintain current

0 commit comments

Comments
 (0)