Page MenuHomePhabricator

TemplateData: TemplateData should have a parameter to support Wikidata
Open, NormalPublic

Description

TemplateData should have a parameter for linking to Wikidata, and then pull information from there if applicable.

Details

Reference
bz67659
Related Gerrit Patches:
mediawiki/extensions/TemplateWizard : masterWikidata support for TemplateWizard

Event Timeline

bzimport raised the priority of this task from to Normal.Nov 22 2014, 3:25 AM
bzimport added a project: TemplateData.
bzimport set Reference to bz67659.
Keegan created this task.Jul 8 2014, 5:50 AM

@Keegan could you elaborate, please?
Are you proposing a new parameter type?

matej_suchanek added a project: Wikidata.
matej_suchanek set Security to None.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptAug 13 2015, 8:19 PM
Lydia_Pintscher moved this task from incoming to monitoring on the Wikidata board.Aug 17 2015, 2:51 PM
eranroz added a subscriber: eranroz.Oct 3 2015, 7:14 AM

TemplateData is a general purpose metadata definition for templates and isn't aware to other extensions (Wikibase, VE, Citeoid etc) - so it is invalid to create special definitions for wikidata.
But what we can do is to agree on a convention for maps for wikidata, similar to Citoid:
https://www.mediawiki.org/wiki/Citoid/Maps_TemplateData

Once we have such maps we can use them to build tools that integrate wikidata in Wikipedia (or in general - on the client side) more easily such as:

  • Client side editing of Wikidata / Templdate editor in VE
    • indicate a parameter is already in wikidata and doesn't need to be filled
    • a parameter is missing in wikidata and can be exported to wikidata from Wikipedia.
  • tools for consistency checking across different wikipedias

I just wrote an example for it on mediawiki: https://www.mediawiki.org/wiki/Wikibase/Maps_TemplateData

This is nothing to do with pulling information from wikidata - TemplateData is just a metadata description, while pulling of the data is the business logic and can have various implementations ({{#property}}, Scribuntu, template editor of VE etc)

Here is a proof of concept how to map wikidata properties to parameters and why it is cool:

mw.loader.load('//en.wikipedia.org/w/index.php?title=User:%D7%A2%D7%A8%D7%9F/TemplateDataI18n.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400');
  • open VE and add new template of Cite web. Note that the mapped parameters are getting translated in the VE template editor.
-jem- added a subscriber: -jem-.Mar 30 2016, 11:44 AM
Krinkle removed a subscriber: Krinkle.Jun 2 2016, 9:13 PM
Trizek-WMF added a subscriber: Trizek-WMF.EditedJun 15 2016, 7:59 AM

I have a similar request here: some people want to have a way to know if a piece of data from Wikidata will be automatically transcluded when they edit a template (especially infoboxes).

TheDJ added subscribers: Mike_Peel, TheDJ.EditedJun 25 2016, 2:14 PM

Was discussing this some more with @Mike_Peel after his Wikidata + Wikipedia integration talk at Wikimania

Example template that uses Wikidata: Infobox telescope

Article fully using WikiData for the infobox. No local data. South Pole Telescope

Article using local data overrides for several paramaters of the infobox: LIGO

I added Templatedata to that infobox to experiment a bit more with how this works in terms of interface, so we can play around with infoboxes as well.

Some ideas:

  1. In templatedata, we could have autovalue point to a Q item perhaps.
  2. When we have this, we could show these parameters in the VE template editor, which is less confusing than having a lot of data and no way to edit it, and worse not even represent this data in the editor, even though it is in the article.
  3. A next step could be to link to the wikidata editor of this property in a new window.
  4. How do we deal with 'hiding' the autovalue. Currently in wikitext we do this by defining the parameter but not defining any content for it. This seems a bit confusing in the VE interface to me. Maybe we can think of a better solution.
  5. Some parameters use multiple wikidata properties, or a chain of fallback properties.. More difficult to model with just autovalue...
  6. Note that the scribunto modules backing this template also include formatting options etc etc. The full solution is more complicated than the pure data...
eranroz added a comment.EditedJun 30 2016, 4:18 AM

Just to comment to TheDJ example, in hewiki we use meta template (actually - Lua Module) for wikidata integration in standard infobox: https://he.wikipedia.org/wiki/%D7%99%D7%97%D7%99%D7%93%D7%94:%D7%AA%D7%91%D7%A0%D7%99%D7%AA_%D7%9E%D7%99%D7%93%D7%A2

To define a infobox template using wikidata we use the following syntax:

{{#invoke:Infobox|infobox|
|label1=Birth date
|data1={{{Birthdate}}}
|Birdate-wikidata=P569
...
}}
Mvolz added a subscriber: Mvolz.Jul 29 2016, 3:09 PM
putnik added a subscriber: putnik.Aug 11 2016, 2:03 PM

I just wrote an example for it on mediawiki: https://www.mediawiki.org/wiki/Wikibase/Maps_TemplateData

The problems of mapping properties for Wikidata (unlike Citoid) that

  1. we have a lot of similar properties, which names are simplified when they are inserted into infoboxes; it's your example of mapping, little extended:
"maps": {
    "wikidata": {
        "P17": "Country",
        "P27": "Country",
        "P41": "Flag",
        "P495": "Country",
        "P1532": "Country",
    }
}
  1. some fields work with a chain of properties, e. g. if there is no P1532, we should use P27 instead.
hoo added a subscriber: hoo.Aug 11 2016, 2:41 PM
Mvolz added a comment.Aug 12 2016, 2:00 PM

@putnik

Could you expand a little bit? Are you saying that the maps is insufficient to work with wikidata?

So in citoid, we have a similar thing, where the citoid service may return the field name "blogTitle" or "websiteTitle" for the template field name "website" in Cite web. It's basically exactly as you've written it out there. Then in the extension we just pick the last one in the list to fill. Could the template do this? Just cycle through all the ones that are "Country" and put it whichever one that has the value and is last or first in the list?

So in that scenario, you'd just put P27 first and P1532 second, and then if there was no P1532 it would be put in from P27.

If maps *isn't* working for you, we could definitely explore expanding it to work for wikidata. We intended 'maps' to be flexible enough to work for any service, but at the time citoid is the only one that was using it so it was hard to predict what that general use case was.

A very closely related issue: T138219.

hewiki is using "wikidata" map extensively: https://he.wikipedia.org/w/index.php?search=insource%3A%2F"wikidata"%2F&title=מיוחד:חיפוש&profile=advanced&fulltext=1&ns10=1

This is used by multiple gadgets and user scripts including:

  • TemplateWizard (a wikitext equivalent for Template Dialog in VE) - Shows as placeholder the formatted values for fields fetched from wikidata.
  • harvestLabel - using the wikidata map to extract field from template and suggest to use the field as label in wikidata (semi automatic)
geraki added a subscriber: geraki.Jun 27 2017, 1:13 PM
He7d3r added a subscriber: He7d3r.Feb 3 2018, 1:25 PM
Mgns added a subscriber: Mgns.Feb 5 2018, 1:06 PM
Samwilson added a subscriber: Samwilson.

Change 446978 had a related patch set uploaded (by Eranroz; owner: Eranroz):
[mediawiki/extensions/TemplateWizard@master] Wikidata support for TemplateWizard

https://gerrit.wikimedia.org/r/446978