summaryrefslogtreecommitdiffstats
path: root/tests/lookup
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2012-05-17 14:16:27 +0800
committerPeng Wu <alexepico@gmail.com>2012-05-17 14:16:27 +0800
commite864fe93329e03ab02e157d44df23d4cd949fecf (patch)
tree13fa8a2d8f787b743350cdf1907e61d070351a51 /tests/lookup
parent1f7619d24db40736a274b1c258c5206b06f3e538 (diff)
downloadlibpinyin-e864fe93329e03ab02e157d44df23d4cd949fecf.tar.gz
libpinyin-e864fe93329e03ab02e157d44df23d4cd949fecf.tar.xz
libpinyin-e864fe93329e03ab02e157d44df23d4cd949fecf.zip
update test_pinyin_lookup and test_phrase_lookup
Diffstat (limited to 'tests/lookup')
-rw-r--r--tests/lookup/test_phrase_lookup.cpp16
-rw-r--r--tests/lookup/test_pinyin_lookup.cpp22
2 files changed, 23 insertions, 15 deletions
diff --git a/tests/lookup/test_phrase_lookup.cpp b/tests/lookup/test_phrase_lookup.cpp
index 4d51f28..9015472 100644
--- a/tests/lookup/test_phrase_lookup.cpp
+++ b/tests/lookup/test_phrase_lookup.cpp
@@ -77,12 +77,16 @@ int main(int argc, char * argv[]){
//init phrase index
FacadePhraseIndex phrase_index;
- chunk = new MemoryChunk;
- chunk->load("../../data/gb_char.bin");
- phrase_index.load(1, chunk);
- chunk = new MemoryChunk;
- chunk->load("../../data/gbk_char.bin");
- phrase_index.load(2, 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;
+ chunk->load(filename);
+ phrase_index.load(i, chunk);
+ g_free(filename);
+ }
//init bi-gram
Bigram system_bigram;
diff --git a/tests/lookup/test_pinyin_lookup.cpp b/tests/lookup/test_pinyin_lookup.cpp
index 577af72..ab67e0d 100644
--- a/tests/lookup/test_pinyin_lookup.cpp
+++ b/tests/lookup/test_pinyin_lookup.cpp
@@ -10,17 +10,21 @@ int main( int argc, char * argv[]){
USE_TONE | USE_RESPLIT_TABLE | PINYIN_CORRECT_ALL | PINYIN_AMB_ALL;
FacadeChewingTable largetable;
- MemoryChunk * new_chunk = new MemoryChunk;
- new_chunk->load("../../data/pinyin_index.bin");
- largetable.load(options, new_chunk, NULL);
+ MemoryChunk * chunk = new MemoryChunk;
+ chunk->load("../../data/pinyin_index.bin");
+ largetable.load(options, chunk, NULL);
FacadePhraseIndex phrase_index;
- new_chunk = new MemoryChunk;
- new_chunk->load("../../data/gb_char.bin");
- phrase_index.load(1, new_chunk);
- new_chunk = new MemoryChunk;
- new_chunk->load("../../data/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;
+ chunk->load(filename);
+ phrase_index.load(i, chunk);
+ g_free(filename);
+ }
Bigram system_bigram;
system_bigram.attach("../../data/bigram.db", ATTACH_READONLY);