Permalink
Browse files

update tests to use phrase table ver2

  • Loading branch information...
1 parent 1b76ad0 commit 13b537cd88a92bd6540ecdaa8f993a409d32776a @epico committed Sep 3, 2012
Showing with 18 additions and 9 deletions.
  1. +1 −1 Makefile.am
  2. +1 −1 tests/lookup/test_phrase_lookup.cpp
  3. +15 −6 tests/storage/test_phrase_table.cpp
  4. +1 −1 tests/tests_helper.h
View
2 Makefile.am
@@ -18,7 +18,7 @@
EXTRA_DIST = COPYING
AUTOMAKE_OPTIONS = gnu
-SUBDIRS = src utils tests data doc
+SUBDIRS = src tests utils data doc
MAINTAINERCLEANFILES = Makefile.in
View
2 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);
View
21 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);
View
2 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;

0 comments on commit 13b537c

Please sign in to comment.