From 2536a6b52c2e1866a025c7b0070d3ada9ab24b7f Mon Sep 17 00:00:00 2001 From: Dvel Date: Tue, 3 Jan 2023 02:48:02 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20Unicode=20=E8=BE=93=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rime.lua | 18 +++++++++++++++++- rime_ice.schema.yaml | 6 ++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/rime.lua b/rime.lua index e85f811..254164b 100755 --- a/rime.lua +++ b/rime.lua @@ -154,7 +154,6 @@ function long_word_filter(input, env) local count = config:get_string(env.name_space .."/count") or 2 local idx = config:get_string(env.name_space .."/idx") or 4 - local l = {} local firstWordLength = 0 -- 记录第一个候选词的长度,提前的候选词至少要比第一个候选词长 -- local s1 = 0 -- 记录筛选了多少个英语词条(只提升 count 个词的权重,并且对comment长度过长的候选进行过滤) @@ -247,3 +246,20 @@ function code_length_limit_processor(key, env) return 2 end ------------------------------------------------------------- +-- Unicode 输入 +-- 复制自: https://github.com/shewer/librime-lua-script/blob/main/lua/component/unicode.lua +function unicode(input, seg, env) + local ucodestr = seg:has_tag("unicode") and input:match("U(%x+)") + if ucodestr and #ucodestr > 1 then + local code = tonumber(ucodestr, 16) + local text = utf8.char(code) + yield(Candidate("unicode", seg.start, seg._end, text, string.format("U%x", code))) + if #ucodestr < 5 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))) + end + end + end +end +------------------------------------------------------------- diff --git a/rime_ice.schema.yaml b/rime_ice.schema.yaml index 2a0b76c..673c9cd 100755 --- a/rime_ice.schema.yaml +++ b/rime_ice.schema.yaml @@ -6,7 +6,7 @@ schema: schema_id: rime_ice name: 雾凇拼音 - version: "1.0.6" + version: "1.1.0" author: - Dvel description: | @@ -65,6 +65,7 @@ engine: - table_translator@custom_phrase # 自定义短语 custom_phrase.txt - table_translator@melt_eng # 英文输入 - reverse_lookup_translator@liangfen # 反查,两分拼字 + - lua_translator@unicode # Unicode filters: - lua_filter@long_word_filter # 长词优先 - simplifier@emoji # Emoji @@ -109,7 +110,7 @@ traditionalize: option_name: traditionalization opencc_config: s2t.json # s2t.json | s2hk.json | s2tw.json | s2twp.json tips: all # 转换提示: all 都显示 | char 仅单字显示 | none 不显示。 - excluded_types: [ reverse_lookup ] # 不转换反查的内容 + excluded_types: [ reverse_lookup ] # 不转换反查(两分拼字)的内容 # 自定义短语:custom_phrase.txt @@ -172,6 +173,7 @@ recognizer: # punct: "^/([0-9]+[a-z]*|[a-z]+)$" # 响应默认的 punctuation/symbols 的「/」开头的字符 punct: "^v([0-9]|10|[A-Za-z]+)$" # 响应 symbols_custom.yaml 下的 punctuator/symbols,用「v」替换「/」并支持大写 reverse_lookup: "^u[a-z]+$" # 响应两分的反查 + unicode: "^U[a-f0-9]+" # 响应 Unicode # 反查:两分(拼字)