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.svg>The
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!
The on-wiki version of this newsletter can be found here:
https://www.wikifunctions.org/wiki/Wikifunctions:Status_updates/2024-05-10
--
Flagship type for enumerations: Months of the Gregorian calendar
<https://www.wikifunctions.org/wiki/File:Plates_of_the_Twelve_Lunar_Months_L…>*Plates
of the Twelve Lunar Months, Ogata Kenzan (Japan, 1663-1743)*
As we announced last week
<https://www.wikifunctions.org/wiki/Wikifunctions:Status_updates/2024-05-03>,
our work for this quarter includes developing type support for enumerations
<https://phabricator.wikimedia.org/T363390>. An enumeration is a type
consisting of a set of named instances. Unlike open types such as natural
number <https://www.wikifunctions.org/view/en/Z13518> or string
<https://www.wikifunctions.org/view/en/Z6>, which can be created on the fly
and can have an arbitrary number of instances, an enumeration must have all
its instances predefined. In Wikifunctions, all instances of an enumeration
must have distinct ZIDs and are distinct objects.
We already have a few types which could be regarded as enumerations, such
as Booleans <https://www.wikifunctions.org/view/en/Z40> (with the two
values true <https://www.wikifunctions.org/view/en/Z41> and false
<https://www.wikifunctions.org/view/en/Z42>) and natural languages
<https://www.wikifunctions.org/view/en/Z60> (with currently hundreds of
values). We will want many more enumerations in Wikifunctions, be it for
the sign of a number, weekdays, cardinal directions, and much more. For
natural language generation, we will need it to represent grammatical
features, such as grammatical number, which we need for the function we
worked together on in this week’s Volunteers’ Corner (see below).
Just like last quarter with natural numbers
<https://www.wikifunctions.org/view/en/Z13518>, we chose a flagship type to
go as the first new enumeration type: months of the Gregorian calendar
<https://www.wikifunctions.org/wiki/Wikifunctions:Type_proposals/Gregorian_c…>.
The community is invited to join the discussion of the specification:
should this also encompass the Julian calendar? Is there a good name for a
single type that covers both? What other considerations are there?
We would also like to ask the community to prepare and discuss similar
enumerations for other calendar systems, so that, once this type works, we
can move swiftly to create them in order to have parity across the world's
calendar systems.
Abstract Wikipedia at the Hackathon
Our tech lead, James
<https://www.wikifunctions.org/wiki/User:Jdforrester_(WMF)>, attended the
annual Wikimedia Hackathon
<https://www.mediawiki.org/wiki/Wikimedia_Hackathon_2024> as a volunteer
last weekend, which took place in Tallinn, Estonia. He was glad to meet
several existing Wikifunctions community members, and help explain the
Wikifunctions and Abstract Wikipedia visions. There were extensive
discussions about linguistic variations and how our community might hope to
model them in forthcoming language generation functions. It was his
pleasure to assist someone making their very first function, even though
technical issues meant it didn't work at first. He and the rest of the team
looks forward to speaking with more people about Wikifunctions.
Recent Changes in the software
Over the past two weeks, we've focused on the areas we laid out last week –
Identity support on Types, production observability improvements,
multi-language interface design improvements, research for the future
Wikipedia integration, and much more.
Beyond that work, we've made a few minor improvements that some of you may
notice. We adjusted the front-end to batch requests for objects, grabbing
at most 50 items at once, rather than unlimited; though in practice we've
not hit this yet, in the future as community-written functions get more
complex, this would have been reached and caused odd breakages in the
front-end (T359035 <https://phabricator.wikimedia.org/T359035>). We fixed a
missed piece of internationalisation in the aria-label of the Toggle
button, for screen readers and other assistive devices (T362056
<https://phabricator.wikimedia.org/T362056>).
We consolidated our duplicate maintenance scripts for managing pre-defined
Objects, merging reloadBuiltinData into loadPreDefinedObject. We added the
last remaining feature from the internal ApiQueryZObjects Action API to the
new Fetch REST API, which will allow us to migrate to these cheaper, faster
calls in future (T274269 <https://phabricator.wikimedia.org/T274269>).
All Wikimedia-deployed code is using the latest version of the Codex UX
library, v1.5.0, as of this week. Though we do not believe the library
upgrade will have any user-visible changes in our use on Wikifunctions,
please comment on the Project chat
<https://www.wikifunctions.org/wiki/Wikifunctions:Project_chat> or
file a Phabricator
task <https://phabricator.wikimedia.org/project/view/4876/> if you spot an
issue.
Volunteers' Corner on May 6th
We met with some of our wonderful Wikifunctions volunteers on Monday. We
discussed our work for this quarter in more detail and built a function
together for language-specific numerical singulars and plurals
<https://www.wikifunctions.org/view/en/Z15982>. The recording of the event
is available on Wikimedia Commons
<https://commons.wikimedia.org/wiki/File:Abstract_Wikipedia_Volunteer_Corner…>
.
Function of the Week: Binomial Coefficient (Z13848)
Binomial coefficients
<https://en.wikipedia.org/wiki/Binomial_coefficient> represent
the number of ways you can choose a certain number of items from a larger
set, regardless of the order. They're often represented as "n choose k",
where n is the total number of items and k is the number of items to choose.
<https://www.wikifunctions.org/wiki/File:Wikifunctions_binomial_function_res…>
For example, imagine we have five beads of different colors (Red, Blue,
Green, Yellow, Orange), and we want to randomly choose two beads from them
at a time. The binomial coefficient "5 choose 2" would tell us how many
different pairs of beads we can make. In this case, it would be 10 pairs:
1. Red and Blue
2. Red and Green
3. Red and Yellow
4. Red and Orange
5. Blue and Green
6. Blue and Yellow
7. Blue and Orange
8. Green and Yellow
9. Green and Orange
10. Yellow and Orange
So, binomial coefficients help you figure out how many combinations you can
make from a set of items. The image shows our function returning a result
of 10 for “5 choose 2” <https://www.wikifunctions.org/view/en/Z13848>.
Mathematically speaking, the binomial coefficient, often denoted as (nk),
represents the number of ways to choose k items from a set of n distinct
items, without considering their order. It's calculated using the formula:
(nk) = n!/(n-k)!
Where n! (read as "n factorial") denotes the product of all positive
integers up to n, and k! is the factorial of k, and so on. We have a function
for the factorial <https://www.wikifunctions.org/view/en/Z13667>, too,
which is used in one of the compositions
<https://www.wikifunctions.org/view/en/Z13907>.
The binomial coefficient function on Wikifunctions has 4 implementations –
2 compositions, and 2 implementations in Python :
- binomial composition via factorial
<https://www.wikifunctions.org/view/en/Z13907>, as just mentioned
- binomial coefficient, python
<https://www.wikifunctions.org/view/en/Z13850>, looping for a factorial
- binomial recursive composition
<https://www.wikifunctions.org/view/en/Z13912>
- binomial coefficient, python
<https://www.wikifunctions.org/view/en/Z14852> (using math.comb from the
standard library)
Binomial coefficients find their practical uses in probability predictions,
to find the chance of getting a specific number of successes in a series of
trials with only two possible outcomes or the likelihood of winning the
lottery, or combinatorics , to count different ways to arrange or choose
things, like distributing items into groups or selecting members for a
committee.
The on-wiki version of this newsletter can be found here:
https://www.wikifunctions.org/wiki/Wikifunctions:Status_updates/2024-05-03
--
Team meeting in San Francisco
<https://www.wikifunctions.org/wiki/File:Maiden_Lane,_San_Francisco_-_View_f…>Maiden
Lane, San Francisco, view from near the office
Last week saw our annual team meeting, and this time we gathered for the
first and last time in the current office space of the Wikimedia Foundation
in San Francisco. Some of us met for the first time, and we used the
meeting to get to know each other, and to sketch out our plans for upcoming
work on Abstract Wikipedia and Wikifunctions.
We improved our shared understanding of the project and how we work
together, and one of the results is our plan for this quarter, which we
present below.
We also had interesting discussions around how Abstract Wikipedia could
look like in the future. We want to capture some of the thoughts from that
session in more detail in an upcoming update, as it opens many questions
for how Abstract Wikipedia can flourish and grow as a project that is
rooted and anchored in the work of our contributors.
It was a bittersweet opportunity for the team to see the current office, as
the Wikimedia Foundation will move to a smaller office space
<https://meta.wikimedia.org/wiki/Wikimedia_Foundation_Annual_Plan/2024-2025/…>
in
the fall as our lease ends.
Quarterly planning
One of the results of the meeting was to establish a plan for the current
quarter. Here is a quick overview of the main tasks we will be working on:
- *Visual prototype for Wikipedia integration
<https://phabricator.wikimedia.org/T363392>*: based on our ongoing
research, what could designs for the integration of Wikifunctions into
Wikipedia look like? This will also be used to improve cross-functional
collaboration and to identify next steps towards building Abstract
Wikipedia.
- *Type support for identity / enumeration
<https://phabricator.wikimedia.org/T363390>*: supporting types that have
a specific set of values, such as grammatical number in English (plural,
singular), cases in Russian (nominative, dative, etc.), signs for integers
(positive, negative, and neutral), or months in the year (January,
February, etc.). This should allow us to create all types that are
necessary to access lexicographic data in Wikidata, which would come next.
- *Improve production monitoring
<https://phabricator.wikimedia.org/T363387>*: so we have an easier time
understanding when something goes wrong, or where the time in orchestration
and evaluation is going. This will also inform future work on caching,
which is critical for integration into Wikipedia.
- *Improve integration with MediaWiki core tests and other test support
<https://phabricator.wikimedia.org/T363389>*: changes to core are
currently not automatically tested against the WikiLambda extension. We
will work on changing that.
- *Demos in a box <https://phabricator.wikimedia.org/T363394>*: provide
resources that help community members to give presentations about
Wikifunctions and Abstract Wikipedia.
- *Wikifunctions’s UX drives user behavior to increase linguistic
accessibility <https://phabricator.wikimedia.org/T363383>*: changes to
the UX that make it easier for users to provide missing translations and a
better experience in other languages than English.
- *DB table for expanded metrics support
<https://phabricator.wikimedia.org/T363439>*: allow for collecting more
metrics about Wikifunctions.
- *Help users debugging implementations by providing more metadata
<https://phabricator.wikimedia.org/T363384>*: function calls are
currently a bit of a black box. We want to provide some more insight into
what is going on inside a function call, and this might help contributors
fix issues more easily.
An overview of this quarter’s work can be seen in a brand new Phabricator
board <https://phabricator.wikimedia.org/project/board/7067/>. All the
tasks listed above are represented in the column “Epics for this quarter”.
Recent Changes in the software and Function of the Week
Because this newsletter is already so long, and due to the team meeting and
the Hackathon, we are skipping these sections this week.
Volunteers’ corner on May 6
On Monday, May 6, 2024, we are going to have our Volunteers’ corner at
17:30 UTC <https://zonestamp.toolforge.org/1715016600>. Bring questions and
curiosity! We will give an overview of recent changes, ongoing work, have
ample opportunities to answer questions and discuss concerns by the
community, and if there’s time, also work collaboratively on a function.
Abstract Wikipedia team at the Wikimedia Hackathon in Tallinn
This weekend sees the Wikimedia Hackathon 2024
<https://www.mediawiki.org/wiki/Wikimedia_Hackathon_2024> in Tallinn,
Estonia. James Forrester of the Abstract Wikipedia team will be there and
if you want to discuss anything about Wikifunctions or Abstract Wikipedia,
feel free to approach him. (Also, he’s an awesome fellow to chat with even
if you don’t.)