;ELC ;;; Compiled ;;; in Emacs version 26.3 ;;; with all optimizations. ;;; This file contains utf-8 non-ASCII characters, ;;; and so cannot be loaded into Emacs 22 or earlier. (and (boundp 'emacs-version) (< (aref emacs-version (1- (length emacs-version))) ?A) (string-lessp emacs-version "23") (error "`%s' was compiled for Emacs 23 or later" #$)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (byte-code "\300\301!\210\300\302\303\304#\210\300\305!\210\300\306!\210\300\307!\210\300\310!\207" [require cl-lib async nil t pyim-common pyim-pymap pyim-dcache pyim-scheme] 4) (defvar pyim-dhashcache-code2word nil) (defvar pyim-dhashcache-code2word-md5 nil) (defvar pyim-dhashcache-word2code nil) (defvar pyim-dhashcache-iword2count nil) (defvar pyim-dhashcache-shortcode2word nil) (defvar pyim-dhashcache-icode2word nil) (defvar pyim-dhashcache-ishortcode2word nil) (defvar pyim-dhashcache-update-shortcode2word nil) (defvar pyim-dhashcache-update-ishortcode2word nil) (defvar pyim-dhashcache-update-icode2word-p nil) #@137 对 WORDS-LIST 排序,词频大的排在前面. 排序使用 `pyim-dhashcache-iword2count' 中记录的词频信息 (fn WORDS-LIST) (defalias 'pyim-dhashcache-sort-words #[257 "\300\301\"\207" [sort #[514 "\301\"\206\302\301\"\206\302V\207" [pyim-dhashcache-iword2count gethash 0] 6 "\n\n(fn A B)"]] 4 (#$ . 1031)]) #@92 获取一个 CODE 的所有简写. 比如:.nihao -> .nihao .niha .nih .ni .n (fn CODE) (defalias 'pyim-dhashcache-get-shortcode #[257 "\211G\301V\205J\302\303\304\305#)\266\203?\205J\306!\211@A@\211G\303\301\211W\203F\211\211\307V\203>\301OPB\262\210\211T\262\202%\266\266\204\207" [inhibit-changing-match-data 0 "-" nil t string-match pyim-dcache-code-split 1] 13 (#$ . 1366)]) #@32 pyim's async-inject-variables. (defalias 'pyim-dhashcache-async-inject-variables #[0 "\300\301!\300\302!\300\303!E\207" [async-inject-variables "^load-path$" "^exec-path$" "^pyim-.+?directory$"] 4 (#$ . 1778)]) #@174 读取 ‘pyim-dhashcache-icode2word’ 中的词库,创建 *简拼* 缓存,然后加载这个缓存. 如果 FORCE 为真,强制加载缓存。 (fn &optional FORCE) (defalias 'pyim-dhashcache-update-ishortcode2word #[256 "\211\204 ?\205\301\302\303\304\305 \306\"BB\307\"\207" [pyim-dhashcache-update-ishortcode2word async-start lambda nil append pyim-dhashcache-async-inject-variables ((require 'pyim-dhashcache) (pyim-dcache-set-variable 'pyim-dhashcache-icode2word) (pyim-dcache-set-variable 'pyim-dhashcache-iword2count) (setq pyim-dhashcache-ishortcode2word (make-hash-table :test #'equal)) (maphash (lambda (key value) (when (and (> (length key) 0) (not (string-match-p "[^a-z-]" key))) (let* ((newkey (mapconcat (lambda (x) (substring x 0 1)) (split-string key "-") "-"))) (puthash newkey (delete-dups `(,@value ,@(gethash newkey pyim-dhashcache-ishortcode2word))) pyim-dhashcache-ishortcode2word)))) pyim-dhashcache-icode2word) (maphash (lambda (key value) (puthash key (pyim-dhashcache-sort-words value) pyim-dhashcache-ishortcode2word)) pyim-dhashcache-ishortcode2word) (pyim-dcache-save-variable 'pyim-dhashcache-ishortcode2word)) (lambda (result) (setq pyim-dhashcache-update-ishortcode2word t) (pyim-dcache-set-variable 'pyim-dhashcache-ishortcode2word t))] 7 (#$ . 1996) nil]) #@153 使用 `pyim-dhashcache-code2word' 中的词条,创建简写 code 词库缓存并加载. 如果 FORCE 为真,强制运行。 (fn &optional FORCE) (defalias 'pyim-dhashcache-update-shortcode2word #[256 "\211\204 ?\205\301\302\303\304\305 \306\"BB\307\"\207" [pyim-dhashcache-update-shortcode2word async-start lambda nil append pyim-dhashcache-async-inject-variables ((require 'pyim-dhashcache) (pyim-dcache-set-variable 'pyim-dhashcache-code2word) (pyim-dcache-set-variable 'pyim-dhashcache-iword2count) (setq pyim-dhashcache-shortcode2word (make-hash-table :test #'equal)) (maphash (lambda (key value) (dolist (x (pyim-dhashcache-get-shortcode key)) (puthash x (mapcar (lambda (word) (if (get-text-property 0 :comment word) word (propertize word :comment (substring key (length x))))) (delete-dups `(,@value ,@(gethash x pyim-dhashcache-shortcode2word)))) pyim-dhashcache-shortcode2word))) pyim-dhashcache-code2word) (maphash (lambda (key value) (puthash key (pyim-dhashcache-sort-words value) pyim-dhashcache-shortcode2word)) pyim-dhashcache-shortcode2word) (pyim-dcache-save-variable 'pyim-dhashcache-shortcode2word) nil) (lambda (result) (setq pyim-dhashcache-update-shortcode2word t) (pyim-dcache-set-variable 'pyim-dhashcache-shortcode2word t))] 7 (#$ . 3306) nil]) #@64 获取保存 VARIABLE 取值的文件的路径. (fn VARIABLE) (defalias 'pyim-dhashcache-get-path #[257 "\2119\205\f\301!\302!P\207" [pyim-dcache-directory file-name-as-directory symbol-name] 4 (#$ . 4593)]) #@404 读取词库文件列表:DICT-FILES, 生成一个词库缓冲文件 DCACHE-FILE. pyim 使用的词库文件是简单的文本文件,编码 *强制* 为 'utf-8-unix, 其结构类似: ni-bu-hao 你不好 ni-hao 你好 妮好 你豪 第一个空白字符之前的内容为 code,空白字符之后为中文词条列表。词库 *不处理* 中文标点符号。 (fn DICT-FILES DCACHE-FILE) (defalias 'pyim-dhashcache-generate-dcache-file #[514 "\301\302\303\304\305$\211\203a\211@\306\307!r\211q\210\310\311\312\313\314!\315\"\316$\216\317\320!\210)eb\210\321y\210m\204X\322 \211@A\203P\211\203P\323\324\325\326\f\"\"! #\210\266\321y\210\202-*\210A\266\202\202\210\327\"\210\211\207" [coding-system-for-read make-hash-table :size 1000000 :test equal generate-new-buffer " *temp*" make-byte-code 0 "\301\300!\205 \302\300!\207" vconcat vector [buffer-name kill-buffer] 2 utf-8-unix insert-file-contents 1 pyim-dline-parse puthash delete-dups append gethash pyim-dcache-save-value-to-file] 16 (#$ . 4812)]) #@160 从 DCACHE 生成一个 word -> code 的反向查询表. DCACHE 是一个 code -> words 的 hashtable. 并将生成的表保存到 FILE 中. (fn DCACHE FILE) (defalias 'pyim-dhashcache-generate-word2code-dcache-file #[514 "\300!\205#\301\302\303\304\305$\306\307\310\311\312\313!\314\"\315\316%\"\210\317\"\262\207" [hash-table-p make-hash-table :size 1000000 :test equal maphash make-byte-code 514 "\301\302\"?\2050\211\211\205.\211@\303\300\"\304\203 B\202#C\300#\266A\266\202\202 \262\207" vconcat vector [pyim-string-match-p "-" gethash puthash] 9 "\n\n(fn CODE WORDS)" pyim-dcache-save-value-to-file] 10 (#$ . 5861)]) #@239 读取并加载词库. 读取 `pyim-dicts' 和 `pyim-extra-dicts' 里面的词库文件,生成对应的 词库缓冲文件,然后加载词库缓存。 如果 FORCE 为真,强制加载。 (fn DICT-FILES DICTS-MD5 &optional FORCE) (defalias 'pyim-dhashcache-update-code2word #[770 "\300\301!\300\302!\300\303!\204\304!\232?\205=\305\306\307\310\311 \312\313\314\315\316D\fEDC\317\314 EE\320\316 D EE\"BB\321\"\207" [pyim-dhashcache-get-path pyim-dhashcache-code2word pyim-dhashcache-word2code pyim-dhashcache-code2word-md5 pyim-dcache-get-value-from-file async-start lambda nil append pyim-dhashcache-async-inject-variables (require 'pyim-dhashcache) let dcache pyim-dhashcache-generate-dcache-file quote pyim-dhashcache-generate-word2code-dcache-file pyim-dcache-save-value-to-file (lambda (result) (pyim-dcache-set-variable 'pyim-dhashcache-code2word t) (pyim-dcache-set-variable 'pyim-dhashcache-word2code t))] 17 (#$ . 6517) nil]) #@182 将一个 pyim DCACHE 导出为文件 FILE. 如果 CONFIRM 为 non-nil,文件存在时将会提示用户是否覆盖, 默认为覆盖模式 (fn DCACHE FILE &optional CONFIRM) (defalias 'pyim-dhashcache-export #[770 "\300\301!r\211q\210\302\303\304\305\306!\307\"\310$\216\311c\210\312\313\"\210\314\"*\207" [generate-new-buffer " *temp*" make-byte-code 0 "\301\300!\205 \302\300!\207" vconcat vector [buffer-name kill-buffer] 2 ";;; -*- coding: utf-8-unix -*-\n" maphash #[514 "\300\301<\203\302\303\304#\202#c\207" [format "%s %s\n" mapconcat identity " "] 9 "\n\n(fn KEY VALUE)"] pyim-dcache-write-file] 10 (#$ . 7478)]) #@334 从 FROM 对应的 dcaches 中搜索 CODE, 得到对应的词条. 当词库文件加载完成后,pyim 就可以用这个函数从词库缓存中搜索某个 code 对应的中文词条了。 如果 FROM 为 nil, 则默认搜索 `pyim-dhashcache-icode2word' 和 `pyim-dhashcache-code2word' 两个 dcache. (fn CODE &optional FROM) (defalias 'pyim-dhashcache-get #[513 "\300\301\203<\203\202C\206\302\"\303\211\203F\211@\3041(\211J0\202*\210\303\211\2053\305\"\211\203=\306\"\262\266A\266\202\202\210\306\307\310\211#\"\207" [mapcar #[257 "\300\301\302!P!\207" [intern "pyim-dhashcache-" symbol-name] 5 "\n\n(fn X)"] (icode2word code2word) nil (error) gethash append pyim-pymap-py2cchar-get t] 11 (#$ . 8127)]) #@220 对 personal 缓存中的词条进行排序,加载排序后的结果. 在这个过程中使用了 `pyim-dhashcache-iword2count' 中记录的词频信息。 如果 FORCE 为真,强制排序。 (fn &optional FORCE) (defalias 'pyim-dhashcache-update-icode2word #[256 "\211\204 ?\205\301\302\303\304\305 \306\"BB\307\"\207" [pyim-dhashcache-update-icode2word-p async-start lambda nil append pyim-dhashcache-async-inject-variables ((require 'pyim-dhashcache) (pyim-dcache-set-variable 'pyim-dhashcache-icode2word) (pyim-dcache-set-variable 'pyim-dhashcache-iword2count) (maphash (lambda (key value) (puthash key (pyim-dhashcache-sort-words value) pyim-dhashcache-icode2word)) pyim-dhashcache-icode2word) (pyim-dcache-save-variable 'pyim-dhashcache-icode2word) nil) (lambda (result) (setq pyim-dhashcache-update-icode2word-p t) (pyim-dcache-set-variable 'pyim-dhashcache-icode2word t))] 7 (#$ . 8878) nil]) #@29 升级 icode2word 缓存。 (defalias 'pyim-dhashcache-upgrade-icode2word #[0 "\302\303!\304\305\306\307\310\"\"!\211\211\205C\211@\211@A\211\203:\211@\311\312\313\314\315\316  #\317\"\320\321% \"\210A\266\202\202\266A\266\202\202 \262\207" [pyim-schemes pyim-dhashcache-icode2word yes-or-no-p "Delete old key after upgrade? " delete-dups remove nil mapcar #[257 "\300A\301\"\300A\302\"\211\205\211B\207" [plist-get :code-prefix :code-prefix-history] 5 "\n\n(fn SCHEME)"] maphash make-byte-code 514 "\304\302\"\205N\305 \"\301\302\304\"\203\211G\306O\266\202\202!\262P\305 \"\307\310\"!\311 #\210\312\313%\210\300\205L\314 \"\210\312\315\"\266\204\207" vconcat vector [pyim-dhashcache-icode2word string-prefix-p gethash nil delete-dups append puthash message "PYIM icode2word upgrade: %S %S -> %S %S" remhash "PYIM icode2word upgrade: %S has been deleted."] 12 "\n\n(fn KEY VALUE)"] 17 (#$ . 9795)]) #@24 (fn &optional FORCE) (defalias 'pyim-dhashcache-update-personal-words #[256 "\300!\210\301!\207" [pyim-dhashcache-update-icode2word pyim-dhashcache-update-ishortcode2word] 3 (#$ . 10750)]) #@38 初始化 dcache 缓存相关变量. (defalias 'pyim-dhashcache-init-variables #[0 "\300\301!\210\300\302!\210\300\303!\210\300\304!\210\300\305!\210\300\306!\207" [pyim-dcache-set-variable pyim-dhashcache-iword2count pyim-dhashcache-code2word pyim-dhashcache-word2code pyim-dhashcache-shortcode2word pyim-dhashcache-icode2word pyim-dhashcache-ishortcode2word] 2 (#$ . 10949)]) (defalias 'pyim-dhashcache-save-personal-dcache-to-file #[0 "\300\301!\210\300\302!\207" [pyim-dcache-save-variable pyim-dhashcache-icode2word pyim-dhashcache-iword2count] 2]) (defalias 'pyim-dhashcache-insert-export-content #[0 "\302\303\"\210\302\304 \"\207" [pyim-dhashcache-iword2count pyim-dhashcache-icode2word maphash #[514 "\300\301#c\207" [format "%s %s\n"] 6 "\n\n(fn KEY VALUE)"] #[514 "\211\211\205\211@\301\"\204\302\303\304#c\210A\266\202\202\207" [pyim-dhashcache-iword2count gethash format "%s %s\n" 0] 8 "\n\n(fn _ WORDS)"]] 3]) #@94 这个用于保存词条,删除词条以及调整词条位置. (fn CACHE CODE &rest BODY) (defalias 'pyim-dhashcache-put '(macro . #[642 "\300\301!\300\302!\300\303!\304DD\305\306EDF\307\310BE\311\312\305E\313 FEF\207" [make-symbol "key" "table" "new-value" let* orig-value gethash setq progn unless equal puthash] 15 (#$ . 11892)])) (byte-code "\300\301\302\303#\300\207" [function-put pyim-dhashcache-put lisp-indent-function 0] 4) #@71 保存词频到缓存. (fn WORD &optional PREPEND WORDCOUNT-HANDLER) (defalias 'pyim-dhashcache-update-iword2count #[769 "\301\"\302\303!\203!\202\"\247\203\202\"\206!\304T\262\232?\2050\305#\207" [pyim-dhashcache-iword2count gethash nil functionp 0 puthash] 11 (#$ . 12356)]) #@58 将中文词条 WORD 从个人词库中删除 (fn WORD) (defalias 'pyim-dhashcache-delete-word #[257 "\302\303\304\305\306\307!\310\"\311\312%\"\210\313 \"\207" [pyim-dhashcache-icode2word pyim-dhashcache-iword2count maphash make-byte-code 514 "\300\235\205\302\300\"\211\203\303 #\202\304 \"\262\207" vconcat vector [pyim-dhashcache-icode2word remove puthash remhash] 7 "\n\n(fn KEY VALUE)" remhash] 8 (#$ . 12664)]) #@53 保存个人词到缓存. (fn WORD PINYIN PREPEND) (defalias 'pyim-dhashcache-insert-word-into-icode2word #[771 "\301\"\302\203\303\"\202\303\"\262\232?\205&\304#\207" [pyim-dhashcache-icode2word gethash nil pyim-list-merge puthash] 11 (#$ . 13105)]) #@15 (fn STRING) (defalias 'pyim-dhashcache-search-word-code #[257 "\301\"\207" [pyim-dhashcache-word2code gethash] 4 (#$ . 13385)]) #@58 导出个人词库到 FILE. (fn FILE &optional CONFIRM) (defalias 'pyim-dhashcache-export-personal-words #[513 "\301#\207" [pyim-dhashcache-icode2word pyim-dhashcache-export] 6 (#$ . 13523)]) (provide 'pyim-dhashcache)