diff --git a/lua/super_english.lua b/lua/super_english.lua index 1846a88..1d62b89 100644 --- a/lua/super_english.lua +++ b/lua/super_english.lua @@ -423,11 +423,11 @@ function F.func(input, env) for cand in input:iter() do local good_cand = restore_sentence_spacing(cand, env.split_pattern, env.delim_check_pattern) local fmt_cand = apply_formatting(good_cand, code_ctx) - local is_ascii = is_ascii_phrase_fast(fmt_cand.text) - + local is_ascii = is_ascii_phrase_fast(good_cand.text) local is_tbl = is_table_type(cand) - -- table/fixed 类型会先输出,直到遇到第一个 completion类型前,插入单字母 + -- [策略1]:如果是普通词(completion),还没输出单字母,则“插队”到它前面 + -- 场景:无高频词时,输出 A, a, able... if not single_char_injected and is_ascii and #single_chars > 0 and not is_tbl then if not best_candidate_saved then env.memory[curr_input] = { text = single_chars[1].text, preedit = single_chars[1].text } @@ -442,7 +442,6 @@ function F.func(input, env) if not is_garbage then has_valid_candidate = true - -- 如果处于拦截状态,就不要把脏数据写进内存了 if not best_candidate_saved and cand.comment ~= "~" and not env.block_derivation then env.memory[curr_input] = { text = fmt_cand.text, @@ -451,16 +450,20 @@ function F.func(input, env) best_candidate_saved = true end end + yield(fmt_cand) - end - if not single_char_injected and #single_chars > 0 then - if not best_candidate_saved then - env.memory[curr_input] = { text = single_chars[1].text, preedit = single_chars[1].text } - best_candidate_saved = true + -- [策略2]:如果是用户词(user_table/fixed),且还没输出单字母,则“紧随”其后输出 + -- 场景:有高频词时,输出 AA, A, a, AB... + if not single_char_injected and is_ascii and #single_chars > 0 and is_tbl then + if not best_candidate_saved then + env.memory[curr_input] = { text = single_chars[1].text, preedit = single_chars[1].text } + best_candidate_saved = true + end + for _, c in ipairs(single_chars) do yield(c) end + single_char_injected = true + has_valid_candidate = true end - for _, c in ipairs(single_chars) do yield(c) end - has_valid_candidate = true end -- [Phase 3] 构造补全 diff --git a/wanxiang_english.schema.yaml b/wanxiang_english.schema.yaml index a4eb5ad..8807169 100755 --- a/wanxiang_english.schema.yaml +++ b/wanxiang_english.schema.yaml @@ -31,8 +31,10 @@ engine: - fallback_segmentor translators: - table_translator + - table_translator@wanxiang_english #英文词汇表导入 - punct_translator filters: + - lua_filter@*auto_phrase - lua_filter@*super_english - uniquifier @@ -42,12 +44,9 @@ speller: algebra: __include: wanxiang_algebra:/english/通用规则 __patch: wanxiang_algebra:/english/全拼 #可选的选项有(全拼, 自然码, 小鹤双拼, 微软双拼, 搜狗双拼, 智能ABC, 紫光双拼, 拼音加加) - translator: dictionary: wanxiang_english - user_dict: en - enable_completion: true - enable_sentence: true + enable_user_dict: false initial_quality: 2 comment_format: - xform/^~.+$// @@ -58,9 +57,16 @@ recognizer: import_preset: default wanxiang_english: + dictionary: wanxiang_english + user_dict: en + enable_completion: true + enable_sentence: true + initial_quality: 3 + comment_format: #这里很重要如果残留带声调字母,剩余编码提示计算出错引发程序崩溃 + - xform/^~.+$// #英文自动加空格,除关闭外共有3种模式可供选择 #off: 关闭; before: 总是前加; after: 总是后加; #smart: 智能模式连续输入英文时第二个单词前开始加空格,非输入状态的回车与空格都能打断加空格状态 #支持设置延时销毁加空格状态,单位秒,0不超时,大于0为超时时间,极大的保证了连续输入的体验。 english_spacing: smart - spacing_timeout: 5 + spacing_timeout: 5 \ No newline at end of file