51 std::vector<EventKeyType> keys_with_options;
52 this->GetKeysWithQuestions(&keys_with_options);
53 for (
size_t i = 0;
i < keys_with_options.size();
i++) {
58 opts.
Write(os, binary);
71 std::vector<EventKeyType> keys_with_options;
76 if (token ==
"</Questions>")
return;
79 KALDI_ERR <<
"Questions::Read, expecting <Key>, got "<<token;
83 opts.
Read(is, binary);
84 SetQuestionsOf(key, opts);
91 std::vector<EventKeyType> all_keys;
94 KALDI_WARN <<
"Questions::InitRand(), using union of all keys. This may work depending on how you are building the tree but may crash (depends if you have already ensured that stats currently on the same leaf all share the same set of keys.)";
97 for (
size_t i = 0;
i < all_keys.size();
i++) {
99 std::vector<EventValueType> all_values;
105 q_for_key.initial_questions.clear();
106 if (all_values.size() == 1) {
109 q_for_key.initial_questions.resize((
size_t)num_quest);
110 for (
size_t i = 0;
i < (
size_t)num_quest;
i++) {
111 std::vector<EventValueType> &this_quest = q_for_key.initial_questions[
i];
112 for (
size_t j = 0;
j < all_values.size()/2;
j++)
113 this_quest.push_back(all_values[
RandInt(0, all_values.size()-1)]);
120 SetQuestionsOf(key, q_for_key);
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
void Write(std::ostream &os, bool binary) const
void DeletePointers(std::vector< A *> *v)
Deletes any non-NULL pointers in the vector v, and sets the corresponding entries of v to NULL...
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...
void FindAllKeys(const BuildTreeStatsType &stats, AllKeysType keys_type, std::vector< EventKeyType > *keys_out)
FindAllKeys puts in *keys the (sorted, unique) list of all key identities in the stats.
void ReadToken(std::istream &is, bool binary, std::string *str)
ReadToken gets the next token and puts it in str (exception on failure).
void SortAndUniq(std::vector< T > *vec)
Sorts and uniq's (removes duplicates) from a vector.
bool PossibleValues(EventKeyType key, const BuildTreeStatsType &stats, std::vector< EventValueType > *ans)
Convenience function e.g.
AllKeysType
Typedef used when we get "all keys" from a set of stats– used in specifying which kinds of questions...
void ReadIntegerVector(std::istream &is, bool binary, std::vector< T > *v)
Function for reading STL vector of integer types.
void ExpectToken(std::istream &is, bool binary, const char *token)
ExpectToken tries to read in the given token, and throws an exception on failure. ...
void InitRand(const BuildTreeStatsType &stats, int32 num_quest, int32 num_iters_refine, AllKeysType all_keys_type)
InitRand attempts to generate "reasonable" random questions.
int32 EventKeyType
Things of type EventKeyType can take any value.
QuestionsForKey is a class used to define the questions for a key, and also options that allow us to ...
std::vector< std::vector< EventValueType > > initial_questions
void Read(std::istream &is, bool binary)
RefineClustersOptions refine_opts
void Write(std::ostream &os, bool binary) const
void WriteToken(std::ostream &os, bool binary, const char *token)
The WriteToken functions are for writing nonempty sequences of non-space characters.
void Read(std::istream &is, bool binary)
#define KALDI_ASSERT(cond)
void WriteIntegerVector(std::ostream &os, bool binary, const std::vector< T > &v)
Function for writing STL vectors of integer types.
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...
std::vector< std::pair< EventType, Clusterable * > > BuildTreeStatsType
void Write(std::ostream &os, bool binary) const
int32 RandInt(int32 min_val, int32 max_val, struct RandomState *state)