Tematiche di genere:How to use data on Wikimedia projects

Da Tematiche di genere.
Jump to navigation Jump to search

<languages/> <translate> Data from Wikidata can be directly displayed on Wikimedia projects, with different methods. With the parser function or Lua code, it is possible to display labels, descriptions, values, references, and a lot of other information stored on Wikidata.</translate> <translate> For an overview of uses on Wikidata on Wikimedia projects see <tvar|link>Wikidata:Wikidata in Wikimedia projects</>.

On this page, you will learn how to use Wikidata data on your wiki. You can also learn more about [[<tvar|what>Special:MyLanguage/Wikidata:Introduction</>|what is Wikidata]], [[<tvar|about>Special:MyLanguage/Help:About_data</>|how the information is organized]], or [[<tvar|glossary>Special:MyLanguage/Wikidata:Glossary</>|browse the glossary]].

Can I access Wikidata data from my wiki?[modifica sorgente]

The two main client functionalities, parser function and access via Lua, can be enabled together on the wikis of the Wikimedia projects. This is the case for almost all Wikimedia projects now.

To check if these functionalities are activated on a wiki, you can access the page Special:Version. In the section "Parser function hooks", if "statements" appears in the list, that means that you can use it on this wiki.

The access to Wikidata data is currently restricted to the Wikimedia projects, because of technical limitations. If you have your own instance of MediaWiki, you can't use Wikidata's data using these features. However, you can set up your own Wikibase instance and use data from there in the same way.

Parser function[modifica sorgente]

The first way to access data is to use the #statements parser function. This function will allow you to display the value of any statement included in an item. </translate>

<translate> Diagram of a Wikidata datamodel.</translate>

<translate>

Direct access[modifica sorgente]

On a page that is connected to a Wikidata item via the interwiki links, you can use the function by adding the label of the property you want in your language or the P-number of the property. The code has to be added in the wikicode.

Examples:

  • {{#statements:member of political party}} or {{#statements:P102}} will return the "member of political party" value.
  • {{#statements:discoverer or inventor}} or {{#statements:P61}} will return the "discoverer or inventor" value.
  • On w:en:Douglas Adams, the code {{#statements:country of citizenship}} will display "United Kingdom".

Arbitrary access[modifica sorgente]

You can also display data from an item that is not connected via an interwiki link. For this, you use the same function, adding a parameter from= followed by the Q-id of the item.

Examples:

  • {{#statements:birth name|from=Q42}} will display "{{#statements:birth name|from=Q42}}"
  • {{#statements:country of citizenship|from=Q42}} will display "{{#statements:country of citizenship|from=Q42}}".
  • {{#statements:P1476|from=Q191380}} will display "{{#statements:P1476|from=Q191380}}"
  • {{#statements:author|from=Q191380}} will display "{{#statements:author|from=Q191380}}"
  • {{#statements:publication date|from=Q191380}} will display "{{#statements:publication date|from=Q191380}}"

Multiple values[modifica sorgente]

When a statements has multiple values, the parser function will show the "best" value, which means:

  • only show the [[<tvar|ranking1>Special:MyLanguage/Help:Ranking</>|preferred value(s)]] if there are any
  • if not, shows all the values
  • but never the [[<tvar|ranking2>Special:MyLanguage/Help:Ranking</>|deprecated]] ones

Example: {{#statements:occupation|from=Q42}} displays "{{#statements:occupation|from=Q42}}" (there are other occupations in Errore Lua in Modulo:Wd alla linea 196: attempt to index field 'wikibase' (a nil value). (Q42) but only some are preferred)

Formatted values[modifica sorgente]

For some properties, the #statements parser function will display the value in a specific format.

Commons images

The parser function displays a thumbnail preview of the image, resizing it to 200 pixels. It links to the Wikimedia Commons file description page.

<tvar|code>{{#statements:image|from=Q42}}</> displays

</translate> {{#statements:image|from=Q42}}

<translate>

Geo coordinates

The parser function displays the coordinates in degree-minute-second format.

<tvar|code>{{#statements:coordinate location|from=Q243}}</> displays <tvar|result>{{#statements:coordinate location|from=Q243}}</>

Monolingual text

The parser function displays the highest ranked string, or the concatenation of all the values.

<tvar|code>{{#statements:native label|from=Q31}}</> displays "<tvar|result>{{#statements:native label|from=Q31}}</>".

Date

The date value will be formatted in day-month-year format.

<tvar|code>{{#statements:date of birth|from=Q42}}</> displays <tvar|result>{{#statements:date of birth|from=Q42}}</>

Links

The links are clickable.

<tvar|code>{{#statements:official website|from=Q243}}</> displays <tvar|result>{{#statements:official website|from=Q243}}</>

External IDs

An external ID will provide a direct link to the external website.

<tvar|code>{{#statements:IMDb ID|from=Q42}}</> displays <tvar|result>{{#statements:IMDb ID|from=Q42}}</>

Items

Raw value[modifica sorgente]

To display the unlinked value, use <tvar|code>#property</>.

Sample:

<tvar|code>{{#property:IMDb ID|from=Q42}}</> displays <tvar|result>{{#property:IMDb ID|from=Q42}}</>

Modules[modifica sorgente]

Data can also be accessed with Lua modules, which are much more flexible. Modules that access data from Wikidata should be organized as instance of Errore Lua in Modulo:Wd alla linea 196: attempt to index field 'wikibase' (a nil value). (Q59259626). For instance, Errore Lua in Modulo:Wd alla linea 196: attempt to index field 'wikibase' (a nil value). (Q12069631) is available on many wikis, see [[<tvar|module>w:⧼Lang⧽:Module:Wikidata#Usage</>|w:Module:Wikidata#Usage]] for usage instruction. If your wiki does not contain a module you can copy it from another wiki and add documentation.

For a full technical reference of Lua functions for accessing Wikidata, see <tvar|1>mw:Extension:Wikibase Client/Lua</>.

Templates[modifica sorgente]

Some templates use modules to access Wikidata data. They are as simple to use as regular templates. Moreover, using Wikidata, some parameters become unnecessary. For instance, some infoboxes are able to retrieve data from Wikidata, so you just have to insert the template and all the data will magically appear (if the needed information is present on the Wikidata item, of course). For templates using Wikidata see Errore Lua in Modulo:Wd alla linea 196: attempt to index field 'wikibase' (a nil value). (Q11985372).

If you want to create a template on your wiki, check your documentation page about Module:Wikidata and already existing templates.

Lists[modifica sorgente]

Regularly updated lists[modifica sorgente]

Daily updated lists based on SPARQL queries can be configured using Errore Lua in Modulo:Wd alla linea 196: attempt to index field 'wikibase' (a nil value). (Q19860885). Content is replaced daily.

There are essentially two uses:

  • Work lists: lists with topics to be covered in project namespace. Results can be limited to topics that don't exist.
  • Reference list: lists for a specific topic in article namespace.

This is currently the most efficient way of doing lists.

Dynamic lists[modifica sorgente]

Content is displayed from various items based on a selection done in a Lua module.

Manual lists[modifica sorgente]

A series of items are selected and their properties displayed in an article. Content from Wikidata can be completed with locally edited text.

Examples of use cases[modifica sorgente]

Magic infobox[modifica sorgente]

A call of the general cheese infobox template [[<tvar name="cheese">:fr:Modèle:Infobox Fromage</tvar>]] without any parameters, on an article about a type of cheese, for example fr:Reblochon, produces an infobox with details about that type of cheese, using data from the Wikidata item linked to the article.

Commons[modifica sorgente]

[[<tvar|creator>c:Template:Creator</>|Commons creator template]] uses Wikidata with arbitrary access to provide information about the creators of the works.

Graph[modifica sorgente]

Authority model[modifica sorgente]

Wikisource[modifica sorgente]

How to find help ?[modifica sorgente]

You will find contributors on the [[<tvar|chat>Special:MyLanguage/Wikidata:Project chat</>|Wikidata project chat]] which exists in different languages. Moreover, some wikis have projects dedicated to Wikidata : see Errore Lua in Modulo:Wd alla linea 196: attempt to index field 'wikibase' (a nil value). (Q20855878). </translate>