From 58cfa406c7ae0fddbd54cc2784f4d28fbe68337d Mon Sep 17 00:00:00 2001 From: Mintimate <43734212+Mintimate@users.noreply.github.com> Date: Tue, 30 Jan 2024 10:17:35 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=8B=B1=E6=96=87=E9=99=8D=E9=A2=91=20?= =?UTF-8?q?all=20=E5=B0=86=E5=90=88=E5=B9=B6=20words=20=E5=86=85=E5=AE=B9?= =?UTF-8?q?=20(#650)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- double_pinyin.schema.yaml | 6 +++--- double_pinyin_abc.schema.yaml | 6 +++--- double_pinyin_flypy.schema.yaml | 6 +++--- double_pinyin_mspy.schema.yaml | 6 +++--- double_pinyin_sogou.schema.yaml | 6 +++--- double_pinyin_ziguang.schema.yaml | 6 +++--- lua/reduce_english_filter.lua | 31 +++++++++++++++++++------------ rime_ice.schema.yaml | 6 +++--- 8 files changed, 40 insertions(+), 33 deletions(-) diff --git a/double_pinyin.schema.yaml b/double_pinyin.schema.yaml index c6d1f92..d6f491e 100644 --- a/double_pinyin.schema.yaml +++ b/double_pinyin.schema.yaml @@ -120,12 +120,12 @@ corrector: "{comment}" # 正常情况: 输入 rug 得到 「1.rug 2.如果 …… 」 # 降低之后: 输入 rug 得到 「1.如果 2.rug …… 」 # 几种模式: -# all 降低所有 3~4 位长度、前 2~3 位是完整拼音、最后一位是声母的单词 +# all 降低脚本内置的单词(所有 3~4 位长度、前 2~3 位是完整拼音、最后一位是声母),words 作为自定义的额外补充 +# custom 完全自定义,只降低 words 里的 # none 不降低任何单词,相当于没有启用这个 Lua -# custom 自定义,只降低 words 里的 # (匹配的是编码,不是单词) reduce_english_filter: - mode: custom # all | none | custom + mode: custom # all | custom | none idx: 2 # 降低到第 idx 个位置 # 自定义的单词列表,示例列表没有降低部分常用单词,如 and cat mail Mac but bad shit …… words: [aid, ann, diff --git a/double_pinyin_abc.schema.yaml b/double_pinyin_abc.schema.yaml index 14b2add..93caa85 100644 --- a/double_pinyin_abc.schema.yaml +++ b/double_pinyin_abc.schema.yaml @@ -120,12 +120,12 @@ corrector: "{comment}" # 正常情况: 输入 rug 得到 「1.rug 2.如果 …… 」 # 降低之后: 输入 rug 得到 「1.如果 2.rug …… 」 # 几种模式: -# all 降低所有 3~4 位长度、前 2~3 位是完整拼音、最后一位是声母的单词 +# all 降低脚本内置的单词(所有 3~4 位长度、前 2~3 位是完整拼音、最后一位是声母),words 作为自定义的额外补充 +# custom 完全自定义,只降低 words 里的 # none 不降低任何单词,相当于没有启用这个 Lua -# custom 自定义,只降低 words 里的 # (匹配的是编码,不是单词) reduce_english_filter: - mode: custom # all | none | custom + mode: custom # all | custom | none idx: 2 # 降低到第 idx 个位置 # 自定义的单词列表,示例列表没有降低部分常用单词,如 and cat mail Mac but bad shit …… words: [aid, ann, diff --git a/double_pinyin_flypy.schema.yaml b/double_pinyin_flypy.schema.yaml index 889703d..c0d4fca 100644 --- a/double_pinyin_flypy.schema.yaml +++ b/double_pinyin_flypy.schema.yaml @@ -120,12 +120,12 @@ corrector: "{comment}" # 正常情况: 输入 rug 得到 「1.rug 2.如果 …… 」 # 降低之后: 输入 rug 得到 「1.如果 2.rug …… 」 # 几种模式: -# all 降低所有 3~4 位长度、前 2~3 位是完整拼音、最后一位是声母的单词 +# all 降低脚本内置的单词(所有 3~4 位长度、前 2~3 位是完整拼音、最后一位是声母),words 作为自定义的额外补充 +# custom 完全自定义,只降低 words 里的 # none 不降低任何单词,相当于没有启用这个 Lua -# custom 自定义,只降低 words 里的 # (匹配的是编码,不是单词) reduce_english_filter: - mode: custom # all | none | custom + mode: custom # all | custom | none idx: 2 # 降低到第 idx 个位置 # 自定义的单词列表,示例列表没有降低部分常用单词,如 and cat mail Mac but bad shit …… words: [aid, ann, diff --git a/double_pinyin_mspy.schema.yaml b/double_pinyin_mspy.schema.yaml index ffecfd9..40bbe84 100644 --- a/double_pinyin_mspy.schema.yaml +++ b/double_pinyin_mspy.schema.yaml @@ -120,12 +120,12 @@ corrector: "{comment}" # 正常情况: 输入 rug 得到 「1.rug 2.如果 …… 」 # 降低之后: 输入 rug 得到 「1.如果 2.rug …… 」 # 几种模式: -# all 降低所有 3~4 位长度、前 2~3 位是完整拼音、最后一位是声母的单词 +# all 降低脚本内置的单词(所有 3~4 位长度、前 2~3 位是完整拼音、最后一位是声母),words 作为自定义的额外补充 +# custom 完全自定义,只降低 words 里的 # none 不降低任何单词,相当于没有启用这个 Lua -# custom 自定义,只降低 words 里的 # (匹配的是编码,不是单词) reduce_english_filter: - mode: custom # all | none | custom + mode: custom # all | custom | none idx: 2 # 降低到第 idx 个位置 # 自定义的单词列表,示例列表没有降低部分常用单词,如 and cat mail Mac but bad shit …… words: [aid, ann, diff --git a/double_pinyin_sogou.schema.yaml b/double_pinyin_sogou.schema.yaml index 3cd7cff..3a96165 100644 --- a/double_pinyin_sogou.schema.yaml +++ b/double_pinyin_sogou.schema.yaml @@ -120,12 +120,12 @@ corrector: "{comment}" # 正常情况: 输入 rug 得到 「1.rug 2.如果 …… 」 # 降低之后: 输入 rug 得到 「1.如果 2.rug …… 」 # 几种模式: -# all 降低所有 3~4 位长度、前 2~3 位是完整拼音、最后一位是声母的单词 +# all 降低脚本内置的单词(所有 3~4 位长度、前 2~3 位是完整拼音、最后一位是声母),words 作为自定义的额外补充 +# custom 完全自定义,只降低 words 里的 # none 不降低任何单词,相当于没有启用这个 Lua -# custom 自定义,只降低 words 里的 # (匹配的是编码,不是单词) reduce_english_filter: - mode: custom # all | none | custom + mode: custom # all | custom | none idx: 2 # 降低到第 idx 个位置 # 自定义的单词列表,示例列表没有降低部分常用单词,如 and cat mail Mac but bad shit …… words: [aid, ann, diff --git a/double_pinyin_ziguang.schema.yaml b/double_pinyin_ziguang.schema.yaml index 80c0d1d..db6f83c 100644 --- a/double_pinyin_ziguang.schema.yaml +++ b/double_pinyin_ziguang.schema.yaml @@ -120,12 +120,12 @@ corrector: "{comment}" # 正常情况: 输入 rug 得到 「1.rug 2.如果 …… 」 # 降低之后: 输入 rug 得到 「1.如果 2.rug …… 」 # 几种模式: -# all 降低所有 3~4 位长度、前 2~3 位是完整拼音、最后一位是声母的单词 +# all 降低脚本内置的单词(所有 3~4 位长度、前 2~3 位是完整拼音、最后一位是声母),words 作为自定义的额外补充 +# custom 完全自定义,只降低 words 里的 # none 不降低任何单词,相当于没有启用这个 Lua -# custom 自定义,只降低 words 里的 # (匹配的是编码,不是单词) reduce_english_filter: - mode: custom # all | none | custom + mode: custom # all | custom | none idx: 2 # 降低到第 idx 个位置 # 自定义的单词列表,示例列表没有降低部分常用单词,如 and cat mail Mac but bad shit …… words: [aid, ann, diff --git a/lua/reduce_english_filter.lua b/lua/reduce_english_filter.lua index 5fbd588..8df698c 100644 --- a/lua/reduce_english_filter.lua +++ b/lua/reduce_english_filter.lua @@ -1,6 +1,9 @@ -- 降低部分英语单词在候选项的位置 -- https://dvel.me/posts/make-rime-en-better/#短单词置顶的问题 -- 感谢大佬 @[Shewer Lu](https://github.com/shewer) 指点 +-- Mintimate 修改: +-- 1. 在不设置 mode 情况下,调整为默认全降模式(原本为 none 模式); +-- 2. all 会合并默认全降内容和自定义内容。 local M = {} @@ -35,17 +38,17 @@ function M.init(env) "pam", "pan", "pans", "pant", "pap", "par", "pat", "paw", "pax", "pay", "pens", "pic", "pier", "pies", "pig", "pin", "ping", "pink", "pins", "pint", "pit", "pix", "pod", "pop", "por", "pos", "pot", "pour", "pow", "pub", "put", "rand", "rang", "rank", "rant", "red", "rent", "rep", "res", "ret", "rex", "rib", "rid", "rig", "rim", - "rip", "rub", "rug", "ruin", "rum", "run", "runc", "runs", "sac", "sad", "said", "sail", "sal", "sam", "san", "sand", - "sang", "sans", "sap", "sat", "saw", "sax", "say", "sec", "send", "sent", "set", "sew", "sex", "sham", "shaw", - "shed", "shin", "ship", "shit", "shut", "sig", "sim", "sin", "sip", "sir", "sis", "sit", "six", "soul", "soup", - "sour", "sub", "suit", "sum", "sun", "sung", "suns", "sup", "sur", "sus", "tab", "tad", "tag", "tail", "taj", - "tan", "tang", "tank", "tap", "tar", "tax", "tec", "ted", "tel", "ten", "ter", "tex", "tic", "tied", "tier", - "ties", "tim", "tin", "tip", "tit", "tour", "tout", "tum", "wag", "wait", "wail", "wan", "wand", "womens", + "rip", "rub", "rug", "ruin", "rum", "run", "runc", "runs", "sac", "sad", "said", "sail", "sal", "sam", "san", + "sand", "sang", "sans", "sap", "sat", "saw", "sax", "say", "sec", "send", "sent", "set", "sew", "sex", "sham", + "shaw", "shed", "shin", "ship", "shit", "shut", "sig", "sim", "sin", "sip", "sir", "sis", "sit", "six", "soul", + "soup", "sour", "sub", "suit", "sum", "sun", "sung", "suns", "sup", "sur", "sus", "tab", "tad", "tag", "tail", + "taj", "tan", "tang", "tank", "tap", "tar", "tax", "tec", "ted", "tel", "ten", "ter", "tex", "tic", "tied", + "tier", "ties", "tim", "tin", "tip", "tit", "tour", "tout", "tum", "wag", "wait", "wail", "wan", "wand", "womens", "want", "wap", "war", "was", "wax", "way", "weir", "went", "won", "wow", "yan", "yang", "yen", "yep", "yes", "yet", "yin", "your", "yum", "zen", "zip", -- 下面是其他长度的 "quanx", "eg", - } + } M.all = {} for _, v in ipairs(all) do M.all[v] = true @@ -54,19 +57,23 @@ function M.init(env) -- 自定义 M.words = {} local list = config:get_list(env.name_space .. "/words") - for i = 0, list.size - 1 do + local listSize = list and list.size or 0 + for i = 0, listSize - 1 do local word = list:get_value_at(i).value M.words[word] = true end -- 模式 local mode = config:get_string(env.name_space .. "/mode") - if mode == "all" then - M.map = M.all - elseif mode == "custom" then + if mode == "custom" then M.map = M.words - else + elseif mode == "none" then M.map = {} + else -- 默认 mode 为 all 且合并 M.all 和 words + for key in pairs(M.words) do + M.all[key] = true + end + M.map = M.all end end diff --git a/rime_ice.schema.yaml b/rime_ice.schema.yaml index 10ceb1e..fe3a89f 100644 --- a/rime_ice.schema.yaml +++ b/rime_ice.schema.yaml @@ -109,12 +109,12 @@ corrector: "{comment}" # 正常情况: 输入 rug 得到 「1.rug 2.如果 …… 」 # 降低之后: 输入 rug 得到 「1.如果 2.rug …… 」 # 几种模式: -# all 降低所有 3~4 位长度、前 2~3 位是完整拼音、最后一位是声母的单词 +# all 降低脚本内置的单词(所有 3~4 位长度、前 2~3 位是完整拼音、最后一位是声母),words 作为自定义的额外补充 +# custom 完全自定义,只降低 words 里的 # none 不降低任何单词,相当于没有启用这个 Lua -# custom 自定义,只降低 words 里的 # (匹配的是编码,不是单词) reduce_english_filter: - mode: custom # all | none | custom + mode: custom # all | custom | none idx: 2 # 降低到第 idx 个位置 # 自定义的单词列表,示例列表没有降低部分常用单词,如 and cat mail Mac but bad shit …… words: [aid, ann,