SimpleDecoder::Token Class Reference
Collaboration diagram for SimpleDecoder::Token:

Public Member Functions

 Token (const StdArc &arc, BaseFloat acoustic_cost, Token *prev)
 
bool operator< (const Token &other)
 

Static Public Member Functions

static void TokenDelete (Token *tok)
 

Public Attributes

LatticeArc arc_
 
Tokenprev_
 
int32 ref_count_
 
double cost_
 

Detailed Description

Definition at line 93 of file simple-decoder.h.

Constructor & Destructor Documentation

◆ Token()

Token ( const StdArc arc,
BaseFloat  acoustic_cost,
Token prev 
)
inline

Definition at line 101 of file simple-decoder.h.

References SimpleDecoder::Token::cost_, and SimpleDecoder::Token::ref_count_.

103  : prev_(prev), ref_count_(1) {
104  arc_.ilabel = arc.ilabel;
105  arc_.olabel = arc.olabel;
106  arc_.weight = LatticeWeight(arc.weight.Value(), acoustic_cost);
107  arc_.nextstate = arc.nextstate;
108  if (prev) {
109  prev->ref_count_++;
110  cost_ = prev->cost_ + (arc.weight.Value() + acoustic_cost);
111  } else {
112  cost_ = arc.weight.Value() + acoustic_cost;
113  }
114  }
fst::LatticeWeightTpl< BaseFloat > LatticeWeight
Definition: kaldi-lattice.h:32

Member Function Documentation

◆ operator<()

bool operator< ( const Token other)
inline

Definition at line 115 of file simple-decoder.h.

References SimpleDecoder::Token::cost_.

115  {
116  return cost_ > other.cost_;
117  }

◆ TokenDelete()

static void TokenDelete ( Token tok)
inlinestatic

Definition at line 119 of file simple-decoder.h.

References KALDI_ASSERT, SimpleDecoder::Token::prev_, SimpleDecoder::ProcessEmitting(), SimpleDecoder::ProcessNonemitting(), and SimpleDecoder::Token::ref_count_.

Referenced by SimpleDecoder::ClearToks(), SimpleDecoder::ProcessEmitting(), SimpleDecoder::ProcessNonemitting(), and SimpleDecoder::PruneToks().

119  {
120  while (--tok->ref_count_ == 0) {
121  Token *prev = tok->prev_;
122  delete tok;
123  if (prev == NULL) return;
124  else tok = prev;
125  }
126 #ifdef KALDI_PARANOID
127  KALDI_ASSERT(tok->ref_count_ > 0);
128 #endif
129  }
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:185
Token(const StdArc &arc, BaseFloat acoustic_cost, Token *prev)

Member Data Documentation

◆ arc_

◆ cost_

◆ prev_

Token* prev_

◆ ref_count_

int32 ref_count_

The documentation for this class was generated from the following file: