Módulo:Taxonbar/candidate

Documentação do módulo

Sobre

Esta predefinição está desenhada para ser utilizada de {{Info/Taxonomia/core}} ou em outras predefinições relacionadas, e segue páginas que podem ser candidatos para uma barra {{Taxonbar}} ou {{Controle de autoridade}}.

Se nenhuma barra {{Taxonbar}} ou {{Controle de autoridade}} existe na página transcluída, a página Wikidata do elemento é verificada se tem os valores instância de (P31)/subclasse de (P279), e uma lista de propriedades não aceitáveis.

Se for encontrada uma instância/subclasse aceitável, então a página é categorizada como:

Se não for encontrada uma instância/subclasse aceitável, então a página é categorizada como:

Se nenhum elemento aceitável e pelo menos 1 elemento não aceitável for encontrado, então a página não é colocada em nenhuma categoria de manutenção.

Uso

{{Taxonbar/candidate}}

local p = {}function p.check(frame)    local taxonbarExists = require('Module:Taxonbar/exists').check    if taxonbarExists(frame) then        return ''    else        local resolveEntity = require( 'Module:ResolveEntityId' )        local currentTitle = mw.title.getCurrentTitle()        local currentItem = nil        local categories = {            '[[Categoria:!Artigos com caixa taxonómica possivelmente sem barra táxon]]' --unset if acceptable or unacceptable found        }                --preliminary exclusion criteria        if string.match( currentTitle.text, '^Lista de ') then            return ''        end                --find Wikidata item        if currentTitle.namespace == 0 then --mainspace            local currentEntityId = mw.wikibase.getEntityIdForCurrentPage()            if resolveEntity._id(currentEntityId) then                currentItem = mw.wikibase.getEntity(currentEntityId)            else --currentEntityId == nil/unresolvable                return categories[1]            end        else            return ''        end                if currentItem then --currentItem should not be nil here, but check just in case            --determine if {{Taxonbar}} is *possibly* missing, or *definitely* missing            local acceptableInstanceOf_All = { --copied from [[Module:Taxonbar]]                ['Q16521'] = 'taxon',                      --strict                ['Q310890'] = 'monotypic taxon',           --strict                ['Q2568288'] = 'ichnotaxon',               --strict                ['Q23038290'] = 'fossil taxon',            --strict                ['Q47487597'] = 'monotypic fossil taxon',  --strict                ['Q42621'] = 'hybrid',                     --lax                ['Q235536'] = 'incertae sedis',            --lax                ['Q713623'] = 'clade',                     --lax                ['Q848328'] = 'serotype',                  --lax                ['Q857968'] = 'candidatus',                --lax                ['Q17487588'] = 'unavailable combination', --lax            }            local unacceptableInstanceOf = {                ['Q913170'] = 'trivial name',                ['Q55983715'] = 'group of organisms known by one particular common name',                ['Q937228'] = 'property',                ['Q14712'] = 'drupe',                ['Q163233'] = 'compound drupe',                ['Q747463'] = 'compound fruit',            }                        local acceptableCount = 0            local unacceptableCount = 0            for _, instanceOfState in pairs ( currentItem:getBestStatements('P31') ) do --instance of                local instanceOf = instanceOfState.mainsnak.datavalue.value.id                if acceptableInstanceOf_All[instanceOf] then                    acceptableCount = acceptableCount + 1                elseif unacceptableInstanceOf[instanceOf] then                    unacceptableCount = unacceptableCount + 1                end            end            for _, subclassOfState in pairs ( currentItem:getBestStatements('P279') ) do --subclass of                local subclassOf = subclassOfState.mainsnak.datavalue.value.id                if acceptableInstanceOf_All[subclassOf] then                    acceptableCount = acceptableCount + 1                elseif unacceptableInstanceOf[subclassOf] then                    unacceptableCount = unacceptableCount + 1                end            end                        if acceptableCount > 0 then                categories[1] = ''                categories[2] = '[[Categoria:!Artigos com caixa taxonómica sem barra táxon]]'            elseif unacceptableCount > 0 then                categories[1] = ''                categories[2] = ''            end                        return table.concat(categories)                    else            return ''        end    endendreturn p