diff options
author | Peng Wu <alexepico@gmail.com> | 2011-05-12 15:05:58 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2011-05-12 15:16:03 +0800 |
commit | fc8fd83c063c0a99bbe4973529670c63e1113cc5 (patch) | |
tree | b592e5609b57fee1cfe2e5e45fb8d2f474204dbc /utils/training | |
parent | 1b5ea010d98d272deb845965cef1511ccf3076de (diff) | |
download | libpinyin-fc8fd83c063c0a99bbe4973529670c63e1113cc5.tar.gz libpinyin-fc8fd83c063c0a99bbe4973529670c63e1113cc5.tar.xz libpinyin-fc8fd83c063c0a99bbe4973529670c63e1113cc5.zip |
refine merge k mixture model
Diffstat (limited to 'utils/training')
-rw-r--r-- | utils/training/merge_k_mixture_model.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/utils/training/merge_k_mixture_model.cpp b/utils/training/merge_k_mixture_model.cpp index c4df992..79434db 100644 --- a/utils/training/merge_k_mixture_model.cpp +++ b/utils/training/merge_k_mixture_model.cpp @@ -34,8 +34,6 @@ static bool merge_two_phrase_array( /* in */ FlexibleBigramPhraseArray first, /* avoid to do empty merge. */ assert( NULL != first && NULL != second && NULL != merged ); - merged = g_array_new(FALSE, FALSE, sizeof(KMixtureModelArrayItemWithToken)); - /* merge two arrays. */ guint first_index, second_index = first_index = 0; KMixtureModelArrayItemWithToken * first_item, @@ -113,7 +111,6 @@ static bool merge_magic_header( /* in & out */ KMixtureModelBigram * target, return true; } -/* Note: must be called after the merge array items method. */ static bool merge_array_headers( /* in & out */ KMixtureModelBigram * target, /* in */ KMixtureModelBigram * new_one){ @@ -128,7 +125,13 @@ static bool merge_array_headers( /* in & out */ KMixtureModelBigram * target, memset(&merged_array_header, 0, sizeof(KMixtureModelArrayHeader)); assert(new_one->get_array_header(*token, new_array_header)); - assert(target->get_array_header(*token, target_array_header)); + bool exists_in_target = target->get_array_header(*token, + target_array_header); + if ( !exists_in_target ){ + target->set_array_header(*token, new_array_header); + continue; + } + merged_array_header.m_WC = target_array_header.m_WC + new_array_header.m_WC; assert(target->set_array_header(*token, merged_array_header)); |