Module talk:Wikidata
This is the talk page for discussing improvements to the Wikidata module. |
|
Archives: 1, 2Auto-archiving period: 6 months ![]() |
![]() | Use Wikipedia talk:Wikidata for general Wikidata support discussions |
|
||
This page has archives. Sections older than 180 days may be automatically archived by Lowercase sigmabot III when more than 3 sections are present. |
QID lookup from enwp article title
Deprecation
This module was marked as deprecated but has 487,638 transclusions. I'm assuming this most come from a few highly transcluded templates. Can anyone help finding those usages? It will give us a star start with converting to Module:WikidataIB and Module:Wd. --Gonnym (talk) 15:27, 2 January 2020 (UTC)
- Here are the transclusions in template space. From that page, click on "links" next to any template name and then click "Transclusion count".
- {{Infobox AFL biography}}: 13,600
- {{Infobox CFL biography}}: 6,161
- {{Infobox Gaelic Athletic Association player}}: 4,187
- {{Infobox anatomy}}: 4,449
- {{Infobox award}}: 7,361
- {{Infobox book}}: 44,111
- {{Infobox college coach}}: 10,000
- {{Infobox lighthouse}}: 2,535
- {{Infobox religious building}}: 9,368
- {{Infobox volleyball biography}}: 4,734
- {{Wikidata sitelink}}: 6,819 (used in the "Expand xxx" templates, so if you get this one, at least 145 templates will be removed from the list)
- {{Wikisource author}}: 4,681
- {{Infobox video game}}: 24,086
- That looks like about 150,000 transclusions. Start there, and if you get through that list, come back and I'll take another look. – Jonesey95 (talk) 17:23, 2 January 2020 (UTC)
- Your assumption is probably correct; remaining requires uses are limited to sandboxes. I suppose someone could invoke the module through wikitext in a module by preprocessing, but I find that less likely (for the curious; most look like documentation and comments). --Izno (talk) 18:23, 2 January 2020 (UTC)
- This is a search of template space for #invoke. There are some 200 templates using the module. --Izno (talk) 18:25, 2 January 2020 (UTC)
- That's a good search. That led me to:
- {{Birth date}}: 269,902 transclusions
- {{Infobox power station}}: 2,471 transclusions
- {{Death date}}: 8,443 transclusions
- {{Birth year and age}}: 25,891 transclusions
- {{Wikidata redirect}}: 25,963 transclusions
- Have fun! – Jonesey95 (talk) 18:36, 2 January 2020 (UTC)
- Thanks for the lists!
- Anyone know how to find an article that uses {{Infobox AFL biography}} and gets the image from wikidata? [1] fails. --Gonnym (talk) 18:43, 2 January 2020 (UTC)
- Query for the presence of P3546 and P18 in the same item. I don't know how to do it. – Jonesey95 (talk) 23:28, 2 January 2020 (UTC)
- @Gonnym: Looks like 25,260 results on Wikidata: see this query. I can't easily tell you how many of those have articles, though. --RexxS (talk) 23:57, 2 January 2020 (UTC)
- P.S. Category:Pages using Wikidata property P3546 shows 13,302 articles using {{Infobox AFL biography}} and having a AustralianFootball.com player ID (P3546). You need the intersection of those two sets. --RexxS (talk) 00:01, 3 January 2020 (UTC)
- Your first link helped me find an article that has a Wikidata:Q5214052 image. On Dan Moriarty (footballer, born 1875) I'm using
{{#invoke:WikidataIB|getValue|P18}}
on the page to test the code but it doesn't return the image. What am I doing wrong? --Gonnym (talk) 00:12, 3 January 2020 (UTC)- @Gonnym: Because
WikidataIB|getValue
is used in articles where the editors insist that fetching Wikidata has to be enabled (i.e. it is disabled by default), you always have to specify further parameters to enable the fetch. The simplest way is to use|ps=1
like this for Dan Moriarty (Q5214052):{{#invoke:WikidataIB|getValue|P18|ps=1|qid=Q5214052}}
→ Dan Moriarty (before 1903).jpg
- Obviously, you don't need the qid if you're calling it from the article's own page. HTH --RexxS (talk) 00:22, 3 January 2020 (UTC)
- Is
|ps=
missing from the doc? I couldn't find it there. Anyways, {{Infobox AFL biography/sandbox}} seems to work.
- Is
- @Gonnym: Because
- Your first link helped me find an article that has a Wikidata:Q5214052 image. On Dan Moriarty (footballer, born 1875) I'm using
- Query for the presence of P3546 and P18 in the same item. I don't know how to do it. – Jonesey95 (talk) 23:28, 2 January 2020 (UTC)
- That's a good search. That led me to:
Template name | No. of transclusions | Test page(s) | Status |
---|---|---|---|
{{Infobox AFL biography}} | 13,600 | Dan Moriarty (footballer, born 1875) | Waiting sandbox review |
{{Infobox CFL biography}} | 6,161 | ||
{{Infobox Gaelic Athletic Association player}} | 4,187 | ||
{{Infobox anatomy}} | 4,449 | ||
{{Infobox award}} | 7,361 | ||
{{Infobox book}} | 44,111 | The Red Pyramid (Library of Congress) Under Fire (Blackwood novel) (website) - Not able to get website to show using the infobox. |
Waiting sandbox review |
{{Infobox college coach}} | 10,000 | ||
{{Infobox lighthouse}} | 2,535 | ||
{{Infobox religious building}} | 9,368 | ||
{{Infobox volleyball biography}} | 4,734 | ||
{{Wikidata sitelink}} | 6,819 | Done | |
{{Wikisource author}} | 4,681 | Done | |
{{Infobox video game}} | 24,086 | Done | |
{{Birth date}} | 269,902 | Atia Abawi (no value on wikidata) Abraham Lincoln (has value) |
Done |
{{Infobox power station}} | 2,471 | Done | |
{{Death date}} | 8,443 | Done | |
{{Birth year and age}} | 25,891 | Done | |
{{Wikidata redirect}} | 25,963 | Abel | Done |
Following the discussion at Template talk:Medical resources #Template-protected edit request on 3 December 2019, I was hopeful that somebody else would add the documentation for a change, so I apologise for not doing it sooner. It's documented now. There's probably no more than a handful of undocumented parameters and calls left now. --RexxS (talk) 18:01, 3 January 2020 (UTC)
- I updated the "Deprecation progress" table above but I believe there are quite a few items missing from that table. For example, I can find many hits in searching template source for "FETCH_WIKIDATA". So far as I know only Module:Wikidata seems to use that sentinel value and that is definitely not an all inclusive use use of the module (as we can search in source for "#invoke:Wikidata|" or similar and go beyond "Template" namespace, etc.). —Uzume (talk) 03:04, 7 June 2020 (UTC)
Infobox AFL biography
When I remove the |image=
value from Dan Moriarty (footballer, born 1875) (leaving a blank parameter), no image is shown, using either the live template or the sandbox template. It seems like an image should be shown. – Jonesey95 (talk) 16:16, 3 January 2020 (UTC)
- Some template editors decide to code parameters as A|B which means that if A is there, even blank, it doesn't show B. I personally code with {{If empty |A |B }} which means that if A is empty, it checks B. I didn't change the syntax there, just the module invoke. --Gonnym (talk) 16:19, 3 January 2020 (UTC)
- @Gonnym and Jonesey95: To produce its image, Template:Infobox AFL biography calls Module:InfoboxImage, which returns empty if the image parameter is missing or empty. So it should be no surprise that removing the value of
|image=
from an article results in no image. However, Module:WikidataIB treats a blank parameter the same as a missing parameter, so in the#invoke:InfoboxImage|InfoboxImage
, if you use the syntax:|image={{#invoke:WikidataIB |getValue |P18 |ps=1 |maxvals=1 |{{{image|}}} }}
- it will return the Wikidata value whenever
|image=
is empty or missing in the article. It relies on getValue always returning the local parameter if one is supplied to it as the second unnamed parameter, and is intended to simplify the template coding. This is possibly what Jonesey95 was looking for. --RexxS (talk) 17:52, 3 January 2020 (UTC)- That works for me in the sandbox. – Jonesey95 (talk) 18:10, 3 January 2020 (UTC)
- @Gonnym and Jonesey95: To produce its image, Template:Infobox AFL biography calls Module:InfoboxImage, which returns empty if the image parameter is missing or empty. So it should be no surprise that removing the value of
Porting Guide
I think we need a porting guide. In many cases it is straightforward to change from {{#invoke:Wikidata|function}}
to {{#invoke:WikidataIB|function}}
but there are several interface functions (all functions that can be directly invoked by a template, i.e., returned functions that directly process frame arguments) that are not implemented in the later. Uzume (talk) 14:59, 16 April 2020 (UTC)
{{#invoke:Wikidata|function}} |
{{#invoke:WikidataIB|function}} or other options
|
---|---|
{{#invoke:Wikidata|inspectI18n|...}} |
|
{{#invoke:Wikidata|descriptionIn|...}} |
|
{{#invoke:Wikidata|labelIn|...}} |
|
{{#invoke:Wikidata|getValue|...}} |
{{#invoke:WikidataIB|getValue|...}}
|
{{#invoke:Wikidata|getValueShortName|...}} |
{{#invoke:WikidataIB|getValue|shortname=yes|...}}
|
{{#invoke:Wikidata|getValueFromID|...}} |
{{#invoke:WikidataIB|getValue|qid= |...}}
|
{{#invoke:Wikidata|getRawValue|...}} |
{{#invoke:WikidataIB|getValue|linked=no|...}}
|
{{#invoke:Wikidata|getUnits|...}} |
use {{stringsplit}} to extract from getValue |
{{#invoke:Wikidata|getUnitID|...}} |
|
{{#invoke:Wikidata|getDateValue|...}} |
{{#invoke:WikidataIB|getValue|...}}
|
{{#invoke:Wikidata|getImages|...}} |
{{#invoke:WikidataIB|getValue|P18|linkprefix="File:"|linkpostfix="{{!}}{{{size|220px}}}"|sep=" "|...}}
|
{{#invoke:Wikidata|getImageLegend|...}} |
{{#invoke:WikidataIB|getValue|P18|qual=P2096|qualsonly=y|...}}
|
{{#invoke:Wikidata|getTAValue|...}} |
construct from getValue with |linkprefix= and |linkpostfix=
|
{{#invoke:Wikidata|getQualifierValue|...}} |
{{#invoke:WikidataIB|getQualifierValue|...}} or {{#invoke:WikidataIB|getValue|qual= |qualsonly=y|...}} depending on use
|
{{#invoke:Wikidata|getRawQualifierValue|...}} |
{{#invoke:WikidataIB|getValue|qual= |qualsonly=y|linked=n|...}}
|
{{#invoke:Wikidata|getQualifierDateValue|...}} |
{{#invoke:WikidataIB|getValue|qual= |qualsonly=y|...}}
|
{{#invoke:Wikidata|pageId|...}} |
{{#invoke:WikidataIB|pageId|...}} or {{#invoke:WikidataIB|getEntityFromTitle|...}} or {{#invoke:Wd|label|raw|...}}
|
{{#invoke:Wikidata|ViewSomething|...}} |
|
{{#invoke:Wikidata|getSiteLink|...}} |
{{#invoke:WikidataIB|getSiteLink|...}}
|
{{#invoke:Wikidata|Dump|...}} |
|
{{#invoke:Wikidata|getPropertyIDs|...}} |
{{#invoke:WikidataIB|getPropertyIDs|...}} or {{#invoke:Wd|properties|raw|...}}
|
{{#invoke:Wikidata|claim|...}} |
|
|FETCH_WIKIDATA |
|fwd=ALL or |ps=1 or |ps=2
|
The philosophy has shifted away from separate specific calls to handle linked items, dates, quantities, etc. toward customising getValue
with parameters to deal with specific cases. An almost up-to-date list of parameters to getValue is at Module:WikidataIB/doc #Parameters to getValue. In particular, qualifiers are much better handled. The parameters linkprefix
, linkpostfix
, prefix
, postfix
, and the corresponding ones for qualifiers allow the construction of complex outputs containing internal or external links.
When experimenting, please remember that unless |fetchwikidata=
(alias fwd
) is set, nothing will be returned from getValue
. Also by default, only sourced values (i.e. that have a reference other than a language Wikipedia) are returned unless |onlysourced=
(alias osd
) is set to no/false/0. The shortcut parameter |ps=1
will set |rank=best
, |fetchwikidata=ALL
, |onlysourced=no
and |noicon=true
, a common set to use when developing. The template {{wdib}} simply #invokes WikidataIB|getValue, so may make wikitext more readable.
Some specialised calls are implemented and documented at Module:WikidataIB/doc #Overview. Functions such as getPropOfProp
, which returns the property values of property values, can be useful to reduce the template coding in some infoboxes. Also, there are some calls to help generate category titles, allowing an infobox to automatically add articles to a particular category. --RexxS (talk) 19:45, 16 April 2020 (UTC)
- Yes, I realized things have changed but the idea is to come up with a porting guide and then move as much as possible off the older module. I am not surprised you would know much about them as you wrote most (if not all) of both of them. I might have to move this to a section on Module:Wikidata/doc Thanks for contributing. Uzume (talk) 04:25, 17 April 2020 (UTC)
- Just stumbled here after spotting changes to Template:Infobox power station/sandbox by Uzume. In the future when this module is no longer used, it would be nice to see Module:WikidataIB renamed to Module:Wikidata. That sounds neater. Anyways, good luck! Rehman 13:38, 16 May 2020 (UTC)
- My intention in developing Module:WikidataIB was to create a tool for template coders to use specifically for creating infoboxes in any language. As a result, it's in use on over 60 projects. Because many projects already had their own custom modules called Module:Wikidata, it's been quite fortuitous that WikidataIB is a unique name that doesn't clash with anything else when copied to other projects. It would be nice to think that at some point every project would be able to share a common codebase, but that doesn't look like happening anytime soon, particularly given enwiki's inherent insularity. Cheers --RexxS (talk) 22:32, 16 May 2020 (UTC)
- Just stumbled here after spotting changes to Template:Infobox power station/sandbox by Uzume. In the future when this module is no longer used, it would be nice to see Module:WikidataIB renamed to Module:Wikidata. That sounds neater. Anyways, good luck! Rehman 13:38, 16 May 2020 (UTC)
getPropertyIDs
Hi Uzume and RexxS. Per the porting guide, I tried testing to change (1) to (2) for {{Infobox power station}}, but it doesn't seem to work:
{{#invoke:Wikidata|getPropertyIDs|P31|qid=Q5001029|FETCH_WIKIDATA}}
→ Q1003207{{#invoke:WikidataIB|getPropertyIDs|P31|qid=Q5001029|ps=1}}
→
Is this something that's still being implemented? And since we're on the topic, would it be possible to allow qualifiers to work this way as well? For instance, I want to get the QID of "longitude" in wikidata:Q15397819#P2043. Would this be possible? Rehman 08:02, 17 May 2020 (UTC)
- @Rehman: I only implemented
|ps=
as a convenience for development work ingetValue
. All of the other related calls still have to use|fwd=ALL |osd=n
, etc. - Because ps=1 and ps=2 let through unsourced data, they don't satisfy the Community's express wish that some assurance is given that information is reliable. That means the parameter sets are not generally suitable for production code on the English Wikipedia, so I didn't bother duplicating them in every call.
{{#invoke:WikidataIB|getPropertyIDs|P31|qid=Q5001029|fwd=ALL|osd=n}}
→ Q1003207
- I'll make a start on writing getQualifierIDs for you. --RexxS (talk) 15:59, 17 May 2020 (UTC)
- @Rehman: I have some provisionally working code. It has an optional parameter
|qlist=
which is a free-form list of property-ids that it will match the qualifier properties against. It implements the usual parameters: fwd, osd, ranks, maxvals, etc.{{#invoke:WikidataIB |getQualifierIDs |fwd=ALL |osd=n |P2043 |qid=Q15397819}}
→{{#invoke:WikidataIB |getQualifierIDs |fwd=ALL |osd=n |P2043 |qid=Q15397819 |qlist=}}
→{{#invoke:WikidataIB |getQualifierIDs |fwd=ALL |osd=n |P2043 |qid=Q15397819 |qlist=All}}
→{{#invoke:WikidataIB |getQualifierIDs |fwd=ALL |osd=n |P2043 |qid=Q15397819 |qlist=P7469}}
→{{#invoke:WikidataIB |getQualifierIDs |fwd=ALL |osd=n |P2043 |qid=Q15397819 |qlist=P26}}
→{{#invoke:WikidataIB |getQualifierIDs |fwd=ALL |osd=n |P2043 |qid=Q15397819 |qlist=P26, P7469}}
→{{#invoke:WikidataIB |getQualifierIDs |fwd=ALL |osd=n |P2043 |qid=Q15397819 |qlist=P74691}}
→
- Would you be kind enough to test it in a few different cases that interest you and let me know if any problems crop up, please? --RexxS (talk) 19:28, 17 May 2020 (UTC)
- Thank you for explaining ps and for the above feature, RexxS. I will test and update here again. Rehman 02:05, 18 May 2020 (UTC)
- In the mean time, would you also be able to see why:
{{#invoke:Wikidata|ViewSomething|labels|en|value}}
→ Hambantota Solar Power Station{{#invoke:WikidataIB |getLabel}}
→
- When previewing the code on Hambantota Solar Power Station? I could then change those instances as well. Rehman 03:06, 18 May 2020 (UTC)
- The
getLabel
function only works with a supplied qid and does not fall back to the current page qid:{{#invoke:WikidataIB |getLabel |qid=Q5001029}}
→ Hambantota Solar Power Station
- That call was designed to return nothing if no qid is supplied for use on Commons where we're often dealing with the qid/label for a category's main topic (different from the qid/label for the category, so we don't want fallback).
- The
label
function does fall back to the current page, however:{{#invoke:WikidataIB |label |qid=Q5001029}}
→ Hambantota Solar Power Station{{#invoke:WikidataIB |label}}
→
- The last call works when previewed in Hambantota Solar Power Station. Cheers --RexxS (talk) 03:48, 18 May 2020 (UTC)
- Nice! Thank you. I will get back regarding the test for getQualifierIDs. Cheers, Rehman 03:51, 18 May 2020 (UTC)
- No issues with
getQualifierIDs
. Many thanks! Cheers, Rehman 17:13, 18 May 2020 (UTC)
- The
Multilingual qualifier
How to get a specific value of a multilingual qualifier e.g. the official UNESCO name of Q351 in german? The function getQualifierSnak
should use the parameter language
if a qualifier is given, currently only the first matched entry is always returned (if qualifier then return qualifier[1] end
).--Sinuhe20 (talk) 19:29, 16 July 2020 (UTC)
- @Sinuhe20: You can do it with WikidataIB's getValue function:
- --RexxS (talk) 17:16, 9 September 2020 (UTC)
Italicization does not work for news publications
{{Wikidata}} does not work appropriately for citing news sources, where the newspaper should be in |work=
and should be italicized (unlike |publisher=
, which is not; see {{cite news}} documentation and discussion over the years at WT:CS1 for more). Currently, the template is only able to pull from publisher (P123), with no equivalent to work on Wikidata. As use of this scales up, it's crucial that we resolve this issue to make the two projects interoperable. Thoughts? {{u|Sdkb}} talk 22:22, 7 November 2021 (UTC)