Module:User:kc kennylau/sandbox
- The following documentation is located at Module:User:kc kennylau/sandbox/documentation. [edit] Categories were auto-generated by Module:documentation. [edit]
- Useful links: root page • root page’s subpages • links • transclusions • testcases • user page • user talk page • userspace
Lua error in Module:inflection_utilities at line 627: bad argument #1 to 'concat' (table expected, got string)
p={}
function p.show(frame)
local text = {}
local iut = require("Module:inflection utilities")
local lang = require("Module:languages").getByCode("la")
local multiword_spec = iut.parse_inflected_text("magn<us> homō<in>",
{
parse_indicator_spec = function(infl,stem)
mw.log("pis",word,spec)
return ({
us = {
type = 2,
subtype = "us",
stem = stem,
lemma = stem .. "us",
},
["in"] = {
type = 3,
lemma = stem,
obl = mw.ustring.gsub(stem,".$","in")},
})[infl]
end,
lang = lang,
split_bracketed_runs_into_words = function(br)
mw.log("br",mw.dumpObject(br))
return br
end,
allow_default_indicator = false,
angle_brackets_omittable = false,
allow_blank_lemma = false,
})
mw.log(multiword_spec)
iut.inflect_multiword_or_alternant_multiword_spec(multiword_spec,
{
slot_list = {{"nom-sg", "nom|sg"}, {"gen-sg", "gen|sg"}, {"acc-pl", "acc|pl"}},
lang = lang,
inflect_word_spec = function(word,infl_type)
mw.log("iws",word,infl_type)
end,
include_user_specified_links = false,
})
--[[
local forms = {}
iut.insert_form(forms, "acc_sg", {form = "carnem"})
iut.insert_form(forms, "gen_sg", {form = "carnis"})
iut.show_forms(forms,
{
lang = lang,
lemmas = {"carnis"},
slot_list = {{"acc_sg", "acc|sg"}, {"gen_sg", "gen|sg"}},
include_translit = false,
create_footnote_obj = nil,
canonicalize = nil,
transform_link = nil,
transform_accel_obj = nil,
join_spans = nil,
allow_footnote_symbols = false,
footnotes = nil,
})]]
table.insert(text, mw.dumpObject(multiword_spec))
return table.concat(text,'\n\n')
end
function p.test_lowercase(fs)
for _,f in ipairs(fs) do
local t1 = f("ABC[g]DEÉF")
local t2 = f("A[E]BC[g]D[h]EF[p]")
local t3 = f("A[E]BC[g]DEF[p]å^[!]")
mw.log(t1,t2,t3)
mw.log("abgdeéf","Ebghep","Ebgdepå!")
end
local s = ("ABCDE[e]"):rep(100)
p.test(fs,s)
end
function p.lowercase0(text)
return (text .. "A[a]")
:gsub("([^%[]*)[%z\1-Z\\^-\127\194-\244][\128-\191]*%[([^%]]+)%]",
function(a,b) return mw.ustring.lower(a)..b end)
:sub(1,-2)
end
function p.lowercase1(text)
local replacements = {}
local i = 1
local new_text = mw.ustring.gsub(text, "()%[([^%[%]])%]",
function(position, new)
replacements[position-i] = new
i = i + 3
return ""
end)
return mw.ustring.gsub(new_text, "()(.)",
function(position, char)
return replacements[position] or mw.ustring.lower(char)
end)
end
function p.lowercase2(text)
local replacements = {}
local offset = 0
local new_text = text:gsub("()%[([%z\1-Z\\^-\127\194-\244][\128-\191]*)%]",
function(position, new)
replacements[position-offset] = new
offset = offset + #new + 2
return ""
end)
return (new_text:gsub("([%z\1-\127\194-\244][\128-\191]*)()",
function(char, position)
return replacements[position] or mw.ustring.lower(char) -- char:lower()
end))
end
function p.lowercase3(text)
return text:gsub("([^%[%]]*)([%z\1-Z\\^-\127\194-\244][\128-\191]*)([%[%]]?)",
function(rest,char,instr)
if instr == "[" then return mw.ustring.lower(rest) end
if instr == "]" then return char end
return mw.ustring.lower(rest .. char)
end)
end
function p.lowercase4(text)
return text
:gsub("^(.+%])(.*)$",
function(a,b) return a..mw.ustring.lower(b) end)
:gsub("(.-)[%z\1-Z\\^-\127\194-\244][\128-\191]*%[([^%]]+)%]",
function(a,b) return mw.ustring.lower(a)..b end)
end
function p.test(fs, x)
local t = os.time()
while os.time() < t+1 do end
t = t + 2
for i,f in ipairs(fs) do
local j = 0
while os.time() < t do f(x) j = j + 1 end
mw.log(j)
t = t + 1
end
end
function p.link1(t)
t = mw.text.split(t, ' ', true)
for i=1,#t do
t[i] = '[[' .. t[i] .. ']]'
end
return table.concat(t, ' ')
end
function p.link2(t)
t = mw.ustring.gsub(t, '%s+', '[[%0]]')
return t
end
return p