[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/pyim 1cb8bf5e59 1/3: Add pyim-pymap-get-duoyinzi-words
From: |
ELPA Syncer |
Subject: |
[elpa] externals/pyim 1cb8bf5e59 1/3: Add pyim-pymap-get-duoyinzi-words command |
Date: |
Sat, 14 Jan 2023 23:58:44 -0500 (EST) |
branch: externals/pyim
commit 1cb8bf5e5918289be0aecc52c5287dfe6c305192
Author: Feng Shu <tumashu@163.com>
Commit: Feng Shu <tumashu@163.com>
Add pyim-pymap-get-duoyinzi-words command
---
pyim-cstring.el | 2 +-
pyim-pymap-utils.el | 26 ++++++++++++++++++++++++++
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/pyim-cstring.el b/pyim-cstring.el
index 8120629052..0a6a6e47dc 100644
--- a/pyim-cstring.el
+++ b/pyim-cstring.el
@@ -198,7 +198,7 @@ BUG: 当 STRING 中包含其它标点符号,并且设置 SEPERATER 时,结
4. 返回结果: hang"
(cl-find-if
(lambda (pinyin)
- (when-let* ((x (string-join (pyim-pymap-py2duoyinzi-get pinyin
search-char) "--")))
+ (when-let* ((x (string-join (pyim-pymap-py2duoyinzi-get pinyin
search-char) "-")))
(cl-some
(lambda (reg)
(and reg (string-match-p reg x)))
diff --git a/pyim-pymap-utils.el b/pyim-pymap-utils.el
index 290b1602bb..e107a623ec 100644
--- a/pyim-pymap-utils.el
+++ b/pyim-pymap-utils.el
@@ -378,6 +378,32 @@
(< (or (cl-position a pyim-pymap--commonly-used-cchar :test #'equal) 1000000)
(or (cl-position b pyim-pymap--commonly-used-cchar :test #'equal)
1000000)))
+(defun pyim-pymap-get-duoyinzi-words ()
+ (interactive)
+ (let (code2word output)
+ (maphash
+ (lambda (key value)
+ (let* ((pys (split-string key "-"))
+ (length (length pys)))
+ (when (and (> length 1)
+ (< length 3))
+ (push (cons pys value) code2word))))
+ pyim-dhashcache-code2word)
+
+ (dolist (x code2word)
+ (let ((words (cdr x)))
+ (dolist (word words)
+ (let ((chars (remove "" (split-string word "")))
+ (i 0))
+ (dolist (char chars)
+ (when-let* ((cpys (pyim-pymap-cchar2py-get char))
+ (py (nth i (car x)))
+ (_ (> (length cpys) 1)))
+ (setf (alist-get py output nil nil #'equal)
+ (delete-dups `(,@(alist-get py output nil nil #'equal)
,word))))
+ (setq i (1+ i)))))))
+
+ (sort output (lambda (a b) (string< (car a) (car b))))))
;; * Footer
(provide 'pyim-pymap-utils)