branch: externals/pyim commit 54417ef9b91b50c728ab2ea68d4f0a00b2baa37a Author: Feng Shu <tuma...@163.com> Commit: Feng Shu <tuma...@163.com>
pyim-candidates-quanpin-chars -> pyim-candidates-quanpin-first-chars --- pyim-candidates.el | 7 +++++-- tests/pyim-tests.el | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pyim-candidates.el b/pyim-candidates.el index 9664bced47..04eb440a65 100644 --- a/pyim-candidates.el +++ b/pyim-candidates.el @@ -218,7 +218,7 @@ (let* ((w1 (pyim-candidates-quanpin-personal-words imobj scheme)) (w2 (pyim-candidates-quanpin-common-words imobj scheme)) ;; 第一个汉字 - (w3 (pyim-candidates-quanpin-chars imobj scheme char-num)) + (w3 (pyim-candidates-quanpin-first-chars imobj scheme char-num)) ;; 如果 w3 找不到第一个拼音对应的汉字,那就进一步使用 ;; `pyim-pymap-py2cchar-get' 来查找,这个函数支持声母搜索。可以得到 ;; 更多的词条。 @@ -247,7 +247,10 @@ '(code2word shortcode2word) '(code2word)))) -(defun pyim-candidates-quanpin-chars (imobj scheme &optional num) +(defun pyim-candidates-quanpin-first-chars (imobj scheme &optional num) + "获取输入的全拼对应的第一个汉字。 + +假如用户输入 nihao 时,获取 ni 对应的汉字。" (let* ((code (car (pyim-codes-create imobj scheme))) (chars (delete-dups `(,@(pyim-dcache-get code '(icode2word code2word)) diff --git a/tests/pyim-tests.el b/tests/pyim-tests.el index a40b52d6db..4406b0ca26 100644 --- a/tests/pyim-tests.el +++ b/tests/pyim-tests.el @@ -625,14 +625,14 @@ (should (equal (pyim-candidates-quanpin-common-words (car imobjs3) quanpin) '("呢耗" "你好" "你坏" "尼耗"))))) -(ert-deftest pyim-tests-pyim-candidates-quanpin-chars () +(ert-deftest pyim-tests-pyim-candidates-quanpin-first-chars () (let* ((pyim-dhashcache-icode2word (make-hash-table :test #'equal)) (pyim-dhashcache-code2word (make-hash-table :test #'equal)) (quanpin (pyim-scheme-get 'quanpin)) (imobjs (pyim-imobjs-create "nihao" quanpin))) (puthash "ni" (list "你" "呢") pyim-dhashcache-icode2word) (puthash "ni" (list "你" "尼") pyim-dhashcache-code2word) - (should (equal (pyim-candidates-quanpin-chars (car imobjs) quanpin 10) + (should (equal (pyim-candidates-quanpin-first-chars (car imobjs) quanpin 10) '("你" "呢" "尼" "泥" "拟" "逆" "倪" "妮" "腻" "匿"))))) (ert-deftest pyim-tests-pyim-candidates-pymap-chars ()