diff --git a/lua/corrector.lua b/lua/corrector.lua index d6ef01a..38c6b76 100644 --- a/lua/corrector.lua +++ b/lua/corrector.lua @@ -7,7 +7,7 @@ 为了让这个 Lua 同时适配全拼与双拼,使用 `spelling_hints` 生成的 comment(全拼拼音)作为通用的判断条件。 感谢大佬@[Shewer Lu](https://github.com/shewer)提供的思路。 - + 容错词在 cn_dicts/others.dict.yaml 中,有新增建议可以提个 issue --]] diff --git a/lua/en_spacer.lua b/lua/en_spacer.lua index 2f3d00b..827f05f 100644 --- a/lua/en_spacer.lua +++ b/lua/en_spacer.lua @@ -1,6 +1,5 @@ -- 英文词条上屏自动添加空格 -- 在 engine/filters 的倒数第二个位置,增加 - lua_filter@*en_spacer --- -- 英文后,再输入英文单词(必须为候选项)自动添加空格 local F = {} diff --git a/lua/number_translator.lua b/lua/number_translator.lua index d21b89d..1f75ec7 100644 --- a/lua/number_translator.lua +++ b/lua/number_translator.lua @@ -63,8 +63,6 @@ end -- 数值转换为中文 local function number2cnChar(num, flag, digitUnit, wordFigure) --flag=0中文小写反之为大写 - local result = "" - if tonumber(flag) < 1 then digitUnit = digitUnit or { [1] = "万", [2] = "亿" } wordFigure = wordFigure or { [1] = "〇", [2] = "一", [3] = "十", [4] = "元" } @@ -73,6 +71,7 @@ local function number2cnChar(num, flag, digitUnit, wordFigure) --flag=0中文小 wordFigure = wordFigure or { [1] = "零", [2] = "壹", [3] = "拾", [4] = "元" } end local lens = string.len(num) + local result if lens < 5 then result = formatNum(num, flag) elseif lens < 9 then diff --git a/lua/pin_cand_filter.lua b/lua/pin_cand_filter.lua index 7e8a06f..70d9a88 100644 --- a/lua/pin_cand_filter.lua +++ b/lua/pin_cand_filter.lua @@ -126,9 +126,9 @@ function M.init(env) -- 额外处理包含空格的 preedit,增加最后一个拼音的首字母和 zh, ch, sh 的简码 if preedit:find(" ") then local preceding_part, last_part = preedit:match("^(.+)%s(%S+)$") - local p1, p2 = "", "" + local p2 = "" -- p1 生成最后一个拼音的首字母简码拼写(最后一个空格后的首字母),如 ni hao 生成 nih - p1 = preceding_part:gsub(" ", "") .. last_part:sub(1, 1) + local p1 = preceding_part:gsub(" ", "") .. last_part:sub(1, 1) -- p2 生成最后一个拼音的 zh, ch, sh 的简码拼写(最后一个空格后以 zh ch sh 开头),如 zhi chi 生成 zhich if last_part:match("^[zcs]h") then p2 = preceding_part:gsub(" ", "") .. last_part:sub(1, 2) diff --git a/lua/search.lua b/lua/search.lua index d8515d9..5600930 100755 --- a/lua/search.lua +++ b/lua/search.lua @@ -45,9 +45,7 @@ local function update_dict_entry( s, code, mem, proj ) local code_convert = code:sub( i, i + 1 ) local p = proj:apply( code_convert, true ) if p and #p > 0 then code_convert = p end - if code_convert == 'dian' and pos[loop] then - -- Ignored - else + if code_convert ~= 'dian' or not pos[loop] then table.insert( custom_code, code_convert ) end loop = loop + 1 @@ -283,12 +281,12 @@ function f.func( input, env ) end -- 上屏其余的候选 - for i, cand in ipairs( long_word_cands ) do yield( cand ) end - if env.show_other_cands then for i, cand in ipairs( other_cand ) do yield( cand ) end end + for _, cand in ipairs( long_word_cands ) do yield( cand ) end + if env.show_other_cands then for _, cand in ipairs( other_cand ) do yield( cand ) end end end function f.tags_match( seg, env ) - for i, v in ipairs( env.tag ) do if seg.tags[v] then return true end end + for _, v in ipairs( env.tag ) do if seg.tags[v] then return true end end return false end diff --git a/lua/select_character.lua b/lua/select_character.lua index 55c9769..1e3021c 100644 --- a/lua/select_character.lua +++ b/lua/select_character.lua @@ -28,7 +28,7 @@ function select.func(key, env) local selected_candidate = context:get_selected_candidate() selected_candidate = selected_candidate and selected_candidate.text or input - local selected_char = "" + local selected_char if (key:repr() == env.first_key) then selected_char = selected_candidate:sub(1, utf8.offset(selected_candidate, 2) - 1) elseif (key:repr() == env.last_key) then diff --git a/lua/unicode.lua b/lua/unicode.lua index d318654..8506182 100644 --- a/lua/unicode.lua +++ b/lua/unicode.lua @@ -26,8 +26,8 @@ local function unicode(input, seg, env) yield(Candidate("unicode", seg.start, seg._end, text, string.format("U%x", code))) if code < 0x10000 then for i = 0, 15 do - local text = utf8.char(code * 16 + i) - yield(Candidate("unicode", seg.start, seg._end, text, string.format("U%x~%x", code, i))) + local next_text = utf8.char(code * 16 + i) + yield(Candidate("unicode", seg.start, seg._end, next_text, string.format("U%x~%x", code, i))) end end end