summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/lookup/test_phrase_lookup.cpp2
-rw-r--r--tests/storage/test_phrase_table.cpp21
-rw-r--r--tests/tests_helper.h2
3 files changed, 17 insertions, 8 deletions
diff --git a/tests/lookup/test_phrase_lookup.cpp b/tests/lookup/test_phrase_lookup.cpp
index 3a5470f..15cc861 100644
--- a/tests/lookup/test_phrase_lookup.cpp
+++ b/tests/lookup/test_phrase_lookup.cpp
@@ -71,7 +71,7 @@ int main(int argc, char * argv[]){
/* init phrase table */
- FacadePhraseTable phrase_table;
+ FacadePhraseTable2 phrase_table;
MemoryChunk * chunk = new MemoryChunk;
chunk->load("../../data/phrase_index.bin");
phrase_table.load(chunk, NULL);
diff --git a/tests/storage/test_phrase_table.cpp b/tests/storage/test_phrase_table.cpp
index 58d634e..3c4c489 100644
--- a/tests/storage/test_phrase_table.cpp
+++ b/tests/storage/test_phrase_table.cpp
@@ -6,9 +6,10 @@
size_t bench_times = 1000;
int main(int argc, char * argv[]){
- PhraseLargeTable largetable;
+ PhraseLargeTable2 largetable;
+ FacadePhraseIndex phrase_index;
- if (!load_phrase_table(NULL, &largetable, NULL))
+ if (!load_phrase_table(NULL, &largetable, &phrase_index))
exit(ENOENT);
MemoryChunk * chunk = new MemoryChunk;
@@ -24,17 +25,25 @@ int main(int argc, char * argv[]){
glong phrase_len = g_utf8_strlen(linebuf, -1);
ucs4_t * new_phrase = g_utf8_to_ucs4(linebuf, -1, NULL, NULL, NULL);
- phrase_token_t token;
+ phrase_token_t token = null_token;
+
+ PhraseTokens tokens;
+ memset(tokens, 0, sizeof(PhraseTokens));
+ phrase_index.prepare_tokens(tokens);
guint32 start = record_time();
for ( size_t i = 0; i < bench_times; ++i){
- largetable.search(phrase_len, new_phrase, token);
+ largetable.search(phrase_len, new_phrase, tokens);
}
print_time(start, bench_times);
- int retval = largetable.search(phrase_len, new_phrase, token);
+ int retval = largetable.search(phrase_len, new_phrase, tokens);
+ int num = get_first_token(tokens, token);
+
+ phrase_index.destroy_tokens(tokens);
+
if ( retval & SEARCH_OK )
- printf("%s:\t%d\n", linebuf, token);
+ printf("%s: num:%d token:%d\n", linebuf, num, token);
else
printf("phrase %s not found.\n", linebuf);
diff --git a/tests/tests_helper.h b/tests/tests_helper.h
index f15c19e..de8ea51 100644
--- a/tests/tests_helper.h
+++ b/tests/tests_helper.h
@@ -48,7 +48,7 @@ static bool load_phrase_index(FacadePhraseIndex * phrase_index){
}
static bool load_phrase_table(ChewingLargeTable * chewing_table,
- PhraseLargeTable * phrase_table,
+ PhraseLargeTable2 * phrase_table,
FacadePhraseIndex * phrase_index){
for (size_t i = 0; i < PHRASE_INDEX_LIBRARY_COUNT; ++i) {
const pinyin_table_info_t * table_info = pinyin_phrase_files + i;