emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/pyim fa9f9f4244 24/41: Update pyim-candidates-dcache-wo


From: ELPA Syncer
Subject: [elpa] externals/pyim fa9f9f4244 24/41: Update pyim-candidates-dcache-words.
Date: Sat, 4 Jun 2022 09:57:47 -0400 (EDT)

branch: externals/pyim
commit fa9f9f4244c29e79c4eb8978892ece39a5c18382
Author: Feng Shu <tumashu@163.com>
Commit: Feng Shu <tumashu@163.com>

    Update pyim-candidates-dcache-words.
---
 pyim-candidates.el  | 10 ++++++----
 tests/pyim-tests.el | 19 ++++++++++---------
 2 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/pyim-candidates.el b/pyim-candidates.el
index 38c8e065e0..3d157a6cac 100644
--- a/pyim-candidates.el
+++ b/pyim-candidates.el
@@ -225,7 +225,7 @@
           (push (delete-dups (append w2 w1)) jianpin-words)))
       (pyim-zip (nreverse jianpin-words) fast-search))))
 
-(defun pyim-candidates-dcache-words (imobjs scheme &optional fast-search 
ignore-pymap-chars)
+(defun pyim-candidates-dcache-words (imobjs scheme &optional fast-search 
pymap-chars-num)
   "从 dcache 获取个人词条,词库词条和第一汉字列表。"
   (let (personal-words common-words pinyin-chars-1 pinyin-chars-2)
     (dolist (imobj imobjs)
@@ -247,9 +247,11 @@
              ;; 如果 w3 找不到第一个拼音对应的汉字,那就进一步使用
              ;; `pyim-pymap-py2cchar-get' 来查找,这个函数支持声母搜索。可以得到
              ;; 更多的词条。
-             (w4 (when (and (not w3) (not ignore-pymap-chars))
-                   (pyim-candidates-pymap-chars
-                    (car (pyim-codes-create imobj scheme))))))
+             (w4 (unless w3
+                   (cl-subseq
+                    (pyim-candidates-pymap-chars
+                     (car (pyim-codes-create imobj scheme)))
+                    0 pymap-chars-num))))
         (push w1 personal-words)
         (push w2 common-words)
         (push w3 pinyin-chars-1)
diff --git a/tests/pyim-tests.el b/tests/pyim-tests.el
index 032e452d7f..879b4277ca 100644
--- a/tests/pyim-tests.el
+++ b/tests/pyim-tests.el
@@ -545,19 +545,20 @@
          (pyim-dhashcache-ishortcode2word (make-hash-table :test #'equal))
          (quanpin (pyim-scheme-get 'quanpin))
          (imobjs1 (pyim-imobjs-create "n" quanpin))
-         (imobjs2 (pyim-imobjs-create "ni-hao" quanpin))
-         (imobjs3 (pyim-imobjs-create "ni" quanpin)))
+         (imobjs2 (pyim-imobjs-create "ni" quanpin))
+         (imobjs3 (pyim-imobjs-create "ni-hao" quanpin)))
     (puthash "n" (list "你" "您" "妮") pyim-dhashcache-ishortcode2word)
     (puthash "ni" (list "你" "尼") pyim-dhashcache-icode2word)
-    (puthash "ni" (list "你" "尼") pyim-dhashcache-code2word)
+    (puthash "ni" (list "尼" "你") pyim-dhashcache-code2word)
+    (puthash "ni-hao" (list "你好" "尼耗" "呢耗") pyim-dhashcache-icode2word)
     (puthash "ni-hao" (list "你好" "尼耗") pyim-dhashcache-code2word)
     (puthash "n-h" (list "你好" "你坏" "尼耗" "南好" "内核" "内河") 
pyim-dhashcache-ishortcode2word)
-    (should (equal (pyim-candidates-dcache-words imobjs1 quanpin nil t)
-                   '(("你" "您" "妮") nil nil nil)))
-    (should (equal (pyim-candidates-dcache-words imobjs2 quanpin nil t)
-                   '(nil ("你好" "尼耗") ("你好" "尼耗") nil)))
-    (should (equal (pyim-candidates-dcache-words imobjs3 quanpin nil t)
-                   '(("你" "尼") ("你" "尼") ("你" "尼" "你" "尼") nil)))))
+    (should (equal (pyim-candidates-dcache-words imobjs1 quanpin nil 10)
+                   '(("你" "您" "妮") nil nil ("南" "乃" "囊" "脑" "呢" "内" "嫩" "能" 
"你" "年"))))
+    (should (equal (pyim-candidates-dcache-words imobjs2 quanpin nil 10)
+                   '(("你" "尼") ("尼" "你") ("你" "尼" "尼" "你") nil)))
+    (should (equal (pyim-candidates-dcache-words imobjs3 quanpin nil 10)
+                   '(("你好" "尼耗" "呢耗") ("你好" "尼耗") ("你好" "尼耗" "呢耗" "你好" "尼耗") 
nil)))))
 
 (ert-deftest pyim-tests-pyim-candidates-pymap-chars ()
   (should (equal (cl-subseq (pyim-candidates-pymap-chars "ni") 0 10)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]