summaryrefslogtreecommitdiff
path: root/utils/storage/export_interpolation.cpp
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2012-05-18 11:42:05 +0800
committerPeng Wu <alexepico@gmail.com>2012-05-18 11:52:20 +0800
commitad922c4b6f8a6f2062a980e7b15b4fa17428b182 (patch)
tree76efbc71f979886ca010340eb5506efd4139d563 /utils/storage/export_interpolation.cpp
parent46d7e4c0e4a1a0a8b8e8b8346e88d222597dacb7 (diff)
downloadlibpinyin-ad922c4b6f8a6f2062a980e7b15b4fa17428b182.tar.gz
refine utils
Diffstat (limited to 'utils/storage/export_interpolation.cpp')
-rw-r--r--utils/storage/export_interpolation.cpp20
1 files changed, 4 insertions, 16 deletions
diff --git a/utils/storage/export_interpolation.cpp b/utils/storage/export_interpolation.cpp
index 60e27d6..10dcbdd 100644
--- a/utils/storage/export_interpolation.cpp
+++ b/utils/storage/export_interpolation.cpp
@@ -24,7 +24,7 @@
#include <assert.h>
#include <glib.h>
#include "pinyin_internal.h"
-
+#include "utils_helper.h"
/* export interpolation model as textual format */
@@ -47,20 +47,8 @@ int main(int argc, char * argv[]){
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;
-
- chunk = new MemoryChunk;
- bool retval = chunk->load(bin_file);
- if (!retval) {
- fprintf(stderr, "open %s failed!\n", bin_file);
- exit(ENOENT);
- }
-
- phrase_index.load(i, chunk);
- }
+ if (!init_phrase_index(&phrase_index))
+ exit(ENOENT);
Bigram bigram;
bigram.attach(bigram_filename, ATTACH_READONLY);
@@ -80,7 +68,7 @@ bool gen_unigram(FILE * output, FacadePhraseIndex * phrase_index) {
PhraseIndexRange range;
int result = phrase_index->get_range(i, range);
- if ( result )
+ if (ERROR_OK != result )
continue;
PhraseItem item;