diff options
author | Peng Wu <alexepico@gmail.com> | 2012-05-18 11:42:05 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2012-05-18 11:52:20 +0800 |
commit | ad922c4b6f8a6f2062a980e7b15b4fa17428b182 (patch) | |
tree | 76efbc71f979886ca010340eb5506efd4139d563 /utils/training/gen_unigram.cpp | |
parent | 46d7e4c0e4a1a0a8b8e8b8346e88d222597dacb7 (diff) | |
download | libpinyin-ad922c4b6f8a6f2062a980e7b15b4fa17428b182.tar.gz libpinyin-ad922c4b6f8a6f2062a980e7b15b4fa17428b182.tar.xz libpinyin-ad922c4b6f8a6f2062a980e7b15b4fa17428b182.zip |
refine utils
Diffstat (limited to 'utils/training/gen_unigram.cpp')
-rw-r--r-- | utils/training/gen_unigram.cpp | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/utils/training/gen_unigram.cpp b/utils/training/gen_unigram.cpp index 29a1bc6..b03235e 100644 --- a/utils/training/gen_unigram.cpp +++ b/utils/training/gen_unigram.cpp @@ -21,7 +21,7 @@ #include <stdio.h> #include "pinyin_internal.h" - +#include "utils_helper.h" /* increase all unigram frequency by a constant. */ @@ -29,20 +29,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); /* Note: please increase the value when corpus size becomes larger. * To avoid zero value when computing unigram frequency in float format. |