summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2013-06-17 15:19:03 +0800
committerPeng Wu <alexepico@gmail.com>2013-06-17 15:19:03 +0800
commit32071df5b2689e040073ef678bfd6766a26a4efd (patch)
tree5c6362a5a1bda5933b62fbd36429c0dd51e5812e
parent46af45028fbb166c3a4be4239b0126db39efd2b4 (diff)
downloadlibpinyin-32071df5b2689e040073ef678bfd6766a26a4efd.tar.gz
libpinyin-32071df5b2689e040073ef678bfd6766a26a4efd.tar.xz
libpinyin-32071df5b2689e040073ef678bfd6766a26a4efd.zip
add asserts
-rw-r--r--utils/storage/import_interpolation.cpp11
-rw-r--r--utils/training/import_k_mixture_model.cpp2
2 files changed, 9 insertions, 4 deletions
diff --git a/utils/storage/import_interpolation.cpp b/utils/storage/import_interpolation.cpp
index d1d60e2..205a27a 100644
--- a/utils/storage/import_interpolation.cpp
+++ b/utils/storage/import_interpolation.cpp
@@ -188,20 +188,23 @@ bool parse_bigram(FILE * input, PhraseLargeTable2 * phrase_table,
if ( last_token && last_single_gram ) {
bigram->store(last_token, last_single_gram);
delete last_single_gram;
- //safe guard
- last_token = 0;
+
+ /* safe guard */
+ last_token = null_token;
last_single_gram = NULL;
}
SingleGram * single_gram = NULL;
bigram->load(token1, single_gram);
- //create the new single gram
+ /* create the new single gram */
if ( single_gram == NULL )
single_gram = new SingleGram;
last_token = token1;
last_single_gram = single_gram;
}
- //save the freq
+
+ /* save the freq */
+ assert(NULL != last_single_gram);
guint32 total_freq = 0;
assert(last_single_gram->get_total_freq(total_freq));
assert(last_single_gram->insert_freq(token2, count));
diff --git a/utils/training/import_k_mixture_model.cpp b/utils/training/import_k_mixture_model.cpp
index d018b78..40870cf 100644
--- a/utils/training/import_k_mixture_model.cpp
+++ b/utils/training/import_k_mixture_model.cpp
@@ -231,6 +231,8 @@ bool parse_bigram(FILE * input, PhraseLargeTable2 * phrase_table,
last_token = token1;
last_single_gram = single_gram;
}
+
+ assert(NULL != last_single_gram);
assert(last_single_gram->insert_array_item(token2, array_item));
break;
}