Wikifunctions:Status updates/2024-10-02
| ◀ | ▶ |
Focus topic: food

As we discussed two weeks ago, we are introducing two focus topics. One focus topic will concern model articles, and one will be for bespoke articles. We are looking for your input around a focus topic for model articles, but this time we want to discuss our chosen focus topic for bespoke articles: food.
Why food? Articles about foods and beverages on the different language editions of Wikipedia have an enormous variety of representation. Some articles talk about culture, others about history; some articles talk about nutrition, others about preparation.

Some have infoboxes; many do not. One might think that foods can easily contain infoboxes about nutritional values, but many foods are prepared in such different ways–and exhibit so many different varieties–that it's difficult to express structured data about the food, such as nutritional values. In short, creating a template for articles about food and beverages is basically impossible.

Foods and beverages also have the interesting quality that, perhaps more than any other topic area, they exhibit cultural differences in the different language articles of Wikipedia. The few articles we checked and compared across languages had sometimes vastly different content. And whereas there are many well-known (and probably even more lesser-known) contentious questions about food, the debates in this area are in general less heated than those on topics such as politics, geography, history, or religion.
Wikidata has items on about 31,000 foods and beverages, of which 26,000 have sitelinks. There are eleven topics with more than 200 sitelinks, giving an indication of their global importance: coffee (243), milk (242), tea (240), bread (239), food (228), beer (221), apple (220), wine (216), rice (213), banana (209), and honey (203) (query).
The chart shows how many foods have how many sitelinks (note the log scale on the y axis).

326 language editions of Wikipedia have articles about foods and beverages (query), showing the universal importance of food. 114 languages have an article about a dish or drink that no other language edition has, showing how much of the knowledge is spread across the globe, and not available across language borders. This includes two of our focus languages, Bengali with six foods and Malayalam with eight (query).
You may assume that the coverage of food on English Wikipedia would be very strong. However, 12,500 foods and beverages that have articles on Wikipedia are not represented with an article on English Wikipedia (query)–i.e., close to half of the foods that have an article on Wikipedia are not represented in English. All of our five focus languages have articles about food which are not described on English Wikipedia (query). And 225 language editions have articles on foods and beverages that English Wikipedia does not cover (query).
One note is that some of these gaps and missing articles might be due to different ways in which foods and beverages are split into articles in different languages: in one language we might have six articles about six different types of a regional dish, which is covered by a single article in a different language. But these are indeed some of the differences we are curious to explore and uncover with Abstract Wikipedia over time.
I hope that you got a taste of the large variety in how food is being represented on Wikipedia, and how much knowledge we may potentially unlock by allowing everyone, across language barriers, to contribute to this unique and amazing stone soup that Wikipedia is.
Volunteer’s Corner on October 7
Next week, on Monday, October 7th, 2024, at 17:30 UTC, we will have our monthly Volunteers’ Corner. Unless you have many questions, we will follow our usual agenda, of giving updates on the upcoming plans and recent activities, having plenty of time and space for your questions, and building a Function together. Looking forward to seeing you on Monday!
Function of the Week: product of list of natural numbers
Last week we were talking about multiplying numbers with each other, and how Wikifunctions beats large language models hands-down in this particular task. This week we follow this direction by picking a function suggested by the community: calculating the Z13558.
A product is the result of a multiplication. The product of 2 and 3 is 6, i.e. 2 multiplied with 3 is 6. The function we look at this week can deal with an arbitrary number of numbers. How does it do that? We can’t add and remove arguments in Wikifunctions!
The trick is that it actually doesn’t take an arbitrary number of arguments, but it takes a single argument: a list. To be more precise, a typed list, a list of natural numbers. This means that when you get to the function page, the Try this function section looks a bit funny: instead of giving you a field or several fields to enter a value, it just shows the name of the argument (List of natural numbers), and a big + button.
Now you have to click on the big + button. Once you do that, you get the opportunity to enter a number. If you want to add another number, just click again on the + button. If you want to remove a number from the list, you can click on the three dots next to the text Item, followed by the number, and then choose the “Delete item” option. By the way, some folks call the three dots the meatballs menu icon.
Play around a bit with this feature, to enter more elements to a list and remove them. It’s a good skill to have, because all lists in Wikifunctions work with this flow.
This function has five tests and eight implementations. The tests really nicely cover a number of interesting cases:
- The product of a single number such as 9 is the number itself, i.e. 9.
- The product of the empty list, i.e. a list with no numbers in it, is 1. You may ask why is it 1, and not, say, 0? The reason why mathematicians define the product of the empty list to be 1 is because 1 is the identity element of the multiplication operation. The sum of an empty list of numbers, by the way, is not 1, but 0 – again, because that’s the identity element of the addition operation. It’s all a bit confusing. But the important thing here is: the tests tell you what to expect in the edge cases, and are a really good form of documentation.
- The product of two numbers is the result of multiplying the two numbers, i.e. 11×9 is 99.
- The next test checks for the product of a somewhat longer list of numbers, five numbers: 2, 3, 5, 7, and 11, and results in 2310.
- And the final test we currently have checks for the product of all prime numbers below 30: that’s ten numbers, 2, 3, 5, 7, 11, 13, 17, 19, 23, and 29. The result is 6,469,693,230. We can see that the first five numbers are the same five numbers in the previous test.
We have eight implementations for this function – quite a few! I actually found it quite instructional and interesting to compare the different implementations, both within the same language and across languages.
- The first implementation in Python starts by setting a variable to 1, and then going through each value in the argument, and then updating the variable to be itself multiplied with the value from the argument, and finally returning the result
- The first implementation in JavaScript does exactly the same, but it displays some interesting variation in syntax when compared to the Python implementation above
- The first composition uses the reduce function on the multiplication function and a starting value of 1. The reduce function is the second half of the famous MapReduce programming pattern, which we will devote a future Function of the Week to.
- The second composition is recursive, i.e. it calls itself under certain conditions. If the argument list has one element, return that element. If it has none, return 1. Otherwise multiply the first number of the list with the product of the rest of the list - and calculating the product of the rest of the list is by calling the product function itself again. Because the argument list gets shorter in every call, we know that the recursion will end at some point.
- The third composition is a variation on the first composition above: it also calls the reduce function, but instead of using 1 as a starting value, it uses the first number in the list as the starting value, and then reduces the rest of the list using multiplication. In order to be able to do so it first needs to check whether the list is empty, in which case it returns 1 directly.
- The fourth composition (and final one, for now) first checks for the empty list, in which case it returns 1, and uses the right fold function with multiplication on the list otherwise. Fold and reduce are two very similar functions, sometimes even used synonymously. In Wikifunctions, the left fold function is the same as the reduce function with the difference that the reduce function gets a starting value as an argument, whereas left fold starts with the first value of the argument list – which is why it cannot deal with an empty list and requires handling of that beforehand. And left fold is like right fold, but with the list turned around.
- The second implementation in Python uses Python’s reduce function and multiplication operator, basically the same as the first composition but in Python
- The second implementation in JavaScript uses JavaScript Array’s reduce method, but since the language has no built-in multiplication function uses a lambda function to express the multiplication
We invite you to play around with the function, and particularly the flow for typed lists. And thanks to 99of9 for suggesting the function as a Function of the Week! If you want to make your own suggestions, please feel free to nominate a function yourself.