[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/pyim 235790ec78: pyim-candidates-create:xingma: 优先排列常用
From: |
ELPA Syncer |
Subject: |
[elpa] externals/pyim 235790ec78: pyim-candidates-create:xingma: 优先排列常用字。 |
Date: |
Fri, 31 Dec 2021 03:57:45 -0500 (EST) |
branch: externals/pyim
commit 235790ec783638803459735dbcb0d8a8e6b8eedb
Author: Feng Shu <tumashu@163.com>
Commit: Feng Shu <tumashu@163.com>
pyim-candidates-create:xingma: 优先排列常用字。
* tests/pyim-tests.el (pyim-tests-pyim-dhashcache-get): test get
count.
* pyim-dhashcache.el (pyim-dhashcache-get): 支持 iword2count.
* pyim-candidates.el (pyim-candidates-create:xingma): 常用字优先排列。
---
pyim-candidates.el | 12 +++++++-----
pyim-dhashcache.el | 3 +++
tests/pyim-tests.el | 5 ++++-
3 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/pyim-candidates.el b/pyim-candidates.el
index 1a6f64286b..f9e1fac446 100644
--- a/pyim-candidates.el
+++ b/pyim-candidates.el
@@ -93,12 +93,14 @@ IMOBJS 获得候选词条。"
(setq output
;; NOTE: 下面这种策略是否合理?
;; 1. 第一个词选择公共词库中的第一个词。
- ;; 2. 剩下的分成字和词,字优先排,字和词各按 count 大小排序。
- (let* ((words (pyim-dcache-get last-code '(code2word)))
- (first-word (car words))
+ ;; 2. 剩下的分成常用字和词,常用字优先排,字和词各按 count 大小排序。
+ (let* ((first-word (car (pyim-dcache-get last-code
'(code2word))))
(chars (cl-remove-if (lambda (word)
- (> (length word) 1))
- words))
+ ;; NOTE:
常用字在这里的定义是用户输入次数超过30次的汉字,30这个数字的选取是非常主观的,也许有
+ ;; 更合理的取值。
+ (or (> (length word) 1)
+ (< (or (car (pyim-dcache-get
word 'iword2count)) 0) 30)))
+ (pyim-dcache-get last-code
'(icode2word))))
(all-words (pyim-dcache-get last-code '(icode2word
code2word shortcode2word))))
(mapcar (lambda (word)
(concat prefix word))
diff --git a/pyim-dhashcache.el b/pyim-dhashcache.el
index d63370ead8..dab9be1ff4 100644
--- a/pyim-dhashcache.el
+++ b/pyim-dhashcache.el
@@ -320,6 +320,9 @@ code 对应的中文词条了。
(dolist (cache caches)
(let* ((cache (ignore-errors (symbol-value cache)))
(value (and cache (gethash code cache))))
+ ;; 处理 iword2count.
+ (unless (listp value)
+ (setq value (list value)))
(when value
(setq result (append result value)))))
result))
diff --git a/tests/pyim-tests.el b/tests/pyim-tests.el
index 5eb843963b..51f713646f 100644
--- a/tests/pyim-tests.el
+++ b/tests/pyim-tests.el
@@ -829,13 +829,16 @@ yin-xing 因行
(ert-deftest pyim-tests-pyim-dhashcache-get ()
(let ((pyim-dhashcache-code2word (make-hash-table :test #'equal))
- (pyim-dhashcache-icode2word (make-hash-table :test #'equal)))
+ (pyim-dhashcache-icode2word (make-hash-table :test #'equal))
+ (pyim-dhashcache-iword2count (make-hash-table :test #'equal)))
(puthash "ni-hao" '("呢耗") pyim-dhashcache-icode2word)
(puthash "ni-hao" '("你好") pyim-dhashcache-code2word)
+ (puthash "你好" 10 pyim-dhashcache-iword2count)
(should (equal (pyim-dhashcache-get "ni-hao" '(code2word)) '("你好")))
(should (equal (pyim-dhashcache-get "ni-hao" '(icode2word)) '("呢耗")))
+ (should (equal (pyim-dhashcache-get "你好" '(iword2count)) '(10)))
(should (equal (pyim-dhashcache-get "ni-hao" '(code2word icode2word))
'("你好" "呢耗")))
(should (equal (pyim-dhashcache-get "ni-hao") '("呢耗" "你好")))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/pyim 235790ec78: pyim-candidates-create:xingma: 优先排列常用字。,
ELPA Syncer <=