summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2011-06-23 10:28:24 +0800
committerPeng Wu <alexepico@gmail.com>2011-06-23 10:28:24 +0800
commit299b703ef1502a74effc7432db93e26d30169ad6 (patch)
tree875929d2d2d2541f1a7378ee764b9708c51049ed /utils
parent387de20bc3ca05f3cdaad1f83cc87c8a40c36d07 (diff)
downloadlibpinyin-299b703ef1502a74effc7432db93e26d30169ad6.tar.gz
libpinyin-299b703ef1502a74effc7432db93e26d30169ad6.tar.xz
libpinyin-299b703ef1502a74effc7432db93e26d30169ad6.zip
fixes an important bug in gen k mixture model
Diffstat (limited to 'utils')
-rw-r--r--utils/training/gen_k_mixture_model.cpp8
-rw-r--r--utils/training/k_mixture_model.h3
2 files changed, 4 insertions, 7 deletions
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;