Module talk:WikidataIB

This is an old revision of this page, as edited by DePiep (talk | contribs) at 18:57, 26 September 2022 (How to add references: Reply). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Latest comment: 2 years ago by DePiep in topic How to add references

Possible bug fix

I'm trying to set up my own wiki, and I've been importing various templates and modules from Wikipedia. Something I imported eventually complained that this module was missing, so I imported it.

At this point I feel like I should note that I have no idea what this module is for. With that said:

After importing this module, pages that were using it then started complaining about an attempted dereference of a nil reference. I "fixed" it (on my local site), at least insofar as that those pages no longer complain, but I don't want to update the module here on Wikipedia because, like I said, I have no idea what it's for. So, in case someone more knowledgeable than me wants to check if it would be appropriate to add my change here too, what I did was insert this line at the top of function _getcommonslink:

if not mw.wikibase then return nil end

The mw.wikibase variable is dereferenced a couple lines later, which is where the error was thrown from. I hope this helps. -Rwv37 (talk) 23:24, 9 February 2022 (UTC)Reply

mw.wikibase is the library of functions for accessing wikibase items via Lua. It's documented here. Without that extension I cannot think how this module can do anything for you on your home wiki. — Martin (MSGJ · talk) 03:37, 24 February 2022 (UTC)Reply
Yeah, I eventually figured out what Wikibase is. The thing the module could do for my home wiki is exist, so as to stop other imported things from complaining about it being missing. Turns out that issues like this are all over the code, not just in Module:WikidataIB. -Rwv37 (talk) 10:15, 5 March 2022 (UTC)Reply

How to get the latest value instead of the largest value?

This gives the largest population value:

  • {{population WD|Härnösand Municipality}} -> 24,502 (2025)  
  • {{#invoke:WikidataIB |getValue |P1082 |qid={{GetQID|Härnösand Municipality}} |fwd=ALL |rank=p n |osd=no |sorted=yes |list=p-1 |qual=ALL}} -> 25,325 (2017)  

I want it to show the newest value, which is 21,012 (2021). Is that possible using WikidataIB? Also in case all values have the same rank? Tomastvivlaren (talk) 09:41, 1 March 2022 (UTC)Reply

I don't think there is a function for that. You should set preferred value and then use rank=best — Martin (MSGJ · talk) 11:26, 1 March 2022 (UTC)Reply
  • {{#invoke:WikidataIB |getValue |P1082 |qid=Q209634|fwd=ALL |rank=best |osd=no |qual=ALL}} -> 24,502 (2025)  
Thnx for your good advise. I believe my current solution shows the most recently edited value (which often but not always is the newest value), if all values have the same rank:
{{#invoke:WikidataIB |getValue |P1082 |qid=... |fwd=ALL |rank=best |osd=no |qual=ALL|list=p-1}}
Tomastvivlaren (talk) 23:53, 10 March 2022 (UTC)Reply

How to only show year of a numeric value?

How can I only show the year of a numeric value, for example the year for the population size of a city? Now I used the following advanced string manipulation to remove the value, which makes the script slow - it gives the error message "The time allocated for running scripts has expired" if the script is included a large number of times in the same Wikipedia page:

  • {{#invoke:Ustring|gsub|{{#invoke:WikidataIB |getValue |P1082 |qid=... |fwd=ALL |rank=best |osd=no |qual=P585|qdf=y|noicon=TRUE|list=p-1}}|^[%d,± ]* %((%d%d%d%d)%)|%1}}

Tomastvivlaren (talk) 00:06, 11 March 2022 (UTC)Reply

sorted=true: by what?

I understand that |sorted=true sorts the returned values, but I cannot see by what ordering. Eg, for quassin (Q2079986), found in taxon (P703):

sorted=false: Picrasma crenata, Picrasma javanica, Picrasma quassioides, Quassia africana, Quassia amara, Samadera indica   dflt
sorted= true: Quassia africana, Picrasma crenata, Picrasma javanica, Picrasma quassioides, Quassia amara, Samadera indica  
So, true-results have unexpected order IMO. (Incidentally, the itempage has/shows alphabetical order).

DePiep (talk) 13:26, 26 September 2022 (UTC)Reply

Does it have to do with wikilinked/unlinked? If so, by some rationale or because of code like "[[..."? DePiep (talk) 13:28, 26 September 2022 (UTC)Reply
@DePiep From the doc page/comments: It's only a very dumb alphabetical sort and sorts linked values as "[[ ...". So a literal alphabetical sort that doesn't break up links to sort by label. That seems to match your example as well. -- ferret (talk) 13:30, 26 September 2022 (UTC)Reply
Thanks; makes me feel good having the question right ;-)
Consider answered. DePiep (talk) 13:38, 26 September 2022 (UTC)Reply

How to add references

Is there a way to show references? {{wikidata}} has this nice option:

{{wikidata|properties|linked|references|normal+|Q18216|P703}}
liquorice,[1] Ixora coccinea[2]

But afaik it is less controllable. Some live examples in infoboxes? -DePiep (talk) 14:48, 26 September 2022 (UTC)Reply

References

  1. ^ L A Mitscher; Y H Park; D Clark; J L Beal (March 1980). "Antimicrobial agents from higher plants. Antimicrobial isoflavanoids and related substances from Glycyrrhiza glabra L. var. typica". Journal of Natural Products. 43 (2): 259–269. doi:10.1021/NP50008A004. ISSN 0163-3864. PMID 7381508. Wikidata Q71214999.
  2. ^ Chia-Lin Lee; Yung-Chih Liao; Tsong-Long Hwang; Chin-Chung Wu; Fang-Rong Chang; Yang-Chang Wu (December 2010). "Ixorapeptide I and ixorapeptide II, bioactive peptides isolated from Ixora coccinea". Bioorganic & Medicinal Chemistry Letters. 20 (24): 7354–7357. doi:10.1016/J.BMCL.2010.10.058. ISSN 0960-894X. PMID 21106454. Wikidata Q39627968.

DePiep (talk) 14:48, 26 September 2022 (UTC)Reply

As far as I know, this module was never designed to produce references. It would be nice to produce well formatted references. I think it will be quite challenging to match an existing citation style on an article. — Martin (MSGJ · talk) 15:11, 26 September 2022 (UTC)Reply
Ouch. This hurts... Thx. DePiep (talk) 18:57, 26 September 2022 (UTC)Reply