@@ -1214,8 +1214,6 @@ If you don't like this funciton, set the variable to nil")
12141214(defvar pyim-cchar2pinyin-cache nil
12151215 " 汉字转拼音功能需要的变量." )
12161216
1217- (defvar pyim-update:icode2word-p nil )
1218-
12191217(defvar pyim-auto-update t
12201218 " 是否自动创建和更新词库对应的 cache 文件.
12211219
@@ -1425,10 +1423,7 @@ pyim 使用函数 `pyim-start' 启动输入法的时候,会将变量
14251423 (pyim-init-variables)
14261424
14271425 (when pyim-auto-update
1428- ; ; 使用 pyim-iword2count 中的信息对 personal 缓存中的词频进行调整。
1429- (pyim-update:icode2word restart)
1430- ; ; 创建简拼缓存, 比如 "ni-hao" -> "n-h"
1431- (pyim-dcache-update:ishortcode2word restart))
1426+ (funcall (pyim-backend-api " update-personal-words" ) restart))
14321427
14331428 (pyim-cchar2pinyin-cache-create)
14341429 (pyim-pinyin2cchar-cache-create)
@@ -1438,7 +1433,7 @@ pyim 使用函数 `pyim-start' 启动输入法的时候,会将变量
14381433 ; ; 如果 `pyim-dicts' 有变化,重新生成 `pyim-dcache-code2word' 缓存。
14391434 (pyim-update:code2word refresh-common-cache)
14401435 ; ; 这个命令 *当前* 主要用于五笔输入法。
1441- (pyim-dcache- update:shortcode2word restart))
1436+ (funcall ( pyim-backend-api " update:shortcode2word" ) restart))
14421437
14431438 (unless (member 'pyim-save-caches kill-emacs-hook)
14441439 (add-to-list 'kill-emacs-hook 'pyim-save-caches ))
@@ -1501,7 +1496,7 @@ pyim 使用函数 `pyim-start' 启动输入法的时候,会将变量
15011496 " Get backend API from API-NAME."
15021497 ; ; make sure the backend is load
15031498 (unless (featurep pyim-backend) (require pyim-backend))
1504- (intern (concat (symbol-name pyim-backend) api-name)))
1499+ (intern (concat (symbol-name pyim-backend) " - " api-name)))
15051500
15061501(defun pyim-update:code2word (&optional force )
15071502 " 读取并加载词库.
@@ -1514,65 +1509,8 @@ pyim 使用函数 `pyim-start' 启动输入法的时候,会将变量
15141509 (unless (plist-get x :disable )
15151510 (plist-get x :file )))
15161511 `(,@pyim-dicts ,@pyim-extra-dicts )))
1517- (dicts-md5 (pyim-create-dicts-md5 dict-files))
1518- (fn (pyim-backend-api " -update:code2word" )))
1519- (cond
1520- ((string= pyim-backend " pyim-dregcache" )
1521- (message " ====hello " )
1522- (funcall fn dict-files dicts-md5 force))
1523- (t
1524- (pyim-dcache-update:code2word dict-files dicts-md5 force)))))
1525-
1526- (defun pyim-update:icode2word (&optional force )
1527- " 对 personal 缓存中的词条进行排序,加载排序后的结果.
1528-
1529- 在这个过程中使用了 `pyim-dcache-iword2count' 中记录的词频信息。
1530- 如果 FORCE 为真,强制排序。"
1531- (interactive )
1532- (when (or force (not pyim-update:icode2word-p))
1533- (if (pyim-use-emacs-thread-p)
1534- (make-thread
1535- `(lambda ()
1536- (cond
1537- ((eq pyim-backend 'pyim-dregcache )
1538- (pyim-dregcache-sort-icode2word)
1539- (pyim-dcache-save-variable 'pyim-dregcache-icode2word ))
1540- (t
1541- (maphash
1542- #' (lambda (key value )
1543- (puthash key (pyim-dcache-sort-words value)
1544- pyim-dcache-icode2word))
1545- pyim-dcache-icode2word)
1546- (pyim-dcache-save-variable 'pyim-dcache-icode2word )))
1547-
1548- (setq pyim-update:icode2word-p t )))
1549- (async-start
1550- `(lambda ()
1551- ,(async-inject-variables " ^load-path$" )
1552- ,(async-inject-variables " ^exec-path$" )
1553- ,(async-inject-variables " ^pyim-.+?directory$" )
1554- (require 'pyim )
1555- (cond
1556- ((eq pyim-backend 'pyim-dregcache )
1557-
1558- (pyim-dcache-save-variable 'pyim-dregcache-icode2word )
1559- (pyim-hashtable-set-variable 'pyim-iword2count )
1560- (pyim-dregcache-sort-icode2word)
1561- (pyim-dcache-save-variable 'pyim-dregcache-icode2word ))
1562- (t
1563- (pyim-hashtable-set-variable 'pyim-dcache-icode2word )
1564- (pyim-hashtable-set-variable 'pyim-iword2count )
1565- (maphash
1566- #' (lambda (key value )
1567- (puthash key (pyim-dcache-sort-words value)
1568- pyim-dcache-icode2word))
1569- pyim-dcache-icode2word)
1570- (pyim-dcache-save-variable 'pyim-dcache-icode2word )))
1571- nil )
1572- `(lambda (result)
1573- (setq pyim-update:icode2word-p t )
1574- (unless (eq pyim-backend 'pyim-dregcache )
1575- (pyim-hashtable-set-variable 'pyim-dcache-icode2word t )))))))
1512+ (dicts-md5 (pyim-create-dicts-md5 dict-files)))
1513+ (funcall (pyim-backend-api " update:code2word" ) dict-files dicts-md5 force)))
15761514
15771515(defun pyim-init-variables ()
15781516 " 初始化 dcache 缓存相关变量."
@@ -1690,9 +1628,8 @@ MERGE-METHOD 是一个函数,这个函数需要两个数字参数,代表
16901628 ; ; 不存在此问题。
16911629 (unless pyim-prefer-emacs-thread
16921630 (pyim-save-caches))
1693- ; ; 更新相关的 dcache
1694- (pyim-update:icode2word t )
1695- (pyim-dcache-update:ishortcode2word t )
1631+ ; ; 更新相关的 cache
1632+ (funcall (pyim-backend-api " update-personal-words" ) t )
16961633
16971634 (message " pyim: 词条相关信息导入完成! " ))
16981635
0 commit comments