emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/pyim de908d1 5/8: pyim-cchar2pinyin/pinyin2cchar -> pyi


From: ELPA Syncer
Subject: [elpa] externals/pyim de908d1 5/8: pyim-cchar2pinyin/pinyin2cchar -> pyim-pymap-cchar2py/py2cchar
Date: Fri, 23 Apr 2021 00:57:12 -0400 (EDT)

branch: externals/pyim
commit de908d10cc23ddeb59033de0a04dff9af89bf72e
Author: Feng Shu <tumashu@163.com>
Commit: Feng Shu <tumashu@163.com>

    pyim-cchar2pinyin/pinyin2cchar -> pyim-pymap-cchar2py/py2cchar
---
 pyim-cregexp.el    |  2 +-
 pyim-cstring.el    |  2 +-
 pyim-dhashcache.el |  4 ++--
 pyim-dregcache.el  | 16 +++++++-------
 pyim-pinyin.el     |  3 ++-
 pyim-pymap.el      | 62 +++++++++++++++++++++++++++---------------------------
 pyim.el            |  6 +++---
 7 files changed, 48 insertions(+), 47 deletions(-)

diff --git a/pyim-cregexp.el b/pyim-cregexp.el
index 555ec5c..ef24211 100644
--- a/pyim-cregexp.el
+++ b/pyim-cregexp.el
@@ -155,7 +155,7 @@
                                      (mapconcat #'identity
                                                 (cl-subseq (split-string x 
"|") 0 char-level-num)
                                                 ""))
-                                 (pyim-pinyin2cchar-get py equal-match nil t) 
"")))
+                                 (pyim-pymap-py2cchar-get py equal-match nil 
t) "")))
                 (push cchars results))
               (setq n (+ 1 n)))
             (nreverse results)))
diff --git a/pyim-cstring.el b/pyim-cstring.el
index c1acdbf..920072e 100644
--- a/pyim-cstring.el
+++ b/pyim-cstring.el
@@ -252,7 +252,7 @@ BUG: 当 STRING 中包含其它标点符号,并且设置 SEPERATER 时,结
              (push (list str) pinyins-list))
             ((and (> (length str) 0)
                   (pyim-string-match-p "\\cc" str))
-             (push (pyim-cchar2pinyin-get (string-to-char str))
+             (push (pyim-pymap-cchar2py-get (string-to-char str))
                    pinyins-list))
             ((> (length str) 0)
              (push (list str) pinyins-list))))
diff --git a/pyim-dhashcache.el b/pyim-dhashcache.el
index de9cffd..333cdaf 100644
--- a/pyim-dhashcache.el
+++ b/pyim-dhashcache.el
@@ -308,7 +308,7 @@ DCACHE 是一个 code -> words 的 hashtable.
      dcache)
     (pyim-dcache-write-file file confirm)))
 
-(declare-function pyim-pinyin2cchar-get "pyim" (pinyin &optional equal-match 
return-list include-seperator))
+(declare-function pyim-pymap-py2cchar-get "pyim-pymap" (pinyin &optional 
equal-match return-list include-seperator))
 
 (defun pyim-dhashcache-get (code &optional from)
   "从 FROM 对应的 dcaches 中搜索 CODE, 得到对应的词条.
@@ -331,7 +331,7 @@ code 对应的中文词条了。
              (value (and cache (gethash code cache))))
         (when value
           (setq result (append result value)))))
-    `(,@result ,@(pyim-pinyin2cchar-get code t t))))
+    `(,@result ,@(pyim-pymap-py2cchar-get code t t))))
 
 (defun pyim-dhashcache-update-icode2word (&optional force)
   "对 personal 缓存中的词条进行排序,加载排序后的结果.
diff --git a/pyim-dregcache.el b/pyim-dregcache.el
index a24ba56..3740837 100644
--- a/pyim-dregcache.el
+++ b/pyim-dregcache.el
@@ -256,17 +256,17 @@ DICT-FILES 是词库文件列表. DICTS-MD5 是词库的MD5校验码.
       (setq word (match-string-no-properties 1 content))
       (when word
         (cond
-          ((string-match "^[^ ]+$" word)
-           ;; 单个词
-           (push word output))
-          (t
-           ;; 多个字
-           (setq output (append (nreverse (split-string word " +")) output)))))
+         ((string-match "^[^ ]+$" word)
+          ;; 单个词
+          (push word output))
+         (t
+          ;; 多个字
+          (setq output (append (nreverse (split-string word " +")) output)))))
       ;; 继续搜索
       (setq start (+ start 2 (length code) (length word))))
     output))
 
-(declare-function pyim-pinyin2cchar-get "pyim" (pinyin &optional equal-match 
return-list include-seperator))
+(declare-function pyim-pymap-py2cchar-get "pyim-pymap" (pinyin &optional 
equal-match return-list include-seperator))
 
 (defun pyim-dregcache-get (code &optional from)
   "从 `pyim-dregcache-cache' 搜索 CODE, 得到对应的词条."
@@ -284,7 +284,7 @@ DICT-FILES 是词库文件列表. DICTS-MD5 是词库的MD5校验码.
       ;; `push' plus `nreverse' is more efficient than `add-to-list'
       ;; Many examples exist in Emacs' own code
       (setq result (nreverse result))
-      `(,@result ,@(pyim-pinyin2cchar-get code t t)))))
+      `(,@result ,@(pyim-pymap-py2cchar-get code t t)))))
 
 (defun pyim-dregcache-get-icode2word-ishortcode2word (code)
   "以 CODE 搜索个人词和个人联想词.  正则表达式搜索词库,不需要为联想词开单独缓存."
diff --git a/pyim-pinyin.el b/pyim-pinyin.el
index 6da67e1..e3d9b7e 100644
--- a/pyim-pinyin.el
+++ b/pyim-pinyin.el
@@ -28,6 +28,7 @@
 ;;; Code:
 ;; * 代码                                                           :code:
 (require 'cl-lib)
+(require 'pyim-pymap)
 
 (defgroup pyim-pinyin nil
   "Pinyin libs for pyim."
@@ -118,7 +119,7 @@
                (shenmu yunmu)
                (cl-some
                 #'(lambda (char-pinyin)
-                    (pyim-pinyin2cchar-get char-pinyin t))
+                    (pyim-pymap-py2cchar-get char-pinyin t))
                 (mapcar #'(lambda (x)
                             (concat (nth 0 x) (nth 1 x)))
                         (pyim-imobjs-find-fuzzy:quanpin-1
diff --git a/pyim-pymap.el b/pyim-pymap.el
index 9ff47c4..1892a6f 100644
--- a/pyim-pymap.el
+++ b/pyim-pymap.el
@@ -41,16 +41,16 @@
 ;; * 代码                                                                 :code:
 (require 'pyim-common)
 
-(defvar pyim-pinyin2cchar-cache1 nil
+(defvar pyim-pymap-py2cchar-cache1 nil
   "拼音查汉字功能需要的变量.")
 
-(defvar pyim-pinyin2cchar-cache2 nil
+(defvar pyim-pymap-py2cchar-cache2 nil
   "拼音查汉字功能需要的变量.")
 
-(defvar pyim-pinyin2cchar-cache3 nil
+(defvar pyim-pymap-py2cchar-cache3 nil
   "拼音查汉字功能需要的变量.")
 
-(defvar pyim-cchar2pinyin-cache nil
+(defvar pyim-pymap-cchar2py-cache nil
   "汉字转拼音功能需要的变量.")
 
 (defvar pyim-pymap
@@ -728,33 +728,33 @@
   "常用汉字")
 
 ;; ** "汉字 -> 拼音" 以及 "拼音 -> 汉字" 的转换函数
-(defun pyim-pinyin2cchar-cache-create (&optional force)
+(defun pyim-pymap-py2cchar-cache-create (&optional force)
   "构建 pinyin 到 chinese char 的缓存.
 
-用于加快搜索速度,这个函数将缓存保存到 `pyim-pinyin2cchar-cache' 变量中,
+用于加快搜索速度,这个函数将缓存保存到 `pyim-pymap-py2cchar-cache' 变量中,
 如果 FORCE 设置为 t, 强制更新索引。"
-  (when (or force (or (not pyim-pinyin2cchar-cache1)
-                      (not pyim-pinyin2cchar-cache2)))
-    (setq pyim-pinyin2cchar-cache1
+  (when (or force (or (not pyim-pymap-py2cchar-cache1)
+                      (not pyim-pymap-py2cchar-cache2)))
+    (setq pyim-pymap-py2cchar-cache1
           (make-hash-table :size 50000 :test #'equal))
-    (setq pyim-pinyin2cchar-cache2
+    (setq pyim-pymap-py2cchar-cache2
           (make-hash-table :size 50000 :test #'equal))
-    (setq pyim-pinyin2cchar-cache3
+    (setq pyim-pymap-py2cchar-cache3
           (make-hash-table :size 50000 :test #'equal))
     (dolist (x pyim-pymap)
       (let* ((py (car x))
              (cchars (cdr x))
              (n (min (length py) 7)))
-        (puthash py cchars pyim-pinyin2cchar-cache1)
+        (puthash py cchars pyim-pymap-py2cchar-cache1)
         (puthash py (cdr (split-string (car cchars) ""))
-                 pyim-pinyin2cchar-cache2)
+                 pyim-pymap-py2cchar-cache2)
         (dotimes (i n)
           (let* ((key (substring py 0 (+ i 1)))
-                 (orig-value (gethash key pyim-pinyin2cchar-cache3)))
+                 (orig-value (gethash key pyim-pymap-py2cchar-cache3)))
             (puthash key (delete-dups `(,@orig-value ,@cchars))
-                     pyim-pinyin2cchar-cache3)))))))
+                     pyim-pymap-py2cchar-cache3)))))))
 
-(defun pyim-pinyin2cchar-get (pinyin &optional equal-match return-list 
include-seperator)
+(defun pyim-pymap-py2cchar-get (pinyin &optional equal-match return-list 
include-seperator)
   "获取拼音与 PINYIN 想匹配的所有汉字.
 
 比如:
@@ -768,53 +768,53 @@
 
 如果 INCLUDE-SEPERATOR 是 non-nil, 返回的列表包含一个 ‘|’ 号,pyim 用这个分隔符
 来区分 3500 个常用汉字和生僻字。"
-  (pyim-pinyin2cchar-cache-create)
+  (pyim-pymap-py2cchar-cache-create)
   (when (and pinyin (stringp pinyin))
     (let ((output
            (if equal-match
                (if return-list
-                   (gethash pinyin pyim-pinyin2cchar-cache2)
-                 (gethash pinyin pyim-pinyin2cchar-cache1))
-             (gethash pinyin pyim-pinyin2cchar-cache3))))
+                   (gethash pinyin pyim-pymap-py2cchar-cache2)
+                 (gethash pinyin pyim-pymap-py2cchar-cache1))
+             (gethash pinyin pyim-pymap-py2cchar-cache3))))
       (delete "" output)
       (if include-seperator
           output
         (delete "|" output)))))
 
-(defun pyim-cchar2pinyin-get (char-or-str)
+(defun pyim-pymap-cchar2py-get (char-or-str)
   "获取字符或者字符串 CHAR-OR-STR 对应的拼音 code.
 
 pyim 在特定的时候需要读取一个汉字的拼音,这个工作由此完成,函数
-从 `pyim-cchar2pinyin-cache' 查询得到一个汉字字符的拼音, 例如:
+从 `pyim-pymap-cchar2py-cache' 查询得到一个汉字字符的拼音, 例如:
 
-(pyim-cchar2pinyin-get ?我)
+(pyim-pymap-cchar2py-get ?我)
 
 结果为:
 
 (\"wo\")"
-  (pyim-cchar2pinyin-cache-create)
+  (pyim-pymap-cchar2py-cache-create)
   (let ((key (if (characterp char-or-str)
                  (char-to-string char-or-str)
                char-or-str)))
     (when (= (length key) 1)
-      (gethash key pyim-cchar2pinyin-cache))))
+      (gethash key pyim-pymap-cchar2py-cache))))
 
-(defun pyim-cchar2pinyin-cache-create (&optional force)
+(defun pyim-pymap-cchar2py-cache-create (&optional force)
   "Build pinyin cchar->pinyin hashtable from `pyim-pymap'.
 
 If FORCE is non-nil, FORCE build."
-  (when (or force (not pyim-cchar2pinyin-cache))
-    (setq pyim-cchar2pinyin-cache
+  (when (or force (not pyim-pymap-cchar2py-cache))
+    (setq pyim-pymap-cchar2py-cache
           (make-hash-table :size 50000 :test #'equal))
     (dolist (x pyim-pymap)
       (let ((py (car x))
             (cchar-list (string-to-list (car (cdr x)))))
         (dolist (cchar cchar-list)
           (let* ((key (char-to-string cchar))
-                 (cache (gethash key pyim-cchar2pinyin-cache)))
+                 (cache (gethash key pyim-pymap-cchar2py-cache)))
             (if cache
-                (puthash key (append (list py) cache) pyim-cchar2pinyin-cache)
-              (puthash key (list py) pyim-cchar2pinyin-cache))))))))
+                (puthash key (append (list py) cache) 
pyim-pymap-cchar2py-cache)
+              (puthash key (list py) pyim-pymap-cchar2py-cache))))))))
 
 (defun pyim-pymap-cchar< (a b)
   "如果汉字 A 的使用频率大于汉字 B 的使用频率时,返回 non-nil"
diff --git a/pyim.el b/pyim.el
index 72b5f76..4dc4cd2 100644
--- a/pyim.el
+++ b/pyim.el
@@ -195,7 +195,7 @@
 
 pyim 是使用 `pyim-start' 来启动输入法,这个命令主要做如下工作:
 1. 重置 `pyim-local-variable-list' 中所有的 local 变量。
-2. 使用 `pyim-cchar2pinyin-create-cache' 创建汉字到拼音的 hash table 对应表。
+2. 使用 `pyim-pymap-cchar2py-create-cache' 创建汉字到拼音的 hash table 对应表。
 3. 运行hook: `pyim-load-hook'。
 4. 将 `pyim-dcache-save-caches' 命令添加到 `kill-emacs-hook' , emacs 关闭
 之前将用户选择过的词生成的缓存和词频缓存保存到文件,供以后使用。
@@ -222,8 +222,8 @@ pyim 使用函数 `pyim-start' 启动输入法的时候,会将变量
   (when pyim-dcache-auto-update
     (pyim-dcache-call-api 'update-personal-words restart))
 
-  (pyim-cchar2pinyin-cache-create)
-  (pyim-pinyin2cchar-cache-create)
+  (pyim-pymap-cchar2py-cache-create)
+  (pyim-pymap-py2cchar-cache-create)
   (run-hooks 'pyim-load-hook)
 
   (when pyim-dcache-auto-update



reply via email to

[Prev in Thread] Current Thread [Next in Thread]