summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2011-09-06 14:18:00 +0800
committerPeng Wu <alexepico@gmail.com>2011-09-06 14:18:00 +0800
commita49d9240720f7a8de1e2418a039f9850ccc08ca8 (patch)
treeaea55de75f33260237bf86ac399ba16fa0d8e380
parentcd0ab1bf9664acee7b014c1b71c05270dee9f080 (diff)
downloadlibpinyin-a49d9240720f7a8de1e2418a039f9850ccc08ca8.zip
libpinyin-a49d9240720f7a8de1e2418a039f9850ccc08ca8.tar.gz
libpinyin-a49d9240720f7a8de1e2418a039f9850ccc08ca8.tar.xz
refine pinyin api
-rw-r--r--src/pinyin.cpp29
-rw-r--r--src/pinyin.h11
2 files changed, 22 insertions, 18 deletions
diff --git a/src/pinyin.cpp b/src/pinyin.cpp
index 45da2fa..8ff947f 100644
--- a/src/pinyin.cpp
+++ b/src/pinyin.cpp
@@ -105,10 +105,12 @@ void pinyin_fini(pinyin_context_t * context){
bool pinyin_alloc_auxiliary_arrays(pinyin_context_t * context,
PinyinKeyVector * pinyin_keys,
+ PinyinKeyPosVector * pinyin_poses,
CandidateConstraints * constraints,
MatchResults * match_results){
*pinyin_keys = g_array_new(FALSE, FALSE, sizeof(PinyinKey));
+ *pinyin_poses = g_array_new(FALSE, FALSE, sizeof(PinyinKeyPos));
*constraints = g_array_new(FALSE, FALSE, sizeof(lookup_constraint_t));
*match_results = g_array_new(FALSE, FALSE, sizeof(phrase_token_t));
@@ -117,10 +119,13 @@ bool pinyin_alloc_auxiliary_arrays(pinyin_context_t * context,
bool pinyin_free_auxiliary_arrays(pinyin_context_t * context,
PinyinKeyVector * pinyin_keys,
+ PinyinKeyPosVector * pinyin_poses,
CandidateConstraints * constraints,
MatchResults * match_results){
g_array_free(*pinyin_keys, TRUE);
*pinyin_keys = NULL;
+ g_array_free(*pinyin_poses, TRUE);
+ *pinyin_poses = NULL;
g_array_free(*constraints, TRUE);
*constraints = NULL;
g_array_free(*match_results, TRUE);
@@ -189,16 +194,14 @@ bool pinyin_parse_full(pinyin_context_t * context,
bool pinyin_parse_more_fulls(pinyin_context_t * context,
const char * pinyins,
- PinyinKeyVector pinyin_keys){
+ PinyinKeyVector pinyin_keys,
+ PinyinKeyPosVector pinyin_poses){
int pinyin_len = strlen(pinyins);
- PinyinKeyPosVector poses;
- poses = g_array_new(FALSE, FALSE, sizeof(PinyinKeyPos));
int parse_len = context->m_default_parser->parse
( context->m_validator, pinyin_keys,
- poses, pinyins, pinyin_len);
+ pinyin_poses, pinyins, pinyin_len);
- g_array_free(poses, TRUE);
return pinyin_len == parse_len;
}
@@ -213,16 +216,14 @@ bool pinyin_parse_double(pinyin_context_t * context,
bool pinyin_parse_more_doubles(pinyin_context_t * context,
const char * pinyins,
- PinyinKeyVector pinyin_keys){
+ PinyinKeyVector pinyin_keys,
+ PinyinKeyPosVector pinyin_poses){
int pinyin_len = strlen(pinyins);
- PinyinKeyPosVector poses;
- poses = g_array_new(FALSE, FALSE, sizeof(PinyinKeyPos));
int parse_len = context->m_shuang_pin_parser->parse
( context->m_validator, pinyin_keys,
- poses, pinyins, pinyin_len);
+ pinyin_poses, pinyins, pinyin_len);
- g_array_free(poses, TRUE);
return pinyin_len == parse_len;
}
@@ -237,16 +238,14 @@ bool pinyin_parse_chewing(pinyin_context_t * context,
bool pinyin_parse_more_chewings(pinyin_context_t * context,
const char * chewings,
- PinyinKeyVector pinyin_keys){
+ PinyinKeyVector pinyin_keys,
+ PinyinKeyPosVector pinyin_poses){
int chewing_len = strlen(chewings);
- PinyinKeyPosVector poses;
- poses = g_array_new(FALSE, FALSE, sizeof(PinyinKeyPos));
int parse_len = context->m_chewing_parser->parse
( context->m_validator, pinyin_keys,
- poses, chewings, chewing_len);
+ pinyin_poses, chewings, chewing_len);
- g_array_free(poses, TRUE);
return chewing_len == parse_len;
}
diff --git a/src/pinyin.h b/src/pinyin.h
index 7b3bacb..dae5e55 100644
--- a/src/pinyin.h
+++ b/src/pinyin.h
@@ -39,10 +39,12 @@ void pinyin_fini(pinyin_context_t * context);
bool pinyin_alloc_auxiliary_arrays(pinyin_context_t * context,
PinyinKeyVector * pinyin_keys,
+ PinyinKeyPosVector * pinyin_poses,
CandidateConstraints * constraints,
MatchResults * match_results);
bool pinyin_free_auxiliary_arrays(pinyin_context_t * context,
PinyinKeyVector * pinyin_keys,
+ PinyinKeyPosVector * pinyin_poses,
CandidateConstraints * constraints,
MatchResults * match_results);
@@ -67,19 +69,22 @@ bool pinyin_parse_full(pinyin_context_t * context,
PinyinKey * onekey);
bool pinyin_parse_more_fulls(pinyin_context_t * context,
const char * pinyins,
- PinyinKeyVector pinyin_keys);
+ PinyinKeyVector pinyin_keys,
+ PinyinKeyPosVector pinyin_poses);
bool pinyin_parse_double(pinyin_context_t * context,
const char * onepinyin,
PinyinKey * onekey);
bool pinyin_parse_more_doubles(pinyin_context_t * context,
const char * pinyins,
- PinyinKeyVector pinyin_keys);
+ PinyinKeyVector pinyin_keys,
+ PinyinKeyPosVector pinyin_poses);
bool pinyin_parse_chewing(pinyin_context_t * context,
const char * onechewing,
PinyinKey * onekey);
bool pinyin_parse_more_chewings(pinyin_context_t * context,
const char * chewings,
- PinyinKeyVector pinyin_keys);
+ PinyinKeyVector pinyin_keys,
+ PinyinKeyPosVector pinyin_poses);
bool pinyin_get_candidates(pinyin_context_t * context,
size_t offset,