The on-wiki version of this newsletter can be found here: https://www.wikifunctions.org/wiki/Wikifunctions:Status_updates/2024-05-15 -- Call for Functions: Spell out the number!
Natural numbers, like most things, have different words for them in different languages https://en.wikipedia.org/wiki/Numeral_(linguistics). A number such as 7 is called *‘seven’* in English, *‘sedam’* in Croatian, *‘ayɔpɔin’* in Dagbani, *‘asaa’* in Igbo, and so on. In many languages, names of larger numbers are often composed according to rules from smaller numbers. https://www.wikifunctions.org/wiki/File:Chiffre-babylonien-1000.svgThe number 1000 in Babylonian cuneiform.
For many numbers, Wikidata offers names. Either through lexemes such as L347774 https://www.wikidata.org/wiki/Lexeme:L347774, or on labels on the respective items, such as on Q23350 https://www.wikidata.org/wiki/Q23350.
In Wikifunctions, we already have a function to create names for the English cardinal numbers https://www.wikifunctions.org/view/en/Z13587. It is presented below as the Function of the Week.
For other languages, we don’t have that function yet. This is a call to the community to create such functions for the languages that you speak!
In order to help with kicking those off, we drafted a PAWS Notebook https://public-paws.wmcloud.org/User:Denny/numbers/numbers.ipynb to create a first draft of the function implementation in JavaScript, using the lexemes and labels in Wikidata for a given language. Feel free to ask Denny https://www.wikifunctions.org/wiki/User_talk:DVrandecic_(WMF) to run the function for your language.
Instead, you may also want to use one of the implementations of the English function below as a template and adapt it to your language.
One interesting source of inspiration for this might be Grammatical Framework’s solution for creating number names https://github.com/GrammaticalFramework/gf-contrib/tree/master/numerals, or any of the many https://github.com/marlun78/number-to-words libraries https://github.com/kwn/number-to-words doing the same thing.
Looking forward to seeing how this challenge develops! Let’s spell out the number! Recent Changes in the software
One of our big pieces of work this Quarter is supporting identity Types, like singular/plural or passive/active (T363390 https://phabricator.wikimedia.org/T363390). This week, we landed middle-ware and front-end support for identity keys in Types (T363405 https://phabricator.wikimedia.org/T363405 and T363497 https://phabricator.wikimedia.org/T363497); expect further movement on this soon!
The "About" dialog, where you can add and edit labels, short descriptions, and aliases, now updates the 'count' of available languages consistently with the publish state (T346031 https://phabricator.wikimedia.org/T346031). The information in the pop-up meta-data dialog is now rounded to 4 significant figures, rather than letting floating-point noise obscure the main information in *e.g.* how long a function call took to run.
We also landed some more minor fixes, including consolidating our front-end code to have only one method to determine if you're creating a new Object ( T358596 https://phabricator.wikimedia.org/T358596), and improving our browser tests to be more reliable and focussed on testing the main expected behaviour (T349836 https://phabricator.wikimedia.org/T349836). We added some logging when language look-up unexpectedly fails in the server-side code (T357702 https://phabricator.wikimedia.org/T357702), though we think this should now be fixed due to database content updates that landed last week.
We also updated our code-documentation generation to use the latest template, and tweaked our JavaScript code to align with Wikimedia-wide coding style updates, using defineComponent() for making Vue components clearer to linters, and avoiding the unnecessary jQuery's $.extend() in favour of Object.assign(). Function of the Week: English cardinals
English cardinals (Z13587 https://www.wikifunctions.org/view/en/Z13587) is a function that, given a natural number, provides the name of the number in English. Looking at the tests, we can find the following examples:
- 42 is https://www.wikifunctions.org/view/en/Z13589 *forty-two* - 0 is https://www.wikifunctions.org/view/en/Z13590 *zero* - 101 is https://www.wikifunctions.org/view/en/Z13591 *one hundred and one* - 777777777777 is https://www.wikifunctions.org/view/en/Z13592 *seven hundred and seventy-seven billion seven hundred and seventy-seven million seven hundred and seventy-seven thousand seven hundred and seventy-seven* - 12 is https://www.wikifunctions.org/view/en/Z13593 *twelve* - 777777777777777777777777777777777777777777777777 is https://www.wikifunctions.org/view/en/Z13594 *seven hundred and seventy-seven quattuordecillion seven hundred and seventy-seven tredecillion seven hundred and seventy-seven duodecillion seven hundred and seventy-seven undecillion seven hundred and seventy-seven decillion seven hundred and seventy-seven nonillion seven hundred and seventy-seven octillion seven hundred and seventy-seven septillion seven hundred and seventy-seven sextillion seven hundred and seventy-seven quintillion seven hundred and seventy-seven quadrillion seven hundred and seventy-seven trillion seven hundred and seventy-seven billion seven hundred and seventy-seven million seven hundred and seventy-seven thousand seven hundred and seventy-seven* - report an overflow error https://www.wikifunctions.org/view/en/Z13595 for a number with more than 48 digits
The last should throw a proper error, not just a string that says error. We need to work on this.
There are two implementations for this function, one in Python https://www.wikifunctions.org/view/en/Z13588 and one in JavaScript https://www.wikifunctions.org/view/en/Z15955, both having a few dozen lines of code and quite a bit more complex than most of the Functions of the Week we have looked at so far. They may be used as templates for implementations for other natural languages, supporting the Call for Functions going out this week!
abstract-wikipedia@lists.wikimedia.org