Module talk:Wd
Module:Wd is permanently protected from editing because it is a heavily used or highly visible module. Substantial changes should first be proposed and discussed here on this page. If the proposal is uncontroversial or has been discussed and is supported by consensus, editors may use {{edit template-protected}} to notify an administrator or template editor to make the requested edit.
|
This is the talk page for discussing improvements to the Wd module. |
|
Archives: 1Auto-archiving period: 3 months |
This module does not require a rating on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | ||||||||
|
Use Wikipedia talk:Wikidata for general Wikidata support discussions. |
Related pages |
---|
Discussion at Template talk:Wikidata entity link § Not picking up mul labels from Wikidata entities
[edit]You are invited to join the discussion at Template talk:Wikidata entity link § Not picking up mul labels from Wikidata entities. Peaceray (talk) 01:10, 30 August 2024 (UTC)
- @Thayts, Janhrach, et al.: What do you think? I was thinking to change Module:Wd#L-704 from
label = mw.wikibase.getLabelByLang(id, self.langCode)
tolabel = mw.wikibase.getLabelByLang(id, self.langCode) or mw.wikibase.getLabel(id)
(at least as an interim step). Is this the right thing to do or should we just removegetLabelByLang()
all together? Currently it is also being (mis)used at Module:Wd#L-1294 (with a hardcoded "en" for the language). Incidentally this module currently also usesgetDescription()
(and notgetDescriptionByLang()
) at Module:Wd#L-2523. It seems like the language usage (and their fallbacks) is not very unified here. Thank you, —Uzume (talk) 15:11, 30 August 2024 (UTC)- I am not familiar with the Wikibase API. As for the status quo, it is not good and I already have had to fix a bug arising from a lack of label fallback. I don't know whether
getLabel
provides a good fallback mechanism, and I don't now have time to check the documentation. (Though maybe tomorrow I will have.) - As for the
hardcoded "en"
, it is required that the language is hardcoded, because the fetched label is used in a Geohack call. (However, I find it much preferable for this string to be fetched from a WD property and not from the label, because in the future, there will be no guarantee that the label will be accepted as a Geohack param.) Janhrach (talk) 19:26, 1 September 2024 (UTC)- Update: I found the documentation is linked in the linked discussion, so I didn't have to search for it. It seems that it is desirable use getLabel only. There may arise some issues, but they would (in my speculation) only affect multilingual wikis. I will look into this possible bug later. Janhrach (talk) 19:36, 1 September 2024 (UTC)
- The hypothetical bug I have mentioned quite probably won't arise, so ignore this part of the comment. Janhrach (talk) 17:53, 2 September 2024 (UTC)
- Update: I found the documentation is linked in the linked discussion, so I didn't have to search for it. It seems that it is desirable use getLabel only. There may arise some issues, but they would (in my speculation) only affect multilingual wikis. I will look into this possible bug later. Janhrach (talk) 19:36, 1 September 2024 (UTC)
- I am not familiar with the Wikibase API. As for the status quo, it is not good and I already have had to fix a bug arising from a lack of label fallback. I don't know whether
Proposed fix
[edit]I made a fix to the sandbox. Sample output:
- English label:
- live module: Europe
- sandbox: Europe
- Multilingual label:
- live module: Douglas Adams
- sandbox: Douglas Adams
—Janhrach (talk) 16:36, 8 September 2024 (UTC)
Property mapping and ignoring unrecognized parameters
[edit]I was brought here by the following citation errors which had too much information:
Extended content
|
---|
References
|
This is partially just an edit request to add some properties to the property mapping. author (P50) and place of publication (P291) are common citation parameters that need to be added to the property mappings documented at Template:Cite Q § Bibliographic parameters and Template:Wikidata § References. I would further map genre (P136) to |type=
and published in (P1433) to |work=
.
However, I also think that this template/module refusing to produce any citation when there are unrecognized parameters is not ideal. I suggest that it should ignore unrecognized parameters without error messages in published articles, and only show a green warning message on previews.
Pinging Sdkb from their prior interest at Module talk:Wd/Archive 1 § References mapping.
Daask (talk) 08:03, 24 September 2024 (UTC)
- As for the errors containing
too much information
, there were repeated complaints that the previous error message, which only indicated that an error had occured and linked to the documentation, was unclear. And I think too little information is a lesser problem than too much information, especially when there is no middle ground. - As for the requested mappings, the usage of the mentioned properties in WD refs is not standard per wikidata:Help:Sources.
- Ignoring unknown properties is problematic, because some properties may be deliberately left from the Cite web mapping to force the module to use Cite Q. This will be very important if new output templates are added, which is something I want to do eventually. Janhrach (talk) 15:06, 27 September 2024 (UTC)
- @Janhrach: I apologize for my unclear comment. My concern was not that the error message was verbose, but rather that the error was caused by Wikidata having too much information about the citation. Daask (talk) 15:36, 27 September 2024 (UTC)
- I have made some edits to the refs on Wikidata, and I will also modify the module later. Janhrach (talk) 18:01, 27 September 2024 (UTC)
- I have added support for place of publication (P291) into the Cite web mapping. Janhrach (talk) 13:20, 5 October 2024 (UTC)
- Why? When citing a web source, that source exists somewhere (or multiple somewheres) on the intarwebs but is not tied to a physical location. Just because a box can be filled, it does not mean that it should be filled.
- —Trappist the monk (talk) 13:44, 5 October 2024 (UTC)
- I added the property because the reference number two above displayed an error, as it contained the P291, which was not in the mapping. Is the usage of "Bloomington" in
publication-place
in the above reference incorrect? Should all instances of usage like this be removed from Wikidata? Janhrach (talk) 13:58, 5 October 2024 (UTC)- Yes, incorrect. And because you are citing a website, the proper parameter is
|website=
not|publisher=
. Wikidata should contain correct data. The problem there is that there are few if any standards so editors will fill-in the boxes because 'omg!-there-is-an-empty-box!-I-must-fill-it!' All that you can do is recognize that and choose{{cite web}}
parameters appropriately. - —Trappist the monk (talk) 14:12, 5 October 2024 (UTC)
- OK, I fixed the incorrect publication-place properties on WD and reverted my edits to this module. Janhrach (talk) 14:24, 5 October 2024 (UTC)
- May I ask why you think Kinsley Institute should be in
website
, not inpublisher
? Janhrach (talk) 16:48, 5 October 2024 (UTC)- Because we cite the work (
|website=Kinsey Institute
in this case – note spelling) not the publisher (Indiana University). - —Trappist the monk (talk) 18:38, 5 October 2024 (UTC)
- Is the Kinsey Institute a work? It quite seems to match the definition of "publisher" from the Cite web documentation (
The publisher is the company, organization or other legal entity that publishes the work being cited.
). - We could say that we cite the institute's website, which has the same name as the institute. Is this what you mean?
- (Thanks for the spelling correction; I sometimes misread words and misspell them afterwards.)
- – Janhrach (talk) 12:55, 11 October 2024 (UTC)
- Is the Kinsey Institute a work? It quite seems to match the definition of "publisher" from the Cite web documentation (
- Because we cite the work (
- Yes, incorrect. And because you are citing a website, the proper parameter is
- I added the property because the reference number two above displayed an error, as it contained the P291, which was not in the mapping. Is the usage of "Bloomington" in
- I have added support for place of publication (P291) into the Cite web mapping. Janhrach (talk) 13:20, 5 October 2024 (UTC)
- I have made some edits to the refs on Wikidata, and I will also modify the module later. Janhrach (talk) 18:01, 27 September 2024 (UTC)
- @Janhrach: I apologize for my unclear comment. My concern was not that the error message was verbose, but rather that the error was caused by Wikidata having too much information about the citation. Daask (talk) 15:36, 27 September 2024 (UTC)
Summing values across items
[edit]Hi,
I am already using this module to call values for specific items (in my case, political parties, such as their number of members).
Is there a way to sum these values for several items that are all instances of an item. For instance, the parties I deal with are all instances of "European political parties", and I am trying to sum their values to display the result (e.g., the sum total number of members of all European political parties).
Is these feasible one way or another?
Thanks! Julius Schwarz (talk) 07:47, 21 October 2024 (UTC)
- This is not possible with this module. Janhrach (talk) 15:41, 25 October 2024 (UTC)
- Thanks for the reply! And too bad. Julius Schwarz (talk) 07:48, 28 October 2024 (UTC)
Support for P5017 last update
[edit]@Thayts and Janhrach: Hi. Is it possible to add support for P5017 last update property? It seems to be perfectly valid citation/reference property for continuously updated sources to indicate last-update date of the version actually cited and it is being used all over WD this way, see backlinks and stat. Right now rendering attempt of a citation having this property filled here on enwiki leads to a nasty error output:
{{#invoke:wd|reference|Q733993|P2046}}
→ [1]
- ^
Error: Unable to display the reference from Wikidata properly. Technical details:
- Reason for the failure of {{Cite web}}: The Wikidata reference contains the property last update (P5017), which is not assigned to any parameter of this template.
- Reason for the failure of {{Cite Q}}: The Wikidata reference contains the property last update (P5017), which is not assigned to any parameter of this template.
On other wikis such citations are citable at least, even if the last update value is not used. E.g.: [1].
If there really is a good reason to keep current strict semantics (i.e. to fail with error on any unknown/unmapped citation property instead of just ignoring it or maybe including some hidden note and a monitoring cat. assignment), maybe an explicit whitelist of "tolerated" though unused citation properties would be useful. It doesn't make much sense to be completely unable to render citations that are valid on WD itself and renderable on other projects. And another negative side effect of this approach is that if anyone adds such an unsupported property on WD side later, unaware of the limitations of this module, it will introduce an unintentional error here, that is out of control of the original author, who inserted a (then working) citation. That's definitely not nice behavior. --Teslaton (talk) 18:41, 24 November 2024 (UTC)
- Hello, sorry for the late reply.
- As for adding P5017, it is of course possible. Which Cite-web parameter should it be mapped to? Should it override publication date?
- Note that wikidata:Help:sources does not mention this property at all, which, in itself, is not a problem. I am mentioning the Wikidata page because it is worth noting that references on Wikidata aren't really standardized. That page is, at least in my knowledge, the only one to say something about formatting references, yet it seems to be far from complete.
- Unfortunately, there is no simple way to fix the citation-rendering function to just ignore unknown properties – outputting an error on failure is an inherent property of the (very simple) algorithm, as long as we want it to always produce understandable results. For example, an exteral id property (together with a "stated in" property) is sufficient to generate a Cite-web citation. However, this combination is also sufficient to create a Cite-Q citation. How should the module decide which citation template to use?
- The original algorithm solved this problem by not using a citation template if the Wikidata reference contained any properties not mapped to its parameters. If neither of the templates could be used, a fallback citation was generated. However, this fallback was removed (almost two years ago), because it was dissimilar to existing citation styles and sometime quite human-unfriendly.
- This is a very conservative solution – it rarely produces gibberish citations (e.g. leaving out information essential to the reference), but always fails on atypical Wikidata citations.
- If you have ideas for a better algorithm, please share your ideas.
- PS: After finishing writing this reply, I got an idea: maybe a good solution would be to ignore properties that are unknown to both of the citation templates (and issue an invisible error when encountering them). I will think about it.
- – Janhrach (talk) 19:08, 5 December 2024 (UTC)
- Test: [1] Janhrach (talk) 20:27, 20 December 2024 (UTC)
Gentlemen, please, any thought on this? --Teslaton (talk) 13:16, 2 December 2024 (UTC)
References
- ^ Hustota obyvateľstva - obce [om7014rr] : Rozloha (Štvorcový meter) (in Slovak), Bratislava: Statistical Office of the Slovak Republic, 28 March 2024, Wikidata Q125653048, retrieved 24 April 2024
Capitalisation
[edit]Hi, Is there a way to change the capitalisation of results? I am trying to call Wikidata to provide the description on Wikipedia articles but Wikidata says descriptions should not be capitalised, while Wikipedia English needs capitalisation. Is there a way to capitalise the first letter of the resulting string? Thanks! Julius Schwarz (talk) 14:16, 9 December 2024 (UTC)
- Help:Magic words § ucfirst
- —Trappist the monk (talk) 14:30, 9 December 2024 (UTC)
- I am so bookmarking this. Thanks a lot! Julius Schwarz (talk) 15:22, 9 December 2024 (UTC)