-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrime.lua
74 lines (69 loc) · 1.81 KB
/
rime.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
--- 过滤器:最长词组和单字在先
function long_phrase_first(input)
local l = {}
local s = {}
local c = {}
local max = 1
for cand in input:iter() do
if (utf8.len(cand.text) > max) then
max = utf8.len(cand.text)
end
if (utf8.len(cand.text) == 1) then
table.insert(c, cand)
elseif (utf8.len(cand.text) < max) then
table.insert(s, cand)
else
table.insert(l, cand)
end
end
for i, cand in ipairs(l) do
yield(cand)
end
for i, cand in ipairs(c) do
yield(cand)
end
for i, cand in ipairs(s) do
yield(cand)
end
end
--- 过滤器:单字在先
function single_char_first(input)
local l = {}
for cand in input:iter() do
if (utf8.len(cand.text) == 1) then
yield(cand)
else
table.insert(l, cand)
end
end
for i, cand in ipairs(l) do
yield(cand)
end
end
--- 过滤器:只显示单字
function single_char_only(input)
for cand in input:iter() do
if (utf8.len(cand.text) == 1) then
yield(cand)
end
end
end
-- select_character_processor: 以词定字
-- 详见 `lua/select_character.lua`
select_character_processor = require("select_character")
-- date_translator: 动态日期时间输入
-- 详见 `lua/date_translator.lua`
date_translator = require("date_translator")
date_time_translator = require("date_time")
xkjd6_filter = require("xkjd6_filter")
topup_processor = require("for_topup")
smart_2 = require("smart_2")
number_translator = require("xnumber")
-- melt_eng
local M= require("melt")
get_date = M.getdate
jpcharset_filter = M.jpcharsetfilter
long_word_filter = M.longwordfilter
autocap_filter =M.autocapfilter
oo_processor = M.ooprocessor
oo_filter =M.oofilter