All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
LatticeHolder Class Reference

#include <kaldi-lattice.h>

Collaboration diagram for LatticeHolder:

Public Types

typedef Lattice T
 

Public Member Functions

 LatticeHolder ()
 
bool Read (std::istream &is)
 
const TValue () const
 
void Clear ()
 
void Swap (LatticeHolder *other)
 
bool ExtractRange (const LatticeHolder &other, const std::string &range)
 
 ~LatticeHolder ()
 

Static Public Member Functions

static bool Write (std::ostream &os, bool binary, const T &t)
 
static bool IsReadInBinary ()
 

Private Attributes

Tt_
 

Detailed Description

Definition at line 107 of file kaldi-lattice.h.

Member Typedef Documentation

typedef Lattice T

Definition at line 109 of file kaldi-lattice.h.

Constructor & Destructor Documentation

LatticeHolder ( )
inline

Definition at line 111 of file kaldi-lattice.h.

References LatticeHolder::t_.

111 { t_ = NULL; }
~LatticeHolder ( )
inline

Definition at line 140 of file kaldi-lattice.h.

References LatticeHolder::Clear().

140 { Clear(); }

Member Function Documentation

void Clear ( )
inline

Definition at line 129 of file kaldi-lattice.h.

References LatticeHolder::t_.

Referenced by LatticeHolder::Read(), and LatticeHolder::~LatticeHolder().

129 { delete t_; t_ = NULL; }
bool ExtractRange ( const LatticeHolder other,
const std::string &  range 
)
inline

Definition at line 135 of file kaldi-lattice.h.

References KALDI_ERR.

135  {
136  KALDI_ERR << "ExtractRange is not defined for this type of holder.";
137  return false;
138  }
#define KALDI_ERR
Definition: kaldi-error.h:127
static bool IsReadInBinary ( )
inlinestatic

Definition at line 122 of file kaldi-lattice.h.

122 { return true; }
bool Read ( std::istream &  is)

Definition at line 494 of file kaldi-lattice.cc.

References LatticeHolder::Clear(), KALDI_WARN, kaldi::ReadLattice(), and LatticeHolder::t_.

494  {
495  Clear(); // in case anything currently stored.
496  int c = is.peek();
497  if (c == -1) {
498  KALDI_WARN << "End of stream detected reading Lattice.";
499  return false;
500  } else if (isspace(c)) { // The text form of the lattice begins
501  // with space (normally, '\n'), so this means it's text (the binary form
502  // cannot begin with space because it starts with the FST Type() which is not
503  // space).
504  return ReadLattice(is, false, &t_);
505  } else if (c != 214) { // 214 is first char of FST magic number,
506  // on little-endian machines which is all we support (\326 octal)
507  KALDI_WARN << "Reading compact lattice: does not appear to be an FST "
508  << " [non-space but no magic number detected], file pos is "
509  << is.tellg();
510  return false;
511  } else {
512  return ReadLattice(is, true, &t_);
513  }
514 }
bool ReadLattice(std::istream &is, bool binary, Lattice **lat)
#define KALDI_WARN
Definition: kaldi-error.h:130
void Swap ( LatticeHolder other)
inline

Definition at line 131 of file kaldi-lattice.h.

References kaldi::swap(), and LatticeHolder::t_.

131  {
132  std::swap(t_, other->t_);
133  }
void swap(basic_filebuf< CharT, Traits > &x, basic_filebuf< CharT, Traits > &y)
const T& Value ( ) const
inline

Definition at line 124 of file kaldi-lattice.h.

References KALDI_ASSERT, and LatticeHolder::t_.

124  {
125  KALDI_ASSERT(t_ != NULL && "Called Value() on empty LatticeHolder");
126  return *t_;
127  }
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:169
static bool Write ( std::ostream &  os,
bool  binary,
const T t 
)
inlinestatic

Definition at line 113 of file kaldi-lattice.h.

References kaldi::WriteLattice().

113  {
114  // Note: we don't include the binary-mode header when writing
115  // this object to disk; this ensures that if we write to single
116  // files, the result can be read by OpenFst.
117  return WriteLattice(os, binary, t);
118  }
bool WriteLattice(std::ostream &os, bool binary, const Lattice &t)

Member Data Documentation


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