summaryrefslogtreecommitdiffstats
path: root/utils/storage/export_interpolation.cpp
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2011-04-18 16:59:03 +0800
committerPeng Wu <alexepico@gmail.com>2011-04-18 16:59:03 +0800
commitc418ddb0e8ec1eb8e79cb03e83ed3ebc202d02e5 (patch)
tree6833bd52722b0655858f060e8b7fe0df7e0568ce /utils/storage/export_interpolation.cpp
parent0b113f330653b82be8a87af8b8b4ac826e72b296 (diff)
downloadlibpinyin-c418ddb0e8ec1eb8e79cb03e83ed3ebc202d02e5.tar.gz
libpinyin-c418ddb0e8ec1eb8e79cb03e83ed3ebc202d02e5.tar.xz
libpinyin-c418ddb0e8ec1eb8e79cb03e83ed3ebc202d02e5.zip
use new bi-gram
Diffstat (limited to 'utils/storage/export_interpolation.cpp')
-rw-r--r--utils/storage/export_interpolation.cpp22
1 files changed, 9 insertions, 13 deletions
diff --git a/utils/storage/export_interpolation.cpp b/utils/storage/export_interpolation.cpp
index 9fc6cde..333470e 100644
--- a/utils/storage/export_interpolation.cpp
+++ b/utils/storage/export_interpolation.cpp
@@ -57,7 +57,7 @@ int main(int argc, char * argv[]){
phrase_index.load(2, chunk);
Bigram bigram;
- bigram.attach(bigram_filename, NULL);
+ bigram.attach(bigram_filename, ATTACH_READONLY);
begin_data(output);
@@ -99,23 +99,19 @@ void gen_bigram(FILE * output, FacadePhraseIndex * phrase_index, Bigram * bigram
fprintf(output, "\\2-gram\n");
/* Retrieve all user items. */
- GArray * system_items = g_array_new(FALSE, FALSE, sizeof(phrase_token_t));
- GArray * user_items = g_array_new(FALSE, FALSE, sizeof(phrase_token_t));
+ GArray * items = g_array_new(FALSE, FALSE, sizeof(phrase_token_t));
- bigram->get_all_items(system_items, user_items);
- assert(0 == user_items->len);
- g_array_free(user_items, TRUE);
+ bigram->get_all_items(items);
PhraseItem item;
- for(size_t i = 0; i < system_items->len; i++){
- phrase_token_t token = g_array_index(system_items, phrase_token_t, i);
- SingleGram * system = NULL, * user = NULL;
- bigram->load(token, system, user);
- assert(NULL == user);
+ for(size_t i = 0; i < items->len; i++){
+ phrase_token_t token = g_array_index(items, phrase_token_t, i);
+ SingleGram * single_gram = NULL;
+ bigram->load(token, single_gram);
BigramPhraseWithCountArray array = g_array_new(FALSE, FALSE, sizeof(BigramPhraseItemWithCount));
- system->retrieve_all(array);
+ single_gram->retrieve_all(array);
for(size_t j = 0; j < array->len; j++) {
BigramPhraseItemWithCount * item = &g_array_index(array, BigramPhraseItemWithCount, j);
@@ -132,7 +128,7 @@ void gen_bigram(FILE * output, FacadePhraseIndex * phrase_index, Bigram * bigram
g_array_free(array, TRUE);
}
- g_array_free(system_items, TRUE);
+ g_array_free(items, TRUE);
}
static const char * special_token_to_string(phrase_token_t token){