Graceful overrides and fallbacks
We are currently looking at different Wikipedias' articles about years in order to test out Abstract Wikipedia's approach. These are highly structured articles that seem to fit the approach particularly well. One of the requirements for these is to provide headers for sections such as births, deaths, events, or Nobel prizes.
The community has created the function header from item in plural (Z28254), initially to be used in the header cells of a table, but it is also perfect for this kind of headers. Given a Wikidata item and a language, it looks for the lexeme connected to that item in the relevant language, and then takes the plural form.
This seems to work fine in many languages: in English, it returns "births", in Dagbani "N-dɔɣi", etc. In German it returns "Geburten", which in my opinion would also work, but the German Wikipedia articles about years seem to prefer the past participle "Geboren" instead of the plural noun.
We could now either change the function – and sometimes that's the right choice – or we could provide a hard-coded list of overrides. The function Births header text (Z31799) implements such a pattern: in implementation get from override, else use header from item (Z31802) it first takes a look in this multilingual text whether the given language is there, and only if not, it uses the function to get the right word. This pattern allows us to override what the function would otherwise create.
Another pattern is to provide a fallback: what if none of the available functions to generate the text work for a given language? Sentence that something begins (Z31405) creates a sentence that something has started. We introduced it a few weeks ago, falls back to default cross-lingual fragment that sth started (Z31406), which gets the label of the subject in the requested language and attaches an emoji, in this case 🚀.
Now, it is debatable whether that is a better solution than creating nothing, but it demonstrates a pattern where, in the case of missing functions, some placeholder is being created.
These two patterns, overrides and fallbacks, allow us to deal pragmatically with real-life scenarios when generating texts in many different languages.
Abstract Wikipedia will be launching soon, and we are excited to see what patterns you will be using when writing articles, and what the first articles will be that you will create.
Recent Changes in the software
This week, we improved how literal parameters are displayed in function calls. Previously, when adding a literal parameter, it would be shown in expanded form, even when there was a simple, usable collapsed form available (for example, for boolean true/false using a radio control instead of a drop-down). These will now show in their compact form from the start (T417749).
Nicolas Verignon talk at Celtic Knot 2025
Last year at Celtic Knot 2025, Nicolas Vigneron was presenting on Wikifunctions. A recording of the presentation is now available and can be watched on Commons. The talk starts at around Minute 53, and goes for about twenty minutes.
Thanks to Nicolas for the presentation and spreading the word!
Volunteer's Corner on March 2
The next Volunteers' Corner will be on Monday, 2 March 2026 at 18:30 UTC. We plan to have our usual agenda: there will be time to ask questions and discuss all matters arising, and, if we have time, write a function together. Everyone is welcome to join us on Google Meet.
Fresh Functions weekly: 16 new Functions
This week we had 16 new functions. Here is an incomplete list of functions with implementations and passing tests to get a taste of what functions have been created. Thanks everybody for contributing!
- apply two-argument function: validated arguments (Z31684)
- Wikipedia link for Wikidata item if available (Z31697)
- URL string of Wikidata sitelink (Z31703)
- Natural number as list of Booleans (Z31716)
- pad start of list (Z31721)
- Korean add (-i/-ga) to the end of a noun (Z31742)
- validated function call as quote (Z31754)
- Typed list has as its last item (Z31758)
- list ends with other (Z31763)
A complete list of all functions sorted by when they were created is available.
No comments:
Post a Comment