QuestionsForKey is a class used to define the questions for a key, and also options that allow us to refine the question during tree-building (i.e. More...

#include <build-tree-questions.h>

Collaboration diagram for QuestionsForKey:

Public Member Functions

 QuestionsForKey (int32 num_iters=5)
 
void Check () const
 
void Write (std::ostream &os, bool binary) const
 
void Read (std::istream &is, bool binary)
 

Public Attributes

std::vector< std::vector< EventValueType > > initial_questions
 
RefineClustersOptions refine_opts
 

Detailed Description

QuestionsForKey is a class used to define the questions for a key, and also options that allow us to refine the question during tree-building (i.e.

make a question specific to the location in the tree). The Questions class handles aggregating these options for a set of different keys.

Definition at line 50 of file build-tree-questions.h.

Constructor & Destructor Documentation

◆ QuestionsForKey()

QuestionsForKey ( int32  num_iters = 5)
inline

Definition at line 56 of file build-tree-questions.h.

Referenced by Questions::SetQuestionsOf().

56  : refine_opts(num_iters, 2) {
57  // refine_cfg with 5 iters and top-n = 2 (this is no restriction because
58  // RefineClusters called with 2 clusters; would get set to that anyway as
59  // it's the only possible value for 2 clusters). User has to add questions.
60  // This config won't work as-is, as it has no questions.
61  }
RefineClustersOptions refine_opts

Member Function Documentation

◆ Check()

void Check ( ) const
inline

Definition at line 63 of file build-tree-questions.h.

References rnnlm::i, kaldi::IsSorted(), KALDI_ASSERT, QuestionsForKey::Read(), and QuestionsForKey::Write().

Referenced by Questions::SetQuestionsOf().

63  {
64  for (size_t i = 0;i < initial_questions.size();i++) KALDI_ASSERT(IsSorted(initial_questions[i]));
65  }
std::vector< std::vector< EventValueType > > initial_questions
bool IsSorted(const std::vector< T > &vec)
Returns true if the vector is sorted.
Definition: stl-utils.h:47
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:185

◆ Read()

void Read ( std::istream &  is,
bool  binary 
)

Definition at line 37 of file build-tree-questions.cc.

References kaldi::ExpectToken(), rnnlm::i, QuestionsForKey::initial_questions, RefineClustersOptions::Read(), kaldi::ReadBasicType(), kaldi::ReadIntegerVector(), and QuestionsForKey::refine_opts.

Referenced by QuestionsForKey::Check(), Questions::Questions(), and Questions::Read().

37  {
38  int32 size;
39  ExpectToken(is, binary, "<QuestionsForKey>");
40  ReadBasicType(is, binary, &size);
41  initial_questions.resize(size);
42  for (int32 i = 0; i < size; i++)
43  ReadIntegerVector(is, binary, &(initial_questions[i]));
44  refine_opts.Read(is, binary);
45  ExpectToken(is, binary, "</QuestionsForKey>");
46 }
void Read(std::istream &is, bool binary)
void ReadBasicType(std::istream &is, bool binary, T *t)
ReadBasicType is the name of the read function for bool, integer types, and floating-point types...
Definition: io-funcs-inl.h:55
kaldi::int32 int32
void ReadIntegerVector(std::istream &is, bool binary, std::vector< T > *v)
Function for reading STL vector of integer types.
Definition: io-funcs-inl.h:232
void ExpectToken(std::istream &is, bool binary, const char *token)
ExpectToken tries to read in the given token, and throws an exception on failure. ...
Definition: io-funcs.cc:191
std::vector< std::vector< EventValueType > > initial_questions
RefineClustersOptions refine_opts

◆ Write()

void Write ( std::ostream &  os,
bool  binary 
) const

Definition at line 27 of file build-tree-questions.cc.

References rnnlm::i, QuestionsForKey::initial_questions, QuestionsForKey::refine_opts, RefineClustersOptions::Write(), kaldi::WriteBasicType(), kaldi::WriteIntegerVector(), and kaldi::WriteToken().

Referenced by QuestionsForKey::Check(), Questions::Questions(), and Questions::Write().

27  {
28  WriteToken(os, binary, "<QuestionsForKey>");
29  int32 size = initial_questions.size();
30  WriteBasicType(os, binary, size);
31  for (int32 i = 0; i < size; i++)
33  refine_opts.Write(os, binary);
34  WriteToken(os, binary, "</QuestionsForKey>");
35 }
void Write(std::ostream &os, bool binary) const
kaldi::int32 int32
std::vector< std::vector< EventValueType > > initial_questions
RefineClustersOptions refine_opts
void WriteToken(std::ostream &os, bool binary, const char *token)
The WriteToken functions are for writing nonempty sequences of non-space characters.
Definition: io-funcs.cc:134
void WriteIntegerVector(std::ostream &os, bool binary, const std::vector< T > &v)
Function for writing STL vectors of integer types.
Definition: io-funcs-inl.h:198
void WriteBasicType(std::ostream &os, bool binary, T t)
WriteBasicType is the name of the write function for bool, integer types, and floating-point types...
Definition: io-funcs-inl.h:34

Member Data Documentation

◆ initial_questions

◆ refine_opts


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