Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

write phrases methods

  • Loading branch information...
commit 4348b63eeec5662fedfc39be6fc78b62e2e26467 1 parent 9c35f8e
@epico authored
Showing with 28 additions and 0 deletions.
  1. +2 −0  src/libpinyin.ver
  2. +21 −0 src/pinyin.cpp
  3. +5 −0 src/pinyin.h
View
2  src/libpinyin.ver
@@ -50,6 +50,8 @@ LIBPINYIN {
pinyin_get_key_rest_positions;
pinyin_get_key_rest_length;
pinyin_get_raw_full_pinyin;
+ pinyin_get_n_phrase;
+ pinyin_get_phrase_token;
local:
*;
View
21 src/pinyin.cpp
@@ -2009,6 +2009,27 @@ bool pinyin_get_raw_full_pinyin(pinyin_instance_t * instance,
return true;
}
+bool pinyin_get_n_phrase(pinyin_instance_t * instance,
+ guint * num) {
+ *num = instance->m_match_results->len;
+ return true;
+}
+
+bool pinyin_get_phrase_token(pinyin_instance_t * instance,
+ guint index,
+ phrase_token_t * token){
+ MatchResults & match_results = instance->m_match_results;
+
+ *token = null_token;
+
+ if (index >= match_results->len)
+ return false;
+
+ *token = g_array_index(match_results, phrase_token_t, index);
+
+ return true;
+}
+
/**
* Note: prefix is the text before the pre-edit string.
View
5 src/pinyin.h
@@ -600,7 +600,12 @@ bool pinyin_get_key_rest_length(pinyin_instance_t * instance,
bool pinyin_get_raw_full_pinyin(pinyin_instance_t * instance,
const gchar ** utf8_str);
+bool pinyin_get_n_phrase(pinyin_instance_t * instance,
+ guint * num);
+bool pinyin_get_phrase_token(pinyin_instance_t * instance,
+ guint index,
+ phrase_token_t * token);
/* hack here. */
typedef ChewingKey PinyinKey;
Please sign in to comment.
Something went wrong with that request. Please try again.