PosteriorHolder Class Reference

#include <posterior.h>

Collaboration diagram for PosteriorHolder:

Public Types

typedef Posterior T
 

Public Member Functions

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

Static Public Member Functions

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

Private Member Functions

 KALDI_DISALLOW_COPY_AND_ASSIGN (PosteriorHolder)
 

Private Attributes

T t_
 

Detailed Description

Definition at line 58 of file posterior.h.

Member Typedef Documentation

◆ T

typedef Posterior T

Definition at line 60 of file posterior.h.

Constructor & Destructor Documentation

◆ PosteriorHolder()

PosteriorHolder ( )
inline

Definition at line 62 of file posterior.h.

References PosteriorHolder::Write().

62 { }

Member Function Documentation

◆ Clear()

void Clear ( )
inline

Definition at line 66 of file posterior.h.

References PosteriorHolder::Read(), kaldi::swap(), and PosteriorHolder::t_.

66 { Posterior tmp; std::swap(tmp, t_); }
void swap(basic_filebuf< CharT, Traits > &x, basic_filebuf< CharT, Traits > &y)
std::vector< std::vector< std::pair< int32, BaseFloat > > > Posterior
Posterior is a typedef for storing acoustic-state (actually, transition-id) posteriors over an uttera...
Definition: posterior.h:42

◆ ExtractRange()

bool ExtractRange ( const PosteriorHolder other,
const std::string &  range 
)
inline

Definition at line 81 of file posterior.h.

References PosteriorHolder::KALDI_DISALLOW_COPY_AND_ASSIGN(), and KALDI_ERR.

81  {
82  KALDI_ERR << "ExtractRange is not defined for this type of holder.";
83  return false;
84  }
#define KALDI_ERR
Definition: kaldi-error.h:147

◆ IsReadInBinary()

static bool IsReadInBinary ( )
inlinestatic

Definition at line 73 of file posterior.h.

73 { return true; }

◆ KALDI_DISALLOW_COPY_AND_ASSIGN()

KALDI_DISALLOW_COPY_AND_ASSIGN ( PosteriorHolder  )
private

◆ Read()

bool Read ( std::istream &  is)

Definition at line 138 of file posterior.cc.

References kaldi::InitKaldiInputStream(), KALDI_WARN, kaldi::ReadPosterior(), and PosteriorHolder::t_.

Referenced by PosteriorHolder::Clear(), and GaussPostHolder::Clear().

138  {
139  t_.clear();
140 
141  bool is_binary;
142  if (!InitKaldiInputStream(is, &is_binary)) {
143  KALDI_WARN << "Reading Table object, failed reading binary header";
144  return false;
145  }
146  try {
147  ReadPosterior(is, is_binary, &t_);
148  return true;
149  } catch (std::exception &e) {
150  KALDI_WARN << "Exception caught reading table of posteriors. " << e.what();
151  t_.clear();
152  return false;
153  }
154 }
bool InitKaldiInputStream(std::istream &is, bool *binary)
Initialize an opened stream for reading by detecting the binary header and.
Definition: io-funcs-inl.h:306
#define KALDI_WARN
Definition: kaldi-error.h:150
void ReadPosterior(std::istream &is, bool binary, Posterior *post)
stand-alone function for reading a Posterior.
Definition: posterior.cc:64

◆ Swap()

void Swap ( PosteriorHolder other)
inline

Definition at line 77 of file posterior.h.

References PosteriorHolder::t_.

77  {
78  t_.swap(other->t_);
79  }

◆ Value()

T& Value ( )
inline

Definition at line 75 of file posterior.h.

References PosteriorHolder::t_.

75 { return t_; }

◆ Write()

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

Definition at line 127 of file posterior.cc.

References kaldi::InitKaldiOutputStream(), KALDI_WARN, and kaldi::WritePosterior().

Referenced by GaussPostHolder::GaussPostHolder(), and PosteriorHolder::PosteriorHolder().

127  {
128  InitKaldiOutputStream(os, binary); // Puts binary header if binary mode.
129  try {
130  WritePosterior(os, binary, t);
131  return true;
132  } catch(const std::exception &e) {
133  KALDI_WARN << "Exception caught writing table of posteriors. " << e.what();
134  return false; // Write failure.
135  }
136 }
#define KALDI_WARN
Definition: kaldi-error.h:150
void InitKaldiOutputStream(std::ostream &os, bool binary)
InitKaldiOutputStream initializes an opened stream for writing by writing an optional binary header a...
Definition: io-funcs-inl.h:291
void WritePosterior(std::ostream &os, bool binary, const Posterior &post)
stand-alone function for writing a Posterior.
Definition: posterior.cc:32

Member Data Documentation

◆ t_


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