From 62f3e107a01a6f18a21fe29519a1f8542756d91d Mon Sep 17 00:00:00 2001 From: mirtlecn Date: Tue, 16 Apr 2024 15:12:00 +0800 Subject: [PATCH] fix(lua): corrector.lua now clears specific cand.comment --- double_pinyin.schema.yaml | 3 +++ double_pinyin_abc.schema.yaml | 3 +++ double_pinyin_flypy.schema.yaml | 3 +++ double_pinyin_mspy.schema.yaml | 3 +++ double_pinyin_sogou.schema.yaml | 3 +++ double_pinyin_ziguang.schema.yaml | 3 +++ lua/corrector.lua | 13 ++++++++----- rime_ice.schema.yaml | 3 +++ 8 files changed, 29 insertions(+), 5 deletions(-) diff --git a/double_pinyin.schema.yaml b/double_pinyin.schema.yaml index 06327e928..7799ce59c 100644 --- a/double_pinyin.schema.yaml +++ b/double_pinyin.schema.yaml @@ -161,6 +161,9 @@ translator: spelling_hints: 8 # corrector.lua :为了让错音错字提示的 Lua 同时适配全拼双拼,将拼音显示在 comment 中 always_show_comments: true # corrector.lua :Rime 默认在 preedit 等于 comment 时取消显示 comment,这里强制一直显示,供 corrector.lua 做判断用。 initial_quality: 1.2 # 拼音的权重应该比英文大 + comment_format: # 标记拼音注释,供 corrector.lua 做判断用 + - xform/^/[/ + - xform/$/]/ preedit_format: # preedit_format 影响到输入框的显示和“Shift+回车”上屏的字符 - xform/([bpmnljqxy])n/$1in/ - xform/(\w)g/$1eng/ diff --git a/double_pinyin_abc.schema.yaml b/double_pinyin_abc.schema.yaml index 36eaeefb7..7b62feeb8 100644 --- a/double_pinyin_abc.schema.yaml +++ b/double_pinyin_abc.schema.yaml @@ -161,6 +161,9 @@ translator: spelling_hints: 8 # corrector.lua :为了让错音错字提示的 Lua 同时适配全拼双拼,将拼音显示在 comment 中 always_show_comments: true # corrector.lua :Rime 默认在 preedit 等于 comment 时取消显示 comment,这里强制一直显示,供 corrector.lua 做判断用。 initial_quality: 1.2 # 拼音的权重应该比英文大 + comment_format: # 标记拼音注释,供 corrector.lua 做判断用 + - xform/^/[/ + - xform/$/]/ preedit_format: # preedit_format 影响到输入框的显示和“Shift+回车”上屏的字符 - xform/o(\w)/0$1/ - xform/(\w)q/$1ei/ diff --git a/double_pinyin_flypy.schema.yaml b/double_pinyin_flypy.schema.yaml index 098f24439..99a40269d 100644 --- a/double_pinyin_flypy.schema.yaml +++ b/double_pinyin_flypy.schema.yaml @@ -161,6 +161,9 @@ translator: spelling_hints: 8 # corrector.lua :为了让错音错字提示的 Lua 同时适配全拼双拼,将拼音显示在 comment 中 always_show_comments: true # corrector.lua :Rime 默认在 preedit 等于 comment 时取消显示 comment,这里强制一直显示,供 corrector.lua 做判断用。 initial_quality: 1.2 # 拼音的权重应该比英文大 + comment_format: # 标记拼音注释,供 corrector.lua 做判断用 + - xform/^/[/ + - xform/$/]/ preedit_format: # preedit_format 影响到输入框的显示和“Shift+回车”上屏的字符 - xform/([bpmfdtnljqx])n/$1iao/ - xform/(\w)g/$1eng/ diff --git a/double_pinyin_mspy.schema.yaml b/double_pinyin_mspy.schema.yaml index 6edbc1ea9..df6c87104 100644 --- a/double_pinyin_mspy.schema.yaml +++ b/double_pinyin_mspy.schema.yaml @@ -161,6 +161,9 @@ translator: spelling_hints: 8 # corrector.lua :为了让错音错字提示的 Lua 同时适配全拼双拼,将拼音显示在 comment 中 always_show_comments: true # corrector.lua :Rime 默认在 preedit 等于 comment 时取消显示 comment,这里强制一直显示,供 corrector.lua 做判断用。 initial_quality: 1.2 # 拼音的权重应该比英文大 + comment_format: # 标记拼音注释,供 corrector.lua 做判断用 + - xform/^/[/ + - xform/$/]/ preedit_format: # preedit_format 影响到输入框的显示和“Shift+回车”上屏的字符 - xform/([aoe])(\w)/0$2/ - xform/([bpmnljqxy])n/$1in/ diff --git a/double_pinyin_sogou.schema.yaml b/double_pinyin_sogou.schema.yaml index aa8f41db1..1e79b4ae1 100644 --- a/double_pinyin_sogou.schema.yaml +++ b/double_pinyin_sogou.schema.yaml @@ -161,6 +161,9 @@ translator: spelling_hints: 8 # corrector.lua :为了让错音错字提示的 Lua 同时适配全拼双拼,将拼音显示在 comment 中 always_show_comments: true # corrector.lua :Rime 默认在 preedit 等于 comment 时取消显示 comment,这里强制一直显示,供 corrector.lua 做判断用。 initial_quality: 1.2 # 拼音的权重应该比英文大 + comment_format: # 标记拼音注释,供 corrector.lua 做判断用 + - xform/^/[/ + - xform/$/]/ preedit_format: # preedit_format 影响到输入框的显示和“Shift+回车”上屏的字符 - xform/([aoe])(\w)/0$2/ - xform/([bpmnljqxy])n/$1in/ diff --git a/double_pinyin_ziguang.schema.yaml b/double_pinyin_ziguang.schema.yaml index 53ec91e44..a7d8929dc 100644 --- a/double_pinyin_ziguang.schema.yaml +++ b/double_pinyin_ziguang.schema.yaml @@ -161,6 +161,9 @@ translator: spelling_hints: 8 # corrector.lua :为了让错音错字提示的 Lua 同时适配全拼双拼,将拼音显示在 comment 中 always_show_comments: true # corrector.lua :Rime 默认在 preedit 等于 comment 时取消显示 comment,这里强制一直显示,供 corrector.lua 做判断用。 initial_quality: 1.2 # 拼音的权重应该比英文大 + comment_format: # 标记拼音注释,供 corrector.lua 做判断用 + - xform/^/[/ + - xform/$/]/ preedit_format: # preedit_format 影响到输入框的显示和“Shift+回车”上屏的字符 - xform/o(\w)/0$1/ # 零聲母先改爲0,以方便後面的轉換 - xform/([jqxy])n/$1ue/ # 提前轉換雙拼碼 n 和 g,因爲轉換後的拼音裏就快要出現這兩個字母了,那時將難以分辨出雙拼碼 diff --git a/lua/corrector.lua b/lua/corrector.lua index 6c2675d68..b77ca3f78 100644 --- a/lua/corrector.lua +++ b/lua/corrector.lua @@ -113,11 +113,14 @@ end function M.func(input) for cand in input:iter() do -- cand.comment 是目前输入的词汇的完整拼音 - local c = M.corrections[cand.comment] - if c and cand.text == c.text then - cand:get_genuine().comment = string.gsub(M.style, "{comment}", c.comment) - elseif cand.type == "user_phrase" or cand.type == "phrase" or cand.type == "sentence" then - cand:get_genuine().comment = "" + local pinyin = cand.comment:match("^[(.-)]$") + if pinyin and #pinyin > 0 then + local c = M.corrections[pinyin] + if c and cand.text == c.text then + cand:get_genuine().comment = string.gsub(M.style, "{comment}", c.comment) + else + cand:get_genuine().comment = "" + end end yield(cand) end diff --git a/rime_ice.schema.yaml b/rime_ice.schema.yaml index 4404fdfd4..f95443203 100644 --- a/rime_ice.schema.yaml +++ b/rime_ice.schema.yaml @@ -293,6 +293,9 @@ translator: spelling_hints: 8 # corrector.lua :为了让错音错字提示的 Lua 同时适配全拼双拼,将拼音显示在 comment 中 always_show_comments: true # corrector.lua :Rime 默认在 preedit 等于 comment 时取消显示 comment,这里强制一直显示,供 corrector.lua 做判断用。 initial_quality: 1.2 # 拼音的权重应该比英文大 + comment_format: # 标记拼音注释,供 corrector.lua 做判断用 + - xform/^/[/ + - xform/$/]/ preedit_format: # preedit_format 影响到输入框的显示和“Shift+回车”上屏的字符 - xform/([jqxy])v/$1u/ # 显示为 ju qu xu yu # - xform/([nl])v/$1ü/ # 显示为 nü lü