全站通知:
模块:文本处理
刷
历
编
跳到导航
跳到搜索
此模块的文档可以在模块:文本处理/doc创建
local p={}
--替换文本中的中文逗号为英文逗号, 以用来筛选
p["替换中文逗号"]=function(frame)
local text_en = frame.args["text"]
text_en = text_en:gsub(',',',')
text_en = text_en:gsub(':',',')
text_en = text_en:gsub(';',',')
frame:callParserFunction{name='#vardefine',args={"文本",text_en}}
--mw.log("文本:",text_en)
return
end
p["速查触发条件"]=function(frame)
local text_en = frame.args["text"]
local condition = ""
local con_table = {"直线","弯道","序盘 ","中盘","终盘","最终直线","最终弯道","最后冲刺"}
local is_first = true
for k,con in ipairs(con_table) do
if(string.find(text_en, con))then
if is_first then
condition = condition .. con
is_first = false
else
condition = condition .. ',' .. con
end
end
end
frame:callParserFunction{name='#vardefine',args={"条件",condition}}
end
--用英文逗号分割比赛时间, 以用来筛选
p["分割比赛时间"]=function(frame)
local time_gec = frame.args["time"]
time_gec = time_gec:gsub('年','年,')
time_gec = time_gec:gsub('月','月,')
time_gec = time_gec:gsub('、',',')
frame:callParserFunction{name='#vardefine',args={"时间",time_gec}}
return
end
p["比赛备注"]=function(frame)
local text_gec = frame.args["text"]
text_gec = text_gec:gsub('マイル','マイル,春秋マイル')
text_gec = text_gec:gsub('ダート','ダート,春秋ダート')
text_gec = text_gec:gsub('グランプリ','グランプリ,春秋グランプリ')
text_gec = text_gec:gsub('スプリント','スプリント,春秋スプリント')
if(text_gec == "")then
text_gec = "1"
end
frame:callParserFunction{name='#vardefine',args={"备注",text_gec}}
--mw.log("备注:",text_gec)
return
end
p["繁中比赛备注"]=function(frame)
local text_gec = frame.args["text"]
text_gec = text_gec:gsub('一哩賽','一哩賽,春秋一哩賽')
text_gec = text_gec:gsub('沙地賽','沙地賽,春秋沙地賽')
text_gec = text_gec:gsub('大獎賽','大獎賽,春秋大獎賽')
text_gec = text_gec:gsub('短途賽','短途賽,春秋短途賽')
if(text_gec == "")then
text_gec = "1"
end
frame:callParserFunction{name='#vardefine',args={"备注",text_gec}}
--mw.log("备注:",text_gec)
return
end
p["简中比赛备注"]=function(frame)
local text_gec = frame.args["text"]
text_gec = text_gec:gsub('英里赛','英里赛,春秋英里赛')
text_gec = text_gec:gsub('泥地赛','泥地赛,春秋泥地赛')
text_gec = text_gec:gsub('大奖赛','大奖赛,春秋大奖赛')
text_gec = text_gec:gsub('短距离赛','短距离赛,春秋短距离赛')
if(text_gec == "")then
text_gec = "1"
end
frame:callParserFunction{name='#vardefine',args={"备注",text_gec}}
--mw.log("备注:",text_gec)
return
end
return p