Modul:Wikidata utilities: Unterschied zwischen den Versionen

erweitert, Kommentare
K (etwas umgestellt)
(erweitert, Kommentare)
Zeile 286: Zeile 286:
return 'error', catArray
return 'error', catArray
end
end
local aType, i, id, j


for i = 1, #p31, 1 do -- check p31 ids first, maybe step 2 is not nessary
local function compareIds( ar )
aType = list[ p31[ i ].id ]
local i, t
if aType then
for i = 1, #ar, 1 do
return aType, catArray
t = list[ ar[ i ].id ]
if t then
return t
end
end
end
return nil
end
local aType, i, id, ids, j
aType = compareIds( p31 ) -- check p31 ids first, maybe step 2 is not nessary
if aType then
return aType, catArray
end
end


-- now functions becomes expensive because of multiple fw.getValues calls
for i = 1, #p31, 1 do -- step 2: analyse P279 chains of first ids
for i = 1, #p31, 1 do -- step 2: analyse P279 chains of first ids
id = p31[ i ].id -- start id
id = p31[ i ].id -- start id
j = 0
j = 0
repeat
repeat
id, catArray = fw.getId( id, 'P279', catArray ) -- only first id
ids, catArray = fw.getValues( id, 'P279', nil, catArray )
if id ~= '' then
if #ids > 0 then
aType = list[ id ]
id = ids[ 1 ].id
aType = compareIds( ids )
if aType then
if aType then
return aType, catArray
return aType, catArray
Zeile 307: Zeile 318:
end
end
j = j + 1
j = j + 1
until j >= limit or id == ''
until j >= limit or #ids == 0
end
end


Anonymer Benutzer