Override function called after the last n-gram has been consumed.
359 std::vector<std::pair<std::vector<int32>*, LmState*> > sorted_vec;
360 unordered_map<std::vector<int32>,
361 LmState*, VectorHasher<int32> >::iterator iter;
363 if (iter->second->MemSize() > 0) {
364 sorted_vec.push_back(
365 std::make_pair(
const_cast<std::vector<int32>*
>(&(iter->first)),
370 std::sort(sorted_vec.begin(), sorted_vec.end(),
371 WordsAndLmStatePairLessThan());
374 for (
int32 i = 0;
i < sorted_vec.size(); ++
i) {
377 sorted_vec[
i].second->SetMyAddress(0);
379 sorted_vec[
i].second->SetMyAddress(sorted_vec[
i - 1].second->MyAddress()
380 + sorted_vec[
i - 1].second->MemSize());
386 int64 lm_states_index = 0;
389 }
catch(
const std::exception &e) {
395 std::vector<int32*> overflow_buffer_vec;
399 for (
int32 i = 0;
i < sorted_vec.size(); ++
i) {
404 Int32AndFloat logprob_f(sorted_vec[
i].second->Logprob());
408 Int32AndFloat backoff_logprob_f(sorted_vec[
i].second->BackoffLogprob());
409 lm_states_[lm_states_index++] = backoff_logprob_f.i;
412 lm_states_[lm_states_index++] = sorted_vec[
i].second->NumChildren();
419 sorted_vec[
i].second->SortChildren();
420 for (
int32 j = 0;
j < sorted_vec[
i].second->NumChildren(); ++
j) {
422 if (sorted_vec[
i].second->IsChildFinalOrder() ||
423 sorted_vec[
i].second->GetChild(
j).second.state->MemSize() == 0) {
427 Int32AndFloat child_logprob_f;
428 if (sorted_vec[
i].second->IsChildFinalOrder()) {
429 child_logprob_f.f = sorted_vec[
i].second->GetChild(
j).second.prob;
432 sorted_vec[
i].second->GetChild(
j).second.state->Logprob();
434 child_info = child_logprob_f.i;
439 sorted_vec[
i].second->GetChild(
j).second.state->MyAddress()
440 - sorted_vec[
i].second->MyAddress();
444 child_info = offset * 2;
449 int32* abs_address = parent_address + offset;
450 overflow_buffer_vec.push_back(abs_address);
451 int32 overflow_buffer_index = overflow_buffer_vec.size() - 1;
452 child_info = overflow_buffer_index * 2;
458 lm_states_[lm_states_index++] = sorted_vec[
i].second->GetChild(
j).first;
460 lm_states_[lm_states_index++] = child_info;
466 if (sorted_vec[
i].second->IsUnigram()) {
unordered_map< std::vector< int32 >, LmState *, VectorHasher< int32 > > seq_to_state_
int32 overflow_buffer_size_
int32 ** overflow_buffer_
#define KALDI_ASSERT(cond)
int32 max_address_offset_