Wikidata:Lua enhancements

From Wikidata
Jump to navigation Jump to search
Let's enhance the Lua bindings for Wikidata!

Lua scripting for the Wikibase Client has been around for a while. Even with the limited functionality the original bindings to to Wikidata expose to Lua, people have been able to make good use of it:

Now we want to take Lua bindings to the next level. We would like to hear from you which functions or object representations would make Wikidata Lua scripting for templates more enjoyable to use for you.

If you have an idea for a Lua-related enhancement please list it below, using the format shown below. If it is already mentioned please add your signature. The developers will go through them and try to prioritize accordingly.

Allow mw.wikibase.getEntity to access arbitrary Wikidata items[edit]

Allow to use mw.wikibase.getEntity( item ) to get the content of the item item like in mw.wikibase.getEntity( 'Q234' )

I think this would be an enhancement
  1. Tpt (talk) 15:21, 8 November 2013 (UTC)
  2. HenkvD (talk) 18:48, 8 November 2013 (UTC)
  3. Legoktm (talk) 19:34, 8 November 2013 (UTC)
  4. --ValterVB (talk) 22:53, 8 November 2013 (UTC)
  5. -happy5214 06:03, 9 November 2013 (UTC)
  6. --Dega180 (talk) 12:01, 9 November 2013 (UTC)
  7. Micru (talk) 12:35, 9 November 2013 (UTC)
  8. Succu (talk) 14:14, 9 November 2013 (UTC)
  9. Lavallen (talk) 14:30, 9 November 2013 (UTC)
  10. Multichill (talk) 15:14, 9 November 2013 (UTC)
  11. Thieol (talk) 16:14, 9 November 2013 (UTC)
  12. TomT0m (talk) 15:37, 9 November 2013 (UTC)
  13. --Shlomo (talk) 22:25, 9 November 2013 (UTC)
  14. Ricordisamoa 00:28, 11 November 2013 (UTC)
  15. Paweł Ziemian (talk) 10:09, 11 November 2013 (UTC)
  16. Voll (talk) 20:32, 11 November 2013 (UTC)
  17. --Rotpunkt (talk) 16:38, 13 November 2013 (UTC)
  18. Albert Villanova del Moral (talk) 00:36, 28 December 2013 (UTC)

Add basic libraries to manipulate easily dates and coordinates[edit]

Add Lua objects that are the implentation of DataValue objects of the DataValue library. The goal is to have an interface to easily manipulate these complex objects with a nice level of abstraction. As example we may have a mw.dataValue.time module that provides a Time object and would have the interface:

  • mw.dataValue.time.newFromIso8601( dateTime ) create a new Time object from an ISO 8601 value
  • mw.dataValue.time.newFromDataValue( dataValue ) create a new Time object from a DataValue serialization as provided by the Wikibase API
  • mw.dataValue.time.equals( a, b ) check if two Time objects are equals
  • Time.year the year
  • ...
  • Time.precision the precision of the date as a mw.dataValue.time.PRECISION constant (the same as the DataValues ones)
  • Time.calendar the calendar of the date as a mw.dataValue.time.CALENDAR constant (the same as the DataValues ones)
  • Time:toIso8601() serialize the time to an ISO 8601 string (not a full ISO 8601 string as managed by DataValue but a short one ie 2013-03-03T12Z and not 2013-03-03T12:00:00.00000Z.
I think this would be an enhancement
  1. Tpt (talk) 15:21, 8 November 2013 (UTC)
  2. --UV (talk) 22:41, 8 November 2013 (UTC)
  3. Thieol (talk) 16:14, 9 November 2013 (UTC)
  4. TomT0m (talk) 15:38, 9 November 2013 (UTC)
  5. Ricordisamoa 00:29, 11 November 2013 (UTC)

Add WikidataQuery API in Lua[edit]

It would be interesting to have an API in Lua for doing the same queries as described in this page: [1], also with many limitations.

I think this would be an enhancement
  1. --Rotpunkt (talk) 16:47, 13 November 2013 (UTC)
This is unlikely to happen. While WikidataQuery is a fascinating and extremely useful experiment in querying database dumps of Wikidata, we will have a different way to create and store queries in Wikidata. Queries are a future feature that is currently being worked on. --Jens Ohlig (WMDE) (talk) 10:48, 10 December 2013 (UTC)

Strings with UTF-8 support in LUA[edit]

We need string functions supporting UTF-8 multi-byte encoding for substrings and regular expressions.

I think this would be an enhancement
  1. -- 22:16, 19 November 2013 (UTC)
    The mw.ustring library in Scribunto already provides this functionality. Besides, this isn't directly related to Wikidata. -happy5214 10:23, 20 November 2013 (UTC)
    Withdrawn. Only a function to remove accents and diacriticals from characters so as to make them better usable for sorting is currently missing from the library. -- 13:40, 25 November 2013 (UTC)
    Try: mw.ustring.gsub(mw.ustring.toNFD(input),'[^%w]+',"")) which removes accents, controls, interpunctuation, nonprintings, etc., so it is likely what one wants as starting point for most general sort keys. --Leeve Jong (talk) 00:13, 27 November 2013 (UTC)

get reverse properties[edit]

As well as getting an items claims could we also get the claims that have the current item as their object? Not just 'What items link here?' but 'What items link here using what properties?'. This would avoid the need to create inverse properties like 'has part' as well as 'part of'. I'm not a coder so I would be grateful to anyone who knows a bit more about this who could rephrase this in code terms.

I think this would be an enhancement
  1. Filceolaire (talk) 18:03, 25 November 2013 (UTC)
Again, this will probably be solved with queries. Queries are a future feature that is currently being worked on.--Jens Ohlig (WMDE) (talk) 10:50, 10 December 2013 (UTC)