You can find the on-wiki version here: https://www.wikifunctions.org/wiki/Wikifunctions:Status_updates/2024-03-07 -- Introducing our second new type: Natural numbers
When Wikifunctions was made publicly available last year, we supported only two types: Strings https://www.wikifunctions.org/view/en/Z6 and Booleans https://www.wikifunctions.org/view/en/Z40. In January, we introduced Lists https://meta.wikimedia.org/wiki/Abstract_Wikipedia/Updates/2024-01-03.
We are happy to announce that the second new type is now available for use by the community: the long-awaited Natural numbers https://www.wikifunctions.org/view/en/Z13518.
What is a natural number https://en.wikipedia.org/wiki/Natural_number? A natural number is what you would usually use to count things. For Wikifunctions, we define this as whole numbers starting with zero and continuing with one, two, three, and so on. No upper limit is defined (but please don’t try to smash the servers trying to find it). We presented a proposal last week https://www.wikifunctions.org/wiki/Wikifunctions:Status_updates/2024-02-28, and had some adjustments based on the community discussion.
What are natural numbers good for? Mainly for two things: for counting, and for arithmetics. Given the previously introduced lists, a very natural question is to ask for the length of a list (the same also for the length of a string). Natural numbers are made for that.
We do not yet support proper internationalization with types like natural numbers. We are currently working on renderers and parsers https://meta.wikimedia.org/wiki/Abstract_Wikipedia/Updates/2023-09-20, and will report here when they are available. We also do not support typed lists of natural numbers https://phabricator.wikimedia.org/T359233 yet.
We were very excited when the necessary technical features for natural numbers were deployed, which we discussed previously, and have now renamed type converters https://meta.wikimedia.org/wiki/Abstract_Wikipedia/Updates/2023-09-27. We then created the natural number type https://www.wikifunctions.org/view/en/Z13518 and the necessary type converters just before Monday’s Volunteer’s Corner, and then went ahead without testing, due to time constraints, into the Volunteer’s Corner to create the first function. We first aimed for addition https://www.wikifunctions.org/view/en/Z13521, but then we realized that in order to write the tests, we first needed equality https://www.wikifunctions.org/view/en/Z13522. We started creating both, but the tests for equality failed.
In the recording for the Volunteers’ Corner, available on Commons https://www.wikifunctions.org/wiki/File:Abstract_Wikipedia_Volunteer_Corner_2024-03.webm, you can watch us try to debug together live what is going on, but we had to stop before achieving our goal. The next day, we fixed the configuration issue, and so on Tuesday the type went live. Since then, more than eighty new functions using natural numbers have been created!
We are excited about the new type, and are looking forward to seeing how the community will use it! Recent Changes in the software
Alongside our visible work to enable Natural number as the first user-controlled Type, discussed above, which included enabling type converters on the back-end services, we've made some more progress on the front-end user experience of custom Types, which will be coming soon.
As well as the priority work, this week we have also fixed a pair of user experience tweaks. We've simplified the header on each Object page to drop the type from the main heading as it's repeated in the sub-heading (T357807 https://phabricator.wikimedia.org/T357807), and the warning message that you can't use a function because it has no implementations now won't show up before you've selected a function (T357807 https://phabricator.wikimedia.org/T346852). Wiki Mentor Africa: Presentation and tutorial of Wikifunctions
Over the weekend we gave a presentation and tutorial during the Wiki Mentor Africa https://www.wikidata.org/wiki/Wikidata:Wiki_Mentor_Africa program. More than 120 people attended the presentation on Saturday, and on Sunday Hogü gave a hands-on tutorial on how to translate labels on Wikifunctions into different languages. We thank Benedict for organizing the event, Hogü for the tutorial, and everyone for attending. Recordings will be available soon. Function of the Week: is decimal natural number string of Arabic numerals (Z13489)
Last week we presented the proposal for natural numbers, which is now implemented. It included a proposal for the validator, and in preparation for the type and in response to the proposal, a function to check whether a string is a decimal natural number string of Arabic numerals https://www.wikifunctions.org/view/en/Z13489 was created.
This is used to check the value for how natural numbers are represented internally. It currently has three implementations:
- The first is a composition https://www.wikifunctions.org/view/en/Z13499 using a function that checks that all conditions are true https://www.wikifunctions.org/view/en/Z12684, and having three conditions: the string is not https://www.wikifunctions.org/view/en/Z10216 empty https://www.wikifunctions.org/view/en/Z10008, it only has characters from https://www.wikifunctions.org/view/en/Z11693 the set of digits https://www.wikifunctions.org/view/en/Z13501, and it either https://www.wikifunctions.org/view/en/Z10184 is https://www.wikifunctions.org/view/en/Z866 0 or does not https://www.wikifunctions.org/view/en/Z10216 start with https://www.wikifunctions.org/view/en/Z10615 0. This composition is a pretty straightforward translation of the specification as given in the type proposal https://www.wikifunctions.org/wiki/Wikifunctions:Type_proposals/Natural_number. It has the big advantage that I find it rather easy to read, but unfortunately it has the disadvantage that it times out frequently. - The second is a composition https://www.wikifunctions.org/view/en/Z13500 using a regular expression https://www.wikifunctions.org/view/en/Z10196. You can learn more about regular expressions on Wikipedia https://en.wikipedia.org/wiki/Regular_expression. - The third implementation is given in Python https://www.wikifunctions.org/view/en/Z13509, and translates the specification https://www.wikifunctions.org/wiki/Wikifunctions:Type_proposals/Natural_number to Python.
Surprisingly, there is no implementation in JavaScript yet.
One particular strength of this function is that it has a quite comprehensive set of tests. We can find eleven tests connected with the function, checking that 1 https://www.wikifunctions.org/view/en/Z13490 and 1234567890 https://www.wikifunctions.org/view/en/Z13491 both are valid, but 0987654321 https://www.wikifunctions.org/view/en/Z13492 is not (due to the leading zero), and yet ensuring that 0 https://www.wikifunctions.org/view/en/Z13493 itself is valid and not mixed up with a leading zero. It further checks a number of strings that look like a number from one point of view or another: the English word "nine https://www.wikifunctions.org/view/en/Z13494", "-1 https://www.wikifunctions.org/view/en/Z13495" (negative numbers are not allowed), the Arabic script number "١٥ https://www.wikifunctions.org/view/en/Z13496", Hexadecimal "FFFFFF https://www.wikifunctions.org/view/en/Z13497", "99,999 https://www.wikifunctions.org/view/en/Z13502" (with the comma), and "1.00 https://www.wikifunctions.org/view/en/Z13503" (with the radix dot) are all tested as invalid. Finally, one test ensures that the empty string https://www.wikifunctions.org/view/en/Z13498 is also invalid.
This set of tests is exemplary, and it is great to see the various implementations. This week’s Function of the Week is in many ways a great example of a function on Wikifunctions.
abstract-wikipedia@lists.wikimedia.org