branch: externals/pyim commit f6a45f6506ea5bff753dd8f911a935e990a798aa Author: Feng Shu <tuma...@163.com> Commit: Feng Shu <tuma...@163.com>
cl-defgeneric pyim-dcache-update-wordcount --- pyim-dcache.el | 5 ++--- pyim-dhashcache.el | 5 +++++ pyim-dregcache.el | 5 +++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/pyim-dcache.el b/pyim-dcache.el index b895774e15..f19d222d8c 100644 --- a/pyim-dcache.el +++ b/pyim-dcache.el @@ -229,14 +229,13 @@ non-nil,文件存在时将会提示用户是否覆盖,默认为覆盖模式" (list version file (nth 5 (file-attributes file 'string)))) files))))) -(defun pyim-dcache-update-wordcount (word &optional wordcount-handler) +(cl-defgeneric pyim-dcache-update-wordcount (word &optional wordcount-handler) "保存 WORD 词频. 1. 如果 WORDCOUNT-HANDLER 是一个函数:那么其返回值将作为词频保存, 参数为原有词频。 2. 如果 WORDCOUNT-HANDLER 是一个数值:那么这个数值直接作为词频保存。 -3. 如果 WORDCOUNT-HANDLER 为其他值:词频不变." - (pyim-dcache-call-api 'update-iword2count word wordcount-handler)) +3. 如果 WORDCOUNT-HANDLER 为其他值:词频不变.") ;; ** Dcache 加词功能 (cl-defgeneric pyim-dcache-insert-word (word code prepend) diff --git a/pyim-dhashcache.el b/pyim-dhashcache.el index 3ce3775f52..0e8de2f2cc 100644 --- a/pyim-dhashcache.el +++ b/pyim-dhashcache.el @@ -568,6 +568,11 @@ code 对应的中文词条了。 (+ (or orig-value 0) 1)) hash-table)) +(cl-defmethod pyim-dcache-update-wordcount + (word &context (pyim-dcache-backend (eql pyim-dhashcache)) + &optional wordcount-handler) + (pyim-dhashcache-update-iword2count word wordcount-handler)) + (defun pyim-dhashcache-update-iword2count (word &optional wordcount-handler) "保存词频到缓存." ;; 更新最近输入 10 个词条的 count 表 diff --git a/pyim-dregcache.el b/pyim-dregcache.el index 2c09913e3e..5e6a62cd98 100644 --- a/pyim-dregcache.el +++ b/pyim-dregcache.el @@ -358,6 +358,11 @@ DICT-FILES 是词库文件列表. DICTS-MD5 是词库的MD5校验码. "TODO" ) +(cl-defmethod pyim-dcache-update-wordcount + (word &context (pyim-dcache-backend (eql pyim-dregcache)) + &optional wordcount-handler) + (pyim-dregcache-update-iword2count word wordcount-handler)) + (defun pyim-dregcache-update-iword2count (word &optional wordcount-handler) "保存词频到缓存." (when pyim-debug (message "pyim-dregcache-update-iword2count. word=%s" word))