[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/pyim 19ab650358 2/3: pyim-pymap-cchars2pys-get -> pyim-
From: |
ELPA Syncer |
Subject: |
[elpa] externals/pyim 19ab650358 2/3: pyim-pymap-cchars2pys-get -> pyim-pymap-str2py-get |
Date: |
Tue, 17 Jan 2023 23:58:06 -0500 (EST) |
branch: externals/pyim
commit 19ab650358016a983fb5df340940611808583e9c
Author: Feng Shu <tumashu@163.com>
Commit: Feng Shu <tumashu@163.com>
pyim-pymap-cchars2pys-get -> pyim-pymap-str2py-get
---
pyim-cstring.el | 7 +------
pyim-pymap.el | 13 +++++++------
tests/pyim-tests.el | 4 ++--
3 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/pyim-cstring.el b/pyim-cstring.el
index 60298d77a1..07d29bafa9 100644
--- a/pyim-cstring.el
+++ b/pyim-cstring.el
@@ -94,7 +94,7 @@ BUG: 当 STRING 中包含其它标点符号,并且设置 SEPERATER 时,结
(if return-list (list string) string)
(let* ((pinyins-list
(or (pyim-cstring-to-pinyin--from-dcache string)
- (pyim-cstring-to-pinyin--from-pymap string)))
+ (pyim-pymap-str2py-get string)))
(list (mapcar (lambda (x)
(mapconcat (lambda (str)
(if shou-zi-mu
@@ -131,11 +131,6 @@ BUG: 当 STRING 中包含其它标点符号,并且设置 SEPERATER 时,结
(split-string code "-"))
(list str)))
-(defun pyim-cstring-to-pinyin--from-pymap (cstring)
- "使用 PYMAP 提供的工具来搜索 CSTRING 对应的拼音。"
- (pyim-pymap-cchars2pys-get
- (pyim-pymap-split-string cstring t)))
-
;;;###autoload
(defun pyim-cstring-to-pinyin-simple (string &optional shou-zi-mu separator
return-list)
"简化版的 `pyim-cstring-to-pinyin', 不处理多音字。"
diff --git a/pyim-pymap.el b/pyim-pymap.el
index 9b36d8211c..d4efd06b7c 100644
--- a/pyim-pymap.el
+++ b/pyim-pymap.el
@@ -1044,29 +1044,30 @@ If FORCE is non-nil, FORCE build."
output
(remove "|" output)))))
-(defun pyim-pymap-cchars2pys-get (cchars)
- "将汉字列表转换为拼音列表,转换过程中矫正多音字。
+(defun pyim-pymap-str2py-get (string)
+ "将 STRING 转换为拼音列表,转换过程中尽可能矫正多音字。
比如:
-1. CCHARS: (\"你\" \"好\")
+1. STRING: 你好
2. OUTPUTS: ((\"ni\" \"hao\"))
注意事项:
1. 这个函数遇到非汉字字符串时,原样输出。
2. 多音字矫正依赖 pymap 自带的多音字矫正信息的完善程度,可能会出
现矫正不正确的情况,这个函数为了保证性能,只处理常用多音字。"
- (let* ((pinyins-list
+ (let* ((chars (pyim-pymap-split-string string t))
+ (pinyins-list
;; ("Hello" "银" "行") -> (("Hello") ("yin") ("hang" "xing"))
(mapcar (lambda (str)
(if (pyim-string-match-p "\\cc" str)
(pyim-pymap-cchar2py-get str)
(list str)))
- cchars)))
+ chars)))
;; 通过排列组合的方式, 重排 pinyins-list。
;; 比如:(("Hello") ("yin") ("hang")) -> (("Hello" "yin" "hang"))
(pyim-permutate-list
(pyim-pymap--adjust-duoyinzi
- cchars pinyins-list))))
+ chars pinyins-list))))
(defun pyim-pymap-split-string (string &optional to-cchar)
"将 STRING 按照中文处理的标准切开.
diff --git a/tests/pyim-tests.el b/tests/pyim-tests.el
index 45d76c6779..d181629be4 100644
--- a/tests/pyim-tests.el
+++ b/tests/pyim-tests.el
@@ -318,10 +318,10 @@
(should (equal (pyim-pymap--py2duoyinzi-get "ai" t)
'("艾")))
- (should (equal (pyim-pymap-cchars2pys-get '("hello" "你" "好" "ma"))
+ (should (equal (pyim-pymap-str2py-get '"hello你好ma")
'(("hello" "ni" "hao" "ma"))))
- (should (equal (pyim-pymap-cchars2pys-get '("hello" "你" "鹢" "ma"))
+ (should (equal (pyim-pymap-str2py-get '"hello你鹢ma")
'(("hello" "ni" "yi" "ma")
("hello" "ni" "ni" "ma")
("hello" "ni" "hua" "ma"))))