Jump to content
Wikipedia The Free Encyclopedia

Module:Taxonbar/candidate

From Wikipedia, the free encyclopedia
Module documentation[view] [edit] [history] [purge]
Warning This Lua module is used on approximately 488,000 pages .
To avoid major disruption and server load, any changes should be tested in the module's /sandbox or /testcases subpages, or in your own module sandbox. The tested changes can be added to this page in a single edit. Consider discussing changes on the talk page before implementing them.
This module depends on the following other modules:
Related pages

About

This template is designed to be called from {{Taxobox/core }} or a related template, and tracks pages which may be candidates for a {{Taxonbar }}.

If no {{Taxonbar }} exists on the transcluded page, the page's Wikidata item is checked against this whitelist of acceptable instance of (P31)s/subclass of (P279)s, and this blacklist of unacceptable properties.

If an acceptable instance/subclass is found, then the page is categorized as:

If no acceptables nor unacceptables are found, then it is categorized as:

If no acceptables & at least 1 unacceptable is found, then no categorization is performed.

Usage

{{Taxonbar/candidate}}

Associated lists

The above documentation is transcluded from Module:Taxonbar/candidate/doc. (edit | history)
Editors can experiment in this module's sandbox (edit | diff) and testcases (create) pages.
Subpages of this module.

 localp={}

 functionp.check(frame)
 localtaxonbarExists=require('Module:Taxonbar/exists').check
 iftaxonbarExists(frame)==truethen
 return''
 else
 localresolveEntity=require('Module:ResolveEntityId')
 localcurrentTitle=mw.title.getCurrentTitle()
 localcurrentItem=nil
 localcategories={
 '[[Category:Taxobox articles possibly missing a taxonbar]]'--unset if acceptable or unacceptable found
 }

 --preliminary exclusion criteria
 ifstring.match(currentTitle.text,'^List of ')then
 return''
 end

 --find Wikidata item
 ifcurrentTitle.namespace==0then--mainspace
 localcurrentEntityId=mw.wikibase.getEntityIdForCurrentPage()
 ifresolveEntity._id(currentEntityId)then
 currentItem=mw.wikibase.getEntity(currentEntityId)
 else--currentEntityId == nil/unresolvable
 returncategories[1]
 end
 else
 return''
 end

 ifcurrentItemthen--currentItem should not be nil here, but check just in case
 --determine if {{Taxonbar}} is *definitely* missing, *possibly* missing, or not missing at all
 localwhitelist=require('Module:Taxonbar/whitelist').whitelist
 localblacklist=require('Module:Taxonbar/blacklist').blacklist
 localacceptableInstanceOf_All=whitelist{args={'all'}}
 localunacceptableInstanceOf=blacklist{args={}}

 localacceptableCount=0
 localunacceptableCount=0
 for_,instanceOfStateinpairs(currentItem:getBestStatements('P31'))do--instance of
 localinstanceOf=instanceOfState.mainsnak.datavalue.value.id
 ifacceptableInstanceOf_All[instanceOf]then
 acceptableCount=acceptableCount+1
 elseifunacceptableInstanceOf[instanceOf]then
 unacceptableCount=unacceptableCount+1
 end
 end
 for_,subclassOfStateinpairs(currentItem:getBestStatements('P279'))do--subclass of
 localsubclassOf=subclassOfState.mainsnak.datavalue.value.id
 ifacceptableInstanceOf_All[subclassOf]then
 acceptableCount=acceptableCount+1
 elseifunacceptableInstanceOf[subclassOf]then
 unacceptableCount=unacceptableCount+1
 end
 end

 ifacceptableCount>0then
 categories[1]=''
 categories[2]='[[Category:Taxobox articles missing a taxonbar]]'
 elseifunacceptableCount>0then
 categories[1]=''
 categories[2]=''
 end

 returntable.concat(categories)

 else
 return''
 end
 end
 end

 returnp

AltStyle によって変換されたページ (->オリジナル) /