User:ElanHR/Proposals/Schema for describing templates and their fields

This document is a draft, and should not be assumed to represent the ultimate structure.

This document describes how templates and their fields can be described through Wikidata schema and how such schema could be represented. This is largely a summary of ideas discussed at a breakout session at WikidataCon 2019 (Q42449814). Notes from that session can be found here.

Feedback and comments are appreciated! :)


Goal edit

Describe templates's scope and usage in a language agnostic way on Wikidata.

Motivation edit

While Wikidata-driven templates are becoming more prevalent, they are still far from the norm. Using Wikidata schema to describe existing templates would go a long way to ease the transition and help coordinate efforts across different Wiki communities. There are a number of efforts that aim to do this (DBpedia, Harvestbot, etc.) but currently data is stored across various locations and formats. By representing this information directly with the Wikimedia template (Q11266439) item using Wikidata schema we would provide a single place to coordinate efforts increasing visibility.

These template descriptions would enable/simplify a number of tasks such as:

  • Suggesting templates for a given article given the existing properties for the item
  • Comparing coverage between templates and their Wikidata-driven equivalents
  • Detecting missing/incorrect interlanguage links for templates that based on property usage
  • Suggesting new properties based on template keys that cannot be expressed using existing schema
  • Simplify Wikidata-driven infoboxes

Related/Previous work edit

Proposed Schema edit

In order to accomplish the stated goals the following new properties are proposed:


  • DESCRIBED_ITEM_TYPE:

Value type: Wikibase item (Q29934200)

This property would be used to describe the scope for the main subject of the template. This would be similar to the semantics of category contains (P4224).


In the case where a template can be used to describe different classes of items (e.g. a real person or a fictional character) then this can be represented by having multiple values for this property (i.e. template scope is a union of values rather than an intersection).


Note: These is a closely related property template has topic (P1423) that could be made to suit this purpose but currently the semantics are slightly different. template has topic (P1423) links to a general topic that describes the class using the template (e.g. artist (Q483501)) whereas this new property would describe the Wikidata semantics for items using this template (e.g. instance of (P31) human (Q5) <qualifier occupation (P106)artist (Q483501)>).


  • PROPERTY_USED_BY_TEMPLATE:

Value type: Wikidata property (Q18616576)

This property would be used indicate that a template makes use of information described by the provided Wikidata property (Q18616576).


  • QUALIFYING_PROPERTY:

Value type: Wikidata property (Q18616576)

This property would be used to describe qualifiers for PROPERTY_USED_BY_TEMPLATE.


  • LOCALE_SPECIFIC_KEY:

Value type: monolingual text (Q21044568)

This property would be used to map a template field to its corresponding Wikidata semantics.


Overall usage pattern:

DESCRIBED_ITEM_TYPE:    Q?????

P????: Q????

Schema to describe semantics of template fields.

PROPERTY_USED_BY_TEMPLATE:  <P???>

QUALIFYING_PROPERTY: <P???>
LOCALE_SPECIFIC_KEY:  <site specific template field>
...

Examples edit

Template:Infobox officeholder (Q5830052) edit

Wikipedia:en:Template:Infobox_officeholder

{{Infobox officeholder
| honorific_prefix   = honorific prefix (P511)
| ...
| native_name        = name in native language (P1559)
| ...
| image              = image (P18)
| ...
| office             = position held (P39)
| term_start         = position held (P39) + start time (P580)
| term_end           = position held (P39) + end time (P582)
| ...
| office2             = position held (P39)
| term_start2         = position held (P39) + start time (P580)
| term_end2           = position held (P39) + end time (P582)
| ...
}}

Wikipedia:ru:Шаблон:Государственный_деятель

{{Государственный_деятель
| ...
| оригинал имени    = name in native language (P1559)
| ...
| изображение       = image (P18) 
| ...
| должность         = position held (P39)
| периодначало      = position held (P39) + start time (P580)
| периодконец       = position held (P39) + end time (P582)
| ...
}}


Template:Infobox officeholder (Q5830052)

DESCRIBED_ITEM_TYPE: human (Q5)

occupation (P106): politician (Q82955)

DESCRIBED_ITEM_TYPE: fictional character (Q95074)

occupation (P106): politician (Q82955)

PROPERTY_USED_BY_TEMPLATE: honorific prefix (P511)

LOCALE_SPECIFIC_KEY: (en) honorific_prefix

PROPERTY_USED_BY_TEMPLATE name in native language (P1559)

LOCALE_SPECIFIC_KEY: (en) native_name
LOCALE_SPECIFIC_KEY: (ru) оригинал имени

PROPERTY_USED_BY_TEMPLATE: position held (P39)

LOCALE_SPECIFIC_KEY: (en) office
LOCALE_SPECIFIC_KEY: (en) office2
LOCALE_SPECIFIC_KEY: (ru) должность

PROPERTY_USED_BY_TEMPLATE: position held (P39)

QUALIFYING_PROPERTY: start time (P580)
LOCALE_SPECIFIC_KEY: (en) term_start
LOCALE_SPECIFIC_KEY: (en) term_start2
LOCALE_SPECIFIC_KEY: (ru) периодначало

PROPERTY_USED_BY_TEMPLATE: position held (P39)

QUALIFYING_PROPERTY: end time (P582)
LOCALE_SPECIFIC_KEY: (en) term_end
LOCALE_SPECIFIC_KEY: (en) term_end2
LOCALE_SPECIFIC_KEY: (ru) периодконец

Template:Infobox artwork (Q6064255) edit

Wikipedia:en:Template:Infobox_artwork

{{Infobox artwork
| title              = title (P1476)
| ...
| image              = image (P18)
| ...
| artist             = creator (P170)
| year               = inception (P571)
| ...
}}

Wikipedia:de:Vorlage:Infobox_Gemälde

{{Infobox Gemälde
| bilddatei = image (P18)
| ...
| titel =  title (P1476)
| künstler = creator (P170)
| jahr = inception (P571)
| ...
}}


Template:Infobox artwork (Q6064255)

DESCRIBED_ITEM_TYPE: visual artwork (Q4502142)

PROPERTY_USED_BY_TEMPLATE: image (P18)

LOCALE_SPECIFIC_KEY: (en) image
LOCALE_SPECIFIC_KEY: (de) bilddatei

PROPERTY_USED_BY_TEMPLATE title (P1476)

LOCALE_SPECIFIC_KEY: (en) title
LOCALE_SPECIFIC_KEY: (de) titel

PROPERTY_USED_BY_TEMPLATE: creator (P170)

LOCALE_SPECIFIC_KEY: (en) artist
LOCALE_SPECIFIC_KEY: (de) künstler

PROPERTY_USED_BY_TEMPLATE: inception (P571)

LOCALE_SPECIFIC_KEY: (en) year
LOCALE_SPECIFIC_KEY: (de) jahr

...