All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MapInputSymbolsMapper< Arc, I > Class Template Reference

#include <fstext-utils-inl.h>

Collaboration diagram for MapInputSymbolsMapper< Arc, I >:

Public Member Functions

Arc operator() (const Arc &arc_in)
 
MapFinalAction FinalAction ()
 
MapSymbolsAction InputSymbolsAction ()
 
MapSymbolsAction OutputSymbolsAction ()
 
uint64 Properties (uint64 props) const
 
 MapInputSymbolsMapper (const vector< I > &to_remove, bool copy)
 
 ~MapInputSymbolsMapper ()
 

Private Attributes

bool owned
 
const vector< I > * symbol_mapping_
 

Detailed Description

template<class Arc, class I>
class fst::MapInputSymbolsMapper< Arc, I >

Definition at line 127 of file fstext-utils-inl.h.

Constructor & Destructor Documentation

MapInputSymbolsMapper ( const vector< I > &  to_remove,
bool  copy 
)
inline

Definition at line 155 of file fstext-utils-inl.h.

References KALDI_ASSERT_IS_INTEGER_TYPE, MapInputSymbolsMapper< Arc, I >::owned, and MapInputSymbolsMapper< Arc, I >::symbol_mapping_.

155  {
157  if (copy) symbol_mapping_ = new vector<I> (to_remove);
158  else symbol_mapping_ = &to_remove;
159  owned = copy;
160  }
#define KALDI_ASSERT_IS_INTEGER_TYPE(I)
Definition: kaldi-utils.h:130
const vector< I > * symbol_mapping_

Member Function Documentation

MapFinalAction FinalAction ( )
inline

Definition at line 136 of file fstext-utils-inl.h.

136 { return MAP_NO_SUPERFINAL; }
MapSymbolsAction InputSymbolsAction ( )
inline

Definition at line 137 of file fstext-utils-inl.h.

137 { return MAP_CLEAR_SYMBOLS; }
Arc operator() ( const Arc &  arc_in)
inline

Definition at line 129 of file fstext-utils-inl.h.

129  {
130  Arc ans = arc_in;
131  if (ans.ilabel > 0 &&
132  ans.ilabel < static_cast<typename Arc::Label>((*symbol_mapping_).size()))
133  ans.ilabel = (*symbol_mapping_)[ans.ilabel];
134  return ans;
135  }
MapSymbolsAction OutputSymbolsAction ( )
inline

Definition at line 138 of file fstext-utils-inl.h.

138 { return MAP_COPY_SYMBOLS; }
uint64 Properties ( uint64  props) const
inline

Definition at line 139 of file fstext-utils-inl.h.

References MapInputSymbolsMapper< Arc, I >::symbol_mapping_.

139  { // Not tested.
140  bool remove_epsilons = (symbol_mapping_->size() > 0 && (*symbol_mapping_)[0] != 0);
141  bool add_epsilons = (symbol_mapping_->size() > 1 &&
142  *std::min_element(symbol_mapping_->begin()+1, symbol_mapping_->end()) == 0);
143 
144  // remove the following as we don't know now if any of them are true.
145  uint64 props_to_remove = kAcceptor|kNotAcceptor|kIDeterministic|kNonIDeterministic|
146  kILabelSorted|kNotILabelSorted;
147  if (remove_epsilons) props_to_remove |= kEpsilons|kIEpsilons;
148  if (add_epsilons) props_to_remove |= kNoEpsilons|kNoIEpsilons;
149  uint64 props_to_add = 0;
150  if (remove_epsilons && !add_epsilons) props_to_add |= kNoEpsilons|kNoIEpsilons;
151  return (props & ~props_to_remove) | props_to_add;
152  }
const vector< I > * symbol_mapping_

Member Data Documentation


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