Modul:Wikidata utilities: Unterschied zwischen den Versionen
KKeine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
Zeile 145: | Zeile 145: | ||
return getNValues( statements, count or #statements ) | return getNValues( statements, count or #statements ) | ||
end | |||
function fw.getValuesWithQualifierIds( entity, p, qualifierP ) | |||
local result = {} | |||
local statements = fw.getStatements( entity, p, nil ) | |||
if #statements == 0 then return result end | |||
local value, id | |||
for i = 1, #statements, 1 do | |||
value = statements[i].mainsnak.datavalue.value | |||
id = 'unknown' | |||
if statements[i].qualifiers and statements[i].qualifiers[ qualifierP ] | |||
and ( #statements[i].qualifiers[ qualifierP ] > 0 ) then | |||
for j = 1, #statements[i].qualifiers[ qualifierP ], 1 do | |||
if statements[i].qualifiers[ qualifierP ][ j ].snaktype == 'value' then | |||
id = statements[i].qualifiers[ qualifierP ][ j ].datavalue.value.id | |||
end | |||
end | |||
end | |||
result[ id ] = value | |||
end | |||
return result | |||
end | end | ||