summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_phrase.cpp2
-rw-r--r--tests/test_pinyin.cpp19
2 files changed, 13 insertions, 8 deletions
diff --git a/tests/test_phrase.cpp b/tests/test_phrase.cpp
index 73aa2de..0137e08 100644
--- a/tests/test_phrase.cpp
+++ b/tests/test_phrase.cpp
@@ -56,8 +56,6 @@ int main(int argc, char * argv[]){
}
printf("\n");
- pinyin_train(context);
- pinyin_reset(context);
pinyin_save(context);
}
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);