summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2013-04-10 13:49:41 +0800
committerPeng Wu <alexepico@gmail.com>2013-04-10 13:49:41 +0800
commit2c7f91dd2546ccba87714391c1281ee8973de4ac (patch)
treeac31c883825c8211d8ec6c4d6e91f1b9cb10ebda /tests
parent4e9b37108c4efc092f03b64a06a43ef95f437541 (diff)
downloadlibpinyin-2c7f91dd2546ccba87714391c1281ee8973de4ac.zip
libpinyin-2c7f91dd2546ccba87714391c1281ee8973de4ac.tar.gz
libpinyin-2c7f91dd2546ccba87714391c1281ee8973de4ac.tar.xz
update tests/lookup
Diffstat (limited to 'tests')
-rw-r--r--tests/lookup/test_phrase_lookup.cpp14
-rw-r--r--tests/lookup/test_pinyin_lookup.cpp12
2 files changed, 23 insertions, 3 deletions
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;