Template talk:Infobox person/Wikidata

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
edit·history·watch·refresh Stock post message.svg To-do list for Template:Infobox person/Wikidata:

  • Implement image caption fetching with Module:WikidataIB
  • Fix capitalisation bugs (occupation section here)
  • Use Wikidata label as infobox title (maybe?)
  • Parameters like years active, etc. (more advanced)
  • Fix age code with Julian dates (throws an error currently)
  • ...
WikiProject Wikidata  
WikiProject iconThis template is within the scope of WikiProject Wikidata, a collaborative effort to improve Wikipedia's integration with Wikidata.
If you would like to participate, please visit the project page.
 

Span tags not working properly after recent edit[edit]

I recently attempted to fix this template's use of span tags for birth and death places, but I was reverted by RexxS with an explanation that {{If then show}} actually uses empty unnamed parameters to do its work (God help us all).

Whether or not that is good programming practice I will leave for a different discussion (hint: it is not). The current problem with this template is that this template currently fails to render the opening span tag for birth and death places, and then it follows the birth information with a closing span tag that has no opening tag. For example, at Marietta Alboni, the infobox is called thus:

{{infobox person/Wikidata | fetchwikidata=ALL | onlysourced = yes |caption = Marietta Alboni ''[[carte de visite]]'' by [[André-Adolphe-Eugène Disdéri]] }}

The birth and death information render thus:

<th scope="row">Born</th><td>6 March 1826 [[File:Blue pencil.svg |frameless |text-top |10px |alt=Edit this on Wikidata|link=https://www.wikidata.org/wiki/Q269130?uselang=en#P569|Edit this on Wikidata]]<br /></span> [[Città di Castello|Città di Castello]] [[File:Blue pencil.svg |frameless |text-top |10px |alt=Edit this on Wikidata|link=https://www.wikidata.org/wiki/Q269130?uselang=en#P19|Edit this on Wikidata]]</td></tr><tr><th scope="row">Died</th><td>23 June 1894 [[File:Blue pencil.svg |frameless |text-top |10px |alt=Edit this on Wikidata|link=https://www.wikidata.org/wiki/Q269130?uselang=en#P570|Edit this on Wikidata]] (aged 68)<br /></span> [[Ville-d'Avray|Ville-d'Avray]] [[File:Blue pencil.svg |frameless |text-top |10px |alt=Edit this on Wikidata|link=https://www.wikidata.org/wiki/Q269130?uselang=en#P20|Edit this on Wikidata]]</td></tr>


Note the closing span tags and the lack of opening span tags. RexxS, please fix. Thanks. – Jonesey95 (talk) 10:36, 2 April 2019 (UTC)

@Jonesey95: Thanks for spotting the problem; the fix was trivial. Using unnamed parameters gives errors when one of the parameters contains an = sign, and the fix is to explicitly use numbered parameters, which I've now done. The rendered html at Marietta Alboni now looks like this (I've snipped the pen icons for clarity):
<th scope="row">Born</th><td>6 March 1826  ...snip... <br><span class="birthplace"><a href="/wiki/Citt%C3%A0_di_Castello" title="Città di Castello">Città di Castello</a>  ...snip... </span></td>
<th scope="row">Died</th><td>23 June 1894  ...snip... (aged 68)<br><span class="deathplace"><a href="/wiki/Ville-d%27Avray" title="">Ville-d'Avray</a>  ...snip... </span></td>
Please let me know if you think any errors remain.
I am concerned that you think there is a problem with empty unnamed parameters. That is standard practice on thousands of {{#if:test|value-if-true|value-if-false}} statements in templates across Wikipedia. Either of those values is commonly omitted and the wiki hasn't fallen over yet.
The Template:if then show is a very simple adaptation of the {{#if: ... parser function. It works like this:
{{if then show |Parameter1|Parameter2|Parameter3|Parameter4}} → Parameter3Parameter1Parameter4
so that Parameter1 is enclosed between parameters 3 and 4, allowing us to add spans, etc. around a Wikidata call:
{{if then show |1=Call to Wikidata|2=|3=<span class="something">|4=</span>}}Call to Wikidata
If the first parameter is blank, then the second parameter alone is returned.
{{if then show ||Parameter2|Parameter3|Parameter4}} → Parameter2
For an infobox we will want that second parameter to be blank. I hope that makes it clearer for you now. --RexxS (talk) 14:02, 2 April 2019 (UTC)
Thanks for fixing. The fragility of unnamed parameters and the equals sign is one of many reasons that templates with multiple unnamed parameters are a bad idea. As for blank sections of if statements, that's a totally different thing, since if statements are not templates and do not take parameters. And as for {{if then show}}, first of all, the parameters seem out of logical order to me, having worked for decades with if-then-else statements (yours is more like if-else-then-implied-also, or something; awkward). Second, I'd rather just see an if statement used; the syntax is more familiar to more editors. Something like this untested code: {{#if:Wikidata value exists|<span class="something">Wikidata value</span>|else show this plain thing}} seems more straightforward than deliberately using blank parameters and hoping that experienced template editors won't helpfully "tidy them up" for you. – Jonesey95 (talk) 19:51, 2 April 2019 (UTC)
I agree that unnamed parameters are fragile, but look at templates like Template:Talk quote or Template:Talk quote inline, which I (ab)use all the time. I've gotten in the habit now of typing {{talkquote|1= before I paste the quoted text, as I then don't have to think about whether it contains equals signs.
It would be nice if a simple #if: statement would do the job, as it does very well for static parameters. But when we fetch something from Wikidata, (1) it's bad practice to make the same call twice (normally you'd just assign it to a variable and use that, but there aren't any general purpose variables in templates); and (2) it clogs up the template enormously if the full use of the available parameters is made. To give an example, for |birth_date= the code using an #if: statement would be:
{{#if: {{#invoke:WikidataIB | getValue | rank=best |P19 |name=birth_place |qid={{{qid|}}} |suppressfields={{{suppressfields|}}} |fetchwikidata={{{fetchwikidata|}}} |noicon={{{noicon|}}} | {{{birth_place|}}} }} | <span class="birthplace">{{#invoke:WikidataIB | getValue | rank=best |P19 |name=birth_place |qid={{{qid|}}} |suppressfields={{{suppressfields|}}} |fetchwikidata={{{fetchwikidata|}}} |noicon={{{noicon|}}} | {{{birth_place|}}} }}</span> }}
which I can replace with a single Wikidata call by using Template:If then show:
{{if then show |1={{#invoke:WikidataIB | getValue | rank=best |P19 |name=birth_place |qid={{{qid|}}} |suppressfields={{{suppressfields|}}} |fetchwikidata={{{fetchwikidata|}}} |noicon={{{noicon|}}} | {{{birth_place|}}} }} |2=|3=<span class="birthplace"> |4=</span> }}
Do you think it would be clearer if I aliased the unnamed parameters with named ones? I've made an example in {{if then show/sandbox}}, so we could write:
{{if then show |test={{#invoke:WikidataIB | getValue | rank=best |P19 |name=birth_place |qid={{{qid|}}} |suppressfields={{{suppressfields|}}} |fetchwikidata={{{fetchwikidata|}}} |noicon={{{noicon|}}} | {{{birth_place|}}} }} |else=|prefix=<span class="birthplace"> |suffix=</span> }}
We could actually just leave out the |else= in that case. What do you think? --RexxS (talk) 21:35, 2 April 2019 (UTC)
My purpose in using the word "multiple" above was to emphasize that having multiple unnamed parameters is a bad idea, since if someone ever wants to add aliases to any of the parameters, the numbers start moving around. {template|foo|bar} will behave differently from {template|name=foo|bar}, causing all sorts of messes ("bar" moves from being 2= to being 1=, which editors do not expect). I recommend converting all unnamed parameters to named parameters and discontinuing the use of unnamed parameters in {{if then show}}. – Jonesey95 (talk) 04:32, 3 April 2019 (UTC)

"stated as" qualifiers[edit]

The instance of this infobox on Mildred Ratcliffe currently displays:

but on Mildred Ratcliffe (Q63872518), both values are qualified using stated as (P1932) with "Rochester Grammar School for Girls" and "Post Office Savings Bank" respectively.

Can the template be made to show the latter values, while linking to the former articles, thus:

please?

The same should apply to named as (P1810). Andy Mabbett (Pigsonthewing); Talk to Andy; Andy's edits 09:00, 24 May 2019 (UTC)

The simplest solution is to use local values. --RexxS (talk) 15:26, 24 May 2019 (UTC)
Perhaps; but this is a very common use case ({{cite Q}}, for example, also needs this for author and venue names); and these are parameters that often have multiple values. Andy Mabbett (Pigsonthewing); Talk to Andy; Andy's edits 17:31, 25 May 2019 (UTC)
Once you get multiple values, I don't see any easy way of making the template show the 'stated as' values, linked to the relevant article.
  • {{#invoke:WikidataIB |getValue |ps=1 |P108 |qid=Q63872518}}Civil Service, National Savings and Investments
  • {{#invoke:WikidataIB |getValue |ps=1 |P108 |qual=P1932 |qualsonly=y |qid=Q63872518}} → Post Office Savings Bank
It would need amendments to the code in WikidataIB to first check whether the stated as (P1932) qualifier exists, then to retrieve the value of employer (P108) and then retrieve the article link and finally to create the linked wikitext. It would also have to do the same for qualifier named as (P1810). That raises some questions: (1) If both qualifiers are present, which one takes precedence? (2) Under what circumstances should this checking for qualifiers take place? We clearly can't insist on doing the check every time; so do we create yet another parameter to switch the checking on, or do we create a new function in the module?
Maybe somebody else can see a better way? --RexxS (talk) 22:00, 3 June 2019 (UTC)

Does not work[edit]

Why it does not work in Mariam Lortkipanidze? Wikisaurus (talk) 19:58, 3 June 2019 (UTC)

@Wikisaurus: The template passes through only that data which has a non-Wikipedia source. If you add such a source on Wikidata, as I've just done for employer, it will appear here. Nikkimaria (talk) 20:44, 3 June 2019 (UTC)
Thank you! I added a comment in documentation. P. S. Quite unusual for me - in Russian Wikipedia not only all common infoboxes have Wikidata support, but they take data without any sources. Wikisaurus (talk) 20:48, 3 June 2019 (UTC)

Wrong age at death[edit]

As can be seen here [1] for someone with a birth recorded in Wikidata as "1930s" and death in 2011, the age at death is shown by this template as 81. They were in fact 76. Andy Mabbett (Pigsonthewing); Talk to Andy; Andy's edits 12:48, 8 June 2019 (UTC)

table#1 {
  table#2 {
    ["id"] = "Q53502280$581b9982-4e4b-4e31-8516-867438b43f67",
    ["mainsnak"] = table#3 {
      ["datatype"] = "time",
      ["datavalue"] = table#4 {
        ["type"] = "time",
        ["value"] = table#5 {
          ["after"] = 0,
          ["before"] = 0,
          ["calendarmodel"] = "http://www.wikidata.org/entity/Q1985727",
          ["precision"] = 11,
          ["time"] = "+1935-05-27T00:00:00Z",
          ["timezone"] = 0,
        },
      },
      ["property"] = "P569",
      ["snaktype"] = "value",
    },
    ["rank"] = "normal",
    ["references"] = table#6 {
      table#7 {
        ["hash"] = "e866efbb3b2074d73e0b13d263078c285339de4a",
        ["snaks"] = table#8 {
          ["P813"] = table#9 {
            table#10 {
              ["datatype"] = "time",
              ["datavalue"] = table#11 {
                ["type"] = "time",
                ["value"] = table#12 {
                  ["after"] = 0,
                  ["before"] = 0,
                  ["calendarmodel"] = "http://www.wikidata.org/entity/Q1985727",
                  ["precision"] = 11,
                  ["time"] = "+2019-06-08T00:00:00Z",
                  ["timezone"] = 0,
                },
              },
              ["property"] = "P813",
              ["snaktype"] = "value",
            },
          },
          ["P854"] = table#13 {
            table#14 {
              ["datatype"] = "url",
              ["datavalue"] = table#15 {
                ["type"] = "string",
                ["value"] = "https://www.ryemuseum.co.uk/brian-hargreaves/",
              },
              ["property"] = "P854",
              ["snaktype"] = "value",
            },
          },
        },
        ["snaks-order"] = table#16 {
          "P854",
          "P813",
        },
      },
    },
    ["type"] = "statement",
  },
}
Yup, Wikidata doesn't really know when he was born: as you can see it stores 1930. This template doesn't seem able to cope with a person whose birthdate is not known, but whose age at death is known. You could try changing the date of birth on Wikidata to 'circa 1935' and see if that helps. Or you could try lower/upper limits of 1 October 1934 and 30 September 1935. Otherwise we have to supply a custom value for |date_of_death= in the article. By the way, Wikidata has Country’s top butterfly artist dies, aged 76 as a reference for his dates of birth and death, but neither are certain from the article. The opening sentence is ambiguous about whether he died on 30 September, or whether he died later following a heart attack on 30 September. I think we can assume the former, but it would be good to have another source for confirmation. --RexxS (talk) 13:48, 8 June 2019 (UTC)

─────────────────────────

Wikidata knows:

          ["precision"] = 8,
          ["time"] = "+1930-00-00T00:00:00Z",

where "8" is a precision of "decade" (resulting from me literally typing "1930s"), so treating it as an exact year gives at best 90% chance of being wrong. I have since added the full date of birth to Wikipedia, using a source that gives both dates, but was holding off adding it to Wikidata until you'd seen what was happening in the infobox. Andy Mabbett (Pigsonthewing); Talk to Andy; Andy's edits 20:26, 9 June 2019 (UTC)

@Pigsonthewing: I disagree that knowing a birth-date to within a decade is sufficient to calculate age at death. I've just added "1930s" for date of birth (P569) to Wikidata Sandbocs (Q4115189); and testing the call used in this template you get this result:
  • {{wikidata|property|raw|Q4115189|P569}}
That call doesn't understand precision. As I said, this template doesn't seem able to cope with a person whose birthdate is not known. The solution is still either to fix the date in Wikidata or use a local custom value in the article. --RexxS (talk) 18:35, 10 June 2019 (UTC)
Where did I say that "knowing a birth-date to within a decade is sufficient to calculate age at death"? My point is that it is not. Andy Mabbett (Pigsonthewing); Talk to Andy; Andy's edits 18:47, 10 June 2019 (UTC)
You didn't say it. You implied it when you said "Wikidata knows". It doesn't. All Wikidata knew was the decade. I'm sure we both agree that that's not enough to calculate an age at death. --RexxS (talk) 21:24, 10 June 2019 (UTC)
RexxS, do you contest that Wikidata "knows" 1930s [that is where Andy used the word] and the year of death? Pigsonthewing didn't imply that knowing "1930s" is sufficient, he also posted the year of death. Then the age at death can be calculated - with nearly the same precision (+-5) as the date of birth. If only the year of death is known the resulting precision is +-6. 77.13.54.171 (talk) 07:43, 11 June 2019 (UTC)
"Wikidata doesn't really know when he was born: as you can see it stores 1930. This template doesn't seem able to cope with a person whose birthdate is not known ..." - which, if any, of those three statements do you disagree with? This template is incapable of calculating an age of death other than as a simple number of years. Yes, you can calculate an age at death ±5 years, but the template can't. If I stored any date from 1930-00-00 to 1939-12-31 as date of birth (P569) and set the precision to '8' (decade), Wikidata would still treat that as '1930s' (although this template would give a different age at death for each case). Please feel free to upgrade this template to cater for varying precisions in the two dates: I'm sure Andy and I would appreciate it. --RexxS (talk) 11:08, 11 June 2019 (UTC)

Icon error[edit]

This revision shows a redlinked "edit this on wikidata", linking to Special:Upload. Other articles appear to be displaying correctly. Nikkimaria (talk) 00:48, 20 June 2019 (UTC)

@Xaosflux: possibly a bug in the changes you were making to the icon yesterday? Thanks. Mike Peel (talk) 06:32, 20 June 2019 (UTC)
@Nikkimaria and Mike Peel: It's probably the use of String2|sentence on what is returned from Wikidata – see Module talk:WikidataIB, section #icon errors caused by #invoke:String2 | sentence. Let me know if my "kludge" doesn't fix the problems. Cheers --RexxS (talk) 09:41, 20 June 2019 (UTC)
Let me know if you need me to look at anything else, most of my updates were just changing the icon file. — xaosflux Talk 11:10, 20 June 2019 (UTC)
@Xaosflux: Thanks for helping to get some consistency in the icons we use. I must admit, I just picked one that looked right when I first wrote that bit of code. It probably makes sense to have all-lower-caps redirects for common icon files, then we don't have to worry about editors down the line transforming entire strings into sentence case. Those redirects are cheap. Cheers --RexxS (talk) 13:26, 20 June 2019 (UTC)
@RexxS: I just happened to come upon it when processing some other edit request and got some input from a WMF UX person, Volker E. (WMF). See also Module talk:EditAtWikidata. The link colors are likely going to change closer to that new image as well, though the one in the side bar is still grayish right now. — xaosflux Talk 13:35, 20 June 2019 (UTC)
@Xaosflux: yes, I saw the original request, and I'm happy with the updated icon, especially as it's named for its function (UI edit) rather than its characteristics (blue), so hopefully further tweaks to the icon itself won't require any action from us. Cheers --RexxS (talk) 13:42, 20 June 2019 (UTC)