Module:Taxonbar/candidate: Difference between revisions

no edit summary
m (1 revision imported)
No edit summary
Tag: Reverted
Line 10:
local currentItem = nil
local categories = {
'[[Category:Taxobox articles possibly missing a taxonbar]]' --unset if acceptable or unacceptable found
}
--preliminary exclusion criteria
if string.match( currentTitle.text, '^List of ') then
return ''
end
--find Wikidata item
Line 40 ⟶ 45:
['Q17487588'] = 'unavailable combination', --lax
}
local unacceptableInstanceOf = {
['Q913170'] = 'trivial name',
['Q55983715'] = 'group of organisms known by one particular common name',
['Q937228'] = 'property',
['Q14712'] = 'drupe',
['Q163233'] = 'compound drupe',
['Q747463'] = 'compound fruit',
}
local acceptableCount = 0
local unacceptableCount = 0
for _, instanceOfState in pairs ( currentItem:getBestStatements('P31') ) do --instance of
local instanceOf = instanceOfState.mainsnak.datavalue.value.id
if acceptableInstanceOf_All[instanceOf] then
acceptableCount = acceptableCount + 1
categories[1] = ''
elseif unacceptableInstanceOf[instanceOf] then
categories[2] = '[[Category:Taxobox articles missing a taxonbar]]'
unacceptableCount = unacceptableCount + 1
break
end
end
for _, subclassOfState in pairs ( currentItem:getBestStatements('P279') ) do --subclass of
local subclassOf = subclassOfState.mainsnak.datavalue.value.id
if acceptableInstanceOf_All[subclassOf] then
acceptableCount = acceptableCount + 1
elseif unacceptableInstanceOf[subclassOf] then
unacceptableCount = unacceptableCount + 1
end
end
if acceptableCount > 0 then
categories[1] = ''
categories[2] = '[[Category:Taxobox articles missing a taxonbar]]'
elseif unacceptableCount > 0 then
categories[1] = ''
categories[2] = ''
end
return table.concat(categories)
else
return ''