[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/pyim 440938c 8/8: split pyim-imobjs-codes to pyim-imobj
From: |
ELPA Syncer |
Subject: |
[elpa] externals/pyim 440938c 8/8: split pyim-imobjs-codes to pyim-imobjs.el and pyim-codes.el |
Date: |
Fri, 23 Apr 2021 00:57:13 -0400 (EDT) |
branch: externals/pyim
commit 440938c488a48cd41074c9cbb24767a8d3c49904
Author: Feng Shu <tumashu@163.com>
Commit: Feng Shu <tumashu@163.com>
split pyim-imobjs-codes to pyim-imobjs.el and pyim-codes.el
---
pyim-codes.el | 95 ++++++++++++++++++++++++++++++++++
pyim-imobjs-codes.el => pyim-imobjs.el | 66 ++---------------------
pyim.el | 3 +-
3 files changed, 101 insertions(+), 63 deletions(-)
diff --git a/pyim-codes.el b/pyim-codes.el
new file mode 100644
index 0000000..d557c2f
--- /dev/null
+++ b/pyim-codes.el
@@ -0,0 +1,95 @@
+;;; pyim-codes.el --- codes lib for pyim. -*- lexical-binding: t; -*-
+
+;; * Header
+;; Copyright (C) 2021 Free Software Foundation, Inc.
+
+;; Author: Feng Shu <tumashu@163.com>
+;; Maintainer: Feng Shu <tumashu@163.com>
+;; URL: https://github.com/tumashu/pyim
+;; Keywords: convenience, Chinese, pinyin, input-method
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;; Code:
+;; * 代码 :code:
+(require 'cl-lib)
+(require 'pyim-scheme)
+(require 'pyim-imobjs)
+
+(defun pyim-codes-create (imobj scheme-name &optional first-n)
+ "按照 SCHEME-NAME 对应的输入法方案,从一个 IMOBJ 创建一个列表 codes, 这个列表
+包含一个或者多个 code 字符串,这些 code 字符串用于从词库中搜索词条."
+ (let ((class (pyim-scheme-get-option scheme-name :class)))
+ (when class
+ (funcall (intern (format "pyim-codes-create:%S" class))
+ imobj scheme-name first-n))))
+
+(defun pyim-codes-create:quanpin (imobj _scheme-name &optional first-n)
+ "从IMOBJ 创建一个 code 列表:codes.
+
+列表 codes 中包含一个或者多个 code 字符串,这些 code 字符串用于从
+词库中搜索相关词条。
+
+ (pyim-codes-create '((\"w\" \"o\" \"w\" \"o\") (\"\" \"ai\" \"\" \"ai\")
(\"m\" \"ei\" \"m\" \"ei\") (\"n\" \"v\" \"n\" \"v\")) 'quanpin)
+
+结果为:
+
+ (\"wo\" \"ai\" \"mei\" \"nv\")"
+ (mapcar
+ #'(lambda (w)
+ (let ((py (replace-regexp-in-string ;去掉分隔符,在词库中搜索候选词不需要分隔符
+ "'" "" (concat (nth 0 w) (nth 1 w)))))
+ (if (numberp first-n)
+ (substring py 0 (min first-n (length py)))
+ py)))
+ imobj))
+
+(defun pyim-codes-create:shuangpin (imobj _scheme-name &optional first-n)
+ (pyim-codes-create:quanpin imobj 'quanpin first-n))
+
+(defun pyim-codes-create:xingma (imobj scheme-name &optional first-n)
+ (when scheme-name
+ (let ((code-prefix (pyim-scheme-get-option scheme-name :code-prefix)))
+ (mapcar
+ #'(lambda (x)
+ (concat (or code-prefix "")
+ (if (numberp first-n)
+ (substring x 0 (min first-n (length x)))
+ x)))
+ imobj))))
+
+(defun pyim-code-search (word scheme-name)
+ "从 SCHEME-NAME 对应的输入法词库中,搜索 WORD 对应的 code.
+
+返回最长的 code."
+ (when (and (stringp word)
+ (> (length word) 0))
+ (let* ((prefix (pyim-scheme-get-option scheme-name :code-prefix))
+ (code
+ (cl-find-if
+ #'(lambda (x)
+ (equal (substring (or x " ") 0 1) prefix))
+ (sort
+ (cl-copy-list (pyim-dcache-call-api 'search-word-code word))
+ #'(lambda (a b) (> (length a) (length b)))))))
+ (substring (or code " ") 1))))
+
+;; * Footer
+(provide 'pyim-codes)
+
+;;; pyim-imobjs.el ends here
diff --git a/pyim-imobjs-codes.el b/pyim-imobjs.el
similarity index 76%
rename from pyim-imobjs-codes.el
rename to pyim-imobjs.el
index 806a37e..297bfe9 100644
--- a/pyim-imobjs-codes.el
+++ b/pyim-imobjs.el
@@ -1,4 +1,4 @@
-;;; pyim-imobjs-codes.el --- imobjs and codes lib for pyim. -*-
lexical-binding: t; -*-
+;;; pyim-imobjs.el --- imobjs for pyim. -*- lexical-binding: t; -*-
;; * Header
;; Copyright (C) 2021 Free Software Foundation, Inc.
@@ -29,8 +29,8 @@
;; * 代码 :code:
(require 'cl-lib)
-(defgroup pyim-imobjs-codes nil
- "Imobjs and codes tools for pyim."
+(defgroup pyim-imobjs nil
+ "Imobjs lib for pyim."
:group 'pyim)
(defvar pyim-imobjs nil
@@ -205,65 +205,7 @@ imobj 组合构成在一起,构成了 imobjs 这个概念。比如:
(push `(,a ,b ,@(nthcdr 2 imelem)) result)))
(reverse result))))
-(defun pyim-codes-create (imobj scheme-name &optional first-n)
- "按照 SCHEME-NAME 对应的输入法方案,从一个 IMOBJ 创建一个列表 codes, 这个列表
-包含一个或者多个 code 字符串,这些 code 字符串用于从词库中搜索词条."
- (let ((class (pyim-scheme-get-option scheme-name :class)))
- (when class
- (funcall (intern (format "pyim-codes-create:%S" class))
- imobj scheme-name first-n))))
-
-(defun pyim-codes-create:quanpin (imobj _scheme-name &optional first-n)
- "从IMOBJ 创建一个 code 列表:codes.
-
-列表 codes 中包含一个或者多个 code 字符串,这些 code 字符串用于从
-词库中搜索相关词条。
-
- (pyim-codes-create '((\"w\" \"o\" \"w\" \"o\") (\"\" \"ai\" \"\" \"ai\")
(\"m\" \"ei\" \"m\" \"ei\") (\"n\" \"v\" \"n\" \"v\")) 'quanpin)
-
-结果为:
-
- (\"wo\" \"ai\" \"mei\" \"nv\")"
- (mapcar
- #'(lambda (w)
- (let ((py (replace-regexp-in-string ;去掉分隔符,在词库中搜索候选词不需要分隔符
- "'" "" (concat (nth 0 w) (nth 1 w)))))
- (if (numberp first-n)
- (substring py 0 (min first-n (length py)))
- py)))
- imobj))
-
-(defun pyim-codes-create:shuangpin (imobj _scheme-name &optional first-n)
- (pyim-codes-create:quanpin imobj 'quanpin first-n))
-
-(defun pyim-codes-create:xingma (imobj scheme-name &optional first-n)
- (when scheme-name
- (let ((code-prefix (pyim-scheme-get-option scheme-name :code-prefix)))
- (mapcar
- #'(lambda (x)
- (concat (or code-prefix "")
- (if (numberp first-n)
- (substring x 0 (min first-n (length x)))
- x)))
- imobj))))
-
-(defun pyim-code-search (word scheme-name)
- "从 SCHEME-NAME 对应的输入法词库中,搜索 WORD 对应的 code.
-
-返回最长的 code."
- (when (and (stringp word)
- (> (length word) 0))
- (let* ((prefix (pyim-scheme-get-option scheme-name :code-prefix))
- (code
- (cl-find-if
- #'(lambda (x)
- (equal (substring (or x " ") 0 1) prefix))
- (sort
- (cl-copy-list (pyim-dcache-call-api 'search-word-code word))
- #'(lambda (a b) (> (length a) (length b)))))))
- (substring (or code " ") 1))))
-
;; * Footer
-(provide 'pyim-imobjs-codes)
+(provide 'pyim-imobjs)
;;; pyim-imobjs.el ends here
diff --git a/pyim.el b/pyim.el
index 4dc4cd2..15684d8 100644
--- a/pyim.el
+++ b/pyim.el
@@ -42,7 +42,8 @@
(require 'pyim-dict)
(require 'pyim-dcache)
(require 'pyim-scheme)
-(require 'pyim-imobjs-codes)
+(require 'pyim-imobjs)
+(require 'pyim-codes)
(require 'pyim-page)
(require 'pyim-entered)
(require 'pyim-candidates)
- [elpa] externals/pyim updated (dff2fad -> 440938c), ELPA Syncer, 2021/04/23
- [elpa] externals/pyim a9997cd 1/8: Update pyim-outcome.el, ELPA Syncer, 2021/04/23
- [elpa] externals/pyim 289f87d 2/8: Move pyim-wash-function to pyim.el, ELPA Syncer, 2021/04/23
- [elpa] externals/pyim 25903ae 3/8: pyim-exhibit-delay-ms -> pyim-entered-exhibit-delay-ms, ELPA Syncer, 2021/04/23
- [elpa] externals/pyim ebf8834 6/8: pyim-flatten-list -> flatten-tree., ELPA Syncer, 2021/04/23
- [elpa] externals/pyim de908d1 5/8: pyim-cchar2pinyin/pinyin2cchar -> pyim-pymap-cchar2py/py2cchar, ELPA Syncer, 2021/04/23
- [elpa] externals/pyim 08dcd41 7/8: * pyim-entered.el (pyim-entered-get): Use point-min instead of 1, ELPA Syncer, 2021/04/23
- [elpa] externals/pyim dda3827 4/8: define-obsolete-function-alias 'pyim-convert-code-at-point to pyim.el, ELPA Syncer, 2021/04/23
- [elpa] externals/pyim 440938c 8/8: split pyim-imobjs-codes to pyim-imobjs.el and pyim-codes.el,
ELPA Syncer <=