summaryrefslogtreecommitdiffstats
path: root/tests/lookup
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2017-02-07 13:38:09 +0800
committerPeng Wu <alexepico@gmail.com>2017-02-07 13:38:09 +0800
commit55d7fed35b663fa4acadc42e24a2175c228f7c37 (patch)
tree23502de338082c99c8e684f34ad46a8c58f90c8a /tests/lookup
parent8df49857ef632ab03c290df8ee6abe9f436d1d3c (diff)
downloadlibpinyin-55d7fed35b663fa4acadc42e24a2175c228f7c37.tar.gz
libpinyin-55d7fed35b663fa4acadc42e24a2175c228f7c37.tar.xz
libpinyin-55d7fed35b663fa4acadc42e24a2175c228f7c37.zip
fixes compile again
Diffstat (limited to 'tests/lookup')
-rw-r--r--tests/lookup/test_pinyin_lookup.cpp24
1 files changed, 10 insertions, 14 deletions
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;