Module:jugs-cell: Difference between revisions

From Linguifex
Jump to navigation Jump to search
Wfeozawra (talk | contribs)
No edit summary
Tag: Reverted
Wfeozawra (talk | contribs)
No edit summary
(34 intermediate revisions by the same user not shown)
Line 1: Line 1:
local m_links = require("Module:links")
local lang = require("Module:languages").getByCode("non")
local export = {}
local export = {}


local accel_forms = {
local accel_forms = {
--NOUNS
--NEUTRALS
nsi = "nom|s",
nsi = "nom|s",
nsd = "def|nom|s",
nsd = "def|nom|s",
Line 40: Line 38:
gpd_la = "def|gen|p|la",
gpd_la = "def|gen|p|la",
--PEJORATIVES
nsi_pej = "nom|s|pej",
nsd_pej = "def|nom|s|pej",
npi_pej = "nom|p|pej",
npd_pej = "def|nom|p|pej",
asi_pej = "acc||pej",
asd_pej = "def|acc|s|pej",
api_pej = "acc|p|pej",
apd_pej = "def|acc|p|pej",
dsi_pej = "dat|s|pej",
dsd_pej = "def|dat|s|pej",
dpi_pej = "dat|p|pej",
dpd_pej = "def|dat|p|pej",
gsi_pej = "gen|s|pej",
gs_pejd = "def|gen|s|pej",
gpi_pej = "gen|p|pej",
gpd_pej = "def|gen|p|pej",
--VERBS
-- Active
pres_inf = "act|pres|inf",
past_inf = "act|past|inf",
pres_part = "act|pres|part",
past_part = "act|past|part",
pres_ind_1sg = "1|s|pres|act|ind",
pres_ind_2sg = "2|s|pres|act|ind",
pres_ind_3sg = "3|s|pres|act|ind",
pres_ind_1pl = "1|p|pres|act|ind",
pres_ind_2pl = "2|p|pres|act|ind",
pres_ind_3pl = "3|p|pres|act|ind",
past_ind_1sg = "1|s|past|act|ind",
past_ind_2sg = "2|s|past|act|ind",
past_ind_3sg = "3|s|past|act|ind",
past_ind_1pl = "1|p|past|act|ind",
past_ind_2pl = "2|p|past|act|ind",
past_ind_3pl = "3|p|past|act|ind",
pres_sub_1sg = "1|s|pres|act|sub",
pres_sub_2sg = "2|s|pres|act|sub",
pres_sub_3sg = "3|s|pres|act|sub",
pres_sub_1pl = "1|p|pres|act|sub",
pres_sub_2pl = "2|p|pres|act|sub",
pres_sub_3pl = "3|p|pres|act|sub",
past_sub_1sg = "1|s|past|act|sub",
past_sub_2sg = "2|s|past|act|sub",
past_sub_3sg = "3|s|past|act|sub",
past_sub_1pl = "1|p|past|act|sub",
past_sub_2pl = "2|p|past|act|sub",
past_sub_3pl = "3|p|past|act|sub",
imp = "act|imp",
-- Mediopassive
mp_pres_inf = "mp|pres|inf",
mp_past_inf = "mp|past|inf",
mp_pres_part = "mp|pres|part",
mp_past_part = "mp|past|part",
mp_pres_ind_1sg = "1|s|pres|mp|ind",
mp_pres_ind_2sg = "2|s|pres|mp|ind",
mp_pres_ind_3sg = "3|s|pres|mp|ind",
mp_pres_ind_1pl = "1|p|pres|mp|ind",
mp_pres_ind_2pl = "2|p|pres|mp|ind",
mp_pres_ind_3pl = "3|p|pres|mp|ind",
mp_past_ind_1sg = "1|s|past|mp|ind",
mp_past_ind_2sg = "2|s|past|mp|ind",
mp_past_ind_3sg = "3|s|past|mp|ind",
mp_past_ind_1pl = "1|p|past|mp|ind",
mp_past_ind_2pl = "2|p|past|mp|ind",
mp_past_ind_3pl = "3|p|past|mp|ind",
mp_pres_sub_1sg = "1|s|pres|mp|sub",
mp_pres_sub_2sg = "2|s|pres|mp|sub",
mp_pres_sub_3sg = "3|s|pres|mp|sub",
mp_pres_sub_1pl = "1|p|pres|mp|sub",
mp_pres_sub_2pl = "2|p|pres|mp|sub",
mp_pres_sub_3pl = "3|p|pres|mp|sub",
mp_past_sub_1sg = "1|s|past|mp|sub",
mp_past_sub_2sg = "2|s|past|mp|sub",
mp_past_sub_3sg = "3|s|past|mp|sub",
mp_past_sub_1pl = "1|p|past|mp|sub",
mp_past_sub_2pl = "2|p|past|mp|sub",
mp_past_sub_3pl = "3|p|past|mp|sub",
mp_impr = "mp|imp",
}
}
function export.create(frame)
local args = frame.args


local data = { forms = {} }
local mode_prefix = { --this is prefixed to the index value in accel_forms
mpass  = "mp_"
}


local function showForm(case, number)
local mode_prepend = { --on the other hand, this is prefixed to the accelerated text itself
local key = cases[case].short_form .. "-" .. number
wk      = "weak|",
return data.forms[key] or ""
str    = "strong|",
end
comp    = "comparative|",
wk_sup  = "weak|superlative|",
str_sup = "strong|superlative|"
}


local function small(text)
return frame:preprocess("{{small|" .. text .. "}}")
end


function export.create(frame)
local args = frame:getParent().args
local out = {}
local out = {}
table.insert(out, '{| class="wikitable" style="text-align:center;"')
if not args[1] or args[1] == "" then
table.insert(out, '|-')
return ""
table.insert(out, '! Number !! Case !! Declension')
else
 
local accel_form = args[2]
-- Singular rows
local accel
table.insert(out, '|-')
if accel_form then
table.insert(out, '! rowspan=4 | Singular')
local mode = args[3]
table.insert(out, '! ' .. small("nom."))
if mode and mode_prefix[mode] then
table.insert(out, '| ' .. showForm("nominative", "sg"))
accel_form = mode_prefix[mode] .. accel_form
 
end
table.insert(out, '|-')
if accel_forms[accel_form] then
table.insert(out, '! ' .. small("acc."))
if mode and mode_prepend[mode] then
table.insert(out, '| ' .. showForm("accusative", "sg"))
accel_form = mode_prepend[mode] .. accel_forms[accel_form]
 
else
table.insert(out, '|-')
accel_form = accel_forms[accel_form]
table.insert(out, '! ' .. small("dat."))
end
table.insert(out, '| ' .. showForm("dative", "sg"))
end
 
accel = {form = accel_form}
table.insert(out, '|-')
end
table.insert(out, '! ' .. small("gen."))
local words = mw.text.split(args[1], "%s*,%s*")
table.insert(out, '| ' .. showForm("genitive", "sg"))
if words then
 
for i,j in ipairs(words) do
-- Plural rows
table.insert(out, args[1])
table.insert(out, '|-')
end
table.insert(out, '! rowspan=4 | Plural')
end
table.insert(out, '! ' .. small("nom."))
end
table.insert(out, '| ' .. showForm("nominative", "pl"))
return table.concat(out, ", ")
 
table.insert(out, '|-')
table.insert(out, '! ' .. small("acc."))
table.insert(out, '| ' .. showForm("accusative", "pl"))
 
table.insert(out, '|-')
table.insert(out, '! ' .. small("dat."))
table.insert(out, '| ' .. showForm("dative", "pl"))
 
table.insert(out, '|-')
table.insert(out, '! ' .. small("gen."))
table.insert(out, '| ' .. showForm("genitive", "pl"))
 
table.insert(out, '|}')
return table.concat(out, '\n')
end
end


return export
return export

Revision as of 21:50, 21 March 2026

Documentation for this module may be created at Module:jugs-cell/doc

local export = {}

local accel_forms = {
	--NEUTRALS
	nsi = "nom|s",
	nsd = "def|nom|s",
	npi = "nom|p",
	npd = "def|nom|p",
	asi = "acc|s",
	asd = "def|acc|s",
	api = "acc|p",
	apd = "def|acc|p",
	dsi = "dat|s",
	dsd = "def|dat|s",
	dpi = "dat|p",
	dpd = "def|dat|p",
	gsi = "gen|s",
	gsd = "def|gen|s",
	gpi = "gen|p",
	gpd = "def|gen|p",
	
	--LAUDATIVES
	nsi_la = "nom|s|la",
	nsd_la = "def|nom|s|la",
	npi_la = "nom|p|la",
	npd_la = "def|nom|p|la",
	asi_la = "acc|s|la",
	as_lad = "def|acc|s|la",
	api_la = "acc|p|la",
	apd_la = "def|acc|p|la",
	dsi_la = "dat|s|la",
	dsd_la = "def|dat|s|la",
	dpi_la = "dat|p|la",
	dpd_la = "def|dat|p|la",
	gsi_la = "gen|s|la",
	gsd_la = "def|gen|s|la",
	gpi_la = "gen|p|la",
	gpd_la = "def|gen|p|la",
	
	--PEJORATIVES
	nsi_pej = "nom|s|pej",
	nsd_pej = "def|nom|s|pej",
	npi_pej = "nom|p|pej",
	npd_pej = "def|nom|p|pej",
	asi_pej = "acc||pej",
	asd_pej = "def|acc|s|pej",
	api_pej = "acc|p|pej",
	apd_pej = "def|acc|p|pej",
	dsi_pej = "dat|s|pej",
	dsd_pej = "def|dat|s|pej",
	dpi_pej = "dat|p|pej",
	dpd_pej = "def|dat|p|pej",
	gsi_pej = "gen|s|pej",
	gs_pejd = "def|gen|s|pej",
	gpi_pej = "gen|p|pej",
	gpd_pej = "def|gen|p|pej",

	--VERBS
	-- Active
	pres_inf = "act|pres|inf",
	past_inf = "act|past|inf",
	pres_part = "act|pres|part",
	past_part = "act|past|part",
	
	pres_ind_1sg = "1|s|pres|act|ind",
	pres_ind_2sg = "2|s|pres|act|ind",
	pres_ind_3sg = "3|s|pres|act|ind",
	pres_ind_1pl = "1|p|pres|act|ind",
	pres_ind_2pl = "2|p|pres|act|ind",
	pres_ind_3pl = "3|p|pres|act|ind",
	past_ind_1sg = "1|s|past|act|ind",
	past_ind_2sg = "2|s|past|act|ind",
	past_ind_3sg = "3|s|past|act|ind",
	past_ind_1pl = "1|p|past|act|ind",
	past_ind_2pl = "2|p|past|act|ind",
	past_ind_3pl = "3|p|past|act|ind",
	
	pres_sub_1sg = "1|s|pres|act|sub",
	pres_sub_2sg = "2|s|pres|act|sub",
	pres_sub_3sg = "3|s|pres|act|sub",
	pres_sub_1pl = "1|p|pres|act|sub",
	pres_sub_2pl = "2|p|pres|act|sub",
	pres_sub_3pl = "3|p|pres|act|sub",
	past_sub_1sg = "1|s|past|act|sub",
	past_sub_2sg = "2|s|past|act|sub",
	past_sub_3sg = "3|s|past|act|sub",
	past_sub_1pl = "1|p|past|act|sub",
	past_sub_2pl = "2|p|past|act|sub",
	past_sub_3pl = "3|p|past|act|sub",
	
	imp = "act|imp",
	
	-- Mediopassive
	
	mp_pres_inf = "mp|pres|inf",
	mp_past_inf = "mp|past|inf",
	mp_pres_part = "mp|pres|part",
	mp_past_part = "mp|past|part",
	
	mp_pres_ind_1sg = "1|s|pres|mp|ind",
	mp_pres_ind_2sg = "2|s|pres|mp|ind",
	mp_pres_ind_3sg = "3|s|pres|mp|ind",
	mp_pres_ind_1pl = "1|p|pres|mp|ind",
	mp_pres_ind_2pl = "2|p|pres|mp|ind",
	mp_pres_ind_3pl = "3|p|pres|mp|ind",
	mp_past_ind_1sg = "1|s|past|mp|ind",
	mp_past_ind_2sg = "2|s|past|mp|ind",
	mp_past_ind_3sg = "3|s|past|mp|ind",
	mp_past_ind_1pl = "1|p|past|mp|ind",
	mp_past_ind_2pl = "2|p|past|mp|ind",
	mp_past_ind_3pl = "3|p|past|mp|ind",
	
	mp_pres_sub_1sg = "1|s|pres|mp|sub",
	mp_pres_sub_2sg = "2|s|pres|mp|sub",
	mp_pres_sub_3sg = "3|s|pres|mp|sub",
	mp_pres_sub_1pl = "1|p|pres|mp|sub",
	mp_pres_sub_2pl = "2|p|pres|mp|sub",
	mp_pres_sub_3pl = "3|p|pres|mp|sub",
	mp_past_sub_1sg = "1|s|past|mp|sub",
	mp_past_sub_2sg = "2|s|past|mp|sub",
	mp_past_sub_3sg = "3|s|past|mp|sub",
	mp_past_sub_1pl = "1|p|past|mp|sub",
	mp_past_sub_2pl = "2|p|past|mp|sub",
	mp_past_sub_3pl = "3|p|past|mp|sub",
	
	mp_impr = "mp|imp",
}

local mode_prefix = { --this is prefixed to the index value in accel_forms
	mpass  = "mp_"
}

local mode_prepend = { --on the other hand, this is prefixed to the accelerated text itself
	wk      = "weak|",
	str     = "strong|",
	comp    = "comparative|",
	wk_sup  = "weak|superlative|",
	str_sup = "strong|superlative|"
}


function export.create(frame)
	local args = frame:getParent().args
	local out = {}
	if not args[1] or args[1] == "" then
		return "―"
	else
		local accel_form = args[2]
		local accel
		if accel_form then
			local mode = args[3]
			if mode and mode_prefix[mode] then
				accel_form = mode_prefix[mode] .. accel_form
			end
			if accel_forms[accel_form] then
				if mode and mode_prepend[mode] then
					accel_form = mode_prepend[mode] .. accel_forms[accel_form]
				else
					accel_form = accel_forms[accel_form]
				end
			end
			accel = {form = accel_form}
		end
		local words = mw.text.split(args[1], "%s*,%s*")
		if words then
			for i,j in ipairs(words) do
				table.insert(out, args[1])
			end
		end
	end
	return table.concat(out, ", ")
end

return export