[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/pyim a96a131 1/2: pyim-dhashcache-get-shortcode -> pyim
From: |
ELPA Syncer |
Subject: |
[elpa] externals/pyim a96a131 1/2: pyim-dhashcache-get-shortcode -> pyim-dhashcache-get-shortcodes |
Date: |
Mon, 13 Dec 2021 20:57:43 -0500 (EST) |
branch: externals/pyim
commit a96a131196f8b82c1995cade27304da5e5174328
Author: Feng Shu <tumashu@163.com>
Commit: Feng Shu <tumashu@163.com>
pyim-dhashcache-get-shortcode -> pyim-dhashcache-get-shortcodes
* tests/pyim-tests.el (pyim-tests-pyim-dhashcache-get-shortcodes):
* pyim-dhashcache.el (pyim-dhashcache-get-shortcodes)
(pyim-dhashcache-update-shortcode2word-1):
---
pyim-dhashcache.el | 12 ++++++++----
tests/pyim-tests.el | 12 ++++++------
2 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/pyim-dhashcache.el b/pyim-dhashcache.el
index b5aa590..2e800a8 100644
--- a/pyim-dhashcache.el
+++ b/pyim-dhashcache.el
@@ -64,10 +64,14 @@
(> (or (gethash a iword2count) 0)
(or (gethash b iword2count) 0))))))
-(defun pyim-dhashcache-get-shortcode (code)
- "获取一个 CODE 的所有简写.
+(defun pyim-dhashcache-get-shortcodes (code)
+ "获取 CODE 所有的 shortcodes.
-比如:.nihao -> .nihao .niha .nih .ni .n"
+比如:wubi/aaaa -> (wubi/aaa wubi/aa)
+
+注意事项:这个函数目前只用于五笔等型码输入法,不用于拼音输入法,
+因为拼音输入法词库太大,这样处理之后,会生成一个特别大的哈希表,
+占用太多内存资源,拼音输入法使用 ishortcode 机制。"
(when (and (pyim-string-match-p "/" code)
(not (pyim-string-match-p "-" code)))
(let* ((x (split-string code "/"))
@@ -161,7 +165,7 @@
(let ((shortcode2word (make-hash-table :test #'equal)))
(maphash
(lambda (key value)
- (dolist (x (pyim-dhashcache-get-shortcode key))
+ (dolist (x (pyim-dhashcache-get-shortcodes key))
(puthash x
(mapcar
(lambda (word)
diff --git a/tests/pyim-tests.el b/tests/pyim-tests.el
index 93fe7cc..fd92455 100644
--- a/tests/pyim-tests.el
+++ b/tests/pyim-tests.el
@@ -600,13 +600,13 @@
(should (equal (gethash "测伌" pyim-dhashcache-iword2count) 0))))
;; ** pyim-dhashcache 相关单元测试
-(ert-deftest pyim-tests-pyim-dhashcache-get-shortcode ()
- (should (equal (pyim-dhashcache-get-shortcode ".abcde") nil))
- (should (equal (pyim-dhashcache-get-shortcode "wubi/abcde")
+(ert-deftest pyim-tests-pyim-dhashcache-get-shortcodes ()
+ (should (equal (pyim-dhashcache-get-shortcodes ".abcde") nil))
+ (should (equal (pyim-dhashcache-get-shortcodes "wubi/abcde")
'("wubi/abcd" "wubi/abc" "wubi/ab")))
- (should (equal (pyim-dhashcache-get-shortcode "abcde") nil))
- (should (equal (pyim-dhashcache-get-shortcode "ni-hao") nil))
- (should (equal (pyim-dhashcache-get-shortcode "") nil)))
+ (should (equal (pyim-dhashcache-get-shortcodes "abcde") nil))
+ (should (equal (pyim-dhashcache-get-shortcodes "ni-hao") nil))
+ (should (equal (pyim-dhashcache-get-shortcodes "") nil)))
(ert-deftest pyim-tests-pyim-dhashcache-get-path ()
(let ((pyim-dcache-directory "/tmp/dcache"))