Bước tới nội dung

Mô đun:dsb-adjective

Từ điển mở Wiktionary
-- [[Module:dsb-adjective]]
-- Generates declension tables for Lower Sorbian adjectives
-- Developed by [[User:Element10101]]

local export = {}

local table_format = [===[
	<div class="NavFrame">
		<div class="NavHead" style="background:var(--wikt-palette-blue-3);color:inherit;">[[Phụ lục:Tính từ tiếng Hạ Sorb|Biến cách]] của <<NOM.M.SG>> (lớp <<CLASS>>)</div>
		<div class="NavContent">
			{| border="1px solid" style="border-collapse:collapse; background:var(--wikt-palette-blue-0);color:inherit; text-align:center; width:100%;" class="inflection-table"
			|-
			! style="background-color:var(--wikt-palette-blue-2);color:inherit;" rowspan="2" |
			! style="background-color:var(--wikt-palette-blue-2);color:inherit;" colspan="3" | Số ít
			! style="background-color:var(--wikt-palette-blue-2);color:inherit;" rowspan="2" | Số đôi
			! style="background-color:var(--wikt-palette-blue-2);color:inherit;" rowspan="2" | Số nhiều
			|-
			! style="background-color:var(--wikt-palette-blue-2);color:inherit;" | Giống đực
			! style="background-color:var(--wikt-palette-blue-2);color:inherit;" | Giống cái
			! style="background-color:var(--wikt-palette-blue-2);color:inherit;" | Giống trung
			|-
			! style="background-color:var(--wikt-palette-blue-1);color:inherit" | [[nominative|Danh cách]]
			| <<NOM.M.SG>>
			| <<NOM.F.SG>>
			| <<NOM.N.SG>>
			| <<NOM.DU>>
			| <<NOM.PL>>
			|-
			! style="background-color:var(--wikt-palette-blue-1);color:inherit" | [[genitive|Sinh cách]]
			| <<GEN.M.SG>>
			| <<GEN.F.SG>>
			| <<GEN.N.SG>>
			| <<GEN.DU>>
			| <<GEN.PL>>
			|-
			! style="background-color:var(--wikt-palette-blue-1);color:inherit" | [[dative|Dữ cách]]
			| <<DAT.M.SG>>
			| <<DAT.F.SG>>
			| <<DAT.N.SG>>
			| <<DAT.DU>>
			| <<DAT.PL>>
			|-
			! style="background-color:var(--wikt-palette-blue-1);color:inherit" | [[accusative|Đối cách]]
			| <<ACC.M.SG>>, <wbr/><<ACC.M.AN.SG>><sup style="color:var(--wikt-palette-blue);">1</sup>
			| <<ACC.F.SG>>
			| <<ACC.N.SG>>
			| <<ACC.DU>>, <wbr/><<ACC.AN.DU>><sup style="color:var(--wikt-palette-blue);">1</sup>
			| <<ACC.PL>>, <wbr/><<ACC.AN.PL>><sup style="color:var(--wikt-palette-blue);">2</sup>
			|-
			! style="background-color:var(--wikt-palette-blue-1);color:inherit" | [[instrumental|Cách công cụ]]
			| <<INS.M.SG>>
			| <<INS.F.SG>>
			| <<INS.N.SG>>
			| rowspan="2" | <<INS.DU>>
			| <<INS.PL>>
			|-
			! style="background-color:var(--wikt-palette-blue-1);color:inherit" | [[locative|Định vị cách]]
			| <<LOC.M.SG>>
			| <<LOC.F.SG>>
			| <<LOC.N.SG>>
			| <<LOC.PL>>
			|}
			<div style="width:100%;text-align:left;background-color:var(--wikt-palette-blue-2);color:inherit;">
				<div style="display:inline-block;text-align:left;padding-left:1em;padding-right:1em;">
					<sup style="color:var(--wikt-palette-blue);">1</sup>Động vật. <sup style="color:var(--wikt-palette-blue);">2</sup>Dạng động vật tùy chọn.
				</div>
			</div>
		</div>
	</div>]===]

-- Suffixes added to decline the adjective
local suffixes = {
	[47] = { -- adjective class 47; used by [[Template:dsb-decl-adj-47]]
		["NOM.M.SG"] = "y", -- nominative masculine singular
		["NOM.F.SG"] = "a", -- nominative feminine singular
		["NOM.N.SG"] = "e", -- nominative neuter singular
		["NOM.DU"] = "ej", -- nominative dual
		["NOM.PL"] = "e", -- nominative plural
		["GEN.M.SG"] = "ego", -- genitive masculine singular
		["GEN.F.SG"] = "eje", -- genitive feminine singular
		["GEN.N.SG"] = "ego", -- genitive neuter singular
		["GEN.DU"] = "eju", -- genitive dual
		["GEN.PL"] = "ych", -- genitive plural
		["DAT.M.SG"] = "emu", -- dative masculine singular
		["DAT.F.SG"] = "ej", -- dative feminine singular
		["DAT.N.SG"] = "emu", -- dative neuter singular
		["DAT.DU"] = "yma", -- dative dual
		["DAT.PL"] = "ym", -- dative plural
		["ACC.M.SG"] = "y", -- accusative masculine singular
		["ACC.M.AN.SG"] = "ego", -- accusative masculine animate singular
		["ACC.F.SG"] = "u", -- accusative feminine singular
		["ACC.N.SG"] = "e", -- accusative neuter singular
		["ACC.DU"] = "ej", -- accusative dual
		["ACC.AN.DU"] = "eju", -- accusative animate dual
		["ACC.PL"] = "e", -- accusative plural
		["ACC.AN.PL"] = "ych", -- accusative animate plural
		["INS.M.SG"] = "ym", -- instrumental masculine singular
		["INS.F.SG"] = "eju", -- instrumental feminine singular
		["INS.N.SG"] = "ym", -- instrumental neuter singular
		["INS.DU"] = "yma", -- instrumental dual; same as locative dual
		["INS.PL"] = "ymi", -- instrumental plural
		["LOC.M.SG"] = "em", -- locative masculine singular
		["LOC.F.SG"] = "ej", -- locative feminine singular
		["LOC.N.SG"] = "em", -- locative neuter singular
		["LOC.PL"] = "ych", -- locative plural
	},
	[48] = { -- adjective class 48; used by [[Template:dsb-decl-adj-48]]
		["NOM.M.SG"] = "i", -- nominative masculine singular
		["NOM.F.SG"] = "a", -- nominative feminine singular
		["NOM.N.SG"] = "e", -- nominative neuter singular
		["NOM.DU"] = "ej", -- nominative dual
		["NOM.PL"] = "e", -- nominative plural
		["GEN.M.SG"] = "ego", -- genitive masculine singular
		["GEN.F.SG"] = "eje", -- genitive feminine singular
		["GEN.N.SG"] = "ego", -- genitive neuter singular
		["GEN.DU"] = "eju", -- genitive dual
		["GEN.PL"] = "ich", -- genitive plural
		["DAT.M.SG"] = "emu", -- dative masculine singular
		["DAT.F.SG"] = "ej", -- dative feminine singular
		["DAT.N.SG"] = "emu", -- dative neuter singular
		["DAT.DU"] = "ima", -- dative dual
		["DAT.PL"] = "im", -- dative plural
		["ACC.M.SG"] = "i", -- accusative masculine singular
		["ACC.M.AN.SG"] = "ego", -- accusative masculine animate singular
		["ACC.F.SG"] = "u", -- accusative feminine singular
		["ACC.N.SG"] = "e", -- accusative neuter singular
		["ACC.DU"] = "ej", -- accusative dual
		["ACC.AN.DU"] = "eju", -- accusative animate dual
		["ACC.PL"] = "e", -- accusative plural
		["ACC.AN.PL"] = "ich", -- accusative animate plural
		["INS.M.SG"] = "im", -- instrumental masculine singular
		["INS.F.SG"] = "eju", -- instrumental feminine singular
		["INS.N.SG"] = "im", -- instrumental neuter singular
		["INS.DU"] = "ima", -- instrumental dual; same as locative dual
		["INS.PL"] = "imi", -- instrumental plural
		["LOC.M.SG"] = "em", -- locative masculine singular
		["LOC.F.SG"] = "ej", -- locative feminine singular
		["LOC.N.SG"] = "em", -- locative neuter singular
		["LOC.PL"] = "ich", -- locative plural
	},
	[49] = { -- adjective class 49; used by [[Template:dsb-decl-adj-49]]
		["NOM.M.SG"] = "i", -- nominative masculine singular
		["NOM.F.SG"] = "ja", -- nominative feminine singular
		["NOM.N.SG"] = "je", -- nominative neuter singular
		["NOM.DU"] = "jej", -- nominative dual
		["NOM.PL"] = "je", -- nominative plural
		["GEN.M.SG"] = "jego", -- genitive masculine singular
		["GEN.F.SG"] = "jeje", -- genitive feminine singular
		["GEN.N.SG"] = "jego", -- genitive neuter singular
		["GEN.DU"] = "jeju", -- genitive dual
		["GEN.PL"] = "ich", -- genitive plural
		["DAT.M.SG"] = "jemu", -- dative masculine singular
		["DAT.F.SG"] = "jej", -- dative feminine singular
		["DAT.N.SG"] = "jemu", -- dative neuter singular
		["DAT.DU"] = "ima", -- dative dual
		["DAT.PL"] = "im", -- dative plural
		["ACC.M.SG"] = "i", -- accusative masculine singular
		["ACC.M.AN.SG"] = "jego", -- accusative masculine animate singular
		["ACC.F.SG"] = "ju", -- accusative feminine singular
		["ACC.N.SG"] = "je", -- accusative neuter singular
		["ACC.DU"] = "jej", -- accusative dual
		["ACC.AN.DU"] = "jeju", -- accusative animate dual
		["ACC.PL"] = "je", -- accusative plural
		["ACC.AN.PL"] = "jich", -- accusative animate plural
		["INS.M.SG"] = "im", -- instrumental masculine singular
		["INS.F.SG"] = "jeju", -- instrumental feminine singular
		["INS.N.SG"] = "im", -- instrumental neuter singular
		["INS.DU"] = "ima", -- instrumental dual; same as locative dual
		["INS.PL"] = "imi", -- instrumental plural
		["LOC.M.SG"] = "jem", -- locative masculine singular
		["LOC.F.SG"] = "jej", -- locative feminine singular
		["LOC.N.SG"] = "jem", -- locative neuter singular
		["LOC.PL"] = "ich", -- locative plural
	}
}

-- Entry point for all templates calling this module
function export.show(frame)
	local class = tonumber(frame.args[1]) -- Adjective class
	
	local base_form = string.sub(tostring(mw.title.getCurrentTitle()), 1, -1 - #suffixes[class]["NOM.M.SG"]) -- The base form is the form of the word with all declensional suffixes stripped off.
	
	local infl_table = table_format
	
	for k, v in pairs(suffixes[class]) do
		infl_table = string.gsub(infl_table, "<<" .. k .. ">>", frame:expandTemplate({
			title = "l-self",
			args = { "dsb", base_form .. suffixes[class][k] }
		}))
	end
	
	infl_table = string.gsub(infl_table, "<<CLASS>>", class)
	
	return infl_table
end

return export