Kontent qismiga oʻtish

Modul:wa-headword

Vikilug‘atdan olingan

Bu modul uchun Modul:wa-headword/doc nomli hujjat sahifasini yaratishingiz mumkin

local export = {}

function export.adjectives(frame)
	local title = mw.title.getCurrentTitle()
	local masculine_singular, feminine_singular, masculine_plural, feminine_plural
		= 'm2', 'f', 'mp', 'pf' -- inconsistent!
	local params = {
		head = { default = title.text },
		[1] = {}, -- gender
		[masculine_singular] = {}, -- masculine singular before vowel
		[feminine_singular] = { list = true }, -- feminine singular
		feminine = { alias_of = feminine_singular },
		sf = { alias_of = feminine_singular },
		[masculine_plural] = {},
		mplural = { alias_of = masculine_plural },
		[feminine_plural] = { list = true },
		fplural = { alias_of = feminine_plural },
		current = {}, -- current pagename?
		sort = {},
		cat = { alias_of = 'sort' },
	}
	local args = require "Module:parameters".process(frame:getParent().args, params)
	
	local headword = {
		lang = require "Module:languages".getByCode "wa",
	}
	
	local stem = args.current or title.text
	if not args[feminine_singular][1] then
		args[feminine_singular][1] = stem .. 'e'
	end
	args[masculine_plural] = args[masculine_plural] or stem .. 's'
	for i, f_form in ipairs(args[feminine_singular]) do
		if not args[feminine_plural][i] then
			args[feminine_plural][i] = f_form[i] .. 's'
		end
	end
	
	local info = {
		[masculine_singular] =
			{ accel = {form = "m"}, label = 'masculine before vowel' },
		[feminine_singular] = 
			{ accel = {form = "f|s"}, label = 'feminine singular' },
		[masculine_plural] = 
			{ accel = {form = "m|p"}, label = 'masculine plural' },
		[feminine_plural] = 
			{ accel = {form = "f|p"}, label = 'feminine plural' },
	}
	
	headword.heads = { args.head }
	headword.inflections = {}
	for _, form in ipairs { masculine_singular, masculine_plural,
							feminine_singular,  feminine_plural } do
		local data = info[form]
		local inflection
		if type(args[form]) == 'table' then
			inflection = { unpack(args[form]) }
		else
			inflection = { args[form] }
		end
		
		inflection.label = data.label
		inflection.accel = data.accel
		
		table.insert(inflections, inflection)
	end
	
	return require 'Module:headword'.full_headword(headword)
end

return export