TemplateData should have a parameter for linking to Wikidata, and then pull information from there if applicable.
Description
Details
- Reference
- bz67659
Subject | Repo | Branch | Lines +/- | |
---|---|---|---|---|
Wikidata support for TemplateWizard | mediawiki/extensions/TemplateWizard | master | +177 -2 |
Status | Subtype | Assigned | Task | ||
---|---|---|---|---|---|
Resolved | Lydia_Pintscher | T136599 [Epic] editing on client | |||
Open | None | T69659 TemplateData should have a parameter to support Wikidata | |||
Resolved | Incabell | T103092 [Story] research editing on clients | |||
Resolved | Charlie_WMDE | T132790 [Concept] Integration and editing of Wikidata in Wikipedia |
Event Timeline
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:
- https://en.wikipedia.org/wiki/User:%D7%A2%D7%A8%D7%9F/Template:Cite_web - Similar to English Template:Cite_web templatedata but with maps to wikidata (only few properties)
- https://en.wikipedia.org/wiki/User:%D7%A2%D7%A8%D7%9F/TemplateDataI18n.js - script that use this mapping (only for cite web) to show in VE the translation of the parameters in all languages. you can test it with:
- get to some page on enwiki with ?uselang=de (or some other language which isn't en)
- load the script:
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.
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).
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:
- In templatedata, we could have autovalue point to a Q item perhaps.
- 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.
- A next step could be to link to the wikidata editor of this property in a new window.
- 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.
- Some parameters use multiple wikidata properties, or a chain of fallback properties.. More difficult to model with just autovalue...
- Note that the scribunto modules backing this template also include formatting options etc etc. The full solution is more complicated than the pure data...
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 ... }}
The problems of mapping properties for Wikidata (unlike Citoid) that
- 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", } }
- some fields work with a chain of properties, e. g. if there is no P1532, we should use P27 instead.
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.
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)
Change 446978 had a related patch set uploaded (by Eranroz; owner: Eranroz):
[mediawiki/extensions/TemplateWizard@master] Wikidata support for TemplateWizard
Putnik's problem is common, but should be relatively easy to deal with (per Mvolz). Where we really run into problems is with the reverse situation: where Wikidata properties conflate multiple concepts that may be handled distinctly in Wikipedia infobox parameters. Many Wikidata properties are vague or inconsistently used due to Wikidata's fuzzy, must-fit-all-languages ontology.
Examples of properties that explicitly conflate distinct concepts:
- P21: sex or gender (which is also clumsily used to handle transgender status, i.e. "transgender male")
- P61: discoverer or inventor
- P629: edition or translation of
Examples of properties that are implicitly vague:
- P131: located in the administrative territorial entity (notice how the South Pole Telescope is located at "South Pole, Antarctic Treaty area" rather than "South Pole, Antarctica" as it would be if we weren't using Wikidata)
- P171: parent taxon (which can in practice correspond to any taxon level: genus, tribe, family, etc.)
- P361: part of
- P571: inception (which is so vague it has 57 English-language aliases listed on Wikidata, including both "start date" and "completed")
- P642: of
- P828: has cause
If we go down this road, we're going to be muddying Wikipedia's more-or-less clearly defined infobox parameters with awkward, inconsistent data (or data suggestions) that may not fit a particular language's understanding of a concept or ontology. P21 and P571 are the most likely to cause obvious problems, but I feel like it's only the tip of the iceberg, and we need to consider this carefully before we open up pandora's box.
The reason why The South Pole Telescope has the location "South Pole, Antarctic Treaty area" is that according to Wikidata, the South Pole is not located in Antarctica; it's only located in the administrative territorial entity of the Antarctic Treaty area. That's just a simple mistake in the organisation of Wikidata, and nothing to do with fetching Wikidata for infoboxes. As it stands, no SPARQL query for what's located in Antarctica will give you the South Pole, which is a bit worrying.
Of course there are issues with Wikidata, but this bug doesn't suggest forcing the usage of Wikidata in all the parameters of all the infoboxes in Wikipedia in all languages. It only suggests adding an option to support Wikidata in TemplateData, and people will use it wherever everyone agrees that it's useful. There are lots of places where it is, and some muddy areas are not a reason not to use it anywhere.
Since the T208305 has already closed, it is possible that on the technical side, everything is ready for this task. I will try to test the implementation shortly.