#include "parse-pinyin.h" #include "../PinyinArray.h" #include "../PinyinParser.h" #include "../Const.h" GList* parse_pinyin (const char* preedit_str, const guint max_pinyin) { GList* result = NULL; PyZy::PinyinArray pyar = {0}; Pinyin* thispy = NULL; const guint FLAGS = PINYIN_INCOMPLETE_PINYIN | PINYIN_CORRECT_ALL | PINYIN_FUZZY_ALL; PyZy::PinyinParser::parse (preedit_str, strlen(preedit_str), FLAGS, pyar, max_pinyin); for (guint i = 0; i < pyar.size(); ++i) { thispy = g_new (Pinyin, 1); thispy->shengmu_i = (int) pyar[i].pinyin->pinyin_id[0].sheng; thispy->yunmu_i = (int) pyar[i].pinyin->pinyin_id[0].yun; thispy->length = pyar[i].len; result = g_list_append (result, thispy); } return result; }