Jump to content

Module talk:WikidataIB/Archive 1

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:38, 17 October 2017 (Archiving 1 discussion(s) from Module talk:WikidataIB) (bot). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Archive 1Archive 2Archive 3Archive 5

Can't get this working

About en:Prussian P 10, item: Prussian P 10 (Q882458). It has P176=Borsig (Company). So Wikidata seems OK.

In this case I test:

-{{#invoke:WikidataIB|getValue|qid=Q882458|P176}}-

Returns empty string: --

Also, when previewing in article page itself (no |qid= used), it returns a blank. Am I missing something? -DePiep (talk) 17:32, 15 January 2017 (UTC)

@DePiep: Remember that this is designed for use in an infobox, therefore there are extra parameters that have to be enabled otherwise it won't return anything. The call matches the name of the field you're using it in with a list of fields that are to enabled ("whitelisted"). What you call the field doesn't matter as long as it's on the whitelist. So you can use:
  • {{#invoke:WikidataIB |getValue |qid=Q882458 |P176 |name=def |fetchwikidata=abd, def, ghi, jkl, etc}}
And it will return manufacturer (P176) for Prussian P 10 (Q882458). I'll miss out the qid in the first part of the following examples as you won't need it other than for testing on pages like this.
Rather than having to list every fieldname on the whitelist, you can use "ALL". So the call you probably want is something like:
  • {{#invoke:WikidataIB |getValue |P176 |name=manufacturer |fetchwikidata=ALL}}
Although if you're designing an infobox, you'll probably want to pass the whitelist (and blacklist) as parameters so the article editor supplies them once and the infobox passes them to each call in the design. Lets say we give them the names |whitelist= and |blacklist=. Then the code in the infobox design for the 'Manufacturer' field would be:
  • {{#invoke:WikidataIB |getValue |P176 |name=manufacturer |fetchwikidata={{{whitelist|}}} |suppressfields={{{blacklist|}}} |{{{manufacturer|}}} }}
The second unnamed parameter allows a local parameter (called 'manufacturer' in this case) to override the Wikidata call as ususal.
The infobox in use in an article could look something as simple as:
{{infobox something
| whitelist = ALL
}}
Does that make sense? Let me know if you're still having problems. Cheers --RexxS (talk) 02:03, 16 January 2017 (UTC)
Thanks, will process this. Could this be in the documentation? Sort of basic "required parameters" list? To me, the description & examples there are already quite abstract (into high end usage). Quite an object that requires studying. -DePiep (talk) 09:16, 16 January 2017 (UTC)

Coordinates

Just to note that it would be nice to be able to set the coordinates to display both inline and in the title (passing "|display=inline,title" to {{coord}}); this module just seems to allow inline coordinates. Thanks. Mike Peel (talk) 17:37, 18 December 2016 (UTC)

@Mike: I've implemented the 'display' parameter now. This is how it would work in Kitt Peak National Observatory (Q592248):
  • {{#invoke:WikidataIB |getCoords |qid=Q592248 |name=coord |fetchwikidata=ALL}}31°57′30″N 111°35′48″W / 31.9583°N 111.5967°W / 31.9583; -111.5967
You should see 31°57′30″N 111°35′48″W in the title position of this page as well.
You can't see multiple examples because the of title coordinates.
If you want to test the "title" or "inline" values, change the above to
  • {{#invoke:WikidataIB |getCoords |qid=Q592248 |display=title |name=coord |fetchwikidata=ALL}}
  • {{#invoke:WikidataIB |getCoords |qid=Q592248 |display=inline |name=coord |fetchwikidata=ALL}}
Of course, you don't need this so much now that the coord templates are Wikidata-aware, but it's useful if you want to implement the white/blacklists. --RexxS (talk) 11:55, 16 January 2017 (UTC)

Date handling

If more extensive date handling is ever needed, consider Module:Date which can parse dates in various formats, including a Wikidata date, and perform date arithmetic. However, the module is limited to four-digit years. The template {{extract}} can be used for quick tests although it does not expose options to choose the BC/BCE format.

  • {{extract|+2016-06-21T14:30:00Z}} → 14:30 21 June 2016
  • {{extract|+2016-06-21T14:30:00Z|show=ymd}} → 14:30 2016-06-21

Johnuniq (talk) 23:41, 20 January 2017 (UTC)

Thanks John. I think I had most of that functionality, as well as the BC/BCE and dmy/mdy/y functionality in Module:Wikidata in the getDateValue function, which dealt with any date BC or AD - I needed that for dob of notable Romans, etc. although the code was hard to read because I was using the timestamp and manipulating that directly. For greater flexibility in this module, I decided to use the mw.wikibase.formatPropertyValues() function – which always returns dmy format dates with BCE as appropriate – because that can be used on properties that are qualifiers as well. I'll need that later as fewer properties are defined and more values are stored as properties of qualifiers (like property:creator - qualifier:has role - item:video game artist instead of property:video game artist). Things like marriages have start-date and end-date that are in qualifiers. Anyway, I think I've managed to create a local function that takes the date in dmy+BCE format and outputs it in whatever format is wanted for use in article infoboxes. I've put a wrapper around it so that it's exported and can be invoked. --RexxS (talk) 04:00, 21 January 2017 (UTC)
Good, and I'm sure Wikidata has many quirks which require dedicated code. I just wanted to say that if more stuff such as date differences or adding time deltas were ever needed, Module:Date is available. Johnuniq (talk) 05:59, 21 January 2017 (UTC)

Alternative field names

Template:Contains Chinese text

Hi, I'm from Chinese Wikipedia. How can I give an alternative name to a field? Because the Chinese language has multiple writing systems (traditional + simplified), each parameter usually both has a traditional and simplified (and sometimes, English) name. How to make the fetchwikidata or suppressfields field work when a traditional or simplified name of a parameter is filled in? Such as:

Jackie Chan (Q36970)

{{Infobox entertainer/WD
<!-- English Wikipedia does not have this template, but this template is available on Chinese Wikipedia. It is called {{藝人/WD}} -->
| fetchwikidata = 出生地点
| name          = Jackie Chan
| type          = Actor
}}

or

{{Infobox entertainer/WD
<!-- English Wikipedia does not have this template, but this template is available on Chinese Wikipedia. It is called {{藝人/WD}} -->
| fetchwikidata = 出生地點
| name          = Jackie Chan
| type          = Actor
}}

or

{{Infobox entertainer/WD
<!-- English Wikipedia does not have this template, but this template is available on Chinese Wikipedia. It is called {{藝人/WD}} -->
| fetchwikidata = birth_place
| name          = Jackie Chan
| type          = Actor
}}

These will fetch place of birth from Wikidata. But now I can only use one of them to do that. --Dabao qian (talk) 16:24, 5 February 2017 (UTC)

@Dabao qian: I'm not sure I understand all that happens on Chinese Wikipedia when multiple labels are available. Nevertheless, I'll try to explain as much of WikidataIB as I can. Both fetchwikidata and suppressfields work by looking for the label/name of the field that is passed in the invocation, within the string that is passed by the article to |fetchwikidata= and |suppressfields=. So if the template defines 'Birth place' as something like {{#invoke:WikidataIB |getValue |P19 |name=birth_place |qid={{{qid|}}} |suppressfields={{{suppressfields|}}} |fetchwikidata={{{fetchwikidata|}}} |onlysourced={{{onlysourced|}}} |noicon={{{noicon|}}} }}, then |fetchwikidata=birth_place, birth_date, death_place, death_date (for example) would match the "|name=birth_place" in the infobox definition, and the call would return place of birth (P19). Using |fetchwikidata=ALL in an article would return all properties that are invoked in the infobox definition.
I think that you can avoid the multiple labels by deciding on using just one style of field name and documenting it, so that editors use just the string you specify in the list of fields passed to fetchwikidata and suppressfields. If you use "|name=birth_place" in the infobox definition, then editors have to use "|fetchwikidata=abc, def, ..., birth_place, ..., xyz".
I've just realised that your two examples you have 出生地點 ("Birth place") and 出生地点 (also "Birth place"). Does that mean you want to use both of those in your infoboxes? If so, then make two invocations in the infobox definition, one with |name=出生地點 and the other with |name=出生地点. Then use |fetchwikidata =abc, ..., 出生地點 出生地点, ..., xyz and both will be displayed, if that's what you want.
Please ping me again if I've not answered your query with something useful, and let me know if I can be more specific. Cheers --RexxS (talk) 19:32, 5 February 2017 (UTC)

Unsafe use of labels

Code like this:

    local label = mw.wikibase.label("Q" .. v.mainsnak.datavalue.value["numeric-id"])
    if label == nil then label = "Q" .. v.mainsnak.datavalue.value["numeric-id"] end
    if sitelink then
        out[#out + 1] = "[[" .. sitelink .. "|" .. label .. "]]"

or like this:

    local label = mw.wikibase.label(valueID)
    if not label then label = valueID end
    if sitelink then
        out[#out + 1] = "[[" .. sitelink .. "|" .. label .. "]]"

is not safe. Labels may contain any characters including [|]{} so a label could be constructed to generate e.g. any internal or external links. I suggest that you add mw.text.nowiki(label) before using labels in wikitext. The same applies to any string and text values from Wikidata. Best regards, Dipsacus fullonum (talk) 07:15, 3 February 2017 (UTC)

That's interesting. As it is clearly necessary to apply the mw.text.nowiki() function to every call to mw.wikibase.label() (without exception for the reasons given), it makes you wonder why the nowiki function is not applied to the mw.wikibase.label() internally. --RexxS (talk) 20:23, 5 February 2017 (UTC)

Bug in fetching referenced data

At Edward Bergh I added a second date at d:Q5572078 with year-only accuracy, as that's what I can easily find a reference for atm. Now that there's a reference, it displays the date in the infobox. However, it fetches the *unreferenced* date (with day-accuracy) rather than the referenced one (with year-accuracy). Not a big deal, since changing the rank causes the correct one to show, but this is probably an edge-case that should be fixed (@RexxS). Thanks. Mike Peel (talk) 16:35, 28 January 2017 (UTC)

(Note: I've found a ref for the day-accuracy one, so I've now removed the year-accuracy one from the entry, but this can be found in the history. Thanks. Mike Peel (talk) 16:39, 28 January 2017 (UTC)
Thanks, Mike. I'll have a think about how best to solve this issue. I originally thought that allowing date format to be set to "y" in the article would be enough, but sometimes there are two different date fields displayed with different precisions. It would be a shame to have to import the hugely complex date parsing code from Module:Wikidata that works from the raw timestamp just to ensure that we can respect the precision set by an referenced date. In many ways, the rank system at Wikidata is the "proper" solution – because a referenced date is always going to be preferred to an unreferenced one, and it makes that clear to other users of the Wikidata – but I know that we'd all prefer not to have to do that manually. Maybe a bot could be run on Wikidata which changed the rankings of unsourced statements to be lower than those of sourced ones? Can you see any downside in that? --RexxS (talk) 18:17, 28 January 2017 (UTC)
I think this is just a question of how the code should select which value to use, rather than having to affect the date formatting code. This could easily happen with a plain-text/Q-linked value as with a date. I haven't figured out the details of the ranking system on Wikidata myself yet - I'm not sure whether you can have more than one "preferred rank" value or not. Thanks. Mike Peel (talk) 18:30, 28 January 2017 (UTC)
@Mike: As far as I know, you can have many of each rank as you wish. The question is how should we deal with the case where multiple values of the property exist with the same rank? We would want to return as a list multiple values of most fields, e.g. occupation, but surely we wouldn't want multiple dates of birth returned? --RexxS (talk) 20:56, 28 January 2017 (UTC)
Apparently sometimes multiple dates of birth do need to be returned, e.g. from d:Q885424. So maybe just return all of the referenced statements for the highest rank available? Thanks. Mike Peel (talk) 22:52, 6 February 2017 (UTC)
I'd prefer to use a local parameter for such a case. We could then have "3 or 9 August 1858", rather than the list that the call would naturally return: "3 August 1858, 9 August 1858". That's because the call doesn't know that we would write the list of dates in the former way for disputed dates of birth. I could certainly make the list output with "or" separating the dates, but shorthand styles like "3 or 9 August 1858" and "30 July or 9 August 1858" are a lot more work to program, and hence more room for errors and edge cases, and I'd want to see a lot more testing in sandbox if we went down that route. --RexxS (talk) 04:34, 7 February 2017 (UTC)

Linking only to Wikipedia

Would it be possible to add an extra parameter that forces all links to be local, rather than to Wikidata, even if the article does not yet exist? E.g. something along the lines of Template:Wikidata list's "links=red" parameter (demo). That might then solve the concern raised at Template_talk:Infobox_person/Wikidata#Lack_of_redlinks. (@RexxS) Thanks. Mike Peel (talk) 15:04, 25 March 2017 (UTC)

@Mike: Well, as it happens, I was intending this weekend to update the getValue() call to check whether there is a redirect available to link to when there is no sitelink corresponding to the label on Wikidata, so I've taken the opportunity to do that job and add a new boolean parameter |wdlinks= which turns on or off the links to Wikidata. I've set the default to "no" links for now (i.e. just plain text if there's no enwiki article). Here is an example for Richard Burton's occupations (showing the redirects) and a couple of examples of George Orwell's awards (showing the wikidata links no/yes):
  • {{#invoke:WikidataIB |getValue |qid=Q151973 |P106 |fetchwikidata=ALL |onlysourced=no}}film actor, diarist, stage actor, actor, film director, film producer, producer, director Edit this on Wikidata
  • {{#invoke:WikidataIB |getValue |qid=Q1396889 |P166 |fetchwikidata=ALL |onlysourced=no}} → Retro Hugo Award for Best Novella, Modern Library's 100 Best Novels, NPR Top 100 Science Fiction and Fantasy Books, Prometheus Award - Hall of Fame Edit this on Wikidata
  • {{#invoke:WikidataIB |getValue |qid=Q1396889 |P166 |fetchwikidata=ALL |onlysourced=no |wdlinks=yes}} → Retro Hugo Award for Best Novella, Modern Library's 100 Best Novels, NPR Top 100 Science Fiction and Fantasy Books, Prometheus Award - Hall of Fame Edit this on Wikidata
What do you think? --RexxS (talk) 18:25, 25 March 2017 (UTC)
P.S. I won't create automatic redlinks because making such a link must require a conscious decision that an article with that title should exist. It's not suitable for an automated task. --RexxS (talk) 18:27, 25 March 2017 (UTC)
Thanks @RexxS:, that seems like a good improvement. :-) I still think that it would be useful to have an option to fetch redlinks, though - this wouldn't have to be completely automatic, we could selectively enable it in individual infobox template lines, or in individual articles, as desired, so that they are added in a curated way. Thanks. Mike Peel (talk) 21:24, 25 March 2017 (UTC)
The problem is, Mike, that templates don't work like that. If we enabled red links for Richard Burton's occupation at the article level, we can't tell what occupation (P106) might be added in future - would we want, for example, Dog whisperer to be created as an article? How could we possibly judge ahead of time what property values might be added on Wikidata, and that we would definitely want an article on them? What if there were multiple values for a property and we only wanted to redlink some of them? --RexxS (talk) 00:54, 26 March 2017 (UTC)
That then comes down to editor judgement - it's an editor that would cause the redlink to exist (by editing Wikidata), and it's also an editor that would decide whether to create a new article, or remove the redlink. I'm suggesting an optional parameter, which could easily be added or removed as needed on a template/article-level basis, not something that is automatically used everywhere (i.e., it should not be the default). Thanks. Mike Peel (talk) 01:04, 26 March 2017 (UTC)
And editor judgement is exactly the problem. The editor (or bot) who adds the value on Wikidata probably won't even know that they would be creating a redlink in an infobox in an article on English Wikipedia. The Wikidata-haters would be the first to spot an inappropriate redlink in an infobox, and it would just be more ammunition for them in their mission to stop Wikidata being used anywhere on Wikipedia. I don't intend to waste any more time than I already do on arguing with them, especially on an issue that seems to me to be wholly preventable. --RexxS (talk) 10:10, 26 March 2017 (UTC)
Don't worry, I'm sure they'll use the fact that redlinks aren't supported as ammunition anyway. ;-) Personally I'm a big fan of redlinks, and think that they could be useful in some cases in the infoboxes, hence this request, but I can cope without them for now. Thanks. Mike Peel (talk) 10:43, 26 March 2017 (UTC)

New testcase

I have started developing a new testcase to support this initiative, where I am using this module in Template:Infobox deity/Wikidata, which is a wrapper of Template:Infobox deity. The module seems to not work for sibling and child, can someone please explain. -- Pankaj Jain Capankajsmilyo (talk · contribs · count) 18:33, 27 April 2017 (UTC)

I can only assume you're looking at articles where those parameters are unsourced on Wikidata. Using calls from WikidataIB, they will only display if sourced. I tried previewing {{Infobox deity/Wikidata |fetchwikidata=ALL |onlysourced=false}} in Rama and could see the Weapon/Spouse/Parents/Siblings/Children/Texts/Born fields. None of those show up using the default {{Infobox deity/Wikidata |fetchwikidata=ALL}} because none of them are sourced on Wikidata. The fix is to add proper sources to the Wikidata entries. --RexxS (talk) 22:34, 27 April 2017 (UTC)
Got it now, thanks. I couldn't add the qualifier and had to comment it in affiliation. Are qualifiers only allowed for specific QID's? Is there a way to add qualifier without mentioning the pval? -- Pankaj Jain Capankajsmilyo (talk · contribs · count) 05:20, 28 April 2017 (UTC)
You may have seen Module talk:Wikidata #Qualifiers where I discussed this problem in more detail. The core of it is that properties can have multiple values and each value can have multiple qualifiers, so how would anybody know which of the possible multiple results is the one you want? The usual example I give is that Richard Burton (Q151973) was married five times, so the property spouse (P26) has five values, each of which has a start time (P580). So if we tried to fetch the start time of Burton's spouse, which of the five start times would you expect to be returned? None of the calls in the earlier Module:Wikidata to retrieve qualifiers works properly for that very reason. Try previewing {{#invoke:Wikidata|getQualifierDateValue|P26|P580|FETCH_WIKIDATA}} in a section of Richard Burton and you get "15 March 1964, 3 July 1983, 5 February 1949, 21 August 1976, 10 October 1975". What use is that to anybody? If, and only if, you can guarantee that the property will have exactly one value, then you can simply fetch the qualifier(s) for that. But as you have no control over someone who might add more information at Wikidata, you can't possibly guarantee there will always be just one property value. --RexxS (talk) 17:04, 28 April 2017 (UTC)
The way I see it, if we link the qualifiers to property and fetch property instead of qualifiers, we might be able to solve it. See |sibling= for example. By default, it fetches all and show as comma separated values. We can fetch properties as br separated and qualifiers as comma separated. Another example, The case I'm using, Rama, I want to show "Avatar of Vishnu". So I can fetch Vishnu using getvalue. If it's possible, allow to fetch all values of incarnation as br separated values and give some formats to display. Examples Qualifier of Propertyval, Propertyval (Qualifier), etc. I might have missed something, so please elaborate if I'm wrong somewhere. `-- Pankaj Jain Capankajsmilyo (talk · contribs · count) 17:20, 28 April 2017 (UTC)

Alphabetical output?

@RexxS: Would it be possible to have an option to sort the Wikidata values alphabetically? This shouldn't be on by default, but it would be useful in cases like the "includes" part of Belfries of Belgium and France. Thanks. Mike Peel (talk) 00:48, 9 May 2017 (UTC)

{{#invoke:WikidataIB |getValue |qid=Q151973 |P26 |fetchwikidata=ALL |onlysourced=no}}Elizabeth Taylor, Sybil Christopher, Suzy Miller, Elizabeth Taylor, Sally Burton Edit this on Wikidata
{{#invoke:WikidataIB |getValue |qid=Q151973 |P26 |fetchwikidata=ALL |onlysourced=no |sorted=yes}}Elizabeth Taylor, Elizabeth Taylor, Sally Burton, Suzy Miller, Sybil Christopher Edit this on Wikidata
@Mike Peel: That's a first attempt – just a simple alphabetical sort on the text. It's not smart, so it treats links as '[['; sorts given names before last names; doesn't de-duplicate, etc. Would you have a look at the particular example you're interested in and see whether the |sorted= parameter is adequate for your purposes, please? If not, it's a lot more messy to code it into what we might consider a "smarter" sort. Cheers --RexxS (talk) 21:38, 9 May 2017 (UTC)
@RexxS: Thanks! I've implemented it in the includes parameter of Belfries of Belgium and France. It seems to work very well, although there is the oddity between "Ypres Cloth Hall" (link) and "Cloth Hall, Ypres" (Wikidata label), which appears at the end of the list - it look more natural if it were sorted on the displayed name rather than the linked name. But that's a minor thing. :-) Thanks. Mike Peel (talk) 21:46, 9 May 2017 (UTC)

Birthplace

Birthplace only shows the city / village in which the person was born in. Is it possible to fetch the state as well from wikidata? -- Pankaj Jain Capankajsmilyo (talk · contribs · count) 08:26, 10 May 2017 (UTC)

Broken

@RexxS and Pppery: Something has gone seriously wrong - values aren't being fetched from Wikidata through this template at South Pole Telescope or any other telescope article. The values that are being shown are through {{convert}}, not this template. This is possibly something to do with onlysourced=no? Thanks. Mike Peel (talk) 11:33, 16 May 2017 (UTC)

YEs, I many a silly typo when I refactored some duplicate code. Now fixed. Pppery 11:35, 16 May 2017 (UTC)
Phew, thanks. :-) Mike Peel (talk) 11:37, 16 May 2017 (UTC)

New parameters: sorted, sep and list

I've implemented three new parameters that still need to be documented:

  • |sorted= is a boolean passed to enable sorting of the values returned. No parameter, or an empty string, or "false", or "no", or "0" disable sorting. It's only a very dumb alphabetical sort and sorts linked values as "[["
  • |sep= allows the separator between multiple returned values to be defined. The default is ", ". If the separator has leading or trailing spaces, enclose it in double quotes (e.g. |sep=" - ").
  • |list= allows multiple returned values to be displayed as a horizontal list (|list=hlist), or a vertical unbulleted list (|list=ubl). These override the separator and do not display the 'pen icon' linked to "Edit at Wikidata"

If any problems occur, please ping me and I'll try to sort them out. --RexxS (talk) 16:14, 18 May 2017 (UTC)

getQualifierValue only works for properties that are Q-number valued ?

It seems getQualifierValue only works for properties that are Q-number valued.

Is there a good reason for this? I had been hoping to use it to extract a qualifier from a property that is external-identifier valued, for example:

  • {{#invoke:WikidataIB |getQualifierValue |P1367 |pval=simpson-charles-walter-18851971 |qual=P1114 |fetchwikidata=ALL |qid=Q5083334 }}
->

to extract the number of works at Art UK associated with Charles Walter Simpson (English artist) (Charles Walter Simpson (Q5083334)).

Also, is it possible to omit the value for pval= in cases where there is only one pval, since my template is not currently written to handle cases when there is more than one anyway? Thanks. Jheald (talk) 09:35, 20 February 2017 (UTC)

@Jheald: Indeed, I only wrote the function getQualifierValue to deal with properties that are wikibase-entities because I knew that infoboxes will normally only be dealing with those sort of values for qualifiers (because of the multi-lingual nature of Wikidata). If somebody comes up with an exception, I can handle that with extra code, but as this module is specifically intended for use in creating infobox templates, I was lazy.
Now, in your case, handling of external identifiers for use in different templates is worth making a separate module for, as we don't need any of the black/white-listing and source-filtering facilities of WikidataIB. So I've made Module:WikidataIdentifiers to hold functions related to that. Try previewing {{#invoke:WikidataIdentifiers |getIdentifierQualifier |P1367 |qual=P1114}} in Charles Walter Simpson (English artist) and you should get 27 (unless somebody changes it in Wikidata). If you want to use it outside of his article, then the expansive call is available:
  • {{#invoke:WikidataIdentifiers |getIdentifierQualifier |P1367 |qual=P1114 |qid=Q5083334}} → 27
The function assumes that there is only one value for the property Art UK artist ID (P1367) – list of exceptions are at d:Wikidata:Database reports/Constraint violations/P1367 #Single_value – and that the value has only one qualifier which is a quantity. I can expand the code to cater for other types of qualifiers, but you'd have to tell me what other types you anticipated. Naturally, the #invoke can be wrapped in a template to sweeten the syntax for others. Hope that does the trick for you. Cheers --RexxS (talk) 15:39, 21 February 2017 (UTC)
I feel I've now been given a fantastic early birthday present, all wrapped up in a bow!
{{Art UK bio}} is now starting to update across 750 transclusions, with a potential further 6,500 ready to add.
I sent an email to Art UK on Friday with the list of potential duplicates from Wikidata (all of which seem pretty plausible); but no response from them as yet.
Thank you again for such-appreciated Lua magic, and very best regards, Jheald (talk)
Would it also be possible to have a routine that pulls source properties, in particular P813 "retrieved" ? (And perhaps a pretty date formatter?) I should perhaps be including that information when the external id is being cited as a ref. Jheald (talk) 19:27, 22 February 2017 (UTC)
@Jheald: I'm not very good at working in the abstract, as it involves too much second-guessing what folks want. But if you could give me a concrete example of a Wikidata entry and the information you want retrieved from it, I could have a bash at writing the code. This module already supports date-formats as |df= with allowed values of "dmy", "mdy" and "y" – is that what you were thinking of for the dates? as I could just re-use that code in the other module. --RexxS (talk) 20:07, 22 February 2017 (UTC)
On second thoughts, no worries. Mostly when people are using the site for a reference, it probably makes more sense to keep the retrieved date hard-coded as to when they looked at the site; rather than when the link was most recently verified, and the number of paintings updated. At least that's what I'm doing at the moment. But let me get back to you if I find a case where using the sourcing from Wikidata would be useful. Jheald (talk) 20:13, 22 February 2017 (UTC)

Update: It seems that quantity (P1114) has been superseded by number of works (P3740) for this sort of application. Fortunately this requires only a minor tweak:

  • {{#invoke:WikidataIdentifiers |getIdentifierQualifier |P1367 |qual=P3740 |qid=Q5083334}} → 27

--RexxS (talk) 15:07, 23 May 2017 (UTC)

King

I have recently created {{Infobox royalty/Wikidata}} and trying to find a way to use this module to fetch (position held=king), (reign=starttime-endtime), (predecessor=replaces), (successor=replacedby), (succession="King of"+of). For an example, you can check Jayasimha Siddharaja and its associated Wikidata item. Please help. Thanks. -- Pankaj Jain Capankajsmilyo (talk · contribs · count) 02:58, 15 May 2017 (UTC)

References

If we are ever going to heavily use this module, we need an option to fetch references with the data value, something like |getValue refs=yes, which would append references to the end of the fetched string (before the pen icon). Template:Wikidata can do this. Maybe this module should call it, so we are not duplicating code and effort? Laurdecl talk 07:44, 19 June 2017 (UTC)

This would be really useful. Note that the way we're currently using this module to fetch the info, and the other module to fetch the references, means that sometimes the wrong references get fetched from a different value of the property than is shown. Fetching both at the same time with consistency always would be good. Thanks. Mike Peel (talk) 12:20, 19 June 2017 (UTC)
(BTW, I know fully supporting references with all the different reference templates would be a lot of work, but the basic setup of just using cite web is working reasonably well so far, and is better than nothing.) Thanks. Mike Peel (talk) 12:22, 19 June 2017 (UTC)
The problem is, Mike, that Wikipedia supports so many different styles of references (I don't mean types like web, journal, etc.) that it's not possible, as far as I am able to tell, to format the resulting reference so that it matches the existing style in an article. I'm sick of having the arguments about citation formatting – see Talk:Jane Austin for example – and I'm not prepared to put in time and effort to create solutions that just give the whiners something else to complain about. When Wikipedia grows up and creates a "house style" for references, then it would make the effort worthwhile. --RexxS (talk) 09:59, 20 June 2017 (UTC)

Wrapper template

We currently can't pass the result of this module to templates like {{convert}} because the Lua is processed after the Wikitext template. This means we can't use things like {{If empty}} as well. If we had a wrapper template that called this module, would that be solved? That seems better than invoking a module anyway. This would instantly solve the problem with computing ages for Template:Infobox person/Wikidata. RexxS? Laurdecl talk 07:25, 20 June 2017 (UTC)

It's easy enough to create a template to wrap the module – why not make one and see if it forces the order of evaluation that you want? My usual solution is to write a new call inside the module that manipulates the table in getValue and then passes that table to frame:expandTemplate(), see how {{hlist}} is called around line 341 in the current module here. Module:Wikidata has a separate function that passes its output to {{coord}}, but it isn't used much. I suppose I ought to re-write this module to uncouple the output formatting from the part that fetches the data into two separate functions internally, then it would be easier to write new outputs, either by passing an additional parameter to getValue, or by making a new public function that only had to modify the processing of the output. --RexxS (talk) 09:59, 20 June 2017 (UTC)
If we use a template, we might as well call Module:Wd with a few qualifiers and attach the pen icon on the end. Is there a good reason we have Module:Wd, Module:Wikidata, and Module:WikidataIB? The other two can handle references, and use different templates, etc. The code for getting only sourced values could easily be merged in. We're maintaining three different forks for no reason... Laurdecl talk 00:45, 22 June 2017 (UTC)
As Module:Wikidata dates from 19 May 2013 and Module:Wd dates from 20 August 2016, you might want to address that question to User:Thayts. If you want to go ahead and merge all three modules, please feel free to go ahead. You'll still find that the problems are not in writing the code, but in meeting all of the conflicting demands of the users. --RexxS (talk) 09:24, 22 June 2017 (UTC)

qid= if needed

Template:Infobox lighthouse is used on articles about lighthouses and also in more general articles. Sample: Vuurtoreneiland. To enable it to read d:Q2921152, I added item=Q2921152 and used "qid={{{item|}}}" in the template when calling this module, but it looks like it doesn't work when the article doesn't need it (e.g. Kõpu Lighthouse). Is there way to have it default to the item that goes with the article? Jura1 (talk) 18:45, 20 July 2017 (UTC)

Actually, it works as expected. There was another problem. Jura1 (talk) 22:52, 20 July 2017 (UTC)

Mannar Island Lighthouse (old)

Mannar Island Lighthouse (old) is displaying "Lua error in Module:WikidataIB at line 271: attempt to index field 'datavalue' (a nil value)." for Deactivated in the infobox. No relevant recent edit has occurred at the article. Is the problem wikitext in the article or is it a problem in this module? Johnuniq (talk) 06:12, 25 July 2017 (UTC)

Thanks, John, the problem was in the module. I hadn't checked for the possibility of time values being set to "somevalue" in Wikidata. Should be fixed now. Cheers --RexxS (talk) 13:44, 25 July 2017 (UTC)

Lua error on unknown value

{{#invoke:WikidataIB|getValue|P195|qid=Q2246489|fetchwikidata=ALL|onlysourced=no}} is currently returning Unknown, Isabella Stewart Gardner Museum Edit this on Wikidata as the second value there is "unknown value". Thanks. Mike Peel (talk) 00:03, 2 July 2017 (UTC)

Ok, Mike. I think I've resolved the error by checking for values that have a snaktype of "somevalue" (which is what is actually stored in the database), and returning "Unknown value" as you can now see above. I'm not sure what you wanted the code to do when it found a value like that, but at least you can explicitly test for "Unknown value" if you want to handle it in a template. Otherwise, let me know what action you want the code to take. Cheers --RexxS (talk) 23:12, 2 July 2017 (UTC)
Update: to keep it in line with the time handling, I've amended the return value to just "Unknown" (exactly that). I think it looks better if it's used raw than "Unknown value". Hope that doesn't cause problems. Cheers --RexxS (talk) 16:22, 25 July 2017 (UTC)

Short names

Hi @RexxS: I'm working on a revised version of {{Infobox video game}} that uses this module rather than Module:Wikidata. The template currently uses getValueShortName, would you be able to add support for that here as well please? getPreferredValueShortName would also be useful (or perhaps a shortname=yes parameter would be a more general solution). Thanks. Mike Peel (talk) 01:35, 8 August 2017 (UTC)

Building

Hello, I just noticed that there might be less opposition in using wikidata in {{Infobox historic site}} as these are mostly developed on wikidata being famous sites. Therefore, I have initiated {{Infobox historic site/Wikidata}}. You are invited to help build and deploy it in mainspace articles. -- Pankaj Jain Capankajsmilyo (talk · contribs · count) 16:39, 18 September 2017 (UTC)