Module:sla-conj

local export = {}

local util = require("Module:utilities") local mSC = require("Module:sla-common") local lang = require("Module:languages").getByCode("sla-pro")

local umatch = mw.ustring.match local usub  = mw.ustring.sub local ugsub = mw.ustring.gsub

function export.show(frame) local cats = {} local params = { [1] = {},	-- aspect [2]	= {},	-- root1-suff1 [3]	= {},	-- root2-suff2 inf = {},	-- infinitive cat	= {},	-- category s	= {},	-- s-aorist ap = {},	-- accent paradigm t2	= {},	-- present PP		t3	= {},	-- past AP		t4	= {},	-- l		t5	= {},	-- past PP		noun= {},	-- verbal noun a	= {},	-- aorist n	= {},	-- togglable imperfect (~nil/nil) }	local args = require("Module:parameters").process(frame:getParent.args, params) local langname = lang:getCanonicalName a_name = "Aorist" u_name = "Present" n_name = "Imperfect" i_name = "Imperative" display0 = 1;	-- togglable table display (Vnoun+inf+sup+Lpart) if args["n"]==nil then args["n"] = 1 elseif args["n"]=="0" then args["n"] = nil end for k in pairs(args) do		if k~=1 and k~=2 and k~=3 and args[k] then table.insert(cats, "sla-conj with extra parameters/"..k)		end end local notes	= "" local root1, suff1 = umatch(args[2], "(.*)-(.*)") local root2, suff2 = root1, suff1 if args[3] then root2, suff2 = umatch(args[3], "(.*)-(.*)") if root2=="" then root2 = root1 end end local stem0 = ( args["inf"] or mw.title.getCurrentTitle.subpageText or error("Parameter 'inf=' is missing") ) -- // infinitive, supine // -- local y1 = "*" .. stem0 local t6 = usub(y1, 1,-3) .. ( umatch(y1,"ť.$") and "ťь" or "tъ" ) -- ti/ťi > tъ/ťь -- get root-suffix from stem0 stem0 = usub(stem0, 1,-3)	-- drop ti	if suff2=="1" and umatch(stem0, "nǫ$") then	-- |-|-1: gъbnǫti/gъbe/gъbnetь root2,suff2 = umatch(stem0, "(.*)(n)ǫ") if root1=="" then root1 = root2 end end if umatch(suff1, "[0-2]$") then if suff1=="2" then			-- ovA/jA if umatch(stem0,"[oe]va$") then root1,suff1 = umatch(stem0, "(.*)([oe]va)$") root2,suff2 = root1,"u" elseif umatch(stem0,"va$") then root1,suff1 = umatch(stem0, "(.*)(va)$") elseif umatch(stem0,"[aěiьeoъyuǫę]ja$") then root1,suff1 = umatch(stem0, "(.*)(ja)") else root1,suff1 = umatch(stem0, "(.*)(.)$") root2,suff2 = root1,suff1 end elseif suff1=="1" then	-- A/Ě/I/ if umatch(stem0, "nǫ$") then root1,suff1 = umatch(stem0, "(.*)(nǫ)$") root2,suff2 = root1,"n" else root1,suff1 = umatch(stem0, "(.*)(.)$") end elseif suff1=="0" then	-- O/X root1,suff1 = stem0,"" end if root2=="" then root2 = ugsub(root1, "ę$", "ьn") end if suff2=="1" or suff2=="0" then	-- if suff1==suff2 suff2 = suff1 end end if suff2~="i" and suff2~="a" and suff2~="u" then	-- avoid pojiti, prijati root2 = ugsub(root2, "([aěiьeoъyuǫę])j$", "%1")	-- drop j (poj- > po-), 'j' will be added in 'stem2' end -- root2: change grade; (unhandled single cases: řuti zъvati pěti ?gъnati) local cat0	= ""	-- category if root2=="h" then cat0 = langname.." ablauting verbs" root2 = root1 if suff1=="a" and umatch(root2, "[ьi]j") then root2 = ugsub(root2, "[ьi]j$", "ě")			 -- smьjati\zijati-? elseif umatch(root2, "[ьъ].?.?$") or umatch(root2, "ov") then root2 = ugsub(root2, "ov$", "u")			 -- snovati-snuti root2 = ugsub(root2, "ьv$", "u")			 -- žьvati-?řuti root2 = ugsub(root2, "ь([lr].?)$", "e%1")	 -- ..., pьlzati-[čersti] root2 = ugsub(root2, "ь(.)$", "i%1")		 -- zьdati-[kvisti] else root2 = ugsub(root2, "u$", "ov")			 -- ... root2 = ugsub(root2, "u(.)$", "ъ%1")		 -- ?-suPti root2 = ugsub(root2, "i$", "ь")			 	 -- kriti-? root2 = ugsub(root2, "e([lr])$", "ь%1")		 -- dьrati-derti root2 = ugsub(root2, "ę$", "ьm")			 -- ęti\pęti end if root2==root1 then error("could not change root grade, write root2") end end if root1 ~= root2 then table.insert(cats, "sla-conj with extra parameters/2root") end -- stem ending in: vowel (not nil), consonant (nil) local stem1V = umatch(root1..suff1,"[aěiьeoъyuǫę]$") local stem2V = umatch(root2..suff2,"[aěiьeoъyuǫę]$") root1,root2 = "*"..root1, "*"..root2 local pcat = args["cat"] local cat local tcat = { ["oo"] = "V",		-- obu-|= ["ao"] = "a/V",	-- trov-a|tru- ["jao"] = "ja/V",	-- ta-ja|ta- ["vao"] = "va/V",	-- da-va|da- ["nǫn"] = "n",		-- dьrz-nǫ|-n ["on"] = "V/n",	-- sta-|-n ["xn"] = "C/n",	-- mъk-|-n ["xj"] = "C/j",	-- por-|-j ["ox"] = "V/C",	-- pę-|pьn-, tru-|trov- ["xx"] = "C",		-- der-|dьr-, pad-|= ["ax"] = "a/C",	-- dьr-a|der- ["aj"] = "a/j",	-- syp-a|-j ["ii"] = "i",		-- trav-i|= ["ěi"] = "ě/i",	-- vьrt-ě|-i ["ai"] = "a/i",	-- slyx-ě|-i, sъp-a|-i ["aa"] = "a",		-- obuv-a|=, pad-a|= ["ěě"] = "ě",		-- gov-ě|= ["ěx"] = "ě/C",	-- (věd-ě|-) ovau  = "ova/u",	-- cěl-ova|-u evau  = "ova/u"	-- boj-eva|-u }	cat = (suff1~="" and suff1 or stem1V and "o" or "x") .. (suff2~="" and suff2 or stem2V and "o" or "x") cat = (tcat[cat] or "unknown") if cat=="a" and args[2]=="-2" then cat = "ja" elseif suff1=="a" and suff2=="a" and umatch(root1, "[žčš]$") then cat = "ě" elseif suff1=="a" and suff2=="i" and umatch(root1,"[jžčš]$") then cat = "ě/i" end if pcat and pcat~="irreg" and pcat~="athem" then cat = pcat pcat = nil end local info_cat = "" if cat=="i" then info_cat = "Suffix: *-iti ― iterative (*nositi⇐*nesti) ― causative (*pojiti⇐*piti) ― ..." elseif cat=="ě/i" or cat=="ě" then info_cat = "Suffix: *-ěti" elseif cat=="ja" then info_cat = "Suffix: *-iti + *-ati ― iterative (e.g. *xaďati⇐*xoditi) ― imperfective (e.g. *otъvěťati⇐*otъvětiti)" elseif umatch(cat,"^a") then	-- a, a/V, a/C, a/j, a/i info_cat = "Suffix: *-ati" end --	--- CONJUGATION (present-imperative, t1 t2 t3 t4 t5 y2, aorist, imperfect) --- t6 y1 see above --	local root1e = mSC.first_palatalization(root1) local root2e = mSC.first_palatalization(root2) local root1j = mSC.iotate(root1) local root2j = mSC.iotate(root2) -- // present, imperative, participle // local stem2 = root2..suff2		-- X, N (default) if suff2=="j" then				-- J		stem2 = root2j elseif stem2V and suff2~="i" then	-- O/A/Ě/U stem2 = stem2 .. "j" end local u1, u2, u3	-- (pekǫ-ziďǫ-broďǫ), (pečetъ-ziďetъ-broditъ), (pekǫtъ-ziďǫtъ-brodętъ) local i1, i2		-- (tьri-borji), (tьrěta-borjite); i1=i1, i2=i1+i2 local t1, t2		-- (present active), (present passive) if suff2=="i" then u1 = root2j u2 = root2e.."i" u3 = root2e.."ę" i1 = root2e.."" i2 = "i" t1 = root2e.."ę" t2 = root2e.."i" else u1 = stem2.."" u2 = mSC.first_palatalization(stem2).."e" u3 = stem2.."ǫ" i1 = mSC.second_palatalization(stem2).."" if suff2~="j" and stem2V==nil then i2 = "ě" t1 = stem2.."y" t2 = stem2.."o" else i2 = "i" t1 = stem2.."ę" t2 = stem2.."e" end if umatch(stem2, "[e][zs]?[gkx]$") then -- ..., reduce vowel before palatal consonant i1 = ugsub(i1, "(.*)e", "%1ь") end end t2 = (args["t2"] or t2.."mъ") -- // participle, verbal noun // -- l-participle local t4 = ( args["t4"] or umatch(root1,"[lr]$") and suff1=="" and root2..suff1.."lъ" or root1..suff1.."lъ") -- past passive participle, verbal noun local t5	if args["t5"] then t5 = args["t5"] elseif suff1=="nǫ" then		-- N		t5 = root1.."novenъ" elseif suff1=="i" then	-- I t5 = root1j .. "enъ" elseif stem1V then			-- O/A/Ě/ovA t5 = root1 .. (suff1=="" and "tъ" or suff1.."nъ") elseif umatch(root1, "[lr]$") then t5 = root2.."tъ" notes = notes .. "" .. "(*)"..root2..suff2.."enъ" .. " is doublet of past passive participle" .. "" else t5 = mSC.first_palatalization(root1) .. "enъ" end local y2 = (args["noun"] or t5~="—" and umatch(t5,"(.*).$").."ьje" or "—") -- past active participle local t3	if args["t3"] then t3 = args["t3"] elseif suff1=="i" then t3 = root1j.."ь" notes = notes .. "" .. "(*)".. root1..suff1.."vъ" .. " is a later doublet of the past active participle" .. "" elseif suff1=="" and umatch(root1, "[rlǫę]$") then t3 = ugsub(root2, "([oe][rl])$", "%1v") .. "ъ"	-- no Xv>>X_ (if not [oe][rl]) else				-- ..., X/J t3 = root1..suff1 .. (stem1V and "v" or "") .. "ъ" end -- // aorist // local aorist_name = "s-aorist" -- (default) local a0 = (args["a"] or root1) .. suff1	-- ..., O/... local a1, a2, a3, a4	-- ved(ox)ъ, vede, ved(e/os)te, vedǫ/vedošę if suff1=="nǫ" or umatch(a0,"[raěiьeoъyu]$") then	-- N, X=r, O/ovA/A/Ě/I a1 = a0.."x" a2 = a0		a3 = a0.."s" a4 = a0.."š".."ę" elseif umatch(a0,"[lǫę]$") then	-- X=l, O(ǫę) a1 = a0.."s" a2 = a0		a3 = a0.."s" a4 = a0.."s".."ę" elseif args["s"] then		-- X (s-aorist) local s = ( umatch(a0,"[^gk]$") and "s" or nil ) a2 = mSC.first_palatalization(a0).."e"	 -- from _-aorist a0 = usub(a0, 1,-2)		-- drop last consonant a0 = ugsub(a0, "[e]$", "ě") a0 = ugsub(a0, "[o]$", "a") a0 = ugsub(a0, "[ь]$", "i") a0 = ugsub(a0, "([jďťžčš])[ě]$", "%1a") a1 = a0 .. (s or "x") a3 = a0 .. "s" a4 = a0 .. (s or "š") .. "ę" else						-- X (_-aorist, ox-aorist) a1 = a0.."(ox)" a2 = mSC.first_palatalization(a0).."e" a3 = a0.."(e/os)" a4 = a0.."ǫ" .. ", " ..a0.."o".."š".."ę" if umatch(a0,"[gkx]$") then notes = notes .. "" .. "Aorist ".. ugsub(a0.."este", "([zs]?[gkx])", " %1 ") .." ⇒ ".. ugsub(a2.."ste", "[žčš]?[d]?[žčš]", " %1 ") ..", ..." .. "" end aorist_name = "_/ox-aorist" end if args["s"]=="t" or args["s"]=="st" then -- St-aorist: V, C[ęr] C(ěsti) a2 = a2 .. "("..args["s"].."ъ)" aorist_name = args["s"] .. "-aorist" end -- // imperfect // local n1 = root2e .. (root2==root2e and "ě" or "a")	-- ... if suff2=="n" then									-- N n1 = root2..suff2 .. "ě" elseif suff1=="i" or (suff2=="j" and stem1V==nil) then	-- I (root1/root2?), J (root1/root2?) n1 = root2j .. "a" elseif suff1~="" or stem2V then					-- ... n1 = (suff1~="" and root1 or root2) .. suff1.."j".."a" n1 = ugsub(n1, "([aě])ja", "%1") end -- // irregular // local u21 if pcat=="irreg" then if root1=="*b" and suff1=="ě" then root2 = "*es" pcat = "athem" elseif suff2=="i" and suff1=="ě" and umatch(root1, "x[oъ]t$") then u21 = ugsub(u2, "(x[oъ])ti$", "%1ť") .. "(eš)i" u2 = ugsub(u2, "(x[oъ])ti$", "%1ťe") i1 = ugsub(i1, "(x[oъ])t$",  "%1ť") pcat = "irregular" table.insert(cats, langname.." irregular verbs") --? 3rd dual imper (xoťite) elseif umatch(root2, "[jn][ьi]d$") then t4 = ugsub(t4, "[jn][ьi]dlъ$",   "šьdlъ") y2 = ugsub(y2, "[jn][ьi]denьje$", "šьstьje") t5 = ugsub(t5, "[jn][ьi]denъ$",  "šьstъ") t3 = ugsub(t3, "[jn][ьi]dъ$",    "šьdъ") pcat = "suppletive" table.insert(cats, langname.." suppletive verbs") end end -- endings of: imperative, present, aorist, imperfect local i = {     "—",  i1.. "i", i1.. "i",		i1..i2.."vě", i1..i2.."ta",          "—",		i1..i2.."mъ",  i1..i2.."te",        "—"} local u = {u1.. "ǫ", u2.. "ši", u2.. "tь",		u2.. "vě", u2.. "ta", u2.. "te",		u2.. "mъ", u2.. "te", u3.. "tь"} local a = {a1.. "ъ", a2.. "", a2.. "",		a1.. "ově", a3.. "ta", a3.. "te",		a1.. "omъ", a3.. "te", a4.. ""}	local n = {n1.."axъ", n1.."aše",  n1.."aše",		n1.. "axově", n1.. "ašeta", n1.."ašete",		n1.. "axomъ", n1.. "ašete", n1.."axǫ"} if pcat=="athem" then -- jьm-ě, es/věd/dad/ěd if umatch(root2, "[ьi]m$") then u1 = root2.."a" u3 = root2.."ǫ" u = {u1.."mь", u1.."ši", u1.."tь",		u1.."vě", u1.."ta", u1.."te",		u1.."mъ", u1.."te", u3.."tь"} t1 = ugsub(t1, "ěję$", "y") t2,t5 = "—","—"  -- hide passive participles pcat = "athematic" table.insert(cats, langname.." athematic verbs") else local u4, i3			u1 = ugsub(root2, "[dt]$", "") -- [d](mv) >   (mv):    daD.ěD.věD (-mь/-vě/-mъ) u4 = ugsub(root2,   ".$", "")  -- [d](s)  >    (s): eS/daD.ěD.věD (-si) u2 = ugsub(root2, "[dt]$", "s") -- [d](t) > [s](t):    daD.ěD.věD (-tь/-ta/-te) u3 = root2.."ę" i3 = root2j i2 = "i" u = {u1.."mь", u4.."si", u2.."tь",		u1.."vě", u2.."ta", u2.."te",		u1.."mъ", u2.."te", u3.."tь"} if root2 ~= "*es" then i = {"—", i3.."ь", i3.."ь",			i1..i2.."vě", i1..i2.."ta", "—",	i1..i2.."mъ",  i1..i2.."te", "—"} end if umatch(root1, "da$") then t2 = "—" -- hide, some sources present it without reference pcat = "athematic" .. " " .. "reduplicated" table.insert(cats, langname.." athematic verbs") table.insert(cats, langname.." reduplicated verbs") end if suff1=="" and umatch(root1, "d$") then -- ěd a[2] = ugsub(a[2], "(.*)de", "%1")	-- aorist is without -e (*ě instead of *ěde) a[3] = a[2] pcat = "athematic" table.insert(cats, langname.." athematic verbs") end if suff1=="ě" and umatch(root1, "d$") then -- věd u[1] = ugsub(u[1], "mь$", "") .. "(mь/dě)" pcat = "athematic" table.insert(cats, langname.." athematic verbs") end if root2=="*es" then	-- *něs: u[9]="*nesǫtь", t1="*nesy" display0 = nil; t3,t1 = "—","*sy" u[9] = ugsub(u[9], "esę", "sę") u[9] = ugsub(u[9], "ę", "ǫ") .. "/" .. u[9] i[1] = "*bimь" i[6] = "*bite" i[9] = "*bǫ" pcat = "athematic".. " " .."suppletive" table.insert(cats, langname.." suppletive verbs") table.insert(cats, langname.." athematic verbs") i_name = "Conditional" end end end if u21 then u[2] = u21 end --	--- end of CONJUGATION                                                    --- --	if args[1]==nil then args[1] = "" end local aspect, trans = umatch(args[1], "(.*)-(.*)") if aspect==nil then -- if there is no #2 parameter aspect = umatch(args[1], "(.*)") end if aspect==nil or aspect=="" then aspect = "?" elseif aspect=="0" or aspect=="impf" then aspect = 'impf. '	elseif aspect=="2" or aspect=="bi" then aspect = 'impf./pf. '	elseif aspect=="1" or aspect=="pf" then aspect = 'perf. '		notes	= notes .. "" .. "In perfective verbs, present expresses future" .. "" t2,t1	= "—","—"			-- hide present participles if args["n"]~=nil then args["n"] = nil			-- hide imperfect end end if args["n"]==nil then n = {"—","—","—", "—","—","—",  "—","—","—"}	-- hide imperfect end if trans==nil then -- nothing elseif trans=="0" or trans=="intr" then trans = 'intr. '		t2,t5	= "—","—"									-- hide passive participles elseif trans=="2" or trans=="ditr" then trans = 'bitr. '	elseif trans=="1" or trans=="tr" then trans = ' tr. '	end local ap,q = "", "" if args["ap"]==nil then ap = "?" else ap = umatch(args["ap"], "^.") q = umatch(args["ap"], ".(.)") if q==nil then q = "" elseif q=="~" then q = " (possibly)" else q = "?" end end local desc = "Conjugation of "..(display0 and y1..', ' or ) ..a[3]..", "..u[3].."'' ("	desc = desc .. aspect .. (trans and ", "..trans or "")	desc = desc .. ", ".. (pcat and pcat.." " or "") .. "-"..cat.."-"	desc = desc .. ", " .. aorist_name	desc = desc .. ", accent paradigm " .. ap..q	desc = desc .. ")" table.insert(cats, langname.." verbs ending in -"..cat.."-") if ap~="?" then table.insert(cats, langname.." verbs with accent paradigm "..ap) end if cat0~="" then table.insert(cats, cat0) end cat = util.format_categories(cats, lang) -- table info local bg1 = "background: rgba(0, 128, 255, 0.16);" local bg2 = "background: rgba(0, 128, 255, 0.08);" if notes~="" then notes = "Notes: " .. notes .. "" end if display0==nil then display0 = "display: none;" end return [=[ ]=].. desc ..[=[ ]=]..notes..[=[ ]=]..cat end

return export