branch: externals/pyim commit 188949301091447cf976c5bf0c818be9466236d7 Author: Feng Shu <tuma...@163.com> Commit: Feng Shu <tuma...@163.com>
pyim-candidates-pymap-chars -> pyim-candidates-quanpin-first-possible-chars --- pyim-candidates.el | 16 +++++++++------- tests/pyim-tests.el | 6 +++--- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/pyim-candidates.el b/pyim-candidates.el index 04eb440a65..40ab8728a9 100644 --- a/pyim-candidates.el +++ b/pyim-candidates.el @@ -217,12 +217,10 @@ (dolist (imobj imobjs) (let* ((w1 (pyim-candidates-quanpin-personal-words imobj scheme)) (w2 (pyim-candidates-quanpin-common-words imobj scheme)) - ;; 第一个汉字 (w3 (pyim-candidates-quanpin-first-chars imobj scheme char-num)) - ;; 如果 w3 找不到第一个拼音对应的汉字,那就进一步使用 - ;; `pyim-pymap-py2cchar-get' 来查找,这个函数支持声母搜索。可以得到 - ;; 更多的词条。 - (w4 (unless w3 (pyim-candidates-pymap-chars imobj scheme char-num)))) + (w4 (unless w3 + (pyim-candidates-quanpin-first-possible-chars + imobj scheme char-num)))) (push w1 personal-words) (push w2 common-words) (push w3 pinyin-chars-1) @@ -259,8 +257,12 @@ (min num (length chars))))) (cl-subseq chars 0 num))) -(defun pyim-candidates-pymap-chars (imobj scheme &optional num) - "从 pymap 表获取汉字。" +(defun pyim-candidates-quanpin-first-possible-chars (imobj scheme &optional num) + "获取输入的全拼对应的第一个可能的常用汉字。 + +1. 假如用户输入 ni 时,获取拼音匹配 ni.* 的常用汉字,比如: ni + niao ning niu 等等。 +2. 假如用户输入 nihao 时,获取拼音为 ni 的常用汉字。" (let* ((pinyin (car (pyim-codes-create imobj scheme))) (chars (mapcar #'char-to-string (pyim-zip diff --git a/tests/pyim-tests.el b/tests/pyim-tests.el index 4406b0ca26..4dd7d7ccbf 100644 --- a/tests/pyim-tests.el +++ b/tests/pyim-tests.el @@ -635,13 +635,13 @@ (should (equal (pyim-candidates-quanpin-first-chars (car imobjs) quanpin 10) '("你" "呢" "尼" "泥" "拟" "逆" "倪" "妮" "腻" "匿"))))) -(ert-deftest pyim-tests-pyim-candidates-pymap-chars () +(ert-deftest pyim-tests-pyim-candidates-quanpin-first-possible-chars () (let* ((quanpin (pyim-scheme-get 'quanpin)) (imobjs1 (pyim-imobjs-create "ni" quanpin)) (imobjs2 (pyim-imobjs-create "nihao" quanpin))) - (should (equal (pyim-candidates-pymap-chars (car imobjs1) quanpin 10) + (should (equal (pyim-candidates-quanpin-first-possible-chars (car imobjs1) quanpin 10) '("你" "年" "娘" "鸟" "摄" "您" "宁" "牛" "尼" "念"))) - (should (equal (pyim-candidates-pymap-chars (car imobjs2) quanpin 10) + (should (equal (pyim-candidates-quanpin-first-possible-chars (car imobjs2) quanpin 10) '("你" "尼" "呢" "泥" "拟" "逆" "倪" "妮" "腻" "匿"))))) (ert-deftest pyim-tests-pyim-candidates-search-buffer ()