Modul:Wikidata utilities: Unterschied zwischen den Versionen
rückgängig; mw.wikibase.getReferencedEntityId ist unbrauchbar
(new typeSearch) |
(rückgängig; mw.wikibase.getReferencedEntityId ist unbrauchbar) |
||
Zeile 279: | Zeile 279: | ||
end | end | ||
function fw.typeSearch( p31, list, catArray ) | function fw.typeSearch( p31, list, limit, catArray ) | ||
-- p31: array of Wikidata values | |||
-- list: indexed array of q id - types relations | |||
-- limit: maximum levels to analyse | |||
if not list or not p31 or #p31 == 0 then | if not list or not p31 or #p31 == 0 then | ||
return 'error', catArray | return 'error', catArray | ||
end | end | ||
local | local aType, i, id, j | ||
for | |||
if | for i = 1, #p31, 1 do -- check p31 ids first | ||
aType = list[ p31[ i ].id ] | |||
if aType then | |||
return aType, catArray | |||
end | end | ||
end | end | ||
for i = 1, #p31, 1 do -- analyse P279 chain | |||
j = 0 | |||
repeat | |||
id, catArray = fw.getId( p31[ i ].id, 'P279', catArray ) | |||
for | if id ~= '' then | ||
aType = list[ id ] | |||
if aType then | |||
return aType, catArray | |||
if | |||
if | |||
catArray | |||
end | end | ||
end | end | ||
j = j + 1 | |||
until j >= limit or id == '' | |||
end | end | ||
return 'error', catArray | return 'error', catArray |