Module:Lexeme

Èn årtike di Wiccionaire.
I gn a nén co di dzo-pådje /doc pol notule d’ esplikêyes. Clitchîz cial po l’ ahiver.
local p = {}
local cat = {
	['Q1084'] = "n.",
	['Q34698'] = "addj."
}
local gender = {
	['Q499327'] = "o.",
	['Q1775415'] = "f."
}
local abbr = {
	['o.n.'] = 'omrin no',
	['f.n.'] = 'femrin no',
	['addj.'] = 'addjectif',
	['adv.'] = 'adviebe',
	['v.'] = 'viebe',
	['v.c.'] = 'viebe å complemint',
	['v.s.c.'] = 'viebe sins complemint'
}

function p.getLexeme(id) 
	if id and type(id) ~= 'string' then return nil end
	lexeme = mw.wikibase.getEntity(id)
	return lexeme
end

function p.getSample(frame)
	local lexeme = p.getLexeme(frame.args[1])
	lemmas = {}
	for i, l in pairs(lexeme.lemmas) do
		local word = l.value
		word = '<strong>' .. word .. '</strong>'
		table.insert(lemmas, word) 
	end
	out = table.concat(lemmas, ', ')
	
	--cat
	local c = ''
	if  lexeme.lexicalCategory ~= nil 
	and cat[lexeme.lexicalCategory] ~= nil
	then
		c = cat[lexeme.lexicalCategory]
	end
	-- djinre
	-- fok pol no (nén addjectif, viebe, etc)
	if  c == "n."
	and lexeme.claims ~= nil 
	and lexeme.claims['P5185'] ~= nil
	and lexeme.claims['P5185'][1].mainsnak.datavalue.value.id
	then
		c = gender[lexeme.claims['P5185'][1].mainsnak.datavalue.value.id] .. c
	end
	c = '{{abbr|'..c..'|'..abbr[c]..'}}'
	
	out = out .. ', ' .. c
	out = frame:newParserValue(out).expand()
	
	return out
end

return p