Módulo:Infobox/Funções/Pessoa/Testes

Origem: Wikipédia, a enciclopédia livre.
Documentação do módulo[ver] [editar] [histórico] [purgar]



Descrição[editar código-fonte]

Este Módulo tem funções auxiliares para criar infocaixas sobre pessoas. Faz parte da predefinição {{Infobox biografia2}}. Por favor consulte a predefinição para mais instruções.

Uso[editar código-fonte]

Outra documentação:

-- Funções utilizadas dentro das infobox sobre pessoas
local p = {}
local localdata = require( 'Módulo:Infobox/Localdata' )
local item = localdata.item
local wikidata = require( "Módulo:Infobox/Wikidata/Testes" )
local general = require "Módulo:Infobox/Funções"
local datemodule = require "Módulo:Data"
local complexdate = require "Módulo:Data complexa"
local linguistic = require "Módulo:Linguística"
local militaryranks = require "Módulo:Dicionário Wikidata/Graus militares"
--local ppath = require 'Módulo:Wikidata/Caminho'
--local noble = require 'Módulo:Nobre'

--=== Acordo em género
local gender = wikidata.getgender(item) -- género da pessoa nesta infocaixa

-- Versão local da wikidata.genderedlabel ou se o género não está indicado
local function genderedlabel(id, labelgender)
    if not labelgender then labelgender = gender end
    return wikidata.genderedlabel(id, labelgender)
end

-- === Gestão das datas

-- Links temáticos para datas
local datelinks = { -- link para a área apropriada de atividade
    Q483501 = 'nas artes plásticas', -- artista
    Q1028181 = 'nas artes plásticas', -- pintura
    Q1281618 = 'nas artes plásticas', -- escultura
    Q2309784 = 'no ciclismo', -- ciclista
    Q16947657 = 'nas artes plásticas', -- litografia
    Q11569986 = 'nas artes plásticas', -- gravura
    Q13365770 = 'nas artes plásticas', -- gravador de cobre
    Q21925567 = 'nas artes plásticas', -- serigrafia
    Q10862983 = 'nas artes plásticas', -- aquafortiste
}

local function getdatetopic() -- Obtém o link mais apropriado para uma data baseada na ocupação
    local claims = wikidata.stringTable{entity = item, property = 'P106', excludespecial = true, displayformat = "raw"}
    if not claims then
        return nil
    end
    for i, j in pairs(claims) do
        if datelinks[j] then
            return datelinks[j]
        end
    end
end

local linktopic = getdatetopic()


local unknowndatelabel = "data desconhecida"

local birthdate = localdata['data_nascimento'] or
    localdata['nascimento_data'] or
    wikidata.formatAndCat{
        entity = item,
        property = 'P569',
        unknownlabel = unknowndatelabel,
        conjtype = 'or',
        sorttype = 'chronological',
        removedupesdate = 'cat',
        minprecision = 8, --precisão mínima para mostrar : década
    }

local dead = wikidata.getClaims{entity = item, property = 'P570'} --usado como um booleano que diz que se uma pessoa está morta para mudar algum elemento de exibição
local stillvalid
if dead then
        stillvalid = "?" -- permet de remplacer des "depuis" par des "à partir de"
end

local deathdate = localdata['morte_data'] or localdata['data_morte']
local wddeathdate = wikidata.formatAndCat{
    entity = item,
    property = 'P570',
    unknownlabel = unknowndatelabel,
    conjtype = 'or',
    sorttype = 'chronological',
    removedupesdate = 'cat',
    minprecision = 8,
}

local disappeardate = localdata['disparition']
local wddisappeardate = wikidata.formatAndCat{
    entity = item,
    property = 'P746',
    unknownlabel = unknowndatelabel,
    conjtype = 'or',
    sorttype = 'chronological',
    removedupesdate = 'cat',
    showqualifiers = 'P276',
    minprecision = 8,
}

local function format1(event, period, predecessor, together, successor, displayformat)
    local mainstr = event
    if predecessor then
        local s = 'precedido por ' .. predecessor
        if gender == 'f' then
            s = 'precedida por ' .. predecessor
        end
        mainstr = mainstr .. '<small><br />&nbsp;' .. s .. '</small>'
    end
    if together then
        local s = 'com ' .. together
        mainstr = mainstr .. '<small><br />&nbsp;' .. s .. '</small>'
    end
    if successor then
        local s = 'sucedido por ' .. successor
        if gender == 'f' then
            s = 'sucedida por ' .. successor
        end
        mainstr = mainstr .. '<small><br />&nbsp;' .. s .. '</small>'
    end
    return {type = 'row', label = period or '', value = function() return mainstr end}
end

-----------------

local function format2(event, period, predecessor, together, successor, displayformat)
    if (not event) then
        return nil
    end

    local rows = {}

    local eventrow = {type = 'row1col', color = 'secondcolor', value = event }
    table.insert(rows, eventrow)

    if period then
        period = '<span style="font-weight:normal">' .. period .. '</span>'
        local periodrow = {type = 'row1col', color = '#F9F9F9', value = period }
        table.insert(rows, periodrow)
    end

    if predecessor then
        local prederow = {type = 'row', label = 'Predecessor', value = function() return predecessor end}
        table.insert(rows, prederow)
    end

    if together then
        local succrow = {type = 'row', label = 'Com', value = function() return together end}
        table.insert(rows, succrow)
    end

    if successor then
        local succrow = {type = 'row', label = 'Sucessor', value = function() return successor end}
        table.insert(rows, succrow)
    end
    return {type = 'multi', rows = rows}
end


local function format3(event, period, predecessor, together, successor, displayformat, details)
    if details then
        details = '<span style="font-weight:normal">' .. details .. '</span>'
        event = linguistic.conj({event, details}, "new line")
    end
    local mainrow =  {type = 'row1col', color = 'secondcolor', value = event }
    if period then
        period = '<span style="font-weight:normal">' .. period .. '</span>'
    end
    local periodrow = {type = 'row1col', color = '#F9F9F9', value = period }
    local successionrow = {
            style = {['background-color'] = '#F9F9F9', ['padding-bottom'] = '2%'},
            type = 'navbox',
            inner = true,
            previousval = function() return predecessor end,
            nextval = function() return successor end,
    }

    return {type = 'multi', rows = {mainrow, periodrow, successionrow}}
end


local function timeline(localparam, wdconf, timelineformat, title, singtitle, details) -- data do poster: event (assume eventos já classificados)
    local rows = {}
    local function returnTable()
        return {
            type = 'table',
            title = title,
            rows = rows
    }
    end

    -- com dados locais
    local val = localdata[localparam]
    if val == '-' then
        return nil
    elseif val then
        table.insert(rows, {type = 'row1col', color = 'secondcolor', value = val})
        return returnTable()
    end
    -- com dados wikidata
    if not wdconf then
        return nil
    end

    wdconf.entity = wdconf.entity or item
    wdconf.sorttype = wdconf.sorttype or 'chronological'
    wdconf.labelformat = wdconf.labelformat  or genderedlabel
    wdconf.linktopic = wdconf.linktopic or '-'

    local statements = wikidata.getClaims(wdconf)
    if not statements then
        return nil
    end
    if #statements == 1 then
        title = singtitle
    end
    local displayformats = {
        A = format1,
        B = format2,
        C = format3,
    }
    local applyformat = displayformats[timelineformat] or displayformats['A']

    rows = {}
    for i, statement in pairs(statements) do
        local event =  linguistic.ucfirst(wikidata.formatStatement(statement, wdconf))
        local predecessor = wikidata.getFormattedQualifiers(statement, {'P155', 'P1365'} )
        local together = wikidata.getFormattedQualifiers(statement, {'P1706', ''})
        local successor = wikidata.getFormattedQualifiers(statement, {'P156', 'P1366'})
        local period = wikidata.getFormattedDate(statement, {linktopic = wdconf.linktopic, stilltrue = stillvalid } ) -- dont pass all wdconf or else qualifiers will show up
        local detailstr
        if type(details) == 'function' then
            detailstr = details(statement)
        end
        local row = applyformat(event, period, predecessor, together, successor, wdconf, detailstr)
        if row then
            table.insert(rows, row)
        end
    end
    table.insert(rows, {type = 'external text', value = function() return wikidata.addTrackingCat(wdconf.property) end})
    return returnTable()
end


local function dateandplace(thedate, theplace)
    if thedate and theplace and mw.ustring.find(thedate, "desconhecido") and mw.ustring.find(theplace, "desconhecido") then
        theplace = nil
        thedate =  mw.ustring.gsub(thedate, linguistic.ucfirst(unknowndatelabel), "Data e local desconhecido")
    end
    return linguistic.conj({thedate, theplace}, "new line")
end


--Título
function p.title(icon, style)
    local title = general.title(icon, style)
    title.value = function()
        return localdata['nome'] or localdata['associacão_nome'] or localdata['nome_think'] or localdata['acrónimolaboratório'] or localdata['título']
            or wikidata.getLabel(localdata.item)
    end
    return title
end

--Imagem
function p.mainimage(cat)

    -- pedido de ilustração apenas se a pessoa nasceu ou morreu depois de 1900, caso contrário, muitas vezes é impossível encontrar
    local defaultimage = 'Padrao 2.svg'
    local age = wikidata.stringTable{property = 'P569,P570', entity = item, displayformat = 'raw', excludespecial = true}

    if age and age [1] then
        local pattern = "(%W)(%d+)%-(%d+)%-(%d+)"
        local era, year = age[1]:match(pattern)
        if (era == '-') or (tonumber(year)) < 1900 then
            defaultimage = nil
        end
    end
    return  general.mainimage(cat or '!Artigos de biografia sem imagens', defaultimage)
end

-- Nomes
function p.othernames()

    local names = {
    --{'P1477', 'Nome nativo', 'Nomes nativos', 'nome nativo'}, --nome de nascimento mesmo que P1559
    {'P1559', 'Nome no idioma nativo', 'Nomes nos idiomas nativos', 'nomecompleto', 'nome nativo'}, --nome de nascimento no idioma nativo
    {'P1449', 'Apelido', 'Apelidos', 'apelido'}, -- sobrenome
    {'P2001', 'Romanização revisada', 'Romanização revisada', 'romanização'},
    {'P1942', 'McCune-Reischauer', 'McCune-Reischauer', 'romanização mccune-reischauer'},
--  {'P460', 'Pseudónimo', 'Pseudónimos', 'pseudónimo'}, -- igual a P742
    {'P742', 'Pseudónimo', 'Pseudónimos', 'pseudónimo'},
    {'P1782', 'Nome de cortesia', 'Nomes de cortesias', 'nome de cortesia'},
    {'P1786', 'Nome póstumo', 'Nomes póstumos', 'nome póstumo'},
    {'P1785', 'Nome de templo', 'Nomes de templo', 'nome de templo'},
    {'P1787', 'Nome artístico', 'Nomes artísticos', 'nome artístico'},
    {'P428', 'Abreviação em botânica', 'Abreviações em botânica', 'abreviação em botânica'}, --abreviação do autor botânico
    {'P835', 'Abreviação', 'Abreviações', 'abreviação'}, -- citação de autor
    {nil, 'Outros nomes', 'Outros nomes', 'outros_nomes'},
    {nil, 'Conhecido por', 'Conhecido por', 'conhecido_por'},
    }

    local nativelangnamerow = { -- um pouco peculiar, tão distante
        type = 'row',
        wikidata  = function()
            local s = wikidata.formatAndCat{entity = item, property = 'P1559', showqualifiers = 'P1721', conjtype = 'or'}
            if (not s) then
                return nil
            end
            -- ver se o nome do valor se parece com o texto (tendo em conta a poluição dos marcadores de idioma
            local label = mw.ustring.lower(wikidata.getLabel(item) or '')
            local useless
            if mw.ustring.find(mw.ustring.lower(s), mw.ustring.lower(label), 1, true) then
                useless = true
            end
            if wikidata.formatStatements{entity = item, property = 'P1559'} == wikidata.formatStatements{entity = item, property = 'P1477'} then
                useless = true --inutile si duplique le "nom de naissance"
            end
            if useless then
                return nil
            end
            return s
            end,
        label = 'Nome na língua materna',
        plurallabel = 'Nomes nas línguas maternas',
        value = 'nome na língua materna',
    }

    local rows = {type = 'multi', rows = {nativelangnamerow}}
    for i, j in pairs(names) do
        local query
        if j[1] and not localdata['outros nomes'] then -- quando existe um parâmetro "outros nomes", o Wikidata fica desabilitado para evitar riscos duplicados
            query = {property = j[1], showqualifiers = {'P1721'}, conjtype = 'new line'}
        end
        table.insert(rows.rows, {type = 'row', value = j[4], wikidata = query, label = j[2], plurallabel = j[3]})
    end
    return rows
end

-- NASCIMENTO E MORTE
function p.birth() -- data de nascimento na primeira linha, local do nascimento no segundo
    return {
        type = 'row',
        label = 'Nascimento',
        value =
            function()
            local thedate = datemodule.dataInfobox{args = {[1] = 'nascimento', [2] = birthdate or '', [3] = deathdate or wddeathdate or disappeardate or wddisappeardate or '', qualificatif = linktopic}}
            local theplace = localdata['local de nascimento'] or
                             wikidata.formatAndCat({entity =item, -- mostrar o nome do local de nascimento em vigor na data de nascimento
                                                    property= 'P19',
                                                    rank = 'best',
                                                    labelformat = function(val) return wikidata.getLabel(val) end,
                                                    conjtype= ' ou ',
                                                    defaultlinkquery =  {property = {'P361'}}, -- links por padrão :  "parte de",
                                                    unknownlabel = "local desconhecido",
                                                    showqualifiers = {'P131', 'P17'},
                                                    qualifconjtype = 'comma'
                                                    }
                                                   )
            return dateandplace(thedate, theplace)
            end
    }
end

function p.death() -- mesma função que a função p.birth

    -- date de disparition
    local ldisappeardate = disappeardate
    if (not ldisappeardate ) and (not deathdate) then -- récupérée de Wikidata seulement si la date de décès n'est pas fournie en locale
        ldisappeardate = wddisappeardate
    end
    if ldisappeardate and birthdate then
        ldisappeardate  = datemodule.dataInfobox{args = {[1] = 'evento', [2] = birthdate  or '', [3] = ldisappeardate or '', qualificatif = linktopic, unknownlabel = 'data desconhecida'}}
    end

    -- data de morte
    local ddate = deathdate -- declarado para todo o módulo

    if (not ddate) and (not ldisappeardate) then
        deathdate = wddeathdate -- obtido do Wikidata apenas se a data do desaparecimento não for fornecida localmente
    end
    local thedate = datemodule.dataInfobox{args = {[1] = 'morte', [2] = birthdate or '', [3] = deathdate or '', qualificatif = linktopic, unknownlabel = 'data desconhecida'}}
    local theplace = localdata['local_morte'] or
                     wikidata.formatAndCat{entity =item,
                                             property= 'P20',
                                             rank = 'best',
                                             -- indicação do nome do local da morte em vigor na data da morte
                                             labelformat = function(val) return wikidata.getLabel(val) end,
                                             conjtype= ' ou ',
                                             defaultlinkquery =  {property = {'P361'}}, -- ligações predefinidas: "parte de",
                                             unknownlabel = "local desconhecido",
                                             showqualifiers = {'P131', 'P17'},
                                             qualifconjtype = 'comma'
                                             }

    local val = dateandplace(thedate, theplace)

    return
    {type = 'multi', rows = {
        { -- desaparecimento
        type = 'row',
        label = 'Desaparecimento',
        value = function() return ldisappeardate end
        },
        { -- morte
        type = 'row',
        label = 'Morte',
        value = function() return val end,
        }
    }}
end

function p.atividade()
    return {
        type = 'row',
        label = "Período de atividade",
        value = "período de atividade",
        wikidata = function()
            local startDate = wikidata.formatAndCat{entity = item, property = 'P2031', conjtype = 'or', sorttype = 'chronological', linkback = '-'}
            local endDate =  wikidata.formatAndCat{entity = item, property = 'P2032', conjtype = 'or', sorttype = 'chronological'}
            if not (startDate or endDate) then
                return wikidata.formatAndCat{entity = item, property = 'P1317', conjtype = 'or', sorttype = 'chronological'}
            end
            if startDate and not endDate then
                startDate = wikidata.formatAndCat{entity = item, property = 'P2031', conjtype = 'or', sorttype = 'chronological'}
            end
            return complexdate.daterange(startDate, endDate, {precision = 11, stilltrue = stillvalid})
            end
    }
end

function p.placeofburial()
    return
    {type = 'row', label = "Sepultamento", value = "sepultamento", property = 'P119'}
end


function table.slice(tbl, first, last, step)
    local sliced = {}

    for i = first or 1, last or #tbl, step or 1 do
        sliced[#sliced+1] = tbl[i]
    end

    return sliced
end

-- function that creates a filter function
-- if the main country "base_country_item" is (replaced by)+
-- the subsequent statement main value that the function will receive as a parameter
-- then the created function will return true for this statement to be filtered out

local function filter_replaces_builder(base_country_item)
    -- P1365 = remplace
    -- P1366 = remplacé par
    local replaced_query = {property = 'P1365'}
    return function(may_be_replacing_stmt)
        local may_be_replacing_item = wikidata.getMainId(may_be_replacing_stmt)
        local replaces = wikidata.inTransitiveVals(may_be_replacing_item, base_country_item, replaced_query)
        return not(wikidata.inTransitiveVals(may_be_replacing_item, base_country_item, replaced_query))
    end
end

-- filter parameterized by each of the values of the claims, in the order
-- « filter_function_builder » will be called by all the values (remaining after filtering) in « claims »
-- to filter the rest of the claims, starting from the first one in the list.
local function iterated_filter(claims, filter_function_builder)
    -- the first country in the list, if any of the following value replaces this one
    -- we remove them. So we split the list
    local first_country_claim = claims[1]
    local to_test = table.slice(claims, 2, #claims)

    if #to_test > 0 then
        -- building the filter function with the first country as base value
        -- (a closure)
        local condition = filter_function_builder(wikidata.getMainId(first_country_claim))
        -- keeping the number of values before the filter
        local nb_before = #to_test
        to_test = wikidata.filterClaims(to_test, {condition = condition}) or {}
        local nb_after = #to_test
        -- if some country was filtered out, we remove the dates of the main statement to avoid showing incomplete dates
        if (nb_before ~= nb_after and first_country_claim.qualifiers) then
            first_country_claim.qualifiers["P580"] = nil
            first_country_claim.qualifiers["P582"] = nil
        end
        -- if there still exists candidate countries, filter them recursively
        if #to_test > 0 then
            to_test = iterated_filter(to_test, filter_function_builder)
        end

        -- reconstruct the list of statement by readding our first country to the filtered list
        to_test = to_test or {}
        table.insert(to_test, 1, first_country_claim)
        return to_test
    end
    -- if there were nothing to filter, just return the first statement
    return {first_country_claim}
end
function p.nationality()

    -- para melhorar as maneiras que Wikidata lida com nacionalidade: Império Alemão (1901-1918) República de Weimar (1918-1933))
    local function wdDate()
    local nation = require "Módulo:Country data".nationality

    -- desativação se data de nascimento antes da era contemporânea: muitas imprecisões e anacronismos
    local mindate = '1789'

    local birthdate = wikidata.formatStatements{entity = item, property = 'P569', displayformat = 'raw', numval = 1}
    if (not birthdate) or complexdate.before(mindate, birthdate) then
       return nil
    end

    return {
           property = 'P27',
           -- vals = statements, -- statments é uma variável não declarada neste módulo
           showdate = true,
           entity = item,
           conjtype = 'comma',
           removedupes = true,
           linktopic = '-',
           displayformat =
           function(snak)
           local g = gender -- tipo da pessoa, para exibição do gentio
           if g == '?' then -- se desconhecido, em masculino
                 g = 'm'
           end
           local val, success = nation(wikidata.getId(snak), g)
           if not success then
                 val = wikidata.formatSnak(snak)
           end
           return val
           end
    }
    end

    return {
           type = 'row',
           label = 'Cidadania',
           plurallabel = 'Cidadanias',
           value = {'nacionalidade', 'cidadania', 'país'},
           wikidata = wdDate() -- wdDate() devolve uma tabela
    }

end

function p.nativelanguage()
    return
    {type = 'row', label = 'Língua materna', value = 'língua materna', property = 'P103'}
end

function p.writinglanguage()
    return
    {type = 'row', label = "Língua da escrita", value = 'língua da escrita', plurallabel = "Língua de escrita" , wikidata = {property = 'P6886' , expl = true}}
end

-- Domícilio
function p.places()
    return {type = 'multi', rows = {
{
    type = 'row',
    label = 'Membro do demo',
    plurallabel = 'Membros dos demos',
    value = 'demo',
    wikidata = {property = 'P2462', showdate = true, sorttype= 'chronological', precision = 'year'},
},
{
    type = 'row',
    label = 'Residência',
    plurallabel = 'Residências',
    value = {'residência', 'residencia'},
    wikidata = {property = 'P551', showdate = true, sorttype= 'chronological', precision = 'year'},
},
    }}
end

-- percurso profissional
function p.education()
    local query = {sorttype= 'chronological', property = 'P69', showdate = true, stilltrue = '?', showqualifiers = 'P512', conjtype = 'new line', linktopic = '-'}
    return {
        type = 'row',
        value = {'educação', 'formação'},
        wikidata = query,
        label = 'Formação',
    }
end

function p.occupation()

    local speciallabels = {
    f = {
    ['Q33999'] = '[[atriz]]',
    ['Q10798782'] = '[[atriz]]',
    ['Q10800557'] = '[[atriz]]',
    ['Q2405480'] = '[[atriz]]',
    ['Q2259451'] = '[[atriz]]',
    ['Q948329'] = '[[atriz]]'
    },
    m = {
    ['Q33999'] = '[[ator]]',
    ['Q10798782'] = '[[ator]]',
    ['Q10800557'] = '[[ator]]',
    ['Q10798782'] = '[[ator]]',
    ['Q2405480'] = '[[ator]]',
    ['Q2259451'] = '[[ator]]',
    ['Q948329'] = '[[ator]]'
    }
    }

    return {
        type = 'row',
        value = {'atividade', 'atividades'},
        wikidata = {
            property = 'P106',
            defaultlink = '-',
            defaultlinkquery = {property = {'P425','P1056'}},
            labelformat = genderedlabel,
            speciallabels = speciallabels[gender] or speciallabels['m'],
            removedupes = true,
            showdate = true,
            sorttype = 'chronological',
            stilltrue = not dead,
            excludevalues = { -- as ocupações que não merecem ser apresentadas
                'Q482980', -- auteur
                'Q15980158', --"auteur de non-fiction"
                'Q12144794', --prosateur
                'Q18814623', -- autobiographe
                'Q1209498', -- juriste-poète
                'Q1097498', -- "dirigeant"
                'Q2478141', -- aristocrate
                'Q116', -- monarque
                'Q115088092', -- participant à un forum international
            }
        },
        label = 'Atividade',
        plurallabel = 'Atividades'
    }
end

function p.haswrittenfor()
    local valueStyle = {}
    valueStyle['font-style'] = 'italic'
    return
        {type = 'row', label =
          function(localdata, item)
              if gender == 'f' then
                  return ''
              else
                  return 'Redator em'
              end
        end, value = 'redator em', wikidata = {property = "P6872", showdate = true}, valueStyle = valueStyle}
end

function p.employer()
    return {
        type = 'row',
        value = 'empregador',
        wikidata = {property = 'P108', showdate = true, sorttype= 'chronological'},
        label = function() return localdata['titulo empregador'] or 'Empregador' end,
    }
end

function p.victories()
    local title, singtitle = "Vitórias", "Vitória"
    local localparam = "vitoria"
    local wdconf = {property = 'P2522'}
    local displayformat = "B"

    return timeline(localparam, wdconf, displayformat, title, singtitle)
end


function p.officialposition()
    local title, singtitle = "Funções", "Função"
    local localparam = "função"
    local wdconf =  {
    property = 'P39',
    rank = 'valid',
    sorttype = 'inverted',
    defaultlinkquery =      {property = {'P2354', 'P2389', 'P453', 'P361', 'P108'}}, -- links padrão: lista, corpo direcionado ao corpo, "membro de", "parte de", empregador
    }
    -- em uma linha separada: jurisdição, "de", distrito eleitoral, diocese, afiliação, assembleia, partido, empregador
    local details = function(statement) return wikidata.getFormattedQualifiers(statement, {'P5054', 'P2937', 'P1001', 'P642', 'P2389', 'P768', 'P708', 'P1416', 'P194', 'P108', 'P937' , 'P1268'}, {conjtype = 'new line'}) end
    local displayformat = 'C'

    return timeline(localparam, wdconf, displayformat, title, singtitle, details)
end

function p.specialrole()
    local localparam = 'estatuto notável'
    local wdconf =  {
        property = 'P2868',
        rank = 'valid',
        sorttype = 'inverted',
        targetsuperclass = 'Q254917',
        defaultlinkquery =  {property = {'P2354'}}, -- link por padrão : lista de elementos
    }
    local displayformat = 'C'

    return timeline(localparam, wdconf, displayformat)
end

function p.nobilitytitle()
    local title, singtitle = "Títulos de nobreza", "Título de nobreza"
    local localparam = "titulo de nobreza"
    local wdconf = {
    property = 'P97',
    entity = item, rank = 'valid',
    showqualifiers =  {'P642'},
    defaultlinkquery =      {property = {'P2354', 'P361'}}, -- links padrão: list, body directed, "member of" e "part of"
    }
    local displayformat = "B"

    return timeline(localparam, wdconf, displayformat, title, singtitle)
end

function p.nobilitytitle()
    local title, singtitle = 'Títulos de nobreza', 'Título de nobreza'
    local localparam = 'título de nobreza'
    local wdconf = {
        property = 'P97',
        entity = item, rank = 'valid',
        showqualifiers =  {'P642'},
        defaultlinkquery =  {property = {'P2354', 'P361'}}, -- links padrão: lista, desenha organização dirigida, "membro de" e "parte de"
    }
    local displayformat = 'B'

    return timeline(localparam, wdconf, displayformat, title, singtitle)
end

function p.honorifictitle()
    local title, singtitle = "Título honorífico", "Títulos honoríficos"
    local localparam = "titulo honorifico"
    local wdconf = {property = 'P511', entity = item, rank = 'valid'}
    local displayformat = "C"

    return timeline(localparam, wdconf, displayformat, title, singtitle)
end

function p.sepultura()
    return {
            type = 'images',
            imageparameters =  {'sepultura'},
            defaultimages = nil,
            defaultupright = 1,
            uprightparameter = 'upright sepultura',
            sizeparameter = 'tamanho urna', -- obsoleto
            captionparameter = 'legenda sepultura',
            defaultcaption = 'Vista da sepultura.',
            property = 'P1442',
            numval = 1,
    }
end

function p.placa()
    return {
            type = 'images',
            imageparameters =  {'placa'},
            defaultimages = nil,
            defaultupright = 1,
            uprightparameter = 'upright placa',
            sizeparameter = 'tamanho placa', -- obsoleto
            captionparameter = 'legenda placa',
            defaultcaption = 'placa comemorativa',
            property = 'P1801',
            numval = 1,
    }
end

function p.brazao()
    return {
            type = 'images',
            imageparameters =  {'brazão'},
            defaultimages = nil,
            defaultupright = 0.7,
            uprightparameter = 'upright brazão',
            sizeparameter = 'tamanho brazão', -- obsoleto
            captionparameter = 'legenda brazão',
            defaultcaption = 'brazão',
            property = 'P94',
            numval = 1,
    }
end

function p.sinete()
    return {
            type = 'images',
            imageparameters =  {'emblema'},
            defaultimages = nil,
            defaultupright = 0.7,
            uprightparameter = 'upright emblema',
            sizeparameter = 'tamanho emblema', -- obsoleto
            captionparameter = 'legenda emblema',
            defaultcaption = 'emblema',
            property = 'P158',
            numval = 1,
    }
end

function p.monogram()
    return {
            type = 'images',
            imageparameters =  {'monograma'},
            defaultimages = nil,
            defaultsize =      '100px',
            sizeparameter = 'tamanho monograma',
            captionparameter = 'legenda monograma',
            defaultcaption = 'Monograma',
            property = 'P1543',
            numval = 1,
    }
end

function p.flag()
    return {
            type = 'images',
            imageparameters =  {'bandeira'},
            defaultimages = nil,
            defaultsize =      '150px',
            sizeparameter = 'tamanho bandeira',
            captionparameter = 'legenda bandeira',
            defaultcaption = 'Bandeira',
            property = 'P41',
            numval = 1,
    }
end

function p.logo()
    return {
            type = 'images',
            imageparameters =  {'logotipo'},
            defaultimages = nil,
            defaultsize =      '150px',
            sizeparameter = 'tamanho logotipo',
            captionparameter = 'legenda logotipo',
            defaultcaption = 'Marca ou logotipo',
            property = 'P154',
            numval = 1,
    }
end

function p.politicalparty()
    return {
        type = 'row',
        value = 'partido político',
        label = 'Partido político',
        plurallabel = 'Partidos políticos',
        wikidata = { property = 'P102', sorttype= 'chronological', showdate = true, conjtype = 'new line', excludespecial = true,
            labelformat = function(id) if id == 'Q327591' and gender == 'f' then return 'independente' end end}
    }
end

function p.memberof()
    return {type = 'multi', rows = {
{
    type = 'row',
    value = 'ordem de cavalaria',
    label = 'Ordens de Cavalarias',
    plurallabel = 'Ordens de Cavalarias',
    wikidata = {property = 'P550', sorttype= 'chronological', showdate = true},
},
{
    type = 'row',
    label = 'Membro de',
    value = {'membro de', 'filiação'},
    wikidata = {property = 'P463', sorttype= 'chronological', showdate = true, precision = 'year', textformat = 'minimum', conjtype = 'new line'},
},
    }}
end

local masclabelitems  = {a='Q10855271', b='Q10855195', c='Q10855212', d='Q10855216', e='Q13422138', f='Q13422140', g='Q13422141', h='Q13452524', i='Q13452528', j='Q13452531', k='Q14637182', l='Q14637176', m='Q14637188',}
-- graus da Legião de Honra, da Ordem Nacional do Mérito, da ordem das palmas académicas e da ordem das Artes e letras em França, de género gramatical masculino, incluindo para as mulheres

function p.awards()

    local function awardsList()
    local majorawards = require "Módulo:Dicionário Wikidata/Distinções"
    local query = {
        entity = item,
        property= 'P166',
        sorttype= 'chronological',
        grouped = true,
        showqualifiers = 'P642',
        showdate= true,
        precision = 'year',
        conjtype = 'new line',
        textformat = 'minimum',
        linktopic = '-',
        defaultlinkquery = {property = {'P2354', 'P361' , 'P1027'}},
        excludevalues = 'Q15631401', -- membro da Royal Society, redundância com o campo "membro de" (P463)
        speciallabels = majorawards,
        labelformat = function(id) return genderedlabel(id) end,
    }
    local claims = wikidata.getClaims(query)
    if (not claims) then
        return nil
    end
    local str = wikidata.formatAndCat(query)
    if #claims < 4 then
        return str, #claims
    end

    --Se muitos valores, apenas exibir os importantes de [[Módulo: Dicionário Wikidata / Distinções]], e colocar os outros em um menu dobrável

    --- recuperação dos importantes
    local majorStr
    local targetvalues = {}
    for i, j in pairs(majorawards) do
        table.insert(targetvalues, i)
    end
    query.targetvalue = targetvalues
    query.value, query.claims, query.valuetable = nil, nil, nil -- aparentemente se não, por quê? BUG IMPORTANTE
    majorStr = wikidata.formatAndCat(query)

    --- dobrar dos outros
    local message = "'''Lista detalhada'''"
    local allAwardsTable = mw.html.create('div')
    :addClass("toccolours mw-collapsible mw-collapsed")
    :wikitext(message)
    :css{border = "none"}
    :tag('div')
    :addClass("mw-collapsible-content")
    :css{['line-height'] = '150%'} -- caso contrário, é realmente apertado
    :wikitext( str)
    :done()
    :allDone()

    return linguistic.conj({majorStr, tostring(allAwardsTable)}, "<br />"), #claims
    end

    return {
            type = 'row',
            value = {'prêmios', 'prémios', 'distincoes', 'distinções'},
            label = 'Distinções',
            singularlabel = 'Distinção',
            wikidata = function() return awardsList() end
    }
end

-- Influences
function p.influencedby()
    return {
            type = 'row',
            label =
            function(localdata, item)
            if gender == 'f' then
                return 'Influenciada por'
            elseif gender == 'f' then
                return 'Influenciado por'
            else
        return 'Influências'
            end
            end,
            value = {'influencias', 'influências'},
            wikidata = {property = 'P737'},
    }
end

function p.influenced()
    return {
    type = 'row',
    label = 'Influenciados',
    value = {'influenciados', 'influenciou'},
}
end

-- Movimentos
function p.movement()
    return
    {
    type = 'row',
        label = 'Movimento',
        value = {'movimento', 'movimentos', 'movimento(s)'},
        wikidata = {property = 'P135', sorttype= 'chronological', showdate = true, precision = 'year'},
    }
end

-- Religião
function p.religion()
    return {type = 'multi', rows = {
{
        type = 'row',
        label = 'Religião',
        value = 'religiões',
},
{
    type = 'row',
    label = 'Data de baptismo',
    value = {'data de baptismo', 'data de batismo'},
    property = 'P1636',
},
--{
--        type = 'row',         Tal como está, exibiria "padrinho", incluindo para a madrinha. De qualquer forma, relevância duvidosa.
--        label = 'Padrinho',
--        plurallabel = 'Padrinhos',
--        value = 'padrino',
--        property = 'P1290',
--},
{
    type = 'row',
    label = 'Paróquia',
    plurallabel = 'Paróquias',
    value = {'paroquia', 'paróquia'},
    property = 'P1290',
},
{
    type = 'row',
    label = 'Nome em religião',
    plurallabel = 'Nomes em religião',
    value = {'nome em religiao', 'nome em religião'},
    property = 'P1635',
},
{
    type = 'row',
    label = 'Ordem religiosa',
    plurallabel = 'Ordens religiosas',
    value = 'ordem religiosa',
    property = 'P611',
},
{
        type = 'row',
        label =
        function(localdata, item)
        if gender == 'f' then
            return 'Venerado por'
        elseif gender == 'm' then
            return 'Venerado por'
        else
            return 'Venerada por'
        end
        end,
        value = 'venerado por',
        property = 'P1049',
},
{
    type = 'row',
    label =
    function(localdata, item)
        if gender == 'f' then
            return 'Venerada por'
        elseif gender == 'm' then
            return 'Venerado por'
        else
        return 'Venerada por'
        end
    end,
    value = 'venerado por',
    property = 'P1049',
},
{
    type = 'row',
    label = 'Etapa de canonização',
    value = 'etapa de canonização',
    wikidata = {
    property = 'P411',
    labelformat = function(id) return genderedlabel(id) end,
    },
},
    }}
end

-- Carreira militar
function p.military()
    return {type = 'multi', rows = {
{
    type = 'row',
    label = 'Exército',
    plurallabel = 'Exércitos',
    value = 'arma',
    wikidata = {property = 'P241', showdate = true, sorttype= 'chronological', precision = 'year'},
},
{
    type = 'row',
    label = 'Grau militar',
    plurallabel = 'Graus militares',
    value = 'grau militar',
    wikidata = {property = 'P410', showdate = true, sorttype= 'chronological', precision = 'year', speciallabels = militaryranks, conjtype ='new line'},
},
{
        type = 'row',
        label = 'Grau militar',
        plurallabel = 'Graus militares',
        value = 'grau militar',
        blockers = {'grade'}, -- parâmetro teoricamente dedicado às artes marciais e go, mas muitas vezes preenchido com fileiras militares
        wikidata = {
            property = 'P410',
            showdate = true, sorttype= 'chronological', precision = 'year',
            speciallabels = militaryranks,
            conjtype ='new line',
            labelformat = genderedlabel,
            stilltrue = not dead
        },
},
{
        type = 'row',
        label = 'Conflito',
        plurallabel = 'Conflitos',
        value = 'conflito',
        wikidata = {property = 'P607', conjtype = 'new line', showdate = true, stilltrue = not dead, sorttype= 'chronological', precision = 'year'},
},
    }}
end

-- Carreira de toureiro
function p.toureiro()
    return {type = 'multi', rows = {
{
    type = "row",
    label = "Alternativo",
    value = "alternativo",
    wikidata = function() return wikidata.keyDate("Q2840411", item) end
},
{
    type = "row",
    label = "Confirmação alternativa",
    value = "confirmacao alt",
    wikidata = function() return wikidata.keyDate("Q23308805", item) end
},
    }}
end

-- Desporto
function p.sport()
    return {type = 'multi', rows = {
{
        type = 'row',
        label = 'Deporto',
        plurallabel = 'Desportos',
        value = {'desporto', 'deporto praticado', 'sport',},
        wikidata = {property = 'P641'},
},
{
        type = 'row',
        label = 'Equipa',
        plurallabel = 'Equipas',
        value = 'equipa',
        wikidata = {
            property = 'P54',
            sorttype= 'chronological',
            conjtype = 'new line',
            statementformat = function(statement)
                local str = wikidata.formatStatement(statement, {showdate = true})
                local compets = wikidata.getFormattedQualifiers(statement, {'P1350'})
                if tonumber(compets) and (tonumber(compets) > 1) then
                    compets = compets .. ' jogos jogados'
                elseif compets then
                    compets = compets .. ' jogo jogado'
                end
                local points = wikidata.getFormattedQualifiers(statement, {'P1351'})
                if tonumber(points) and (tonumber(points) > 1) then
                    points = points .. ' ponto marcados'
                elseif points then
                    points = points  .. 'ponto marcado'
                end
                local qualifiers = linguistic.conj{compets, points}
                if qualifiers then
                    str= str .. ' <small> – ' .. qualifiers .. ' </small>'
                end
                return str
            end
        }
},
{
        type = 'row',
        label = 'Posição',
        plurallabel = 'Posições',
        value = {'posição', 'posto', 'especialidade'},
        wikidata = {property = 'P413',
            labelformat = genderedlabel,
            },
},
{
        type = 'row',
        label = 'Disciplina desportiva',
        plurallabel = 'Disciplinas desportivas',
        value = 'disciplina desportiva',
        wikidata = {property = 'P2416'},
},
{
        type = 'row',
        label = 'Mão de jogo',
        value = 'mão de jogo',
        wikidata = {property = 'P741'},
},
{
        type = 'row',
        label = 'Destreza',
        value = 'destreza',
        wikidata = {property = 'P423'},
},
{
        type = 'row',
        label = 'Convocado por',
        plurallabel = 'Convodados por',
        value = 'convocado',
        wikidata = {
            property = 'P647',
            statementformat = function(statement)
                local team = wikidata.formatStatement(statement)
                local moment = wikidata.getFormattedQualifiers(statement, {'P793'}) or  wikidata.getFormattedQualifiers(statement, {'P585'})
                local rank = wikidata.getFormattedQualifiers(statement, {'P1836'})
                if rank then
                    rank = require 'Module:Nome2texto'.ordinal(rank) .. ' escolha'
                end
                local qualifs = linguistic.conj({moment, rank}, '&nbsp;– ')
                if not qualifs then
                    return team
                end
                return team .. ' <small>(' .. qualifs  .. ')</small>'
            end

            },
},
{
        type = 'row',
        label = 'Jogos pela seleção nacional',
        value = 'jogos seleção',
        wikidata = {property = 'P1129', numval = 1},
},
{
        type = 'row',
        label = 'Título em xadrez',
        plurallabel = 'Títulos em xadrez',
        value = 'título em xadrez',
        wikidata = {property = 'P2962', sorttype= 'chronological', showdate = true, stilltrue = not dead, precision = 'year'},
},
{
        type = 'row',
        label = 'Classificação Elo',
        value = 'classificação elo',
        wikidata = {property = 'P1087', numval = '1', sorttype = 'inverted', showdate = true, precision = 'year', removedupes = true},
},
{
        type = 'row',
        label = 'Recorde detido',
        plurallabel = 'Recordes detidos',
        value = 'recorde detido',
        wikidata = {property = 'P1000', sorttype= 'chronological', showdate = true},
},
{
        type = 'row',
        label = 'Treinador',
        plurallabel = 'Treinadores',
        value = 'treinador',
        wikidata = {property = 'P286', sorttype= 'chronological', showdate = true, stilltrue = not dead, precision = 'year'},
},
{
        type = 'row',
        label = 'Copiloto',
        plurallabel = 'Copilotos',
        value = 'copiloto',
        wikidata = {property = 'P2095', sorttype= 'chronological', showdate = true, stilltrue = not dead, precision = 'year'},
},
{
        type = 'row',
        label = 'Mecenas',
        plurallabel = 'Mecenas',
        value = {'mecena', 'mecenas', 'patrocinador', 'patrocinadores'},
        wikidata = {property = 'P859', sorttype= 'chronological', showdate = true, stilltrue = not dead, precision = 'year'},
},
    }}
end

-- Contatos
function p.contacts()
    return {type = 'multi', rows = {
{
    type = 'row',
    label = localdata['estudante de'] or 'estudante',
    plurallabel = 'estudantes',
    value = {'estudante', 'estudantes'},
    wikidata = {property = 'P1066', sorttype= 'chronological', showdate = true, stilltrue = not dead, precision = 'year'},
},
{
        type = 'row',
        label = {
            ms = 'Diretor de tese',
            fs = 'Diretora de tese',
            mp = 'Diretores de tese',
            fp = 'Diretoras de tese',
            default = '<abbr class="abbr" title="Direção">Dir.</abbr> de tese'
        },
        value = {'diretor de tese', 'dir. de tese'},
        wikidata = {property = 'P184', sorttype= 'chronological', showdate = true, precision = 'year'},
},
{
    type = 'row',
    label = 'Agente',
    label =
    function(localdata, item)
        if gender == 'f' then
            return 'Representada por'
        elseif gender == 'm' then
            return 'Representado por'
        else
        return 'Representado por'
        end
    end,
    value = 'representado por',
    wikidata = {property = 'P1875'},
},
{
    type = 'row',
    label = 'Sócio',
    plurallabel = 'Sócios',
    value = {'sócio', 'socio'},
    wikidata = {property = 'P1327', showdate = true, sorttype= 'chronological'},},
{
    type = 'row',
    label = localdata['instituto superior'] or 'Superior',
    plurallabel = 'Superiores',
    value = {'superior', 'superiores'},
    wikidata = {property = 'P802', sorttype= 'chronological', showdate = true, stilltrue = not dead, precision = 'year', numval = 5, expl = ''},
},
{
    type = 'row',
    label = 'Estudante de doutorado',
    plurallabel = 'Estudantes de doutoramento',
    value = 'estudante de doutoramento',
    wikidata = {property = 'P185', sorttype= 'chronological', showdate = true, precision = 'year', numval = 5, expl = ''},
},
{
    type = 'row',
    label = 'Pessoa relacionada',
    plurallabel = 'Pessoas relacionadas',
    value = 'pessoa relacionada',
 wikidata = {property = 'P3342', numval = 5, showqualifiers = 'P3831',qualiflink="-",qualiflabelformat="objectgender" },
}}}
end

-- Mecenato
function p.patron()
    return {
    type = 'row',
    label = '[[Mecenato|Mecena]]',
    singularlabel = '[[Mecenato|Mecena]]',
    plurallabel = '[[Mecenato|Mecenas]]',
    value = 'mecenas',
    wikidata = {property = 'P859', showdate = true, stilltrue = not dead, sorttype = 'chronological', conjtype = 'comma'},
    }
end

-- Música
function p.music()
    return {type = 'multi', rows = {
{
    type = 'row',
    label = 'Alcance',
    value = 'alcance',
    property = 'P412',
},
{
    type = 'row',
    label = 'Fach',
    value = 'fach',
    property = 'P1731',
},
{
    type = 'row',
    label = 'Instrumento',
    plurallabel = 'Instrumentos',
    value = 'instrumento',
    wikidata = {property = 'P1303', sorttype= 'chronological', excludevalues='Q17172850'},
},
{
    type = 'row',
    label = 'Editora discográfica',
    plurallabel = 'Editoras discográficas',
    value = {'editora discografica', 'label'},
    wikidata = {property = 'P264', sorttype= 'chronological', showdate = true, precision = 'year'},
},
    }}
end

-- Vitímas
function p.victims()
    return {type = 'multi', rows = {
{
    type = 'row',
    label = 'Vitímas',
    value = {'vitímas', 'vitimas'},
    wikidata = {property = 'P1345'},
},
    }}
end

-- Condenações
function p.penalties()
    return {type = 'multi', rows = {
{
    type = 'row',
    label =
    function(localdata, item)
        if gender == 'f' then
            return 'Condenada por'
        elseif gender == 'm' then
            return 'Condenado por'
        else
        return 'Condenado por'
        end
    end,
    value = 'condenado por',
    wikidata = {property = 'P1399', showdate = true, sorttype = 'chronological', precision = 'year', conjtype = 'comma'},
},
{
    type = 'row',
    label = 'Condenação',
    plurallabel = 'Condenações',
    value = {'condenacao', 'condenação'},
    wikidata = {property = 'P1596', showdate = true, sorttype = 'chronological', precision = 'year', conjtype = 'comma'},
},
{
    type = 'row',
    label = 'Ordem de detenção',
    plurallabel = 'Ordem de detenção',
    value = {'ordem de detenção', 'ordem de detencao'},
    wikidata = {property = 'P2632', showdate = true, sorttype = 'chronological', precision = 'year', conjtype = 'comma'},
},
    }}
end

-- Físico
function p.appearance()
    return {type = 'multi', rows = {
{
    type = 'row',
    label = 'Altura',
    value = {'tamanho', 'altura'},
    wikidata = {property = 'P2048', targetunit = 'm', rounding = '2'},
},
--[[
{
    type = 'row',
    label = 'Peso',
    value = 'peso',
    wikidata = {property = 'P2067', targetunit = 'kilogram', conjtype = 'new line', showdate=true, rounding = '1'},},
]]--
{
    type = 'row',
    label = 'Cabelo',
    value = 'cabelo',
    wikidata = {property = 'P1884'},
},
{
    type = 'row',
    label = 'Olhos',
    value = 'olhos',
    wikidata = {property = 'P1340'},
},
    }}
end
-- Família
function p.gens()
    return {type = 'multi', rows = {
{
        type = 'row',
        label = 'Gens',
        value = 'gens',
        wikidata = {property = 'P5025'},
},
    }}
end
function p.family()
    local  function showkinship(statement)
        local personid = wikidata.getMainId(statement)
        local personlabel = wikidata.formatEntity(personid)
        local persongender = wikidata.getgender(personid)
        local kintype = wikidata.getFormattedQualifiers(
            statement,
            'P1039',
            {
                labelformat = function(id) return genderedlabel(id, persongender) end,
                link = '-'
            }
            )
        if kintype then
            return personlabel .. ' ' .. linguistic.inparentheses(kintype)
        end
        return personlabel
    end

    return {type = 'multi', rows = {
{
        type = 'row',
        label = 'Família',
        plurallabels = 'Famílias',
        value = {'família', 'famílias'},
        property = 'P53',
},
{
        type = 'row',
        label = 'Pai',
        value = 'pai',
        wikidata = {
            property = 'P22',
            showqualifiers = "P1039",
            conjtype = ' ou '
        },
},
{
        type = 'row',
        label = 'Mãe',
        value = {'mãe', 'mae'},
        wikidata = {property = 'P25',
            showqualifiers = "P1039",
            unknownlabel = 'Desconhecida',
            conjtype = ' ou '
        },
},
{
        type = 'row',
        label = 'Padrasto',
        plurallabel = 'Padrastos',
        value = {'padrastro', 'madrastra'},
        wikidata = {
            property = 'P3448'
        },
},
{
        type = 'row',
        label = 'Irmão',
        value = 'irmão',
        wikidata = {
            property = 'P3373',
            sorttype = 'age',
            conjtype = 'new line',
            textformat = 'long',
            precision = 'year',
            stilltrue = not dead,
            statementformat = showkinship,
            excludespecial = true
        }
},
{
        type = 'row',
        label = 'Cônjuge', -- todo : adaptar o rótulo ao género ?
        plurallabel = 'Cônjugues',
        value = {'cônjuge', 'conjuge'},
        wikidata = {
            property = 'P26',
            showdate = true,
            linktopic = '-',
            sorttype = 'chronological',
            conjtype = 'new line',
            textformat = 'long',
            precision = 'year',
            stilltrue = not dead,
            precision = 'year',
            excludespecial = true
        }
},
{
        type = 'row',
        label = localdata['criança titulada'] or 'Descendentes',-- todo : adaptar a redação em genéro ?
        plurallabel = 'Descendentes',
        value = 'descendentes',
        wikidata = {
            property = 'P40',
            conjtype = 'new line',
            showdate = false,
            sorttype = 'age'
        }
},
{
    type = 'row',
    label = 'Parentesco',
    value = 'parentesco',
    wikidata = {
        property = 'P1038',
        excludespecial = true,
        conjtype = 'new line',
        statementformat = showkinship
        }
},
    }}
end

-- Escravos
function p.slavery()
    return {type = 'multi', rows = {
{
        type = 'row',
        label = 'Estatuto',
        plurallabel = 'Estatutos',
        value = 'estatuto',
        wikidata = {property = 'P3716',
            showdate = true,
            labelformat = genderedlabel,
            excludevalues = {'Q11573099','Q10076267'}, -- membro da família real (duplicado com propriedades familiares) e proprietário de escravos (não é realmente um status)
            defaultlinkquery = 'P425'},
},
{
    type = 'row',
    label = 'Proprietário',
    plurallabels = 'Proprietários',
    value = {'proprietário', 'proprietario'},
    wikidata = {property = 'P127'},
},
    }}
end

-- Obras
function p.works(params)
    params = params or {}
    local title = params.title or "''''[[Magnum opus]]''''"
    params.title = nil

    local wikidata = {
        excludespecial = true,
        numval = 5,
        property = 'P800',
        defaultlink = 'image',
        showdate= true,
        labelformat = function(id)
            local label =  wikidata.getLabel(id)
            if label then
                if wikidata.isInstance('Q386724', id, 6) then     --itálico para instâncias de "trabalho" ou suas subclasses
                    if wikidata.isInstance('Q14897293', id, 5) or wikidata.isInstance('Q13226383', id, 5) then     --exceto para instâncias de "entidade fictícia", "equipamento" ou suas subclasses
                        return label
                    else
                        return '<i>' .. label .. '</i>'
                    end
                else
                    return label
                end
            end
            end,
    }

    for i, j in pairs(params) do
        wikidata[i] = j
    end

    return
    {type = 'table', title = title, singulartitle = singulartitle, rows =
        {
            {
            type = 'row',
            value = 'obras principais',
            wikidata = wikidata
            }
        }
    }
end

function p.filmography()
    local title = 'Filmes notáveis'
    return
    {type = 'row', label = 'Filmes notáveis', value = 'filmes notáveis', property = 'P1283'}
    end

function p.discography()
    local title = 'Discografia'
    return
    {type = 'row', label = 'Discografia', value = 'discografia', property = 'P358'}
end

-- Assinatura
function p.assinatura(default)
    local nom = localdata.nome or mw.title.getCurrentTitle().text
    local alt = 'assinatura de ' .. nom
    if mw.ustring.match( nom, '^[AEÈÉIOUY]' )  then
        alt = "assinatura de " .. nom
    end
    return {
        type = 'images',
        imageparameters =  {'assinatura'},
        defaultimage = default,
        captionparameter = 'legenda assinatura',
        defaultcaption = 'Assinatura',
        uprightparameter = 'upright assinatura',
        defaultupright = 0.75,
        defaultalt = alt,
        property = 'P109',
        numval = 1
    }
end

-- Registo vocal
function p.voice()
    return {
        type             = 'images',
        style            = {['padding-top'] = '25px'},--{['border-width'] = '10px', ['border-style'] = 'solid'},
        defaultcaption   = 'Registo vocal',
        captionparameter = 'legenda voz',
        imageparameters  = 'voix',
        defaultsize      = '280',
        wikidata         = general.selectSound('P990'),
        numval           = 1,
    }
end

-- Website
p.website = general.website

-- Pronúnciação
p.prononciation = general.prononciation

-- festa do santo
function p.feast()
    local title = 'Festa'
    return {type = 'row', label = 'Festa', value = 'festa', wikidata = {property = 'P841' , showqualifiers = 'P276'}}
end

-- arquivado por
function p.archivesat()
    return {type = 'row', label = 'Arquivos conservados por', value = "arquivado por",
        wikidata = {
            property = 'P485', conjtype = 'new line',
            showqualifiers = {'P217','P7328','P585','P7103','P7104'}, qualifprecision = 'year',
            qualifformat = function(statement, qualifs, params) -- basé sur wikidata.getFormattedQualifiers dans [[Module:Wikidata]]
                local str = ''
                if not params then params = {} end
                local qualiftable = wikidata.getQualifiers(statement, qualifs)
                if not qualiftable then
                    return nil
                end
                qualiftable = wikidata.filterClaims(qualiftable, params) or {}
                for i, snak in pairs(qualiftable) do
                    if (snak.datatype == 'time' and snak.property == 'P7104') then -- fim do período abrangido
                        str = str .. '-'
                    elseif i > 1 then
                        str = str .. ', '
                    end
                    qualiftable[i] = wikidata.formatSnak(snak, params)
                    if snak.datatype == 'quantity' and tonumber(snak.datavalue.value.amount) > 1 then -- pluriel
                        qualiftable[i] = qualiftable[i] .. 's'
                    end
                    str = str .. qualiftable[i]
                end
                return str
            end,
            showsource = true
        }
    }
end

return p