[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/pyim 0d357b5fd9 08/41: pyim-candidates-create-like-znab
From: |
ELPA Syncer |
Subject: |
[elpa] externals/pyim 0d357b5fd9 08/41: pyim-candidates-create-like-znabc |
Date: |
Sat, 4 Jun 2022 09:57:45 -0400 (EDT) |
branch: externals/pyim
commit 0d357b5fd94a6b77317d54b20af561fab4ae3eee
Author: Feng Shu <tumashu@163.com>
Commit: Feng Shu <tumashu@163.com>
pyim-candidates-create-like-znabc
---
pyim-candidates.el | 30 ++++++++++++++----------------
tests/pyim-tests.el | 13 +++++++++++++
2 files changed, 27 insertions(+), 16 deletions(-)
diff --git a/pyim-candidates.el b/pyim-candidates.el
index dce753394f..84c40428da 100644
--- a/pyim-candidates.el
+++ b/pyim-candidates.el
@@ -165,22 +165,9 @@
(defun pyim-candidates-create-quanpin (imobjs scheme &optional fast-search)
"`pyim-candidates-create' 内部使用的函数。"
- (let (;; Let indent beautiful.
- jianpin-words znabc-words
- personal-words common-words
- pinyin-chars-1 pinyin-chars-2
- chief-word)
- ;; 智能ABC模式,得到尽可能的拼音组合,查询这些组合,得到的词条做为联想词。
- (let ((codes (mapcar (lambda (x)
- (pyim-subconcat x "-"))
- (mapcar (lambda (imobj)
- (pyim-codes-create imobj scheme))
- imobjs))))
- (setq znabc-words
- (pyim-zip (mapcar #'pyim-dcache-get
- (pyim-zip codes))
- fast-search)))
-
+ (let ((znabc-words (pyim-candidates-create-like-znabc imobjs scheme
fast-search))
+ jianpin-words personal-words common-words
+ pinyin-chars-1 pinyin-chars-2 chief-word)
;; 假如输入 "nih" ,那么搜索 code 为 "n-h" 的词条,然后筛选出所有拼音匹配
;; "ni-h" 或者 "ni[^-]*-h" 的词条。
(when (and pyim-enable-shortcode
@@ -279,6 +266,17 @@
,@pinyin-chars-2
)))))
+(defun pyim-candidates-create-like-znabc (imobjs scheme &optional fast-search)
+ "智能ABC模式,得到尽可能的拼音组合,查询这些组合,得到的词条做为联想词。"
+ (let ((codes (mapcar (lambda (x)
+ (pyim-subconcat x "-"))
+ (mapcar (lambda (imobj)
+ (pyim-codes-create imobj scheme))
+ imobjs))))
+ (pyim-zip (mapcar #'pyim-dcache-get
+ (pyim-zip codes))
+ fast-search)))
+
(cl-defmethod pyim-candidates-create (_imobjs (_scheme pyim-scheme-shuangpin))
"按照 SCHEME, 从 IMOBJS 获得候选词条,用于双拼输入法。"
(cl-call-next-method))
diff --git a/tests/pyim-tests.el b/tests/pyim-tests.el
index 710cfdc77b..87d8101e21 100644
--- a/tests/pyim-tests.el
+++ b/tests/pyim-tests.el
@@ -513,6 +513,19 @@
wubi)
'("㠭子叕" "㠭子又")))))
+(ert-deftest pyim-tests-pyim-candidates-create-like-znabc ()
+ (let* ((pyim-dhashcache-code2word (make-hash-table :test #'equal))
+ (pyim-dhashcache-icode2word (make-hash-table :test #'equal))
+ (quanpin (pyim-scheme-get 'quanpin))
+ (imobjs (pyim-imobjs-create "nihaomapengyou" quanpin)))
+ (puthash "ni-hao" (list "你好" "尼耗") pyim-dhashcache-code2word)
+ (puthash "ni-hao-ma" (list "你好吗" "你好马") pyim-dhashcache-code2word)
+ (puthash "ni-hao-ma-peng-you" (list "你好吗朋友" "你好吗喷油")
pyim-dhashcache-code2word)
+ (should (equal (pyim-candidates-create-like-znabc imobjs quanpin)
+ '("你好吗朋友" "你好吗" "你好" "你好吗喷油" "你好马" "尼耗")))
+ (should (equal (pyim-candidates-create-like-znabc imobjs quanpin t)
+ '("你好吗朋友" "你好吗" "你好")))))
+
(ert-deftest pyim-tests-pyim-candidates-search-buffer ()
(with-temp-buffer
(insert "你好你好你坏你坏你话牛蛤牛和牛蛤牛蛤牛蛤牛蛤牛蛤")
- [elpa] externals/pyim a4143ce691 12/41: pyim-candidates-create-like-jianpin -> pyim-candidates-jianpin-words, (continued)
- [elpa] externals/pyim a4143ce691 12/41: pyim-candidates-create-like-jianpin -> pyim-candidates-jianpin-words, ELPA Syncer, 2022/06/04
- [elpa] externals/pyim 5f716730ea 17/41: Update pyim-test.el, ELPA Syncer, 2022/06/04
- [elpa] externals/pyim 665867fc0a 31/41: Set pyim-process-autoselector default value is nil., ELPA Syncer, 2022/06/04
- [elpa] externals/pyim 424e488118 36/41: Add preview test, ELPA Syncer, 2022/06/04
- [elpa] externals/pyim 845e9f6e4f 23/41: * pyim-candidates.el (pyim-candidates-create-async): Simplify shuangpin., ELPA Syncer, 2022/06/04
- [elpa] externals/pyim 5611319de0 35/41: Add page test, ELPA Syncer, 2022/06/04
- [elpa] externals/pyim aa07a23fda 39/41: * pyim-probe.el (pyim-probe-org-latex-mode): Update., ELPA Syncer, 2022/06/04
- [elpa] externals/pyim 573fefe532 38/41: Use (eql symbol) instead of (eql 'symbol)., ELPA Syncer, 2022/06/04
- [elpa] externals/pyim 2f1aaaa9a7 41/41: Merge pull request #442 from tumashu/struct, ELPA Syncer, 2022/06/04
- [elpa] externals/pyim c5a77c3f73 05/41: Add pyim-candidate-create-async, ELPA Syncer, 2022/06/04
- [elpa] externals/pyim 0d357b5fd9 08/41: pyim-candidates-create-like-znabc,
ELPA Syncer <=
- [elpa] externals/pyim 6ce5f49b8f 01/41: Big refactor: use cl-defstruct and cl-defgeneric., ELPA Syncer, 2022/06/04
- [elpa] externals/pyim f5300086fd 02/41: * tests/pyim-tests.el (pyim-tests-pyim-candidates-get-chief): New test., ELPA Syncer, 2022/06/04
- [elpa] externals/pyim f536e5ede3 06/41: Fix warns., ELPA Syncer, 2022/06/04
- [elpa] externals/pyim 33a0f5a9b7 09/41: Add pyim-candidates-create-like-jianpin, ELPA Syncer, 2022/06/04
- [elpa] externals/pyim b6b46a4e36 22/41: * pyim-candidates.el (pyim-candidates-create): Remove method of shuangpin., ELPA Syncer, 2022/06/04
- [elpa] externals/pyim b3868caa80 29/41: Add pyim-probe tests, ELPA Syncer, 2022/06/04
- [elpa] externals/pyim 951013539c 33/41: Add progress to commentary, ELPA Syncer, 2022/06/04
- [elpa] externals/pyim f4cc14ac64 32/41: Fix pyim-test.el, ELPA Syncer, 2022/06/04
- [elpa] externals/pyim 1b767c669e 40/41: * pyim-probe.el (pyim-probe-org-speed-commands): Updated., ELPA Syncer, 2022/06/04
- [elpa] externals/pyim 6ef8630475 11/41: pyim-candidates-create-like-znabc -> pyim-candidates-znabc-words, ELPA Syncer, 2022/06/04