Skip to content

Commit 88ebe26

Browse files
committed
fix: 解决纠错功能和预编辑脚本冲突
1 parent ef5dede commit 88ebe26

6 files changed

Lines changed: 22 additions & 12 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
因为破坏性变更,当前还需要解决问题:
2222
- [x] 切换为万象词库后,用户词典(.userdb)需要脚本刷写。否则音调无法显示。提供 Python 脚本以方便用户迁移。
23-
- [ ] 万象预编辑脚本和纠错脚本冲突问题已经解决,但是纠错样式和万象词库的样式一致,无法区分,考虑后续是否调整。
23+
- [x] 万象预编辑脚本和纠错脚本冲突问题已经解决,但是纠错样式和万象词库的样式一致,无法区分,考虑后续是否调整。
2424

2525
## Oh-my-rime指南
2626

‎README_en.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Or, if you just want to download the Oh-my-rime without cloning the repository v
2020

2121
Due to these breaking changes, the following issues still need to be addressed:
2222
- [x] After switching to the Wanxiang dictionary, user dictionaries (.userdb) require script rewriting. Otherwise, tone marks will not display. A Python script has been provided to facilitate user migration.
23-
- [ ] The conflict between the Wanxiang pre-editing script and the error correction script has been resolved, but the error correction style is now consistent with the Wanxiang dictionary style, making them indistinguishable. Consideration is being given to potential adjustments in the future.
23+
- [x] The conflict between the Wanxiang pre-editing script and the error correction script has been resolved, but the error correction style is now consistent with the Wanxiang dictionary style, making them indistinguishable. Consideration is being given to potential adjustments in the future.
2424

2525
## Oh-my-rime guide
2626

‎README_zh-CHT.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
因為破壞性變更,當前還需要解決問題:
2222
- [x] 切換為萬象詞庫後,用戶詞典(.userdb)需要腳本刷寫。否則音調無法顯示。提供 Python 腳本以方便用戶遷移。
23-
- [ ] 萬象預編輯腳本和糾錯腳本沖突問題已經解決,但是糾錯樣式和萬象詞庫的樣式一致,無法區分,考慮後續是否調整。
23+
- [x] 萬象預編輯腳本和糾錯腳本沖突問題已經解決,但是糾錯樣式和萬象詞庫的樣式一致,無法區分,考慮後續是否調整。
2424

2525
## Oh-my-rime指南
2626

‎README_zh-cn.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
因为破坏性变更,当前还需要解决问题:
2222
- [x] 切换为万象词库后,用户词典(.userdb)需要脚本刷写。否则音调无法显示。提供 Python 脚本以方便用户迁移。
23-
- [ ] 万象预编辑脚本和纠错脚本冲突问题已经解决,但是纠错样式和万象词库的样式一致,无法区分,考虑后续是否调整。
23+
- [x] 万象预编辑脚本和纠错脚本冲突问题已经解决,但是纠错样式和万象词库的样式一致,无法区分,考虑后续是否调整。
2424

2525
## Oh-my-rime指南
2626

‎lua/corrector_filter.lua‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,14 @@ function M.func(input, env)
130130
end
131131
local c = M.corrections[pinyin]
132132
if c and cand.text == c.text then
133-
cand:get_genuine().comment = string.gsub(M.style, "{comment}", c.comment)
133+
local target_comment = '[' .. c.comment .. ']'
134+
cand:get_genuine().comment = string.gsub(M.style, "{comment}", target_comment)
135+
-- 获取当前 composition 和 segment
136+
local context = env.engine.context
137+
local composition = context.composition
138+
local seg = composition:back() -- 获取当前 segment
139+
-- 设置标签
140+
seg.tags = seg.tags + Set({ "correntor" })
134141
else
135142
-- 20250708 是否保持原本注释;如: 拼音
136143
local keep_source_comment = env.engine.context:get_option("tone_display") or false

‎lua/super_preedit.lua‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
-- 复制自<万象拼音方案> https://github.com/amzxyz/rime_wanxiang
22
-- @author: amzxyz
33
-- @modify: Mintimate
4+
-- 修改内容: ① 兼容纠错
45

56
local function modify_preedit_filter(input, env)
67
local config = env.engine.schema.config
@@ -22,20 +23,22 @@ local function modify_preedit_filter(input, env)
2223
local context = env.engine.context
2324

2425
local seg = context.composition:back()
25-
env.is_radical_mode = seg and (
26-
seg:has_tag("radical_lookup") or seg:has_tag("reverse_stroke")
26+
env.is_special_tag_mode = seg and (
27+
seg:has_tag("radical_lookup") or seg:has_tag("reverse_stroke") or seg:has_tag("correntor")
2728
) or false
2829

2930
for cand in input:iter() do
30-
if env.is_radical_mode then
31-
yield(cand)
32-
goto continue
33-
end
34-
3531
local genuine_cand = cand:get_genuine()
3632
local preedit = genuine_cand.preedit or ""
3733
local comment = genuine_cand.comment
3834

35+
if env.is_special_tag_mode then
36+
-- 2025-07-10 Mintimate 使其兼容纠错
37+
genuine_cand.preedit = comment:gsub("[%[%]]", "")
38+
yield(genuine_cand)
39+
goto continue
40+
end
41+
3942
if not comment or comment == "" or not is_tone_display then
4043
yield(cand)
4144
goto continue

0 commit comments

Comments
 (0)