summaryrefslogtreecommitdiffstats
path: root/tests/lookup
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2016-06-01 14:25:18 +0800
committerPeng Wu <alexepico@gmail.com>2016-06-01 14:25:18 +0800
commit134b406336b467b89fbc6e1723a5e86044d94e68 (patch)
treeefe2e7a83b31992946461f01320234441b5229de /tests/lookup
parent17bff01510c9c2512af911948fe8307596d02adf (diff)
downloadlibpinyin-134b406336b467b89fbc6e1723a5e86044d94e68.tar.gz
libpinyin-134b406336b467b89fbc6e1723a5e86044d94e68.tar.xz
libpinyin-134b406336b467b89fbc6e1723a5e86044d94e68.zip
update test_pinyin_lookup.cpp
Diffstat (limited to 'tests/lookup')
-rw-r--r--tests/lookup/test_pinyin_lookup.cpp29
1 files changed, 22 insertions, 7 deletions
diff --git a/tests/lookup/test_pinyin_lookup.cpp b/tests/lookup/test_pinyin_lookup.cpp
index bbea71f..16437e0 100644
--- a/tests/lookup/test_pinyin_lookup.cpp
+++ b/tests/lookup/test_pinyin_lookup.cpp
@@ -37,7 +37,7 @@ int main( int argc, char * argv[]){
}
pinyin_option_t options =
- USE_TONE | USE_RESPLIT_TABLE | PINYIN_CORRECT_ALL | PINYIN_AMB_ALL;
+ USE_TONE | PINYIN_CORRECT_ALL | PINYIN_AMB_ALL | PINYIN_INCOMPLETE;
FacadeChewingTable2 largetable;
largetable.load("../../data/pinyin_index.bin", NULL);
@@ -55,9 +55,8 @@ int main( int argc, char * argv[]){
user_bigram.attach(NULL, ATTACH_CREATE|ATTACH_READWRITE);
gfloat lambda = system_table_info.get_lambda();
-
- PinyinLookup2 pinyin_lookup(lambda, options,
- &largetable, &phrase_index,
+
+ PinyinLookup2 pinyin_lookup(lambda, &largetable, &phrase_index,
&system_bigram, &user_bigram);
/* prepare the prefixes for get_best_match. */
@@ -85,9 +84,23 @@ int main( int argc, char * argv[]){
g_array_new(FALSE, FALSE, sizeof(ChewingKeyRest));
parser.parse(options, keys, key_rests, linebuf, strlen(linebuf));
+ PhoneticKeyMatrix matrix;
+
if ( 0 == keys->len ) /* invalid pinyin */
continue;
+ /* fill the matrix. */
+ fill_phonetic_key_matrix_from_chewing_keys
+ (&matrix, keys, key_rests);
+
+ resplit_step(options, &matrix);
+
+ inner_split_step(options, &matrix);
+
+ fuzzy_syllable_step(options, &matrix);
+
+ dump_phonetic_key_matrix(&matrix);
+
/* initialize constraints. */
g_array_set_size(constraints, keys->len);
for ( size_t i = 0; i < constraints->len; ++i){
@@ -96,16 +109,18 @@ int main( int argc, char * argv[]){
}
guint32 start_time = record_time();
- for ( size_t i = 0; i < bench_times; ++i)
- pinyin_lookup.get_best_match(prefixes, keys, constraints, results);
+ for (size_t i = 0; i < bench_times; ++i)
+ pinyin_lookup.get_best_match(prefixes, &matrix, constraints, results);
print_time(start_time, bench_times);
- for ( size_t i = 0; i < results->len; ++i){
+
+ for (size_t i = 0; i < results->len; ++i){
phrase_token_t * token = &g_array_index(results, phrase_token_t, i);
if ( null_token == *token)
continue;
printf("pos:%ld,token:%d\t", i, *token);
}
printf("\n");
+
char * sentence = NULL;
pinyin_lookup.convert_to_utf8(results, sentence);
printf("%s\n", sentence);