From 55d7fed35b663fa4acadc42e24a2175c228f7c37 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Tue, 7 Feb 2017 13:38:09 +0800 Subject: fixes compile again --- tests/lookup/test_pinyin_lookup.cpp | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'tests/lookup') diff --git a/tests/lookup/test_pinyin_lookup.cpp b/tests/lookup/test_pinyin_lookup.cpp index 8a1647d..86199af 100644 --- a/tests/lookup/test_pinyin_lookup.cpp +++ b/tests/lookup/test_pinyin_lookup.cpp @@ -59,18 +59,16 @@ int main( int argc, char * argv[]){ gfloat lambda = system_table_info.get_lambda(); - PinyinLookup2 pinyin_lookup(lambda, &largetable, &phrase_index, - &system_bigram, &user_bigram); + PhoneticLookup<1> pinyin_lookup(lambda, &largetable, &phrase_index, + &system_bigram, &user_bigram); /* prepare the prefixes for get_best_match. */ TokenVector prefixes = g_array_new (FALSE, FALSE, sizeof(phrase_token_t)); g_array_append_val(prefixes, sentence_start); - - CandidateConstraints constraints = g_array_new - (TRUE, FALSE, sizeof(lookup_constraint_t)); - MatchResult result = g_array_new(FALSE, FALSE, sizeof(phrase_token_t)); + ForwardPhoneticConstraints constraints; + NBestMatchResults results; char* linebuf = NULL; size_t size = 0; ssize_t read; while( (read = getline(&linebuf, &size, stdin)) != -1 ){ @@ -105,17 +103,17 @@ int main( int argc, char * argv[]){ dump_matrix(&matrix); /* initialize constraints. */ - g_array_set_size(constraints, matrix.size()); - for ( size_t i = 0; i < constraints->len; ++i){ - lookup_constraint_t * constraint = &g_array_index(constraints, lookup_constraint_t, i); - constraint->m_type = NO_CONSTRAINT; - } + constraints.validate_constraint(&matrix); guint32 start_time = record_time(); for (size_t i = 0; i < bench_times; ++i) - pinyin_lookup.get_best_match(prefixes, &matrix, constraints, result); + pinyin_lookup.get_nbest_match(prefixes, &matrix, &constraints, &results); print_time(start_time, bench_times); + assert(1 == results.size()); + MatchResult result = NULL; + assert(results.get_result(0, result)); + for (size_t i = 0; i < result->len; ++i){ phrase_token_t * token = &g_array_index(result, phrase_token_t, i); if ( null_token == *token) @@ -134,8 +132,6 @@ int main( int argc, char * argv[]){ } g_array_free(prefixes, TRUE); - g_array_free(constraints, TRUE); - g_array_free(result, TRUE); free(linebuf); return 0; -- cgit