summaryrefslogtreecommitdiffstats
path: root/tests/test_phrase.cpp
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2011-09-09 15:07:56 +0800
committerPeng Wu <alexepico@gmail.com>2011-09-09 15:07:56 +0800
commit014d8c208f4edd8be02929893e270b1fbe17082b (patch)
tree765571268273b618da7cd85a304c67ee0ae42c5d /tests/test_phrase.cpp
parent65d222d080b2bea07a49b981460435f39bff4f4b (diff)
downloadlibpinyin-014d8c208f4edd8be02929893e270b1fbe17082b.tar.gz
libpinyin-014d8c208f4edd8be02929893e270b1fbe17082b.tar.xz
libpinyin-014d8c208f4edd8be02929893e270b1fbe17082b.zip
update test case for pinyin header
Diffstat (limited to 'tests/test_phrase.cpp')
-rw-r--r--tests/test_phrase.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/tests/test_phrase.cpp b/tests/test_phrase.cpp
index 0137e08..31ed518 100644
--- a/tests/test_phrase.cpp
+++ b/tests/test_phrase.cpp
@@ -27,8 +27,7 @@ int main(int argc, char * argv[]){
pinyin_context_t * context =
pinyin_init("../data", "../data");
- TokenVector tokens =
- g_array_new(FALSE, FALSE, sizeof(phrase_token_t));
+ pinyin_instance_t * instance = pinyin_get_instance(context);
char* linebuf = NULL;
size_t size = 0;
@@ -41,7 +40,9 @@ int main(int argc, char * argv[]){
if ( strcmp ( linebuf, "quit" ) == 0)
break;
- pinyin_phrase_segment(context, linebuf, tokens);
+ pinyin_phrase_segment(instance, linebuf);
+ MatchResults & tokens = instance->m_match_results;
+
for ( size_t i = 0; i < tokens->len; ++i ){
phrase_token_t token = g_array_index
(tokens, phrase_token_t, i);
@@ -50,7 +51,7 @@ int main(int argc, char * argv[]){
continue;
char * word = NULL;
- pinyin_translate_token(context, token, &word);
+ pinyin_translate_token(instance, token, &word);
printf("%s\t", word);
g_free(word);
}
@@ -59,8 +60,8 @@ int main(int argc, char * argv[]){
pinyin_save(context);
}
+ pinyin_release_instance(instance);
pinyin_fini(context);
- g_array_free(tokens, TRUE);
free(linebuf);
return 0;
}