From 41286716a6b90e78eb3abe3aa5f1620bc5f0f605 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Thu, 17 May 2012 14:55:52 +0800 Subject: update utils/storage --- utils/storage/export_interpolation.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'utils/storage/export_interpolation.cpp') diff --git a/utils/storage/export_interpolation.cpp b/utils/storage/export_interpolation.cpp index 93854b6..a049975 100644 --- a/utils/storage/export_interpolation.cpp +++ b/utils/storage/export_interpolation.cpp @@ -44,18 +44,26 @@ bool end_data(FILE * output){ int main(int argc, char * argv[]){ FILE * output = stdout; const char * bigram_filename = "bigram.db"; + MemoryChunk * chunk = NULL; FacadePhraseIndex phrase_index; + for (size_t i = 0; i < PHRASE_INDEX_LIBRARY_COUNT; ++i) { + const char * bin_file = pinyin_phrase_files[i]; + if (NULL == bin_file) + continue; - //gb_char binary file - MemoryChunk * chunk = new MemoryChunk; - chunk->load("gb_char.bin"); - phrase_index.load(1, chunk); + gchar * filename = g_build_filename("..", "..", "data", + bin_file, NULL); + chunk = new MemoryChunk; + bool retval = chunk->load(filename); + if (!retval) { + fprintf(stderr, "open %s failed!\n", bin_file); + exit(ENOENT); + } - //gbk_char binary file - chunk = new MemoryChunk; - chunk->load("gbk_char.bin"); - phrase_index.load(2, chunk); + phrase_index.load(i, chunk); + g_free(filename); + } Bigram bigram; bigram.attach(bigram_filename, ATTACH_READONLY); -- cgit