LmState Class Reference
Collaboration diagram for LmState:

Classes

struct  ChildrenVectorLessThan
 
union  ChildType
 

Public Member Functions

 LmState (const bool is_unigram, const bool is_child_final_order, const float logprob, const float backoff_logprob)
 
void SetMyAddress (const int64 address)
 
void AddChild (const int32 word, LmState *child_state)
 
void AddChild (const int32 word, const float child_prob)
 
int64 MyAddress () const
 
bool IsUnigram () const
 
bool IsChildFinalOrder () const
 
float Logprob () const
 
float BackoffLogprob () const
 
int32 NumChildren () const
 
std::pair< int32, union ChildTypeGetChild (const int32 index)
 
void SortChildren ()
 
bool IsLeaf () const
 
int32 MemSize () const
 

Private Attributes

bool is_unigram_
 
bool is_child_final_order_
 
int64 my_address_
 
float logprob_
 
float backoff_logprob_
 
std::vector< std::pair< int32, union ChildType > > children_
 

Detailed Description

Definition at line 55 of file const-arpa-lm.cc.

Constructor & Destructor Documentation

◆ LmState()

LmState ( const bool  is_unigram,
const bool  is_child_final_order,
const float  logprob,
const float  backoff_logprob 
)
inline

Definition at line 73 of file const-arpa-lm.cc.

74  :
75  is_unigram_(is_unigram), is_child_final_order_(is_child_final_order),
76  logprob_(logprob), backoff_logprob_(backoff_logprob) {}
bool is_child_final_order_

Member Function Documentation

◆ AddChild() [1/2]

void AddChild ( const int32  word,
LmState child_state 
)
inline

Definition at line 82 of file const-arpa-lm.cc.

References KALDI_ASSERT, and LmState::ChildType::state.

82  {
84  ChildType child;
85  child.state = child_state;
86  children_.push_back(std::make_pair(word, child));
87  }
bool is_child_final_order_
std::vector< std::pair< int32, union ChildType > > children_
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:185

◆ AddChild() [2/2]

void AddChild ( const int32  word,
const float  child_prob 
)
inline

Definition at line 89 of file const-arpa-lm.cc.

References KALDI_ASSERT, and LmState::ChildType::prob.

89  {
91  ChildType child;
92  child.prob = child_prob;
93  children_.push_back(std::make_pair(word, child));
94  }
bool is_child_final_order_
std::vector< std::pair< int32, union ChildType > > children_
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:185

◆ BackoffLogprob()

float BackoffLogprob ( ) const
inline

Definition at line 112 of file const-arpa-lm.cc.

112  {
113  return backoff_logprob_;
114  }

◆ GetChild()

std::pair<int32, union ChildType> GetChild ( const int32  index)
inline

Definition at line 120 of file const-arpa-lm.cc.

References KALDI_ASSERT.

120  {
121  KALDI_ASSERT(index < children_.size());
122  KALDI_ASSERT(index >= 0);
123  return children_[index];
124  }
std::vector< std::pair< int32, union ChildType > > children_
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:185

◆ IsChildFinalOrder()

bool IsChildFinalOrder ( ) const
inline

Definition at line 104 of file const-arpa-lm.cc.

104  {
105  return is_child_final_order_;
106  }
bool is_child_final_order_

◆ IsLeaf()

bool IsLeaf ( ) const
inline

Definition at line 131 of file const-arpa-lm.cc.

131  {
132  return (backoff_logprob_ == 0.0 && children_.empty());
133  }
std::vector< std::pair< int32, union ChildType > > children_

◆ IsUnigram()

bool IsUnigram ( ) const
inline

Definition at line 100 of file const-arpa-lm.cc.

100  {
101  return is_unigram_;
102  }

◆ Logprob()

float Logprob ( ) const
inline

Definition at line 108 of file const-arpa-lm.cc.

108  {
109  return logprob_;
110  }

◆ MemSize()

int32 MemSize ( ) const
inline

Definition at line 137 of file const-arpa-lm.cc.

137  {
138  if (IsLeaf() && !is_unigram_) {
139  // We don't create an entry in this case; the logprob will be stored in
140  // the same int32 that we would normally store the pointer in.
141  return 0;
142  } else {
143  // We store the following information:
144  // logprob, backoff_logprob, children.size() and children data.
145  return (3 + 2 * children_.size());
146  }
147  }
std::vector< std::pair< int32, union ChildType > > children_
bool IsLeaf() const

◆ MyAddress()

int64 MyAddress ( ) const
inline

Definition at line 96 of file const-arpa-lm.cc.

96  {
97  return my_address_;
98  }

◆ NumChildren()

int32 NumChildren ( ) const
inline

Definition at line 116 of file const-arpa-lm.cc.

116  {
117  return children_.size();
118  }
std::vector< std::pair< int32, union ChildType > > children_

◆ SetMyAddress()

void SetMyAddress ( const int64  address)
inline

Definition at line 78 of file const-arpa-lm.cc.

78  {
79  my_address_ = address;
80  }

◆ SortChildren()

void SortChildren ( )
inline

Definition at line 126 of file const-arpa-lm.cc.

126  {
127  std::sort(children_.begin(), children_.end(), ChildrenVectorLessThan());
128  }
std::vector< std::pair< int32, union ChildType > > children_

Member Data Documentation

◆ backoff_logprob_

float backoff_logprob_
private

Definition at line 169 of file const-arpa-lm.cc.

◆ children_

std::vector<std::pair<int32, union ChildType> > children_
private

Definition at line 172 of file const-arpa-lm.cc.

◆ is_child_final_order_

bool is_child_final_order_
private

Definition at line 156 of file const-arpa-lm.cc.

◆ is_unigram_

bool is_unigram_
private

Definition at line 152 of file const-arpa-lm.cc.

◆ logprob_

float logprob_
private

Definition at line 165 of file const-arpa-lm.cc.

◆ my_address_

int64 my_address_
private

Definition at line 161 of file const-arpa-lm.cc.


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