summaryrefslogtreecommitdiffstats
path: root/tests/test_pinyin.cpp
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2011-09-06 11:34:04 +0800
committerPeng Wu <alexepico@gmail.com>2011-09-06 11:34:04 +0800
commite2f06b37b9e2f8c1c1a9428c1619af4a8c5566c8 (patch)
tree7b47ed0cd159f5d61ac0e4b1d33d33bb5324971e /tests/test_pinyin.cpp
parentdbdfd3b658f0f723513fd08415d08554d125f302 (diff)
downloadlibpinyin-e2f06b37b9e2f8c1c1a9428c1619af4a8c5566c8.tar.gz
libpinyin-e2f06b37b9e2f8c1c1a9428c1619af4a8c5566c8.tar.xz
libpinyin-e2f06b37b9e2f8c1c1a9428c1619af4a8c5566c8.zip
refine pinyin apis
Diffstat (limited to 'tests/test_pinyin.cpp')
-rw-r--r--tests/test_pinyin.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/tests/test_pinyin.cpp b/tests/test_pinyin.cpp
index fe37ba5..ce00f14 100644
--- a/tests/test_pinyin.cpp
+++ b/tests/test_pinyin.cpp
@@ -27,8 +27,12 @@ int main(int argc, char * argv[]){
pinyin_context_t * context =
pinyin_init("../data", "../data");
- PinyinKeyVector pinyin_keys =
- g_array_new(FALSE, FALSE, sizeof(PinyinKey));
+ PinyinKeyVector pinyin_keys = NULL;
+ CandidateConstraints constraints = NULL;
+ MatchResults match_results = NULL;
+
+ pinyin_alloc_auxiliary_arrays
+ (context, &pinyin_keys, &constraints, &match_results);
char* linebuf = NULL;
size_t size = 0;
@@ -42,17 +46,20 @@ int main(int argc, char * argv[]){
break;
pinyin_parse_more_fulls(context, linebuf, pinyin_keys);
- pinyin_set_pinyin_keys(context, pinyin_keys);
char * sentence = NULL;
- pinyin_get_guessed_sentence(context, &sentence);
+ pinyin_get_guessed_tokens(context, pinyin_keys, constraints,
+ match_results);
+ pinyin_get_sentence (context, match_results, &sentence);
printf("%s\n", sentence);
g_free(sentence);
- pinyin_train(context);
- pinyin_reset(context);
+ pinyin_train(context, pinyin_keys, constraints, match_results);
+ pinyin_reset(context, pinyin_keys, constraints, match_results);
pinyin_save(context);
}
+ pinyin_free_auxiliary_arrays
+ (context, &pinyin_keys, &constraints, &match_results);
pinyin_fini(context);
g_array_free(pinyin_keys, TRUE);
free(linebuf);