[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/pyim d33526ad00 3/5: * pyim-candidates.el (pyim-candid
From: |
ELPA Syncer |
Subject: |
[elpa] externals/pyim d33526ad00 3/5: * pyim-candidates.el (pyim-candidates-create:xingma): 字和词分开排序,字优先。 |
Date: |
Fri, 31 Dec 2021 01:57:46 -0500 (EST) |
branch: externals/pyim
commit d33526ad00d7d3cb829690ef9131b08b938bea9e
Author: Feng Shu <tumashu@163.com>
Commit: Feng Shu <tumashu@163.com>
* pyim-candidates.el (pyim-candidates-create:xingma): 字和词分开排序,字优先。
---
pyim-candidates.el | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/pyim-candidates.el b/pyim-candidates.el
index fe50cd2755..72ea1a5d2b 100644
--- a/pyim-candidates.el
+++ b/pyim-candidates.el
@@ -91,14 +91,21 @@ IMOBJS 获得候选词条。"
;; 5. output => 工子又 工子叕
(setq output
- (mapcar (lambda (word)
- (concat prefix word))
- ;; NOTE: 形码输入法的第一个词选择公共词库中的第一个词,
- ;; 剩下的词按照词条 count 大小排序。这种策略是否合理?
- `(,(car (pyim-dcache-get last-code '(code2word)))
- ,@(pyim-dcache-call-api
- 'sort-words
- (pyim-dcache-get last-code '(icode2word code2word
shortcode2word))))))
+ ;; NOTE: 下面这种策略是否合理?
+ ;; 1. 第一个词选择公共词库中的第一个词。
+ ;; 2. 剩下的分成字和词,字优先排,字和词各按 count 大小排序。
+ (let* ((first-word (car (pyim-dcache-get last-code
'(code2word))))
+ (all-words (pyim-dcache-get last-code '(icode2word
code2word shortcode2word)))
+ (chars (cl-remove-if (lambda (word)
+ (> (length word) 1))
+ all-words)))
+ (mapcar (lambda (word)
+ (concat prefix word))
+ ;; NOTE: 形码输入法的第一个词选择公共词库中的第一个词,
+ ;; 剩下的词按照词条 count 大小排序。这种策略是否合理?
+ `(,first-word
+ ,@(pyim-dcache-call-api 'sort-words chars)
+ ,@(pyim-dcache-call-api 'sort-words all-words)))))
(setq output (remove "" (or output (list prefix))))
(setq result (append result output))))
(when (car result)