Mòdul:Guilhelma:wikidata-test

La documentacion d'utilizacion d'aquel modul se pòt crear a Mòdul:Guilhelma:wikidata-test/ús

local p = {}
function makeNounDeclensionTable(frame,current_lexeme)
	local forms = {}
	for i, form in pairs(current_lexeme:getForms()) do
		local representations = form:getRepresentations()
		local feats = form:getGrammaticalFeatures()
		table.sort(feat)
		local feats_cat = table.concat(feats,'_')
        forms[feats_cat] = representations[1][1]
	end
	return frame:expandTemplate {
		title ='nom template'
	}
end

function p.makeNounDeclensionTable(frame)
	local lexeme_id = frame.args[1]
	local current_lexeme = mw.wikibase.getEntity(lexeme_id)
	return makeNounDeclensionTable(frame,current_lexeme)
end	

function p.nomlabel(frame )
	local val = frame.args[1]
	return mw.wikibase.getLabel(val)
end

function p.forma(frame, item_id )
    local lexeme_id = frame.args[1]
    local myitem = frame.args[2]
    local current_lexeme = mw.wikibase.getEntity(lexeme_id)
    local myform = {}
    local myresult ='not found'
    for i, form in pairs( current_lexeme:getForms() ) do
		if form:hasGrammaticalFeature( myitem ) then 
		    myform = form
		    local representations = myform:getRepresentations()
            myresult = representations[1][1]
        end
    end
	return myresult
end

	
function p.all(frame)
    local lexeme_id = frame.args[1]
    local current_lexeme = mw.wikibase.getEntity(lexeme_id)
    local current_lemma = current_lexeme:getLemma()
    current_heading = '='..current_lemma.."="
    local declension_table = makeNounDeclensionTable(frame,current_lexeme)
    return current_heading..'\n\n'..declension_table
end

return p