From 299b703ef1502a74effc7432db93e26d30169ad6 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Thu, 23 Jun 2011 10:28:24 +0800 Subject: fixes an important bug in gen k mixture model --- utils/training/gen_k_mixture_model.cpp | 8 ++++---- utils/training/k_mixture_model.h | 3 --- 2 files changed, 4 insertions(+), 7 deletions(-) (limited to 'utils') diff --git a/utils/training/gen_k_mixture_model.cpp b/utils/training/gen_k_mixture_model.cpp index bd350b4..f89dce4 100644 --- a/utils/training/gen_k_mixture_model.cpp +++ b/utils/training/gen_k_mixture_model.cpp @@ -221,6 +221,10 @@ static bool train_second_word(KMixtureModelBigram * bigram, return false; } + /* save the single gram. */ + assert(bigram->store(token1, single_gram)); + delete single_gram; + KMixtureModelMagicHeader magic_header; if (!bigram->get_magic_header(magic_header)){ /* the first time to access the new k mixture model file. */ @@ -234,9 +238,6 @@ static bool train_second_word(KMixtureModelBigram * bigram, magic_header.m_WC += delta; assert(bigram->set_magic_header(magic_header)); - /* save the single gram. */ - assert(bigram->store(token1, single_gram)); - delete single_gram; return true; } @@ -252,7 +253,6 @@ static bool post_processing_unigram(KMixtureModelBigram * bigram, guint32 token = GPOINTER_TO_UINT(key); guint32 freq = GPOINTER_TO_UINT(value); KMixtureModelArrayHeader array_header; - memset(&array_header, 0, sizeof(KMixtureModelArrayHeader)); bool result = bigram->get_array_header(token, array_header); array_header.m_freq += freq; total_freq += freq; diff --git a/utils/training/k_mixture_model.h b/utils/training/k_mixture_model.h index 9dda1c2..50218c2 100644 --- a/utils/training/k_mixture_model.h +++ b/utils/training/k_mixture_model.h @@ -122,11 +122,8 @@ typedef struct{ } KMixtureModelMagicHeader; typedef struct{ - /* dummy varibles */ - guint32 dummy[3]; /* the total number of instances of word W1. */ guint32 m_WC; - guint32 dummy2[3]; /* the freq of uni-gram. see m_total_freq in magic header also. */ guint32 m_freq; } KMixtureModelArrayHeader; -- cgit