Skip to content

Commit

Permalink
Pack up v2.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
forFudan committed Aug 29, 2023
1 parent f846062 commit 0904ddb
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions dist/yuhao/schema/lua/yuhao/yuhao_postpone_full_code.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
-- 版本: 20230103
-- 修改介紹:
-- 根據宇浩輸入法更新字根列表。
-- 只後置排名第一的簡碼字的全碼

local radstr = "也不亡尚穴韋甲屮丌鬼巛丶户用爪石非僉巳儿酉雨乃生马电豸馬囗禺了矛尸丅面食寸幺瓦壬足麻齒乙骨又米冊爿末西王古讠人毛世丨止母{shuxia}丰自艮士合禾曰广见上灬〇𬺰𠂤缶七牛卯刀文千扌瓜阝斤風气魚衤工厶龰欠攴宀彡見丂竹罒烏目至艹𠂇二丬已方兀一木之八且臣矢乚卩鸟犬牙弓疒糸向山匚{sui}戊{suw}廴夕土田黽丷凡貝饣鱼刂大豕弋亦门巾長示片車犭耳夫羽𧘇水飛亠黑未戈小礻火㗊虎爾三车𡗗辛鬥鹵冖口手氵辰言白虫尤心入高龶臼殳舟卜走立來鹿子辶彐纟丿身贝申皿其匕乌亍皮早十日而{nuyx}〢歹甫羊革夂予干亥隹月己丁彳咼钅力門女川长亻乂巴夭舌九几冂金厂由鳥𫝀⺄㇂丩⺶𠕁龴⻟𫩏𠂒〣冎髟ソ𠂎㇞⼌マ釒⼓丄𣥂𡈼𡿨⻍⺂ッ卄乀丆戶⻎訁⼹𫠠⺧𠃌コ䒑𰃦⺮氺卝戸匸𰁜⼁𩙿𠃊习乜忄𭕄㇍兀㐄𠂊𠥓勹冫丱乁𰀁𤣩爫⼅㇇⼂廾㇣㇈⺈𠘧𠀎𥫗㔾㇕㇀龷⺆凵Γ𠂉𫶧㇜耂ス㇒𦥑糹𡭔⺼攵⼃𰆊飠𠃎ユ⺊𥝌㇏⺍⾻乛⻗虍卅ュ㐅⻞⼶㇝卌𠁼⺬𠆢尢⺌⺁𠃍𠃋龵⺥㇉𧰨𠄌朩𠤎镸⼢牜亅㇅癶𠂆⻊巜𠄎𠃑𱼀𠃜⾅覀䶹キヰ⺋⺝𠘨⼫⺕夊𰀪⺩𠂭𧾷⺀"

local function init(env)
local config = env.engine.schema.config
local code_rvdb = config:get_string('schema_name/code')
env.code_rvdb = ReverseDb('build/' .. code_rvdb .. '.reverse.bin')
env.mem = Memory(env.engine, Schema(code_rvdb))
env.his_inp = config:get_string('history/input')
env.delimiter = config:get_string('speller/delimiter')
env.max_index = config:get_int('yuhao_postpone_full_code/lua/max_index')
Expand Down Expand Up @@ -49,11 +51,24 @@ local function has_short_and_is_full(cand, env)
-- history_translator 不后置。
if cand_input == env.his_inp then return end
local codestr = env.code_rvdb:lookup(cand_gen.text)
local is_comp = not
local is_first = true
if env.mem:dict_lookup(string.sub(codestr,1,3), false, 1) then
local count = 0
for entry in env.mem:iter_dict() do
count = count + 1
if entry.text == cand_gen.text then
break
end
end
if count > 1 then
is_first = false
end
end
local not_full = not
string.find(' ' .. codestr .. ' ', ' ' .. cand_input .. ' ', 1, true)
local short = not is_comp and get_short(codestr)
local short = not not_full and get_short(codestr)
-- 注意排除有简码但是输入的是不规则编码的情况
return short and cand_input:find('^' .. short .. '%l+'), is_comp
return short and is_first and cand_input:find('^' .. short .. '%l+'), not_full
end

local function filter(input, env)
Expand All @@ -76,9 +91,9 @@ local function filter(input, env)
-- 四码的位置,能消除这类候选。2) 顶功方案的造词翻译器允许出现的
-- completion 类型候选。3) 顶功方案的补空候选——全角空格( U+3000)。
local is_bad_script_cand = cand._end < context.caret_pos
local drop, is_comp = has_short_and_is_full(cand, env)
local drop, not_full = has_short_and_is_full(cand, env)
if pos >= env.max_index
or is_bad_script_cand or is_comp or cand.text == ' ' then
or is_bad_script_cand or not_full or cand.text == ' ' then
for i, cand in ipairs(dropped_cands) do yield(cand) end
done_drop = true
yield(cand)
Expand Down

0 comments on commit 0904ddb

Please sign in to comment.