From 2c7f91dd2546ccba87714391c1281ee8973de4ac Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Wed, 10 Apr 2013 13:49:41 +0800 Subject: update tests/lookup --- tests/lookup/test_phrase_lookup.cpp | 14 ++++++++++++-- tests/lookup/test_pinyin_lookup.cpp | 12 +++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/lookup/test_phrase_lookup.cpp b/tests/lookup/test_phrase_lookup.cpp index 57bcf90..36a070d 100644 --- a/tests/lookup/test_phrase_lookup.cpp +++ b/tests/lookup/test_phrase_lookup.cpp @@ -51,18 +51,28 @@ bool try_phrase_lookup(PhraseLookup * phrase_lookup, } int main(int argc, char * argv[]){ - setlocale(LC_ALL, ""); + SystemTableInfo system_table_info; + + bool retval = system_table_info.load("../../data/table.conf"); + if (!retval) { + fprintf(stderr, "load table.conf failed.\n"); + exit(ENOENT); + } + /* init phrase table */ FacadePhraseTable2 phrase_table; MemoryChunk * chunk = new MemoryChunk; chunk->load("../../data/phrase_index.bin"); phrase_table.load(chunk, NULL); + const pinyin_table_info_t * phrase_files = + system_table_info.get_table_info(); + /* init phrase index */ FacadePhraseIndex phrase_index; - if (!load_phrase_index(&phrase_index)) + if (!load_phrase_index(phrase_files, &phrase_index)) exit(ENOENT); /* init bi-gram */ diff --git a/tests/lookup/test_pinyin_lookup.cpp b/tests/lookup/test_pinyin_lookup.cpp index 3c714b9..446d8fd 100644 --- a/tests/lookup/test_pinyin_lookup.cpp +++ b/tests/lookup/test_pinyin_lookup.cpp @@ -28,6 +28,13 @@ size_t bench_times = 100; int main( int argc, char * argv[]){ + SystemTableInfo system_table_info; + + bool retval = system_table_info.load("../../data/table.conf"); + if (!retval) { + fprintf(stderr, "load table.conf failed.\n"); + exit(ENOENT); + } pinyin_option_t options = USE_TONE | USE_RESPLIT_TABLE | PINYIN_CORRECT_ALL | PINYIN_AMB_ALL; @@ -37,8 +44,11 @@ int main( int argc, char * argv[]){ chunk->load("../../data/pinyin_index.bin"); largetable.load(options, chunk, NULL); + const pinyin_table_info_t * phrase_files = + system_table_info.get_table_info(); + FacadePhraseIndex phrase_index; - if (!load_phrase_index(&phrase_index)) + if (!load_phrase_index(phrase_files, &phrase_index)) exit(ENOENT); Bigram system_bigram; -- cgit