Modulo:Wikidata: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
rimossa mw.wikibase.getEntity per l'utilizzo di mw.wikibase.getBestStatements e mw.wikibase.getAllStatements |
m aggiunti geo-shape e tabular-data, ordine alfabetico datatypes, rinominata property in propertyId come per entityId e nel manuale |
||
Riga 10:
-- =============================================================================
-- 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
--
-- Gli unici due utilizzi nel modulo sono in getLabel quando si deve specificare
-- una lingua diversa dall'italiano (non usata nelle voci)
-- e in getDatatype (solo per proprietà), non essendoci alternative -- =============================================================================
Riga 44:
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',
▲ ['external-id'] = 'identificativo esterno',
['wikibase-item'] = 'elemento',
['wikibase-property'] = 'proprietà'
▲ ['math'] = 'espressione matematica'
}
}
Riga 422 ⟶ 424:
-- Gli statement restituiti sono eventualmente filtrati in base ai parametri:
-- "rank", "qualifier", "qualifiertype" e "n"
local function getClaims(
local entityId, claims, filteredClaims
Riga 433 ⟶ 435:
args.rank = args.rank or 'best'
if args.rank == 'best' then
claims = mw.wikibase.getBestStatements(entityId,
else
-- statements filtrati per rank
claims = mw.wikibase.getAllStatements(entityId,
claims = filterRankValue(claims, args.rank)
end
Riga 514 ⟶ 516:
-------------------------------------------------------------------------------
function p._getClaims(
return getClaims(
end
Riga 529 ⟶ 531:
-- la proprietà non esistono, o se per parametri di selezione gli statement sono zero.
function p._getProperty(args, rawTable)
local
-- parametri posizionali
if not
error(i18n.errors['property-param-not-provided'], 2)
end
Riga 543 ⟶ 545:
ret = formatUserValue(value, args)
elseif args.wd ~= 'no' then
claims = getClaims(
ret = (claims and #claims > 0) and formatStatements(claims, args, rawTable) or nil
end
Riga 553 ⟶ 555:
-- 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
-- parametri posizionali
if not
error(i18n.errors['property-param-not-provided'], 2)
end
Riga 569 ⟶ 571:
ret = formatUserValue(value, args)
elseif args.wd ~= 'no' then
claims = getClaims(
if claims and #claims > 0 then
local formattedQualifiers = {}
Riga 585 ⟶ 587:
-- Restituisce l'indice dello statement con il valore richiesto, o nil se non trovato.
function p._indexOf(args)
local ret,
-- parametri posizionali
if not
error(i18n.errors['property-param-not-provided'], 2)
end
Riga 597 ⟶ 599:
end
claims = getClaims(
if claims and #claims > 0 then
args.formatting = 'raw'
Riga 613 ⟶ 615:
-- Restituisce il numero di statement di una proprietà di Wikidata.
function p._N(args)
local
-- parametri posizionali
if not
error(i18n.errors['property-param-not-provided'], 2)
end
-- get claims
claims = getClaims(
return claims and #claims or 0
Riga 628 ⟶ 630:
-- Restituisce true se la propriertà specificata ha come valore
-- almeno uno tra gli entityId passati come argomento.
function p._propertyHasEntity(
local statements = p._getProperty({
if statements then
for _, statement in ipairs(statements) do
Riga 680 ⟶ 682:
-- Restituisce il datatype di una proprietà Wikidata.
function p._getDatatype(args)
local
-- parametri posizionali
if not
error(i18n.errors['property-param-not-provided'], 2)
end
entity = mw.wikibase.getEntity(
if not entity then
error(i18n.errors['entity-not-found'], 2)
|