summaryrefslogtreecommitdiffstats
path: root/utils/training/eval_correction_rate.cpp
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2012-05-17 15:01:11 +0800
committerPeng Wu <alexepico@gmail.com>2012-05-17 15:01:11 +0800
commit4797c0419273b71e5fa64ba7a1ee233de7c0ac48 (patch)
tree222c7be46f7e2bd64bd767273d8b62b98153e041 /utils/training/eval_correction_rate.cpp
parent41286716a6b90e78eb3abe3aa5f1620bc5f0f605 (diff)
downloadlibpinyin-4797c0419273b71e5fa64ba7a1ee233de7c0ac48.tar.gz
libpinyin-4797c0419273b71e5fa64ba7a1ee233de7c0ac48.tar.xz
libpinyin-4797c0419273b71e5fa64ba7a1ee233de7c0ac48.zip
update utils/training
Diffstat (limited to 'utils/training/eval_correction_rate.cpp')
-rw-r--r--utils/training/eval_correction_rate.cpp35
1 files changed, 23 insertions, 12 deletions
diff --git a/utils/training/eval_correction_rate.cpp b/utils/training/eval_correction_rate.cpp
index 5a0ec77..55fc3b0 100644
--- a/utils/training/eval_correction_rate.cpp
+++ b/utils/training/eval_correction_rate.cpp
@@ -118,22 +118,33 @@ int main(int argc, char * argv[]){
pinyin_option_t options = USE_TONE;
FacadeChewingTable largetable;
- MemoryChunk * new_chunk = new MemoryChunk;
- new_chunk->load("pinyin_index.bin");
- largetable.load(options, new_chunk, NULL);
+ MemoryChunk * chunk = new MemoryChunk;
+ chunk->load("pinyin_index.bin");
+ largetable.load(options, chunk, NULL);
FacadePhraseIndex phrase_index;
- new_chunk = new MemoryChunk;
- new_chunk->load("gb_char.bin");
- phrase_index.load(1, new_chunk);
- new_chunk = new MemoryChunk;
- new_chunk->load("gbk_char.bin");
- phrase_index.load(2, new_chunk);
+ for (size_t i = 0; i < PHRASE_INDEX_LIBRARY_COUNT; ++i) {
+ const char * bin_file = pinyin_phrase_files[i];
+ if (NULL == bin_file)
+ continue;
+
+ 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);
+ }
+
+ phrase_index.load(i, chunk);
+ g_free(filename);
+ }
FacadePhraseTable phrases;
- new_chunk = new MemoryChunk;
- new_chunk->load("phrase_index.bin");
- phrases.load(new_chunk, NULL);
+ chunk = new MemoryChunk;
+ chunk->load("phrase_index.bin");
+ phrases.load(chunk, NULL);
Bigram system_bigram;
system_bigram.attach("bigram.db", ATTACH_READONLY);