void Determinize(bool *debug_ptr) {
assert(!determinized_);
// This determinizes the input fst but leaves it in the "special format"
// in "output_arcs_".
InputStateId start_id = ifst_->Start();
if (start_id == kNoStateId) { determinized_ = true; return; } // Nothing to do.
else { // Insert start state into hash and queue.
Element elem;
elem.state = start_id;
elem.weight = Weight::One();
elem.string = repository_.IdOfEmpty(); // Id of empty sequence.
std::vector<Element> vec;
vec.push_back(elem);
OutputStateId cur_id = SubsetToStateId(vec);
assert(cur_id == 0 && "Do not call Determinize twice.");
}
while (!Q_.empty()) {
std::pair<std::vector<Element>*, OutputStateId> cur_pair = Q_.front();
Q_.pop_front();
ProcessSubset(cur_pair);
if (debug_ptr && *debug_ptr) Debug(); // will exit.
if (max_states_ > 0 && output_arcs_.size() > max_states_) {
if (allow_partial_ == false) {
KALDI_ERR << "Determinization aborted since passed " << max_states_
<< " states";
} else {
KALDI_WARN << "Determinization terminated since passed " << max_states_
<< " states, partial results will be generated";
is_partial_ = true;
break;
}
}
}
determinized_ = true;
}
Q_.pop_front() pop a element every loop, but Q_.size() didn't change, so an endless loop appear.