summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2011-07-26 15:36:18 +0800
committerPeng Wu <alexepico@gmail.com>2011-07-26 15:36:18 +0800
commit35ef8dadd9f969f10ae7c4910e1417c848ecafd5 (patch)
treefb91eaec770a6540dd549328001e602a255d75d5
parent16a42ce9d4cc77de1670b725dcfb5c7e8e8c25bf (diff)
downloadlibpinyin-35ef8dadd9f969f10ae7c4910e1417c848ecafd5.tar.gz
libpinyin-35ef8dadd9f969f10ae7c4910e1417c848ecafd5.tar.xz
libpinyin-35ef8dadd9f969f10ae7c4910e1417c848ecafd5.zip
improve gen binary files
-rw-r--r--utils/storage/gen_binary_files.cpp32
1 files changed, 9 insertions, 23 deletions
diff --git a/utils/storage/gen_binary_files.cpp b/utils/storage/gen_binary_files.cpp
index 5d32b58..95374c1 100644
--- a/utils/storage/gen_binary_files.cpp
+++ b/utils/storage/gen_binary_files.cpp
@@ -28,28 +28,35 @@ int main(int argc, char * argv[]){
PinyinLargeTable pinyinlargetable(&custom);
PhraseLargeTable phraselargetable;
+ /* generate phrase index */
+ FacadePhraseIndex phrase_index;
+
FILE * gbfile = fopen("../../data/gb_char.table", "r");
if ( gbfile == NULL) {
fprintf(stderr, "open gb_char.table failed!");
- return 1;
+ exit(ENOENT);
}
pinyinlargetable.load_text(gbfile);
fseek(gbfile, 0L, SEEK_SET);
phraselargetable.load_text(gbfile);
+ fseek(gbfile, 0L, SEEK_SET);
+ phrase_index.load_text(1, gbfile);
fclose(gbfile);
FILE * gbkfile = fopen("../../data/gbk_char.table","r");
if ( gbkfile == NULL) {
fprintf(stderr, "open gb_char.table failed!");
- return 1;
+ exit(ENOENT);
}
pinyinlargetable.load_text(gbkfile);
fseek(gbkfile, 0L, SEEK_SET);
phraselargetable.load_text(gbkfile);
+ fseek(gbkfile, 0L, SEEK_SET);
+ phrase_index.load_text(2, gbkfile);
fclose(gbkfile);
MemoryChunk * new_chunk = new MemoryChunk;
@@ -62,27 +69,6 @@ int main(int argc, char * argv[]){
new_chunk->save("../../data/phrase_index.bin");
phraselargetable.load(new_chunk);
- /* generate phrase index*/
- FacadePhraseIndex phrase_index;
-
- FILE* infile = fopen("../../data/gb_char.table", "r");
- if ( NULL == infile ){
- fprintf(stderr, "open gb_char.table failed!\n");
- exit(ENOENT);
- }
-
- phrase_index.load_text(1, infile);
- fclose(infile);
-
- infile = fopen("../../data/gbk_char.table", "r");
- if ( NULL == infile ){
- fprintf(stderr, "open gbk_char.table failed!\n");
- exit(ENOENT);
- }
-
- phrase_index.load_text(2, infile);
- fclose(infile);
-
phrase_index.compat();
new_chunk = new MemoryChunk;