Jump to content

Module talk:Wikidata

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Lowercase sigmabot III (talk | contribs) at 05:55, 11 April 2020 (Archiving 1 discussion(s) to Module talk:Wikidata/Archive 2) (bot). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

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)[reply]

Here are the transclusions in template space. From that page, click on "links" next to any template name and then click "Transclusion count".
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)[reply]
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)[reply]
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)[reply]
That's a good search. That led me to:
Have fun! – Jonesey95 (talk) 18:36, 2 January 2020 (UTC)[reply]
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)[reply]
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)[reply]
@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)[reply]
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)[reply]
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)[reply]
@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)[reply]
Is |ps= missing from the doc? I couldn't find it there. Anyways, {{Infobox AFL biography/sandbox}} seems to work.
Deprecation progress
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
{{Wikisource author}} 4,681
{{Infobox video game}} 24,086
{{Birth date}} 269,902 Atia Abawi (no value on wikidata)
Abraham Lincoln (has value)
Waiting sandbox review
{{Infobox power station}} 2,471
{{Death date}} 8,443
{{Birth year and age}} 25,891
{{Wikidata redirect}} 25,963 Abel Waiting sandbox review

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)[reply]

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)[reply]

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)[reply]
@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)[reply]
That works for me in the sandbox. – Jonesey95 (talk) 18:10, 3 January 2020 (UTC)[reply]

Maxvals & inverted

Hi, I have two question :

First question :

{{#invoke:wd|properties|normal+|Q55|P1082}} display :"17,942,942, 17,590,672, 17,407,585, 17,282,163, 17,181,084, 17,081,507, 17,000,000, 16,829,289, 16,779,575, 10,026,773",

how can I display just three first number for to have just : "17,181,084, 16,829,289, 16,779,575" ?

I have unsuccessfully tested "maxvals" and "numval" :

{{#invoke:wd|properties|normal+|Q55|P1082|maxvals=3}} (display ever :"17,942,942, 17,590,672, 17,407,585, 17,282,163, 17,181,084, 17,081,507, 17,000,000, 16,829,289, 16,779,575, 10,026,773")

and

{{#invoke:wd|properties|normal+|Q55|P1082|numval=3}} (display ever :"17,942,942, 17,590,672, 17,407,585, 17,282,163, 17,181,084, 17,081,507, 17,000,000, 16,829,289, 16,779,575, 10,026,773")


Second question :

{{#invoke:wd|properties|normal+|Q55|P1082}} display :"17,942,942, 17,590,672, 17,407,585, 17,282,163, 17,181,084, 17,081,507, 17,000,000, 16,829,289, 16,779,575, 10,026,773",

how can I to reverse the chronological order for to display : "17,132,854 17,000,000, 10,026,773, 16,779,575, 16,829,289, 17,181,084" ?

I have unsuccessfully tested "sorttype = inverted" :

{{#invoke:wd|properties|normal+|Q55|P1082|sorttype = inverted}} (display ever :"17,942,942, 17,590,672, 17,407,585, 17,282,163, 17,181,084, 17,081,507, 17,000,000, 16,829,289, 16,779,575, 10,026,773")

My project is to do this table on page https://fr.wikipedia.org/wiki/Épidémie_de_maladie_à_coronavirus_de_2020_en_France#Localisation_des_cas to https://en.wikipedia.org/wiki/2020_coronavirus_outbreak_in_France.

Thanks, --Viruscorona2020 (talk) 08:24, 12 March 2020 (UTC)[reply]

Looking at both questions: Module:WikidataIB has the code to fetch the first 3 values:
  • {{#invoke:WikidataIB |getValue |fwd=ALL |osd=n |noicon=y |qid=Q55 |P1082 |maxvals=3}} → 17,942,942, 17,590,672, 17,407,585
However, those will depend on the order that they are stored in Wikidata. The module has the code to sort property values, and to sort qualifier values, but it's not able to sort property values by qualifier value at present, mainly because of the logic difficulties of defining behaviour when there are multiple values of a single qualifier.
If you can find a module that does sort property values by qualifier values, then you could use a unique separator like "; " to return all of the values, and then use string handling functions to give you just three values. This example shows how you might use a string function to extract the first three sorted values:
  • {{wdib|fwd=ALL|osd=n|noicon=y|qid=Q55|P1082|sep="; "|sorted=y}} → 10,026,773; 16,779,575; 16,829,289; 17,000,000; 17,081,507; 17,181,084; 17,282,163; 17,407,585; 17,590,672; 17,942,942
  • {{#invoke:String |match |s={{wdib|fwd=ALL|osd=n|noicon=y|qid=Q55|P1082|sep="; "|sorted=y}} |pattern=[^;]*; [^;]*; [^;]* }} → 10,026,773; 16,779,575; 16,829,289
But, of course, the WikidataIB call ({{wdib}}) above sorts property values on property value, not property values on qualifier value. Perhaps someone knows a module that can do the sort you want. --RexxS (talk) 13:05, 12 March 2020 (UTC)[reply]