Modulo:Wikidata: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
m commento non aggiornato
m inverto logica del parametro per retrocompatibilità
 
(40 versioni intermedie di 7 utenti non mostrate)
Riga 1:
--[[
* Modulo per implementare le funzionalità dei template:
* {{Wikidata}}, {{WikidataQ}}, {{WikidataIdx}}, {{WikidataN}}, {{WikidataLabel}}, {{WikidataDescription}}
* {{WikidataLink}}, {{WikidataId}}, {{WikidataTipo}} e {{WikidataIstanza}}.
* Permette di accedere a Wikidata in modo più avanzato rispetto a {{#property}}.
Riga 9:
]]
 
-- =============================================================================
require('Module:No globals')
-- Non utilizzare mai mw.wikibase.getEntity, per esempio un solo utilizzo di
-- mw.wikibase.getEntity('Q183') fa aumentare di 7 MB l'utilizzo di memoria
-- per Lua ed è molto lenta se ripetuta (unico utilizzo in getDatatype,
-- solo per proprietà, non essendoci alternative).
-- =============================================================================
 
require('strict')
 
local getArgs = require('Module:Arguments').getArgs
local mConvert = require('Module:Conversione')
local mLanguages = require('Module:LinguaggiLingue')
 
-- Categoria per le pagine con errori
local errorCategory = '[[Categoria:Voci con errori del modulo Wikidata]]'
 
-- Messaggi
local p = {}
 
-- Messaggi di errore
local i18n = {
["errors"] = {
["'entityid-param-not-provided"'] = "Parametro ''entityid'' non fornito",
["'property-param-not-provided"'] = "Parametro ''property'' non fornito",
["'qualifier-param-not-provided"'] = "Parametro ''qualifier'' non fornito",
["'value-param-not-provided"'] = "Parametro ''valore'' da ricercare non fornito",
["'entity-not-found"'] = "'Entità non trovata"',
["'unknown-claim-type"'] = "'Tipo asserzione sconosciuta"',
["'unknown-snak-type"'] = "'Tipo di snak sconosciuto"',
["'unknown-datavalue-type"'] = "'Tipo di dato sconosciuto"',
["'unknown-entity-type"'] = "'Tipo di entità sconosciuta"',
['unknown-output-format'] = 'Formato di output sconosciuto'
},
["somevalue"] = "''valore sconosciuto''",
["novalue"] = "''nessun valore''",
datatypes = {
['commonsMedia'] = 'file multimediale su Commons',
['external-id'] = 'identificativo esterno',
['geo-shape'] = 'forma geografica',
['globe-coordinate'] = 'coordinate geografiche',
['math'] = 'espressione matematica',
['monolingualtext'] = 'testo monolingua',
['quantity'] = 'quantità',
['string'] = 'stringa',
['tabular-data'] = 'tabular data',
['time'] = 'data e ora',
['url'] = 'URL',
['wikibase-item'] = 'elemento',
['wikibase-property'] = 'proprietà'
}
}
 
local p = {}
 
-------------------------------------------------------------------------------
Riga 57 ⟶ 80:
if success and uri.protocol and protocols[uri.protocol] then
local dest = tostring(uri)
return string.format('<divspan style="word-break: break-all;">[%s %s]</divspan>', dest, dest:gsub(uri.protocol .. '://', ''))
else
return url
Riga 64 ⟶ 87:
 
local function formatEntityId(entityId)
local label = mw.wikibase.labelgetLabel(entityId)
local linksiteLink = mw.wikibase.sitelinkgetSitelink(entityId)
local ret
if link then
if entityId == mw.wikibase.getEntityIdForCurrentPage() then
if label and label ~= link then
ret = siteLink
return '[[' .. link .. '|' .. label .. ']]'
elseif siteLink and label then
else
ret = mw.getContentLanguage():ucfirst(label) == siteLink and
return '[[' .. link .. ']]'
string.format('[[%s]]', label) or
end
string.format('[[%s|%s]]', siteLink, label)
elseif siteLink then
ret = string.format('[[%s]]', siteLink)
elseif label then
ret = label
else
returnret label or= ''
end
return ret
end
 
Riga 83 ⟶ 112:
ret = value.text
if args.showlang then
ret = mLanguages.lingue( { value.language } ) .. '&nbsp;' .. ret
end
end
Riga 143 ⟶ 172:
ret = value.globe
else
ret = valuestring.latitude .. format('%s, %s', value..latitude, value.longitude)
end
return ret
Riga 175 ⟶ 204:
 
local function formatUnitSymbol(entityId, args)
local ret
local ret = p._getProperty( { 'P558', n = 1, from = entityId } )
for _, lang in ipairs({ 'mul', 'it', 'en' }) do
ret = p._getProperty({ 'P5061', includelang = lang, from = entityId })
if ret and ret ~= '' then
break
else
ret = nil
end
end
local space = ret == '°' and '' or ' '
if ret and args.showunitlink then
local link = mw.wikibase.sitelinkgetSitelink(entityId)
if link then
ret = string.format('[[%s|%s]]', link, ret)
Riga 203 ⟶ 240:
showunitlink = args.showunitlink,
formatnum = args.formatnum,
rounding = args.rounding
}
ret = mConvert._main(ret, unitId, args.unit, opts)
else
-- se è richiesto solo il simbolo dell'unità
-- senza la conversione lo ottiene da P558P5061
ret = args.rounding and round(ret, args.rounding) or ret
if args.formatnum then
Riga 222 ⟶ 259:
ret = mConvert._main(ret, unitId, 'second')
ret = ret and mw.language.getContentLanguage()
:formatDuration(tonumber(ret), { 'days', 'hours', 'minutes', 'seconds' } )
end
 
Riga 234 ⟶ 271:
local entityId = getEntityIdFromValue(datavalue.value)
if args.showprop then
ret = p._getProperty( { args.showprop, n = 1, from = entityId, }formatting = args.formatting }) or ''
elseif args.formatting then
local formatting = args.formatting:lower()
ret = (formatting == 'raw' or formatting == 'id') and entityId or
formatting == 'label' and mw.wikibase.getLabel(entityId) or
formatting == 'title' and (mw.wikibase.getSitelink(entityId) or '') or
error(i18n.errors['unknown-output-format'])
else
ret = args.formatting == 'raw' and entityId or formatEntityId(entityId)
end
elseif datavalue.type == 'string' then
Riga 278 ⟶ 321:
-- È al plurale perché anche i qualifier possono avere più di un valore
-- (si ottiene inserendo due volte lo stesso qualifier)
local function formatQualifiers(claim, qualifierqualifierId, args, rawTable, retTable)
local formattedQualifiers = retTable or {}
 
if claim.qualifiers and claim.qualifiers[qualifierqualifierId] then
local qualifiers = claim.qualifiers[qualifierqualifierId]
-- con args.nq seleziona solo l'n-esimo qualifier
if args.nq then
Riga 288 ⟶ 331:
qualifiers = (n and n <= #qualifiers) and { qualifiers[n] } or {}
end
-- qualifier filtrati per snaktype, default "value"
for _, q in pairs(qualifiers) do
args.snaktype = args.snaktype or 'value'
local formattedQualifier = formatSnak(q, args)
for _, qualifier in ipairs(qualifiers) do
if formattedQualifier ~= '' then
if qualifier.snaktype == args.patternsnaktype or args.snaktype == 'all' then
local formattedQualifier = formatFromPatternformatSnak(formattedQualifierqualifier, args)
if formattedQualifier ~= '' then
if args.pattern then
formattedQualifier = formatFromPattern(formattedQualifier, args)
if formattedQualifier ~= '' then
table.insert(formattedQualifiers, formattedQualifier)
end
else
table.insert(formattedQualifiers, formattedQualifier)
end
end
table.insert(formattedQualifiers, formattedQualifier)
end
end
Riga 309 ⟶ 360:
local function appendQualifiers(statement, text, args)
local formattedQualifiers = {}
local qualifiersqualifierIds = mw.text.split(args.showqualifiers, ',')
for _, qualifierqualifierId in ipairs(qualifiersqualifierIds) do
if statement.qualifiers[qualifierqualifierId] then
local formattedQualifier = formatQualifiers(statement, qualifierqualifierId, args)
table.insert(formattedQualifiers, formattedQualifier)
end
Riga 339 ⟶ 390:
local formattedStatements = {}
 
for i_, claim in pairsipairs(claims) do
local formattedStatement = formatStatement(claim, args)
if formattedStatement ~= '' then
Riga 345 ⟶ 396:
if args.pattern then
formattedStatement = formatFromPattern(formattedStatement, args)
if formattedStatement ~= '' then
table.insert(formattedStatements, formattedStatement)
end
else
table.insert(formattedStatements, formattedStatement)
end
table.insert(formattedStatements, formattedStatement)
end
end
Riga 362 ⟶ 417:
-------------------------------------------------------------------------------
 
-- RitornaRestituisce true se lo statement contiene il qualifier richiesto con un dato valore (o uno tra più valori separati da virgola)
local function hasQualifierValue(statement, qualifierId, qualifierValue)
local ret = false
for i_, qualifier in pairsipairs(statement.qualifiers[qualifierId]) do
local isItem = qualifier.snaktype == 'value' and
qualifier.datavalue.type == 'wikibase-entityid'
local qualifierValues = mw.text.split(qualifierValue, ',')
-- per le proprietà di tipo item il confronto è eseguito sull'id
for _, qualifierHas in ipairs(qualifierValues) do
if formatSnak(qualifier, isItem and { formatting = 'raw' } or {} ) == qualifierValue then
-- per le proprietà di tipo item il confronto è eseguito sull'id
ret = true
if formatSnak(qualifier, isItem and { formatting = 'raw' } or {}) == qualifierHas then
break
ret = true
break
end
end
end
Riga 377 ⟶ 435:
end
 
-- RitornaRestituisce i claim con il rank richiesto
local function filterRankValue(claims, rank)
local ret = {}
for i_, claim in pairsipairs(claims) do
if claim.rank == rank then
table.insert(ret, claim)
Riga 388 ⟶ 446:
end
 
-- RitornaRestituisce una tablesequence Lua contenente gli statement per la property richiesta,
-- oppureanche nilvuota se l'entity o la proprietà non esistono.esiste, o non ci sono valori che soddisfano i criteri
-- ("rank", "qualifier", "qualifiertype", "noqualifier", ...).
-- Gli statement ritornati sono eventualmente filtrati in base ai parametri:
-- Restituisce nil solo se la pagina non è collegata a un elemento Wikidata e non è indicato il from.
-- "rank", "qualifier", "qualifiertype" e "n"
local function getClaims(propertypropertyId, args)
local entityentityId, claims, filteredClaims
entityId = args.from or mw.wikibase.getEntityIdForCurrentPage()
-- get entity
if not entityId then
entity = mw.wikibase.getEntity(args.from)
if not entity then
return nil
end
 
-- il default rank è 'best'
if property and entity.claims and entity.claims[property] and
args.rank = args.rank or 'best'
#entity.claims[property] > 0 then
if args.rank == 'best' then
claims = entity.claims[property]
claims = mw.wikibase.getBestStatements(entityId, propertyId)
else
-- statements filtrati per rank
return nil
claims = mw.wikibase.getAllStatements(entityId, propertyId)
claims = filterRankValue(claims, args.rank)
end
 
-- statements filtrati per ranksnaktype, (default 'best')"value"
args.ranksnaktype = args.ranksnaktype or 'bestvalue'
if args.ranksnaktype =and args.snaktype ~= 'bestall' then
filteredClaims = filterRankValue(claims, 'preferred'){}
for _, claim in ipairs(claims) do
if #filteredClaims == 0 then
if claim.mainsnak.snaktype == args.snaktype then
filteredClaims = filterRankValue(claims, 'normal')
table.insert(filteredClaims, claim)
end
end
claims = filteredClaims
else
filteredClaims = filterRankValue(claims, args.rank)
end
claims = filteredClaims
 
-- statements filtrati per qualifier
if args.qualifier then
filteredClaims = {}
for i_, claim in pairsipairs(claims) do
if claim.qualifiers and claim.qualifiers[args.qualifier] then
if args.qualifiervalue then
Riga 440 ⟶ 500:
if args.noqualifier then
filteredClaims = {}
for i_, claim in pairsipairs(claims) do
if not (claim.qualifiers and claim.qualifiers[args.noqualifier]) then
table.insert(filteredClaims, claim)
Riga 451 ⟶ 511:
if args.qualifieroptnovalue and args.qualifiervalue then
filteredClaims = {}
for i_, claim in pairsipairs(claims) do
if claim.qualifiers and claim.qualifiers[args.qualifieroptnovalue] then
if not hasQualifierValue(claim, args.qualifieroptnovalue, args.qualifiervalue) then
Riga 463 ⟶ 523:
end
 
-- con args.qualifiertype=latest ritornarestituisce solo il più recente
if args.qualifier and args.qualifiertype == 'latest' then
local latest, latestTime
for i_, claim in pairsipairs(claims) do
if claim.qualifiers and claim.qualifiers[args.qualifier] then
for j_, qualifier in pairsipairs(claim.qualifiers[args.qualifier]) do
if qualifier.datavalue.type == 'time' then
if not latestTime or qualifier.datavalue.value.time > latestTime then
Riga 478 ⟶ 538:
end
end
claims = latest and { latest } or {}
end
 
-- con args.n ritornarestituisce solo l'n-esimo elemento
if args.n then
local n = tonumber(args.n)
Riga 491 ⟶ 551:
 
-------------------------------------------------------------------------------
-- Funzioni esportate per altri APImoduli
-------------------------------------------------------------------------------
 
function p._getClaims(propertypropertyId, args)
return getClaims(propertypropertyId, args or {})
end
 
Riga 502 ⟶ 562:
end
 
function p._formatQualifiers(claim, qualifierqualifierId, args, rawTable, retTable)
return formatQualifiers(claim, qualifierqualifierId, args or {}, rawTable, retTable)
end
 
-- RitornaRestituisce il valore di una proprietà di Wikidata oppure nil se l'entity o
-- la proprietà non esistono, o se per parametri di selezione gli statement sono zero.
function p._getProperty(args, rawTable)
local propertypropertyId, value, claims, ret
 
-- parametri posizionali
propertypropertyId = args[1] and string.upper(args[1]) or nil
if not propertypropertyId then
error(i18n.errors['property-param-not-provided'], 2)
end
value = args[2]
-- fix uppercase
args.qualifier = args.qualifier and string.upper(args.qualifier) or nil
 
if value then
ret = formatUserValue(value, args)
elseif args.wd ~= 'no' then
claims = getClaims(propertypropertyId, args)
ret = (claims and #claims > 0) and formatStatements(claims, args, rawTable) or nil
end
Riga 530 ⟶ 590:
end
 
-- RitornaRestituisce il valore di un qualifier di una proprietà di Wikidata,
-- o nil se l'entity o la proprietà non esistono, o se per parametri di selezione non ci sono risultati.
function p._getQualifier(args)
local propertypropertyId, qualifierqualifierId, value, claims, ret
 
-- parametri posizionali
propertypropertyId = args[1] and string.upper(args[1]) or nil
if not propertypropertyId then
error(i18n.errors['property-param-not-provided'], 2)
end
qualifierqualifierId = args[2] and string.upper(args[2]) or nil
if not qualifierqualifierId then
error(i18n.errors['qualifier-param-not-provided'], 2)
end
Riga 549 ⟶ 609:
ret = formatUserValue(value, args)
elseif args.wd ~= 'no' then
claims = getClaims(propertypropertyId, args)
if claims and #claims > 0 then
local formattedQualifiers = {}
for _, claim in pairsipairs(claims) do
formattedQualifiers = formatQualifiers(claim, qualifierqualifierId, args, true, formattedQualifiers)
end
ret = #formattedQualifiers > 0 and
Riga 563 ⟶ 623:
end
 
-- RitornaRestituisce l'indice dello statement con il valore richiesto, o nil se non trovato.
function p._indexOf(args)
local ret, propertypropertyId, value, claims
 
-- parametri posizionali
propertypropertyId = args[1] and string.upper(args[1]) or nil
if not propertypropertyId then
error(i18n.errors['property-param-not-provided'], 2)
end
Riga 577 ⟶ 637:
end
 
claims = getClaims(propertypropertyId, args)
if claims and #claims > 0 then
args.formatting = 'raw'
for i, claim in pairsipairs(claims) do
if formatStatement(claim, args) == value then
ret = i
Riga 591 ⟶ 651:
end
 
-- RitornaRestituisce il numero di statement di una proprietà di Wikidata.
function p._N(args)
local propertypropertyId, claims
 
-- parametri posizionali
propertypropertyId = args[1] and string.upper(args[1]) or nil
if not propertypropertyId then
error(i18n.errors['property-param-not-provided'], 2)
end
-- get claims
claims = getClaims(propertypropertyId, args)
 
return claims and #claims or 0
end
 
-- RitornaRestituisce true se la proprietàpropriertà P31 (instance of)specificata ha come valore almeno uno tra gli entityId specificati
-- almeno uno tra gli entityId passati come argomento.
function p._instanceOf(args)
function p._propertyHasEntity(propertyId, args)
local statements = p._getProperty( { 'P31', from = args.from, formatting = 'raw' }, true)
local statements = p._getProperty({ propertyId, from = args.from, formatting = 'raw' }, true)
if statements then
for _, statement in ipairs(statements) do
Riga 614 ⟶ 675:
if statement == entityId then
return true
end
end
end
 
-- Se non è stato trovato alcun valore, controlla se questo sia ereditato
-- tramite la proprietà "sottoclasse di" (P279) scavando in profondità
-- fino all'esaurirsi del numero specificato in args.recursion.
--[[ TODO: Valutare se sia opportuna una ricerca ricorsiva potenzialmente infinita.
Per farlo si può aggiungere un parametro (opzionale) maxDepth
che svolga l'attuale funzione di recursion e cambiare quest'ultimo
in un parametro booleano.
]]
args.recursion = tonumber(args.recursion) or 0
if args.recursion > 0 then
local recursion = args.recursion
if type(args.loadedEntities) ~= 'table' then
args.loadedEntities = setmetatable({}, {
__newindex = function(t, k, v)
rawset(t, k, v)
rawset(t, #t+1, k)
end })
args.loadedEntities[args.from or mw.wikibase.getEntityIdForCurrentPage()] = true
end
for _, statement in ipairs(statements) do
if not args.loadedEntities[statement] then
args.loadedEntities[statement] = true
args.recursion = args.recursion - 1
args.from = statement
if p._propertyHasEntity('P279', args) then
return true, args.loadedEntities
end
args.recursion = recursion
end
end
Riga 619 ⟶ 712:
end
 
return false, args.loadedEntities
end
 
-- Restituisce true se la proprietà P31 (instance of) ha come valore almeno uno tra gli entityId specificati
-- Ritorna l'etichetta di un item o di una proprietà Wikidata.
function p._getLabel_instanceOf(args)
return p._propertyHasEntity('P31', args)
-- parametri posizionali
end
local entityId = args[1] and string.upper(args[1]) or nil
local langCode = args[2]
 
-- Restituisce true se la proprietà P279 (subclass of) ha come valore almeno uno tra gli entityId specificati
local entity = mw.wikibase.getEntity(entityId)
function p._subclassOf(args)
if not entity then
return p._propertyHasEntity('P279', args)
error(i18n.errors['entity-not-found'], 2)
end
 
-- Restituisce l'etichetta di un item o di una proprietà Wikidata.
function p._getLabel(args)
local entityId = args[1] and string.upper(args[1])
local ret
if args[2] then
ret = mw.wikibase.getLabelByLang(entityId, args[2])
else
ret = mw.wikibase.getLabel(entityId)
end
return ret
end
 
-- Restituisce la descrizione di un item o di una proprietà Wikidata.
return entity:getLabel(langCode)
function p._getDescription(args)
local entityId = args[1] and string.upper(args[1])
local ret = mw.wikibase.getDescription(entityId)
return ret
end
 
-- RitornaRestituisce il titolo della pagina collegata a un dato item Wikidata.
function p._getLink(args)
-- parametri posizionali
local entityId = args[1] and string.upper(args[1]) or nil
if not entityId then
error(i18n.errors['entityid-param-not-provided'], 2)
Riga 647 ⟶ 755:
end
 
-- RitornaRestituisce il datatype di una proprietà Wikidata.
function p._getDatatype(args)
local ret, propertypropertyId, entity, datatype
 
-- parametri posizionali
propertypropertyId = args[1] and string.upper(args[1]) or nil
if not propertypropertyId then
error(i18n.errors['property-param-not-provided'], 2)
end
 
entity = mw.wikibase.getEntity(propertypropertyId)
if not entity then
error(i18n.errors['entity-not-found'], 2)
end
 
datatypeif =not i18n.datatypes[entity.datatype] then
if datatype == 'commonsMedia' then
ret = 'file multimediale su Commons'
elseif datatype == 'globe-coordinate' then
ret = 'coordinate geografiche'
elseif datatype == 'monolingualtext' then
ret = 'testo monolingua'
elseif datatype == 'quantity' then
ret = 'quantità'
elseif datatype == 'string' then
ret = 'stringa'
elseif datatype == 'time' then
ret = 'data e ora'
elseif datatype == 'url' then
ret = 'URL'
elseif datatype == 'external-id' then
ret = 'identificatore esterno'
elseif datatype == 'wikibase-item' then
ret = 'elemento'
elseif datatype == 'wikibase-property' then
ret = 'proprietà'
elseif datatype == 'math' then
ret = 'espressione matematica'
else
error(i18n.errors['unknown-datavalue-type'], 2)
end
 
return reti18n.datatypes[entity.datatype]
end
 
-- RitornaRestituisce l'ID dell'item Wikidata collegato alla pagina corrente. o a una pagina specificata
-- (nota: se il parametro followRedirects è valorizzato con "no", segue i redirect fermandosi al primo redirect collegato a un elemento)
function p._getId()
function p._getId(args)
return mw.wikibase.getEntityIdForCurrentPage()
local ret
local followRedirects = not args.followRedirects or args.followRedirects ~= "no"
if args[1] then
local title = mw.title.new(args[1])
while title do
local id = mw.wikibase.getEntityIdForTitle(title.prefixedText)
if id then
ret = id
break
else
title = followRedirects and title.redirectTarget or nil
end
end
else
ret = mw.wikibase.getEntityIdForCurrentPage()
end
return ret
end
 
-------------------------------------------------------------------------------
-- Entry-point per {{Wikidata}}
-- Funzioni esportate per i template
-------------------------------------------------------------------------------
 
-- Funzione per il template {{Wikidata}}
function p.getProperty(frame)
return select(2, xpcall(function()
return p._getProperty(getArgs(frame, { parentOnly = true }))
end, errhandler))
end
 
-- Entry-pointFunzione per il template {{WikidataQ}}
function p.getQualifier(frame)
return select(2, xpcall(function()
return p._getQualifier(getArgs(frame, { parentOnly = true }))
end, errhandler))
end
 
-- Entry-pointFunzione per il template {{WikidataIdx}}
function p.indexOf(frame)
return select(2, xpcall(function()
return p._indexOf(getArgs(frame, { parentOnly = true }))
end, errhandler))
end
 
-- Entry-pointFunzione per il template {{WikidataN}}
function p.N(frame)
return select(2, xpcall(function()
return p._N(getArgs(frame, { parentOnly = true }))
end, errhandler))
end
 
-- Entry-pointFunzione per il template {{WikidataLabel}}
function p.getLabel(frame)
return select(2, xpcall(function()
return p._getLabel(getArgs(frame, { parentOnly = true }))
end, errhandler))
end
 
-- Entry-pointFunzione per il template {{WikidataLinkWikidataDescription}}
function p.getDescription(frame)
return select(2, xpcall(function()
return p._getDescription(getArgs(frame, { parentOnly = true }))
end, errhandler))
end
 
-- Funzione per il template {{WikidataLink}}
function p.getLink(frame)
return select(2, xpcall(function()
return p._getLink(getArgs(frame, { parentOnly = true }))
end, errhandler))
end
 
-- Entry-pointFunzione per il template {{WikidataIstanza}}
function p.instanceOf(frame)
return select(2, xpcall(function()
return p._instanceOf(getArgs(frame, { parentOnly = true })) and 1 or ''
end, errhandler))
end
 
-- Entry-pointFunzione per il template {{WikidataTipo}}
function p.getDatatype(frame)
return select(2, xpcall(function()
return p._getDatatype(getArgs(frame, { parentOnly = true }))
end, errhandler))
end
 
-- Entry-pointFunzione per il template {{WikidataId}}
function p.getId(frame)
return select(2, xpcall(function()
return p._getId(getArgs(frame, { parentOnly = true }))
end, errhandler))
end
 
-- Funzione per il template {{WikidataValido}}
function p.checkProperty(frame)
return select(2, xpcall(function()
return p._N(getArgs(frame, { parentOnly = true })) > 0 and 1 or ''
end, errhandler))
end
 
-- Funzione per il template {{WikidataClasse}}
function p.propertyHasEntity(frame)
local args = getArgs(frame)
local propertyId = args[1]
return select(2, xpcall(function()
return p._propertyHasEntity(propertyId, args) and 1 or ''
end, errhandler))
end