[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/pyim 9440f7e 1/2: * pyim-pinyin.el (pyim-pinyin-find-fu
From: |
ELPA Syncer |
Subject: |
[elpa] externals/pyim 9440f7e 1/2: * pyim-pinyin.el (pyim-pinyin-find-fuzzy-alist): simplify. |
Date: |
Wed, 8 Dec 2021 22:57:32 -0500 (EST) |
branch: externals/pyim
commit 9440f7e6dfd133ba16b369d670a38e9785f4a6ce
Author: Feng Shu <tumashu@163.com>
Commit: Feng Shu <tumashu@163.com>
* pyim-pinyin.el (pyim-pinyin-find-fuzzy-alist): simplify.
---
pyim-pinyin.el | 37 ++++++++++++++++---------------------
1 file changed, 16 insertions(+), 21 deletions(-)
diff --git a/pyim-pinyin.el b/pyim-pinyin.el
index 0958996..b68b427 100644
--- a/pyim-pinyin.el
+++ b/pyim-pinyin.el
@@ -156,28 +156,23 @@
(cons (list shenmu yunmu shenmu yunmu)
(substring yunmu-and-rest (length yunmu)))))
-;; (\"f\" \"en\" \"f\" \"en\") -> ((\"f\" \"en\" \"f\" \"en\") (\"f\" \"eng\"
\"f\" \"en\"))
(defun pyim-pinyin-find-fuzzy (info)
- "Find all fuzzy pinyins.
-
-INFO is a list like: (shenmu yunmu shenmu yunmu)"
- (cl-labels ((find-list (str list)
- (let (result)
- (dolist (x list)
- (when (member str x)
- (setq list nil)
- (setq result
- (delete-dups
- `(,str ,@(cl-copy-list x))))))
- (or result (list str)))))
- (let* ((fuzzy-alist pyim-pinyin-fuzzy-alist)
- (sm-list (find-list (nth 0 info) fuzzy-alist))
- (ym-list (find-list (nth 1 info) fuzzy-alist))
- result)
- (dolist (a sm-list)
- (dolist (b ym-list)
- (push `(,a ,b ,@(nthcdr 2 info)) result)))
- (reverse result))))
+ "Find all fuzzy pinyins, INFO is (shenmu yunmu shenmu yunmu).
+
+ (\"f\" \"en\" \"f\" \"en\") -> ((\"f\" \"en\" \"f\" \"en\")
+ (\"f\" \"eng\" \"f\" \"en\"))"
+ (let* ((fuzzy-alist pyim-pinyin-fuzzy-alist)
+ (sm-list (or (assoc (nth 0 info)
+ fuzzy-alist #'equal)
+ (list (nth 0 info))))
+ (ym-list (or (assoc (nth 1 info)
+ fuzzy-alist #'equal)
+ (list (nth 1 info))))
+ result)
+ (dolist (a sm-list)
+ (dolist (b ym-list)
+ (push `(,a ,b ,@(nthcdr 2 info)) result)))
+ (reverse result)))
(defun pyim-pinyin-split (pinyin)
"将一个代表拼音的字符串 PINYIN, 分解为声母韵母对组成的列表.