Module:bac à sable/Lepticed7

La documentation pour ce module peut être créée à Module:bac à sable/Lepticed7/Documentation

local p = {}

function p.main(frame)
	local lex_id = frame.args['1']
	local forms = p._main(lex_id)
	return string.format([[{|class="flextable"
|-
! Cas
! Singulier
! Pluriel
|-
! Nominatif
| %s
| %s
|-
! Génitif
| %s
| %s
|-
! Datif
| %s
| %s
|-
! Accusatif
| %s
| %s
|-
! Instrumental
| %s
| %s
|-
! Prépositionnel
| %s
| %s
|}]], forms[0], forms[1], forms[2], forms[3], forms[4], forms[5], forms[6], forms[7], forms[8], forms[9], forms[10], forms[11])
end

function p._main(lex_id)
	local lex_ent = mw.wikibase.getEntity( lex_id )
	local lex_forms = lex_ent:getForms()
	local forms = {}
	local r = ""
	for k, form in pairs(lex_forms) do
		local n = -1
		local c = -1
		for k, feat in pairs(form:getGrammaticalFeatures()) do
			if feat == 'Q110786' then
				n = 0
			elseif feat == 'Q146786' then
				n = 1
			end
			if feat == 'Q131105' then
				c = 0
			elseif feat == 'Q146233' then
				c = 1
			elseif feat == 'Q145599' then
				c = 2
			elseif feat == 'Q146078' then
				c = 3
			elseif feat == 'Q192997' then
				c = 4
			elseif feat == 'Q2114906' then
				c = 5
			end
		end
		local pron = form:getBestStatements('P7243')[1]
		local repr = form:getRepresentation('ru')
		if pron ~= nil then
			label = pron['mainsnak']['datavalue']['value'].text
		else
			label = repr
		end
		forms[c * 2 + n] = string.format("[[%s|%s]]", repr, label)
	end
	return forms
end

return p