Module:rad-stem/templates: Difference between revisions

ਕੋਈ ਸੋਧ ਸਾਰ ਨਹੀਂ
(Fixed issue with * interfering with ending regex)
No edit summary
 
(21 intermediate revisions by the same user not shown)
Line 181: Line 181:
local stem = args[1]
local stem = args[1]
local disable_ipa = args['noipa']
local disable_ipa = args['noipa']
local irregular = args["irr"] or args["irregular"] or mw.ustring.find(stem, "%*")
local irregular = args["irr"] or args["irregular"] or mw.ustring.find(stem or "", "%*")
if args[1] and args[2] ~= "adj" and args[2] ~= "adv" then error("Second parameter must be adj or adv") end
if args[1] and args[2] ~= "adj" and args[2] ~= "adv" then error("Second parameter must be adj or adv") end
Line 203: Line 203:
local irregular_title = ""
local irregular_title = ""
if irregular then irregular_title = " (''irregular''" .. irregular_icon .. ")" end
if irregular then irregular_title = ", ''irregular''" .. irregular_icon end
local type_title = (args[1] == nil and "periphrastic") or "inflected"
local function get_forms(ending, pre)
local function get_forms(ending, pre)
Line 220: Line 221:
add("<table class=\"blacklinks mw-collapsible mw-collapsed wikitable inflection table\" style=\"text-align: center\">")
add("<table class=\"blacklinks mw-collapsible mw-collapsed wikitable inflection table\" style=\"text-align: center\">")
tr()
tr()
th("Comparative forms of ''" .. lemma .. "''" .. irregular_title .. "&nbsp;",1,2)
th("Comparative forms of ''" .. lemma .. "'' (" .. type_title .. irregular_title .. ")&nbsp;",1,2)
_tr()
_tr()
th("degree")
th("degree")
Line 251: Line 252:
add("</table>")
add("</table>")
if irregular then
if irregular and not args['entry'] then
if pos == "adj" then
if pos == "adj" then
add("[[Category:Radestrian adjectives with irregular comparative forms]]")
add("[[Category:Radestrian adjectives with irregular comparative forms]]")
Line 267: Line 268:
local stem_gen = get_stems(args)
local stem_gen = get_stems(args)
local stems = {
local stems = {
nom = args['nom'] or stem_gen.nom,
nom = (args['nom'] == "*" and stem_gen.nom .. "*") or args['nom'] or stem_gen.nom,
voc = args['voc'] or stem_gen.voc,
voc = (args['voc'] == "*" and stem_gen.voc .. "*") or args['voc'] or stem_gen.voc,
acc = args['acc'] or stem_gen.acc,
acc = (args['acc'] == "*" and stem_gen.acc .. "*") or args['acc'] or stem_gen.acc,
dat = args['dat'] or stem_gen.dat,
dat = (args['dat'] == "*" and stem_gen.dat .. "*") or args['dat'] or stem_gen.dat,
gen = args['gen'] or stem_gen.gen,
gen = (args['gen'] == "*" and stem_gen.gen .. "*") or args['gen'] or stem_gen.gen,
ins = args['ins'] or stem_gen.ins,
ins = (args['ins'] == "*" and stem_gen.ins .. "*") or args['ins'] or stem_gen.ins,
nompl = args['nompl'] or stem_gen.nompl,
nompl = (args['nompl'] == "*" and stem_gen.nompl .. "*") or args['nompl'] or stem_gen.nompl,
genpl = args['genpl'] or stem_gen.genpl,
genpl = (args['genpl'] == "*" and stem_gen.genpl .. "*") or args['genpl'] or stem_gen.genpl,
genpl_short = args['genpl_short'] or stem_gen.genpl_short,
genpl_short = (args['genpl_short'] == "*" and stem_gen.genpl_short .. "*") or args['genpl_short'] or stem_gen.genpl_short,
anim = args['anim'] or stem_gen.anim,
anim = args['anim'] or stem_gen.anim,
['type'] = stem_gen['type'],
['type'] = stem_gen['type'],
Line 514: Line 515:
nom_cite = get_forms("nom", stems.nom, adj_broken_e, "", true)
nom_cite = get_forms("nom", stems.nom, adj_broken_e, "", true)
end
end
nom_cite = mw.ustring.gsub(nom_cite, "%*", "")
local voc = get_forms("voc", stems.voc, adj_broken_e)
local voc = get_forms("voc", stems.voc, adj_broken_e)
local gen = ""
local gen = ""
Line 538: Line 540:
local nompl_cite = get_forms("nompl", stems.nompl, adj_broken_e, "", true)
local nompl_cite = get_forms("nompl", stems.nompl, adj_broken_e, "", true)
local vocpl = get_forms("vocpl", stems.nompl, adj_broken_e)
local vocpl = get_forms("vocpl", stems.nompl, adj_broken_e)
local genpl = get_forms("genpl", stems.genpl .. "ris", adj, "eris")
local genpl = get_forms("genpl", mw.ustring.gsub(stems.genpl .. "ris", "sris$", "sis"), adj, "eris")
local genpl_short = get_forms("genpl_short", stems.genpl_short, adj, "es")
local genpl_short = get_forms("genpl_short", stems.genpl_short, adj, "es")
local datpl = get_forms("datpl", stems.genpl .. "rín", adj, "erín")
local datpl = get_forms("datpl", mw.ustring.gsub(stems.genpl .. "rín", "srín$", "sín"), adj, "erín")
local accpl = get_forms("accpl", stems.genpl .. "rid", adj, "erid")
local accpl = get_forms("accpl", mw.ustring.gsub(stems.genpl .. "rid", "srid$", "sid"), adj, "erid")
local inspl = get_forms("inspl", stems.genpl .. "ríe", adj, "eríe")
local inspl = get_forms("inspl", mw.ustring.gsub(stems.genpl .. "ríe", "sríe$", "síe"), adj, "eríe")
local nomdu = get_forms("nomdu", stems.dat .. "te", adj_broken_e)
local nomdu = get_forms("nomdu", stems.dat .. "te", adj_broken_e)
Line 560: Line 562:
local anim_acc = ""
local anim_acc = ""
local anim_ins = ""
local anim_ins = ""
local def_stem = ""
if table_type == "adj" then
if table_type == "adj" then
inan = get_forms("inan", stems.anim, adj_broken_e)
def_stem = mw.ustring.gsub(stems.anim, "oș$", "ûș")
anim = get_forms("anim", stems.anim .. "e", adj_broken_e)
inan = get_forms("inan", mw.ustring.gsub(stems.anim, "oș$", "uș"), adj_broken_e)
anim = get_forms("anim", def_stem .. "e", adj_broken_e)
anim_gen = get_forms("anim_gen", stems.anim .. "esk", adj, "esk")
anim_gen = get_forms("anim_gen", stems.anim .. "esk", adj, "esk")
anim_dat = get_forms("anim_dat", stems.anim .. "en", adj, "en")
anim_dat = get_forms("anim_dat", stems.anim .. "en", adj, "en")
Line 573: Line 577:
th("Emphatic combined forms with the definite article", 1, 6)
th("Emphatic combined forms with the definite article", 1, 6)
_tr()
_tr()
th("inanimate", 2, 1)
th("singular", 1, 2)
th("animate", 1, 2)
th("plural", 2, 1)
th("+ " .. rad_link("a"), 2)
th("+ " .. rad_link("a"), 2)
th("+ " .. rad_link("a'"), 2)
th("+ " .. rad_link("a'"), 2)
Line 582: Line 586:
th("+ " .. rad_link("u"), 2)
th("+ " .. rad_link("u"), 2)
_tr()
_tr()
th("definite")
th("inanimate")
th("indefinite")
th("animate")
_tr()
_tr()
td(inan, 1, 2)
td(inan)
td(anim)
td(anim, 1, 2)
td(get_forms("anim", stems.anim .. "a", adj_broken_e))
td(get_forms("anim", def_stem .. "a", adj_broken_e))
td(get_forms("anim", stems.anim .. "a'", adj_broken_e))
td(get_forms("anim", def_stem .. "a'", adj_broken_e))
td(get_forms("anim", stems.anim .. "ag", adj_broken_e))
td(get_forms("anim", def_stem .. "ag", adj_broken_e))
td(get_forms("anim", stems.anim .. "ai", adj_broken_e))
td(get_forms("anim", def_stem .. "ai", adj_broken_e))
td(get_forms("anim", stems.anim .. "i", adj_broken_e))
td(get_forms("anim", def_stem .. "i", adj_broken_e))
td(get_forms("anim", stems.anim .. "u", adj_broken_e))
td(get_forms("anim", def_stem .. "u", adj_broken_e))
tr_()
tr_()
add("</table>")
add("</table>")
end
end
if table_type == "adjn" then table_type = "adj" end


add("<table class=\"blacklinks mw-collapsible mw-collapsed wikitable inflection table\" style=\"text-align: center\">")
add("<table class=\"blacklinks mw-collapsible mw-collapsed wikitable inflection table\" style=\"text-align: center\">")
Line 668: Line 674:
tr_()
tr_()
elseif table_type == "sg" then
elseif table_type == "sg" then
local sg_title = "Declension of <i>" .. nom_cite .. "</i> (" .. type_name .. ", ''[[:Category:Radestrian singularia tantum|singulare tantum]]''" .. irregular_title .. ") &nbsp;"
if definite then
if definite then
th("Declension of <i>" .. nom_cite .. "</i> (" .. type_name .. irregular_title .. ") &nbsp;", 1, 3)
th(sg_title, 1, 3)
tr()
tr()
th("", 1, 2)
th("", 1, 2)
Line 697: Line 704:
tr_()
tr_()
else
else
th("Declension of <i>" .. nom_cite .. "</i> (" .. type_name .. irregular_title .. ") &nbsp;", 1, 2)
th(sg_title, 1, 2)
tr()
tr()
th("")
th("")
Line 722: Line 729:
end
end
elseif table_type == "pl" then
elseif table_type == "pl" then
th("Declension of <i>" .. nompl_cite .. "</i> (" .. type_name .. irregular_title .. ") &nbsp;", 1, 3)
th("Declension of <i>" .. nompl_cite .. "</i> (" .. type_name .. ", ''[[:Category:Radestrian pluralia tantum|plurale tantum]]''" .. irregular_title .. ") &nbsp;", 1, 3)
tr()
tr()
th("", 1, 2)
th("", 1, 2)
Line 750: Line 757:
tr_()
tr_()
elseif table_type == "du" then
elseif table_type == "du" then
th("Declension of <i>" .. nom_cite .. "</i> (" .. type_name .. irregular_title .. ") &nbsp;", 1, 5)
th("Declension of <i>" .. nom_cite .. "</i> (" .. type_name .. ", ''[[:Category:Radestrian pluralia binaria|cum plurali binario]]''" .. irregular_title .. ") &nbsp;", 1, 5)
tr()
tr()
th("", 2, 2)
th("", 2, 2)
Line 780: Line 787:
_tr()
_tr()
th("constructive")
th("constructive")
if not (definite or adj) then td(gendu_short) end
td(genpl_short)
td(genpl_short)
_tr()
_tr()
Line 799: Line 805:
tr_()
tr_()
elseif table_type == "dupl" and (definite or adj) then
elseif table_type == "dupl" and (definite or adj) then
th("Declension of <i>" .. nomdu_cite .. "</i> (" .. type_name .. irregular_title .. ") &nbsp;", 1, 3)
th("Declension of <i>" .. nomdu_cite .. "</i> (" .. type_name .. ", ''[[:Category:Radestrian pluralia binaria tantum|plurale binarium tantum]]''" .. irregular_title .. ") &nbsp;", 1, 3)
tr()
tr()
th("", 1, 2)
th("", 1, 2)
Line 827: Line 833:
tr_()
tr_()
elseif table_type == "dupl" then
elseif table_type == "dupl" then
th("Declension of <i>" .. nomdu_cite .. "</i> (" .. type_name .. irregular_title .. ") &nbsp;", 1, 2)
th("Declension of <i>" .. nomdu_cite .. "</i> (" .. type_name .. ", ''[[:Category:Radestrian pluralia binaria tantum|plurale binarium tantum]]''" .. irregular_title .. ") &nbsp;", 1, 2)
tr()
tr()
th("")
th("")
Line 863: Line 869:
end
end
if definite then add("[[Category:Radestrian definite terms]]") end
if definite then add("[[Category:Radestrian definite terms]]") end
if irregular then add("[[Category:Radestrian irregular nouns]]") end
end
end
if irregular then add("[[Category:Radestrian irregular nouns]]") end
return table.concat(format_table, string.char(10))
return table.concat(format_table, string.char(10))
Line 970: Line 975:
local function get_forms(stem, ending, regex1, regex2, regex3, regex4, regex5, regex6)
local function get_forms(stem, ending, regex1, regex2, regex3, regex4, regex5, regex6)
if mw.ustring.find(stem, "%*") then
stem = "*" .. mw.ustring.gsub(stem, "%*", "")
end
local temp = {}
local temp = {}
local post = ""
local post = ""
Line 997: Line 999:
if type(stem) == "table" then
if type(stem) == "table" then
for i, form in ipairs(stem) do
for i, form in ipairs(stem) do
if mw.ustring.find(form['word'], "%*") then
form['word'] = "*" .. mw.ustring.gsub(form['word'], "%*", "")
end
temp[i] = {['word'] = mw.ustring.gsub(form['word'] .. ending, regex1, regex2), ['note'] = form['note']}
temp[i] = {['word'] = mw.ustring.gsub(form['word'] .. ending, regex1, regex2), ['note'] = form['note']}
temp[i]['word'] = mw.ustring.gsub(temp[i]['word'], regex3, regex4)
temp[i]['word'] = mw.ustring.gsub(temp[i]['word'], regex3, regex4)
Line 1,012: Line 1,017:
temp = new_temp
temp = new_temp
elseif type(stem) == "string" then
elseif type(stem) == "string" then
if mw.ustring.find(stem, "%*") then
stem = "*" .. mw.ustring.gsub(stem, "%*", "")
end
temp = mw.ustring.gsub(stem .. ending, regex1, regex2)
temp = mw.ustring.gsub(stem .. ending, regex1, regex2)
temp = mw.ustring.gsub(temp, regex3, regex4)
temp = mw.ustring.gsub(temp, regex3, regex4)
Line 1,296: Line 1,304:
th("connegative", 1, 3)
th("connegative", 1, 3)
if cite == "vat" or cite == "hjeat" then
if cite == "vat" or cite == "hjeat" then
th("copular verbs do not have connegatives", 1, 11)
th("''" .. cite .. "'' does not have a connegative", 1, 11)
else
else
td(get_forms(pp.inf,"a","([^a])uta$","%1ûta"), 1, 11)
td(get_forms(pp.inf,"a","([^a])uta$","%1ûta"), 1, 11)
Line 2,443: Line 2,451:
end
end
add("</small>")
add("</small>")
if irregular then add("[[Category:Radestrian irregular verbs]]") end
if irregular and not args['entry'] then add("[[Category:Radestrian irregular verbs]]") end
local function check_stems()
local function check_stems()
Line 2,539: Line 2,547:
table.insert(review, "* <code>EPST</code>: '''" .. pp.pst .. "e'''" .. endings['epst'])
table.insert(review, "* <code>EPST</code>: '''" .. pp.pst .. "e'''" .. endings['epst'])
end
end
end
for i, term in ipairs(review) do
review[i] = mw.ustring.gsub(term, "(%'%'%'%S*)%*(%S*)", "%1%2" .. irregular_icon)
end
end
table.sort(review, function(a,b) return a < b end)
table.sort(review, function(a,b) return a < b end)
Line 2,587: Line 2,598:
local function governs(case)
local function governs(case)
return m_government.generate({case})
return m_government.show{"&" .. case}
end
end