Loading operational +5 −1 Original line number Diff line number Diff line * COMMENT -*- mode: org -*- #+Date: 2019-04-05 Time-stamp: <2019-04-05> Time-stamp: <2019-04-17> #+STARTUP: content * notes :entry: ** 2019-04-05 zero-pinyin-service file structure :doc: Loading Loading @@ -42,5 +42,9 @@ Time-stamp: <2019-04-05> * later :entry: * current :entry: ** ** 2019-04-17 make flags configurable at runtime. - add dbus method to set flags. - make the method work. use gobject property maybe. - set default flags to my flags. reflect this in UI/config file. * done :entry: * wontfix :entry: parse-pinyin-test.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ test_parse_pinyin() GList *result = NULL; Pinyin *thispy = NULL; result = parse_pinyin("liyifeng", 15); result = parse_pinyin("liyifeng", 15, PINYIN_FLAGS_NONE); g_assert_cmpint(g_list_length(result), ==, 3); thispy = (Pinyin *) g_list_nth_data(result, 0); Loading Loading @@ -52,7 +52,7 @@ test_parse_pinyin_incomplete_pinyin() GList *result = NULL; Pinyin *thispy = NULL; result = parse_pinyin("zhey", 15); result = parse_pinyin("zhey", 15, PINYIN_INCOMPLETE_PINYIN); print_parse_result(result); g_assert_cmpint(g_list_length(result), ==, 2); Loading parse-pinyin.cpp +4 −3 Original line number Diff line number Diff line Loading @@ -4,13 +4,14 @@ #include "../Const.h" GList * parse_pinyin(const char *preedit_str, const guint max_pinyin) parse_pinyin(const char *preedit_str, const guint max_pinyin, const guint flags) { 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); 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; Loading parse-pinyin.h +15 −9 Original line number Diff line number Diff line Loading @@ -3,20 +3,26 @@ #include <glib.h> #include "zero-pinyin-service.h" #include "../Const.h" #ifdef __cplusplus extern "C" { #endif G_BEGIN_DECLS #define PINYIN_FLAGS_NONE 0 /** * parse preedit_str to groups of pinyin. * caller should free each Pinyin and the GList after use. * * @preedit_str: the preedit str * @max_pinyin: parse at most this many pinyin from preedit str. * @flags: support incomplete pinyin, fuzzy pinyin, correction, see ../Const.h * * Returns: a list of Pinyin struct. caller should free each Pinyin and the * GList after use. */ GList *parse_pinyin(const char *preedit_str, const guint max_pinyin); GList *parse_pinyin(const char *preedit_str, const guint max_pinyin, const guint flags); #ifdef __cplusplus } #endif G_END_DECLS #endif /* _PARSE_PINYIN_H_ */ zero-pinyin-service.c +11 −1 Original line number Diff line number Diff line Loading @@ -310,8 +310,18 @@ get_candidates(sqlite3 *db, } GList *pylist = NULL; guint pylist_len = 0; const guint FLAGS = (PINYIN_INCOMPLETE_PINYIN | PINYIN_FUZZY_C_CH | PINYIN_FUZZY_CH_C | PINYIN_FUZZY_Z_ZH | PINYIN_FUZZY_ZH_Z | PINYIN_FUZZY_S_SH | PINYIN_FUZZY_SH_S | PINYIN_FUZZY_IN_ING | PINYIN_FUZZY_ING_IN | PINYIN_CORRECT_ALL); pylist = parse_pinyin(preedit_str, 15); pylist = parse_pinyin(preedit_str, 15, FLAGS); pylist_len = g_list_length(pylist); guint group_size = pylist_len; Loading Loading
operational +5 −1 Original line number Diff line number Diff line * COMMENT -*- mode: org -*- #+Date: 2019-04-05 Time-stamp: <2019-04-05> Time-stamp: <2019-04-17> #+STARTUP: content * notes :entry: ** 2019-04-05 zero-pinyin-service file structure :doc: Loading Loading @@ -42,5 +42,9 @@ Time-stamp: <2019-04-05> * later :entry: * current :entry: ** ** 2019-04-17 make flags configurable at runtime. - add dbus method to set flags. - make the method work. use gobject property maybe. - set default flags to my flags. reflect this in UI/config file. * done :entry: * wontfix :entry:
parse-pinyin-test.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ test_parse_pinyin() GList *result = NULL; Pinyin *thispy = NULL; result = parse_pinyin("liyifeng", 15); result = parse_pinyin("liyifeng", 15, PINYIN_FLAGS_NONE); g_assert_cmpint(g_list_length(result), ==, 3); thispy = (Pinyin *) g_list_nth_data(result, 0); Loading Loading @@ -52,7 +52,7 @@ test_parse_pinyin_incomplete_pinyin() GList *result = NULL; Pinyin *thispy = NULL; result = parse_pinyin("zhey", 15); result = parse_pinyin("zhey", 15, PINYIN_INCOMPLETE_PINYIN); print_parse_result(result); g_assert_cmpint(g_list_length(result), ==, 2); Loading
parse-pinyin.cpp +4 −3 Original line number Diff line number Diff line Loading @@ -4,13 +4,14 @@ #include "../Const.h" GList * parse_pinyin(const char *preedit_str, const guint max_pinyin) parse_pinyin(const char *preedit_str, const guint max_pinyin, const guint flags) { 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); 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; Loading
parse-pinyin.h +15 −9 Original line number Diff line number Diff line Loading @@ -3,20 +3,26 @@ #include <glib.h> #include "zero-pinyin-service.h" #include "../Const.h" #ifdef __cplusplus extern "C" { #endif G_BEGIN_DECLS #define PINYIN_FLAGS_NONE 0 /** * parse preedit_str to groups of pinyin. * caller should free each Pinyin and the GList after use. * * @preedit_str: the preedit str * @max_pinyin: parse at most this many pinyin from preedit str. * @flags: support incomplete pinyin, fuzzy pinyin, correction, see ../Const.h * * Returns: a list of Pinyin struct. caller should free each Pinyin and the * GList after use. */ GList *parse_pinyin(const char *preedit_str, const guint max_pinyin); GList *parse_pinyin(const char *preedit_str, const guint max_pinyin, const guint flags); #ifdef __cplusplus } #endif G_END_DECLS #endif /* _PARSE_PINYIN_H_ */
zero-pinyin-service.c +11 −1 Original line number Diff line number Diff line Loading @@ -310,8 +310,18 @@ get_candidates(sqlite3 *db, } GList *pylist = NULL; guint pylist_len = 0; const guint FLAGS = (PINYIN_INCOMPLETE_PINYIN | PINYIN_FUZZY_C_CH | PINYIN_FUZZY_CH_C | PINYIN_FUZZY_Z_ZH | PINYIN_FUZZY_ZH_Z | PINYIN_FUZZY_S_SH | PINYIN_FUZZY_SH_S | PINYIN_FUZZY_IN_ING | PINYIN_FUZZY_ING_IN | PINYIN_CORRECT_ALL); pylist = parse_pinyin(preedit_str, 15); pylist = parse_pinyin(preedit_str, 15, FLAGS); pylist_len = g_list_length(pylist); guint group_size = pylist_len; Loading