Commit 56662390 authored by Yuanle Song's avatar Yuanle Song

v0.8.0 type a, en, o etc is much easier now.

do not allow omit shengmu.
only allow omit yunmu.
parent d0d76238
DEST/
*.deb
build/
release/
# -*- mode: conf -*-
project('zero-pinyin-service', ['c', 'cpp'],
version: '0.7.3',
version: '0.8.0',
license: 'GPL',
default_options: [
'warning_level=2',
......@@ -63,8 +63,8 @@ executable('zero-pinyin-service', src,
dependencies: shared_dep,
install: true, install_dir: '/home/sylecn/bin/sbin/')
test('parse-pinyin',
executable('parse-pinyin',
test('parse-pinyin-test',
executable('parse-pinyin-test',
['../PinyinParser.cc', 'parse-pinyin.cpp', 'parse-pinyin-test.cpp'],
dependencies: shared_dep))
test('zero-pinyin-service-test',
......
* COMMENT -*- mode: org -*-
#+Date: 2019-04-05
Time-stamp: <2019-08-31>
Time-stamp: <2019-10-22>
#+STARTUP: content
* notes :entry:
** 2019-08-31 ibus-pinyin userdb inference notice.
......@@ -52,6 +52,40 @@ shared between zero-pinyin and ibus-pinyin.
* later :entry:
* current :entry:
**
** 2019-10-22 handle a an o en etc differently. only match exactly the character.
no fuzzy matching or incomplete pinyin matching.
if shengmu is 0, always strict match it.
do not allow omit shengmu in zero.
ao men
澳门
e nuo
婀娜
- DONE use different FLAGS for them.
FLAGS doesn't affect pinyin parsing.
if flag support is to be added, just add it in appdata, as property.
then use the property when building SQL.
- DONE test in bogon VM.
- DONE git push
- build on debian 9 and release deb. later.
- problems
- result = parse_pinyin("an", 15, PINYIN_FUZZY_ALL);
this only return 1 result.
not an and ang.
why?
- maybe flag is not used when parsing pinyin string. only used when building
the SQL statement.
build_sql_for_n_pinyin()
build_where_clause(pylist, n);
yes. here. I should pass the flags around.
-
** 2019-08-31 how to format C code? do it before git commit.
see ~/c/gtk-im-module/, it uses myastyle-pre-commit-check in git pre-commit
~/bin/myastyle-pre-commit-check
......
......@@ -69,6 +69,32 @@ test_parse_pinyin_incomplete_pinyin()
g_list_free_full(result, g_free);
}
static void
test_parse_pinyin_yunmu_only_pinyin()
{
GList *result = NULL;
Pinyin *thispy = NULL;
result = parse_pinyin("a", 15, PINYIN_FLAGS_NONE);
print_parse_result(result);
g_assert_cmpint(g_list_length(result), ==, 1);
thispy = (Pinyin *) g_list_nth_data(result, 0);
g_assert_cmpint(thispy->shengmu_i, ==, 0);
g_assert_cmpint(thispy->yunmu_i, ==, 24);
g_assert_cmpint(thispy->length, ==, 1);
g_list_free_full(result, g_free);
// flag doesn't affect pinyin parsing.
// flags are only effective when building the SQL.
result = parse_pinyin("an", 15, PINYIN_FUZZY_ALL);
print_parse_result(result);
g_assert_cmpint(g_list_length(result), ==, 1);
g_list_free_full(result, g_free);
}
int
main(int argc, char *argv[])
{
......@@ -77,6 +103,8 @@ main(int argc, char *argv[])
test_parse_pinyin);
g_test_add_func("/zero/test_parse_pinyin incomplete pinyin",
test_parse_pinyin_incomplete_pinyin);
g_test_add_func("/zero/test_parse_pinyin yunmu only pinyin",
test_parse_pinyin_yunmu_only_pinyin);
return g_test_run();
}
......@@ -52,14 +52,14 @@ build_where_clause(GList *pylist,
for (guint i = 0; i < n; ++i) {
g_assert_nonnull(iter);
thispy = (Pinyin *) iter->data;
if (thispy->shengmu_i) {
if (G_LIKELY(first_condition_done)) {
g_string_append_printf(s, "AND s%u=%d ", i, thispy->shengmu_i);
} else {
g_string_append_printf(s, "s%u=%d ", i, thispy->shengmu_i);
first_condition_done = TRUE;
}
/* do not allow omit shengmu. always do strict match */
if (G_LIKELY(first_condition_done)) {
g_string_append_printf(s, "AND s%u=%d ", i, thispy->shengmu_i);
} else {
g_string_append_printf(s, "s%u=%d ", i, thispy->shengmu_i);
first_condition_done = TRUE;
}
/* allow omit yunmu, if 0 don't match on it */
if (thispy->yunmu_i) {
if (G_LIKELY(first_condition_done)) {
g_string_append_printf(s, "AND y%u=%d ", i, thispy->yunmu_i);
......@@ -310,18 +310,7 @@ 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, FLAGS);
pylist = parse_pinyin(preedit_str, 15, PINYIN_FLAGS_NONE);
pylist_len = g_list_length(pylist);
guint group_size = pylist_len;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment