[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/pyim 62d9217ced 2/3: Add pyim-pymap-duoyinzi-include-p
From: |
ELPA Syncer |
Subject: |
[elpa] externals/pyim 62d9217ced 2/3: Add pyim-pymap-duoyinzi-include-p |
Date: |
Mon, 16 Jan 2023 02:58:09 -0500 (EST) |
branch: externals/pyim
commit 62d9217ced7dacdfd6ebadcaec81b9d788d16a6a
Author: Feng Shu <tumashu@163.com>
Commit: Feng Shu <tumashu@163.com>
Add pyim-pymap-duoyinzi-include-p
---
pyim-pymap.el | 9 +++++++++
tests/pyim-tests.el | 2 ++
2 files changed, 11 insertions(+)
diff --git a/pyim-pymap.el b/pyim-pymap.el
index d4f5f8e4f7..4d014d9025 100644
--- a/pyim-pymap.el
+++ b/pyim-pymap.el
@@ -1090,6 +1090,15 @@ pyim 在特定的时候需要读取一个汉字的拼音,这个工作由此完
(gethash pinyin pyim-pymap--py2duoyinzi-cache1)
(gethash pinyin pyim-pymap--py2duoyinzi-cache2))))
+(defun pyim-pymap-duoyinzi-include-p (cstring)
+ "判断 CSTRING 中文字符串是否包含多音字。"
+ (pyim-pymap--cchar2py-cache-create)
+ (let ((chars (split-string cstring "")))
+ (cl-some
+ (lambda (char)
+ (> (length (pyim-pymap-cchar2py-get char)) 1))
+ chars)))
+
;; * Footer
(provide 'pyim-pymap)
diff --git a/tests/pyim-tests.el b/tests/pyim-tests.el
index 987efe94f8..87f145f496 100644
--- a/tests/pyim-tests.el
+++ b/tests/pyim-tests.el
@@ -293,6 +293,8 @@
'("抓挝爪||髽|膼撾檛簻")))
(should (equal (pyim-pymap-py2duoyinzi-get "a")
'("吖啶" "腌臜")))
+ (should (pyim-pymap-duoyinzi-include-p "银行"))
+ (should-not (pyim-pymap-duoyinzi-include-p "银子"))
(should (equal (pyim-pymap-py2duoyinzi-get "ai" t)
'("艾")))
(should (equal (mapcar (lambda (x)