Skip to content

Commit

Permalink
feat: 纠错添加原有注释选项
Browse files Browse the repository at this point in the history
如果想保持原本的自动纠错功能,可以修改方案内的 corrector_filter/keep_source_comment 为 true

resolved: #91
  • Loading branch information
Mintimate committed Oct 2, 2024
1 parent 6a0e77c commit 03fdc65
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 13 deletions.
7 changes: 6 additions & 1 deletion double_pinyin.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
schema:
schema_id: double_pinyin
name: "自然码双拼-薄荷定制"
version: "24.09.25"
version: "24.10.02"
author:
- Dvel
- Mintimate
Expand Down Expand Up @@ -145,6 +145,11 @@ reduce_english_filter:
zach
]

# 错音错字提示
corrector_filter:
# 当文字没有触发错字错音的情况下,保持原本的注释
keep_source_comment: false

# 中国农历配置
chineseLunarCalendar_translator: lunar

Expand Down
7 changes: 6 additions & 1 deletion double_pinyin_abc.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
schema:
schema_id: double_pinyin_abc
name: "智能ABC双拼-薄荷定制"
version: "24.09.25"
version: "24.10.02"
author:
- Dvel
- Mintimate
Expand Down Expand Up @@ -146,6 +146,11 @@ reduce_english_filter:
zach
]

# 错音错字提示
corrector_filter:
# 当文字没有触发错字错音的情况下,保持原本的注释
keep_source_comment: false

# 中国农历配置
chineseLunarCalendar_translator: lunar

Expand Down
7 changes: 6 additions & 1 deletion double_pinyin_flypy.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
schema:
schema_id: double_pinyin_flypy
name: "小鹤双拼-薄荷定制"
version: "24.09.25"
version: "24.10.02"
author:
- Mintimate
description: |
Expand Down Expand Up @@ -164,6 +164,11 @@ reduce_english_filter:
tad, tail, taj, tar, tax, tec, ted, tel, ter, tex, tic, tied, tier, ties, tim, tin, tit, tour, tout, tum,
wag, wand, womens, wap, wax, weir, won,
yan, yen]

# 错音错字提示
corrector_filter:
# 当文字没有触发错字错音的情况下,保持原本的注释
keep_source_comment: false

# 中国农历配置
chineseLunarCalendar_translator: lunar
Expand Down
7 changes: 6 additions & 1 deletion double_pinyin_mspy.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
schema:
schema_id: double_pinyin_mspy
name: "微软双拼-薄荷定制"
version: "24.09.25"
version: "24.10.02"
author:
- Dvel
- Mintimate
Expand Down Expand Up @@ -145,6 +145,11 @@ reduce_english_filter:
zach
]

# 错音错字提示
corrector_filter:
# 当文字没有触发错字错音的情况下,保持原本的注释
keep_source_comment: false

# 中国农历配置
chineseLunarCalendar_translator: lunar

Expand Down
7 changes: 6 additions & 1 deletion double_pinyin_sogou.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
schema:
schema_id: double_pinyin_sogou
name: "搜狗双拼-薄荷定制"
version: "24.09.25"
version: "24.10.02"
author:
- Dvel
- Mintimate
Expand Down Expand Up @@ -146,6 +146,11 @@ reduce_english_filter:
zach
]

# 错音错字提示
corrector_filter:
# 当文字没有触发错字错音的情况下,保持原本的注释
keep_source_comment: false

# 中国农历配置
chineseLunarCalendar_translator: lunar

Expand Down
7 changes: 6 additions & 1 deletion double_pinyin_ziguang.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
schema:
schema_id: double_pinyin_ziguang
name: "紫光双拼-薄荷定制"
version: "24.09.25"
version: "24.10.02"
author:
- Dvel
- Mintimate
Expand Down Expand Up @@ -146,6 +146,11 @@ reduce_english_filter:
zach
]

# 错音错字提示
corrector_filter:
# 当文字没有触发错字错音的情况下,保持原本的注释
keep_source_comment: false

# 中国农历配置
chineseLunarCalendar_translator: lunar

Expand Down
17 changes: 14 additions & 3 deletions lua/corrector_filter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ local M = {}
function M.init(env)
local config = env.engine.schema.config
local delimiter = config:get_string('speller/delimiter')
env.name_space = env.name_space:gsub('^*', '')
-- 是否保持原有注释
M.keep_source_comment = config:get_bool(env.name_space .. "/keep_source_comment")
if delimiter and #delimiter > 0 and delimiter:sub(1,1) ~= ' ' then
env.delimiter = delimiter:sub(1,1)
end
Expand All @@ -24,7 +27,6 @@ function M.init(env)
["hun dun"] = { text = "馄饨", comment = "hún tun" },
["zhu jiao"] = { text = "主角", comment = "zhǔ jué" },
["jiao se"] = { text = "角色", comment = "júe sè" },
["pi sa"] = { text = "比萨", comment = "bǐ sà" },
["chi pi sa"] = { text = "吃比萨", comment = "chī bǐ sà" },
["pi sa bing"] = { text = "比萨饼", comment = "bǐ sà bǐng" },
["shui fu"] = { text = "说服", comment = "shuō fú" },
Expand Down Expand Up @@ -94,6 +96,10 @@ function M.init(env)
["nan jing liu he"] = { text = "南京六合", comment = "nán jīng lù hé" },
["nan jing shi liu he"] = { text = "南京六合区", comment = "nán jīng lù hé qū" },
["nan jing shi liu he qu"] = { text = "南京市六合区", comment = "nán jīng shì lù hé qū" },
["nuo da"] = { text = "偌大", comment = "偌(ruò)大" },
["yin jiu zhi ke"] = { text = "饮鸩止渴", comment = "饮鸩(zhèn)止渴" },
["yin jiu jie ke"] = { text = "饮鸩解渴", comment = "饮鸩(zhèn)解渴" },
["gong shang jiao zhi yu"] = { text = "宫商角徵羽", comment = "宫商角(jué)徵羽" },
-- 错字
["pu jie"] = { text = "扑街", comment = "仆街" },
["pu gai"] = { text = "扑街", comment = "仆街" },
Expand All @@ -113,7 +119,7 @@ function M.init(env)
["cou huo"] = { text = "凑活", comment = "凑合(he)" },
["ju hui"] = { text = "钜惠", comment = "巨惠" },
["mo xie zuo"] = { text = "魔蝎座", comment = "摩羯(jié)座" },
["nuo da"] = { text = "诺大", comment = "偌(ruò)大" },
["pi sa"] = { text = "披萨", comment = "比(bǐ)萨" },
}
end

Expand All @@ -129,7 +135,12 @@ function M.func(input, env)
if c and cand.text == c.text then
cand:get_genuine().comment = string.gsub(M.style, "{comment}", c.comment)
else
cand:get_genuine().comment = ""
-- 20241002 是否保持原本注释;如: 拼音
if M.keep_source_comment then
cand:get_genuine().comment = string.gsub(M.style, "{comment}", pinyin)
else
cand:get_genuine().comment = ""
end
end
end
yield(cand)
Expand Down
8 changes: 6 additions & 2 deletions rime_mint.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
schema:
schema_id: rime_mint
name: 薄荷拼音-全拼输入
version: "24.09.25"
version: "24.10.02"
author:
- mintimate < @Mintimate|https://www.mintimate.cn >
description: |
Expand Down Expand Up @@ -141,7 +141,11 @@ reduce_english_filter:
tad, tail, taj, tar, tax, tec, ted, tel, ter, tex, tic, tied, tier, ties, tim, tin, tit, tour, tout, tum,
wag, wand, womens, wap, wax, weir, won,
yan, yen]


# 错音错字提示
corrector_filter:
# 当文字没有触发错字错音的情况下,保持原本的注释
keep_source_comment: false

# 中国农历配置
chineseLunarCalendar_translator: lunar
Expand Down
7 changes: 6 additions & 1 deletion rime_mint_flypy.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
schema:
schema_id: rime_mint_flypy
name: 薄荷拼音-小鹤混输
version: "24.09.25"
version: "24.10.02"
author:
- mintimate < @Mintimate|https://www.mintimate.cn >
description: |
Expand Down Expand Up @@ -142,6 +142,11 @@ reduce_english_filter:
tad, tail, taj, tar, tax, tec, ted, tel, ter, tex, tic, tied, tier, ties, tim, tin, tit, tour, tout, tum,
wag, wand, womens, wap, wax, weir, won,
yan, yen]

# 错音错字提示
corrector_filter:
# 当文字没有触发错字错音的情况下,保持原本的注释
keep_source_comment: false

# 中国农历配置
chineseLunarCalendar_translator: lunar
Expand Down
7 changes: 6 additions & 1 deletion terra_pinyin.schema.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
schema:
schema_id: terra_pinyin
name: "地球拼音-薄荷定制"
version: "24.09.25"
version: "24.10.02"
author:
- 佛振 <[email protected]>
- mintimate < @Mintimate|https://www.mintimate.cn >
Expand Down Expand Up @@ -120,6 +120,11 @@ reduce_english_filter:
wag, wand, womens, wap, wax, weir, won,
yan, yen]

# 错音错字提示
corrector_filter:
# 当文字没有触发错字错音的情况下,保持原本的注释
keep_source_comment: false

speller:
alphabet: 'zyxwvutsrqponmlkjihgfedcba-;/<,>\'
initials: zyxwvutsrqponmlkjihgfedcba
Expand Down

0 comments on commit 03fdc65

Please sign in to comment.