[Wikidata-bugs] [Maniphest] [Commented On] T182147: more convenience functions for Lua

2019-10-02 Thread Thayts
Thayts added a comment.


  It would be convenient if there were a function or variable to get the 
current wiki's site ID from, something like "`mw.site.siteId`".
  
  On Wikipedia, I'm now trying to determine the site ID as follows, which is 
not a 100% reliable way:
  
  `siteId = (function() for i,v in pairs(mw.site.interwikiMap("local")) do if 
v.isCurrentWiki and i~="w" then return mw.ustring.gsub(i,"-","_").."wiki" end 
end end)()`
  
  I need this in order to get the badges of the article on the current wiki 
from the attached Wikidata entity object:
  
  `entity.sitelinks[siteId].badges`

TASK DETAIL
  https://phabricator.wikimedia.org/T182147

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Thayts
Cc: Thayts, Simon_Villeneuve, Pigsonthewing, Lea_Lacroix_WMDE, jberkel, 
RolandUnger, Agabi10, RexxS, Vriullop, MisterSynergy, Ghuron, Uzume, putnik, 
Jonas, aude, hoo, Ladsgroup, Tpt, thiemowmde, eranroz, Aklapper, 
Lydia_Pintscher, darthmon_wmde, DannyS712, Nandana, Lahi, Gq86, 
GoranSMilovanovic, QZanden, LawExplorer, _jensen, rosalieper, Wikidata-bugs, 
Mbch331
___
Wikidata-bugs mailing list
Wikidata-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs


[Wikidata-bugs] [Maniphest] [Commented On] T182147: more convenience functions for Lua

2018-03-27 Thread eranroz
eranroz added a comment.

In T182147#4083789, @NehalDaveND wrote:
Sanskrit community wants counting in Devanagari digit, but we can't get the support till now. I think by Lua you can add the facility into Sanskrit wikis.

https://sa.wikipedia.org/wiki/%E0%A4%B5%E0%A4%BF%E0%A4%95%E0%A4%BF%E0%A4%AA%E0%A5%80%E0%A4%A1%E0%A4%BF%E0%A4%AF%E0%A4%BE:%E0%A4%B8%E0%A4%AE%E0%A5%81%E0%A4%A6%E0%A4%BE%E0%A4%AF%E0%A4%AA%E0%A5%8D%E0%A4%B0%E0%A4%B5%E0%A5%87%E0%A4%B6%E0%A4%A6%E0%A5%8D%E0%A4%B5%E0%A4%BE%E0%A4%B0%E0%A4%AE%E0%A5%8D#%E0%A4%A6%E0%A5%87%E0%A4%B5%E0%A4%A8%E0%A4%BE%E0%A4%97%E0%A4%B0%E0%A5%80-%E0%A4%85%E0%A4%99%E0%A5%8D%E0%A4%95%E0%A4%AE%E0%A5%8D_%E0%A4%89%E0%A4%A4%E0%A5%8D%E0%A4%B8%E0%A4%B0%E0%A5%8D%E0%A4%97%E0%A4%A4%E0%A5%8D%E0%A4%B5%E0%A5%87%E0%A4%A8_%E0%A4%B8%E0%A5%8D%E0%A4%A5%E0%A4%BE%E0%A4%AA%E0%A4%AF%E0%A4%BF%E0%A4%A4%E0%A5%81%E0%A4%AE%E0%A5%8D


@NehalDaveND Can you please clarify how it relates to Wikidata?TASK DETAILhttps://phabricator.wikimedia.org/T182147EMAIL PREFERENCEShttps://phabricator.wikimedia.org/settings/panel/emailpreferences/To: eranrozCc: NehalDaveND, Lea_Lacroix_WMDE, jberkel, RolandUnger, Agabi10, RexxS, Vriullop, MisterSynergy, Ghuron, Uzume, putnik, Jonas, aude, hoo, Ladsgroup, Tpt, thiemowmde, eranroz, Aklapper, Lydia_Pintscher, Lahi, Gq86, GoranSMilovanovic, QZanden, LawExplorer, Wikidata-bugs, Mbch331___
Wikidata-bugs mailing list
Wikidata-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs


[Wikidata-bugs] [Maniphest] [Commented On] T182147: more convenience functions for Lua

2018-03-27 Thread NehalDaveND
NehalDaveND added a comment.
Sanskrit community wants counting in Devanagari digit, but we can't get the support till now. I think by Lua you can add the facility into Sanskrit wikis.

https://sa.wikipedia.org/wiki/%E0%A4%B5%E0%A4%BF%E0%A4%95%E0%A4%BF%E0%A4%AA%E0%A5%80%E0%A4%A1%E0%A4%BF%E0%A4%AF%E0%A4%BE:%E0%A4%B8%E0%A4%AE%E0%A5%81%E0%A4%A6%E0%A4%BE%E0%A4%AF%E0%A4%AA%E0%A5%8D%E0%A4%B0%E0%A4%B5%E0%A5%87%E0%A4%B6%E0%A4%A6%E0%A5%8D%E0%A4%B5%E0%A4%BE%E0%A4%B0%E0%A4%AE%E0%A5%8D#%E0%A4%A6%E0%A5%87%E0%A4%B5%E0%A4%A8%E0%A4%BE%E0%A4%97%E0%A4%B0%E0%A5%80-%E0%A4%85%E0%A4%99%E0%A5%8D%E0%A4%95%E0%A4%AE%E0%A5%8D_%E0%A4%89%E0%A4%A4%E0%A5%8D%E0%A4%B8%E0%A4%B0%E0%A5%8D%E0%A4%97%E0%A4%A4%E0%A5%8D%E0%A4%B5%E0%A5%87%E0%A4%A8_%E0%A4%B8%E0%A5%8D%E0%A4%A5%E0%A4%BE%E0%A4%AA%E0%A4%AF%E0%A4%BF%E0%A4%A4%E0%A5%81%E0%A4%AE%E0%A5%8DTASK DETAILhttps://phabricator.wikimedia.org/T182147EMAIL PREFERENCEShttps://phabricator.wikimedia.org/settings/panel/emailpreferences/To: NehalDaveNDCc: NehalDaveND, Lea_Lacroix_WMDE, jberkel, RolandUnger, Agabi10, RexxS, Vriullop, MisterSynergy, Ghuron, Uzume, putnik, Jonas, aude, hoo, Ladsgroup, Tpt, thiemowmde, eranroz, Aklapper, Lydia_Pintscher, Lahi, Gq86, GoranSMilovanovic, QZanden, LawExplorer, Wikidata-bugs, Mbch331___
Wikidata-bugs mailing list
Wikidata-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs


[Wikidata-bugs] [Maniphest] [Commented On] T182147: more convenience functions for Lua

2018-03-27 Thread Lea_Lacroix_WMDE
Lea_Lacroix_WMDE added a comment.
FYI, we started a feedback round on this page. All editors are welcome to give more information about the modules they use or improve, and what functions could be useful for them.TASK DETAILhttps://phabricator.wikimedia.org/T182147EMAIL PREFERENCEShttps://phabricator.wikimedia.org/settings/panel/emailpreferences/To: Lea_Lacroix_WMDECc: Lea_Lacroix_WMDE, jberkel, RolandUnger, Agabi10, RexxS, Vriullop, MisterSynergy, Ghuron, Uzume, putnik, Jonas, aude, hoo, Ladsgroup, Tpt, thiemowmde, eranroz, Aklapper, Lydia_Pintscher, Lahi, Gq86, GoranSMilovanovic, QZanden, LawExplorer, Wikidata-bugs, Mbch331___
Wikidata-bugs mailing list
Wikidata-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs


[Wikidata-bugs] [Maniphest] [Commented On] T182147: more convenience functions for Lua

2018-03-15 Thread Agabi10
Agabi10 added a comment.
At eswiki we mostly use it for the infoboxes and there are some things we have to do in many infoboxes that could be useful for others too:


Get the value of the qualifier of a known specific value for a property: For example, when we want to get the title in Spain for a given film, we need the value of the title qualifier for the claim has quality -> title for Spain (entity['claims']['P1552'] -> check if any of them has the value Q27847754 -> ['qualifiers']['P1476'][1])



Get the value of a property with a given qualifier and value: For example, when we want to display the different crew members that don't have their own property in Wikidata. If we want to display the art director we have to loop through all the film crew members and check who of them (if any) has a role of art director.



An easy way to sort the claims by label in a given language (for alphabetically sorted lists), by qualifier value (for dates or numeric values).



A way to get the most recent value for a property (like for the population of the cities and towns). Usually it should be set as preferred, and sorting these claims by date at Wikidata to make setting the most recent as preferred easier would work too.
TASK DETAILhttps://phabricator.wikimedia.org/T182147EMAIL PREFERENCEShttps://phabricator.wikimedia.org/settings/panel/emailpreferences/To: Agabi10Cc: RolandUnger, Agabi10, RexxS, Vriullop, MisterSynergy, Ghuron, Uzume, putnik, Jonas, aude, hoo, Ladsgroup, Tpt, thiemowmde, eranroz, Aklapper, Lydia_Pintscher, Lahi, Gq86, GoranSMilovanovic, QZanden, LawExplorer, Wikidata-bugs, Mbch331___
Wikidata-bugs mailing list
Wikidata-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs


[Wikidata-bugs] [Maniphest] [Commented On] T182147: more convenience functions for Lua

2018-03-06 Thread RexxS
RexxS added a comment.
The reason why different projects develop different modules is that different communities have different demands. Working on the English Wikipedia has led me to alter the original line of coding that I developed early on.

I think it's important to examine the demand for functionality in order to determine which functions would be most valuable. On en-wp there is already an acceptance that any locally supplied value must override whatever may exist on Wikidata. That may be easiest to code within a module. There is also consensus that Wikidata may be used within infoboxes, but not elsewhere (with minor exceptions). See https://en.wikipedia.org/wiki/Wikipedia:Requests_for_comment/Wikidata_Phase_2

Beyond that, the two demands that are strongest are that information pulled from Wikidata must be sourced (not just "Imported from xyz Wikipedia), and that the use of Wikidata on any article must be able to be determined on an article-by-article basis - in other words, the fetching of Wikidata into an infobox has be enabled by a conscious decision on each article. See https://en.wikipedia.org/wiki/Wikipedia:Village_pump_(policy)/Archive_128#RfC:_Wikidata_in_infoboxes,_opt-in_or_opt-out? and https://en.wikipedia.org/wiki/Template_talk:Infobox_book/Archive_8

The code to implement a whitelist (a flexible way to create "opt-in" infoboxes) is probably best left to the module.

There is code to meet those requirements in https://en.wikipedia.org/wiki/Module:WikidataIB but it would be valuable to have "smart" utility functions to encapsulate some of the common jobs such as returning a table of formatted wikitext, (taking into account links to redirects (should be linked) and dab pages (should not be linked)), as well as handling all date values according to precision and era, ranges of quantities, etc. In each case, the default needs to be to return only properly sourced values (with the option to return all values by setting a parameter).

It would also be appreciated if a similar generalised function could retrieve values that are stored on Wikidata as values of a given qualifier i.e. value of property1 -> qualifier -> property2 as there is little consistency on how properties are stored.

Similarly, there is a demand for a function that scans a property prop1 in the current page (or another page if qid is given) and for each value of the property that is a wikibase item, it fetches all of the values of prop2; then for each value of prop2 it retrieves each qualifier and its returns its value. That's potentially a hugely expensive function as it has to load multiple entities not directly associated with the current page using arbitrary access. There's some code to do that at the getValueQualIndirect function in https://en.wikipedia.org/wiki/Module:RexxS but I'm loathe to make it more generally available unless the overhead can be significantly reduced. Something for thought by the developers.TASK DETAILhttps://phabricator.wikimedia.org/T182147EMAIL PREFERENCEShttps://phabricator.wikimedia.org/settings/panel/emailpreferences/To: RexxSCc: RexxS, Vriullop, MisterSynergy, Ghuron, Uzume, putnik, Jonas, aude, hoo, Ladsgroup, Tpt, thiemowmde, eranroz, Aklapper, Lydia_Pintscher, Lahi, Gq86, GoranSMilovanovic, QZanden, LawExplorer, Wikidata-bugs, Mbch331___
Wikidata-bugs mailing list
Wikidata-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs


[Wikidata-bugs] [Maniphest] [Commented On] T182147: more convenience functions for Lua

2018-03-04 Thread Vriullop
Vriullop added a comment.
I miss functions dealing with grammatical cases. For example an immediate query to https://www.wikidata.org/wiki/Q37459 returns Nicole Kidman is an actor. Two more queries are necessary to fetch property 21 (sex or gender) and property 2521 (female form of label) from the corresponding item to reach the correct label as "actress". Since it is a common need, not resolved in many of the local Lua modules, it would be nice to solve it directly in a single query.TASK DETAILhttps://phabricator.wikimedia.org/T182147EMAIL PREFERENCEShttps://phabricator.wikimedia.org/settings/panel/emailpreferences/To: VriullopCc: Vriullop, MisterSynergy, Ghuron, Uzume, putnik, Jonas, aude, hoo, Ladsgroup, Tpt, thiemowmde, eranroz, Aklapper, Lydia_Pintscher, Lahi, Gq86, GoranSMilovanovic, QZanden, LawExplorer, Wikidata-bugs, Mbch331___
Wikidata-bugs mailing list
Wikidata-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs


[Wikidata-bugs] [Maniphest] [Commented On] T182147: more convenience functions for Lua

2018-01-14 Thread Uzume
Uzume added a comment.

In T182147#3815415, @thiemowmde wrote:

A boolean entityExists (T143970).
Use case: Currently, I see a lot of code that does if getEntity( … ) then, which is super-expensive for no reason. The cheapest workaround that currently exists is getEntityUrl, but thats awkward to use in an if.




I actually like this idea but it should be noted that it currently does not actually work as getEntityUrl(eid) will happily return URLs for invalid entities. It could perhaps be changed to support such by checking if the entity actually exists and returning nil when it does not.

I do find it ironic that I can use getAllStatements(eid, pid) to get various claims on multiple entities without incurring an "expensive" hit but I get an "expensive" hit if I want to check if the same set of entities actually exist or not because I currently have to use getEntity(eid) (not to mention the resulting error message is hard to machine process).

The issues with more claim filtering and/or the "parent" cases mentioned above seem more applicable to a more generalized query interface as such things are actually quite simple to specify with SPARQL.

Currently without pulling the entire entity object with getEntity, we have some filtered access to the following: labels, descriptions, claims, and sitelinks. It should be noted there currently is no way to obtain any aliases data whatsoever without pulling the entire entity object.

In terms of wishlists, I would like to see something along the lines of a getProperties(eid) that lets me get a list of available property claims on an entity without having to pull the entity object with code like pids = getEntity(eid):getProperties(). An it would be cool if I could then send the same list through orderProperties(pids).

In short, my current wishlist items are:


entity exists functionality without getEntity and the error it yields
property list functionality without getEntity (ala getProperties)
language filtered aliases access functionality without getEntity (ala getLabelWithLang and getLabelByLang)
a getDescriptionByLang  to align with getLabelByLang
TASK DETAILhttps://phabricator.wikimedia.org/T182147EMAIL PREFERENCEShttps://phabricator.wikimedia.org/settings/panel/emailpreferences/To: UzumeCc: Uzume, putnik, Jonas, aude, hoo, Ladsgroup, Tpt, thiemowmde, eranroz, Aklapper, Lydia_Pintscher, Lahi, Gq86, GoranSMilovanovic, QZanden, LawExplorer, Wikidata-bugs, Mbch331___
Wikidata-bugs mailing list
Wikidata-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs