TidToTstateMapper Class Reference
Collaboration diagram for TidToTstateMapper:

Public Types

typedef int32 Result
 

Public Member Functions

 TidToTstateMapper (const TransitionModel &trans_model, const std::vector< int32 > &disambig_syms, bool check_no_self_loops)
 
int32 operator() (int32 label) const
 

Private Attributes

const TransitionModeltrans_model_
 
const std::vector< int32 > & disambig_syms_
 
bool check_no_self_loops_
 

Detailed Description

Definition at line 425 of file hmm-utils.cc.

Member Typedef Documentation

◆ Result

typedef int32 Result

Definition at line 446 of file hmm-utils.cc.

Constructor & Destructor Documentation

◆ TidToTstateMapper()

TidToTstateMapper ( const TransitionModel trans_model,
const std::vector< int32 > &  disambig_syms,
bool  check_no_self_loops 
)
inline

Definition at line 440 of file hmm-utils.cc.

442  :
443  trans_model_(trans_model),
444  disambig_syms_(disambig_syms),
445  check_no_self_loops_(check_no_self_loops) { }
const TransitionModel & trans_model_
Definition: hmm-utils.cc:464
const std::vector< int32 > & disambig_syms_
Definition: hmm-utils.cc:465

Member Function Documentation

◆ operator()()

int32 operator() ( int32  label) const
inline

Definition at line 447 of file hmm-utils.cc.

References KALDI_ASSERT, KALDI_ERR, and fst::kNontermBigNumber.

447  {
448  if (label == static_cast<int32>(fst::kNoLabel)) return -1; // -1 -> -1
449  else if (label >= 1 && label <= trans_model_.NumTransitionIds()) {
451  KALDI_ERR << "AddSelfLoops: graph already has self-loops.";
453  } else { // 0 or (presumably) disambiguation symbol. Map to zero
454  int32 big_number = fst::kNontermBigNumber; // 1000000
455  if (label != 0 && label < big_number)
456  KALDI_ASSERT(std::binary_search(disambig_syms_.begin(),
457  disambig_syms_.end(),
458  label)); // or invalid label
459  return 0;
460  }
461  }
kaldi::int32 int32
const TransitionModel & trans_model_
Definition: hmm-utils.cc:464
int32 NumTransitionIds() const
Returns the total number of transition-ids (note, these are one-based).
bool IsSelfLoop(int32 trans_id) const
#define KALDI_ERR
Definition: kaldi-error.h:147
int32 TransitionIdToTransitionState(int32 trans_id) const
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:185
const std::vector< int32 > & disambig_syms_
Definition: hmm-utils.cc:465

Member Data Documentation

◆ check_no_self_loops_

bool check_no_self_loops_
private

Definition at line 466 of file hmm-utils.cc.

◆ disambig_syms_

const std::vector<int32>& disambig_syms_
private

Definition at line 465 of file hmm-utils.cc.

◆ trans_model_

const TransitionModel& trans_model_
private

Definition at line 464 of file hmm-utils.cc.


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