[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/pyim 33d9d46fa9 1/2: * pyim-pinyin.el (pyim-pinyin-fin
From: |
ELPA Syncer |
Subject: |
[elpa] externals/pyim 33d9d46fa9 1/2: * pyim-pinyin.el (pyim-pinyin-find-fuzzy): 模糊映射表是双向的。 |
Date: |
Wed, 29 Dec 2021 00:57:46 -0500 (EST) |
branch: externals/pyim
commit 33d9d46fa99d6883fd1688c68808793570296537
Author: Feng Shu <tumashu@163.com>
Commit: Feng Shu <tumashu@163.com>
* pyim-pinyin.el (pyim-pinyin-find-fuzzy): 模糊映射表是双向的。
---
pyim-pinyin.el | 18 +++++++++++-------
tests/pyim-tests.el | 17 ++++++++++++++++-
2 files changed, 27 insertions(+), 8 deletions(-)
diff --git a/pyim-pinyin.el b/pyim-pinyin.el
index 49961d7ab7..41bef56abf 100644
--- a/pyim-pinyin.el
+++ b/pyim-pinyin.el
@@ -160,14 +160,18 @@
(\"f\" \"en\" \"f\" \"en\") -> ((\"f\" \"en\" \"f\" \"en\")
(\"f\" \"eng\" \"f\" \"en\"))"
- (let* ((fuzzy-alist pyim-pinyin-fuzzy-alist)
- (sm-list (or (cl-assoc (nth 0 info) fuzzy-alist :test #'equal)
- (list (nth 0 info))))
- (ym-list (or (cl-assoc (nth 1 info) fuzzy-alist :test #'equal)
- (list (nth 1 info))))
+ (let* ((fuzzy-alist (copy-alist pyim-pinyin-fuzzy-alist))
+ (sm (nth 0 info))
+ (ym (nth 1 info))
+ (sm-list (cl-find-if (lambda (x)
+ (member sm x))
+ fuzzy-alist))
+ (ym-list (cl-find-if (lambda (x)
+ (member ym x))
+ fuzzy-alist))
result)
- (dolist (a sm-list)
- (dolist (b ym-list)
+ (dolist (a (delete-dups (cons sm sm-list)))
+ (dolist (b (delete-dups (cons ym ym-list)))
(push `(,a ,b ,@(nthcdr 2 info)) result)))
(reverse result)))
diff --git a/tests/pyim-tests.el b/tests/pyim-tests.el
index 06c5ba03fe..57c0ba8597 100644
--- a/tests/pyim-tests.el
+++ b/tests/pyim-tests.el
@@ -246,7 +246,22 @@
'(("f" "en" "f" "en")
("f" "eng" "f" "en")
("h" "en" "f" "en")
- ("h" "eng" "f" "en")))))
+ ("h" "eng" "f" "en"))))
+ (should (equal (pyim-pinyin-find-fuzzy '("h" "en" "h" "en"))
+ '(("h" "en" "h" "en")
+ ("h" "eng" "h" "en")
+ ("f" "en" "h" "en")
+ ("f" "eng" "h" "en"))))
+ (should (equal (pyim-pinyin-find-fuzzy '("f" "eng" "f" "eng"))
+ '(("f" "eng" "f" "eng")
+ ("f" "en" "f" "eng")
+ ("h" "eng" "f" "eng")
+ ("h" "en" "f" "eng"))))
+ (should (equal (pyim-pinyin-find-fuzzy '("h" "eng" "h" "eng"))
+ '(("h" "eng" "h" "eng")
+ ("h" "en" "h" "eng")
+ ("f" "eng" "h" "eng")
+ ("f" "en" "h" "eng")))))
;; pyim-pinyin-build-regexp
(should (equal (pyim-pinyin-build-regexp "ni-hao")
"ni[a-z]*-hao[a-z]*"))