The on-wiki version of this newsletter can be found here: https://www.wikifunctions.org/wiki/Wikifunctions:Status_updates/2024-10-02 -- Focus topic: food https://www.wikifunctions.org/wiki/File:Christmas_table_(Serbian_cuisine).jpg
As we discussed two weeks ago, we are introducing two focus topics https://www.wikifunctions.org/wiki/Wikifunctions:Status_updates/2024-09-20. One focus topic will concern model articles https://meta.wikimedia.org/wiki/Abstract_Wikipedia/Updates/2022-06-07, and one will be for bespoke articles https://meta.wikimedia.org/wiki/Abstract_Wikipedia/Updates/2022-06-21. 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. https://www.wikifunctions.org/wiki/File:Egyptian_food_Koshary.jpg
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. https://www.wikifunctions.org/wiki/File:Goblet_of_Fire_Cocktail.jpg
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 https://w.wiki/BDb7).
The chart shows how many foods have how many sitelinks (note the log scale on the y axis). [image: A chart showing the number of foods with a certain number of sitelinks on Wikimedia projects as of September 2024] https://www.wikifunctions.org/wiki/File:Log_Number_of_foods_vs._Sitelinks.svg
326 language editions of Wikipedia have articles about foods and beverages ( query https://w.wiki/BDcr), 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 https://w.wiki/BDdQ).
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 https://w.wiki/BDdT)–*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 https://w.wiki/BDdb). And 225 language editions have articles on foods and beverages that English Wikipedia does not cover (query https://w.wiki/BDdu).
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 https://en.wikipedia.org/wiki/Stone_Soup that Wikipedia is. Volunteer’s Corner on October 7
Next week, on Monday, October 7th, 2024, at 17:30 UTC https://zonestamp.toolforge.org/1728322200, 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 https://www.wikifunctions.org/wiki/Wikifunctions:Status_updates/2024-09-26#Function_of_the_Week:_multiply_two_natural_numbers, 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 https://www.wikifunctions.org/wiki/Wikifunctions:Function_of_the_Week#Suggest_your_own_Function_of_the_Week: calculating the product of list (natural number) (Z13558) https://www.wikifunctions.org/view/en/Z13558.
A product https://en.wikipedia.org/wiki/Product_(mathematics) 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 https://www.wikifunctions.org/view/en/Z17709 such as 9 is the number itself, *i.e.* 9. - The product of the empty list https://www.wikifunctions.org/view/en/Z17710, *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 https://en.wikipedia.org/wiki/Multiplication#Properties. The sum of an empty list of numbers https://www.wikifunctions.org/view/en/Z14038, by the way, is not 1, but 0 – again, because that’s the identity element of the addition https://en.wikipedia.org/wiki/Addition#Identity_element 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 https://www.wikifunctions.org/view/en/Z17711 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 https://www.wikifunctions.org/view/en/Z13566 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 https://www.wikifunctions.org/view/en/Z18910: 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 https://www.wikifunctions.org/view/en/Z13560 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 https://www.wikifunctions.org/view/en/Z17399 does exactly the same, but it displays some interesting variation in syntax when compared to the Python implementation above - The first composition https://www.wikifunctions.org/view/en/Z17400 uses the reduce function https://www.wikifunctions.org/view/en/Z876 on the multiplication function https://www.wikifunctions.org/view/en/Z13539 and a starting value of 1. The reduce function is the second half of the famous MapReduce https://en.wikipedia.org/wiki/MapReduce programming pattern, which we will devote a future Function of the Week to. - The second composition is recursive https://www.wikifunctions.org/view/en/Z16828, *i.e.* it calls itself under certain conditions. If the argument list has one element https://www.wikifunctions.org/view/en/Z12755, return that element. If it has none https://www.wikifunctions.org/view/en/Z813, return 1. Otherwise multiply https://www.wikifunctions.org/view/en/Z13539 the first number https://www.wikifunctions.org/view/en/Z811 of the list with the product of the rest of the list https://www.wikifunctions.org/view/en/Z812 - and calculating the product of the rest of the list is by calling the product function https://www.wikifunctions.org/view/en/Z13558 itself again. Because the argument list gets shorter in every call, we know that the recursion will end at some point. - The third composition https://www.wikifunctions.org/view/en/Z17401 is a variation on the first composition above: it also calls the reduce function https://www.wikifunctions.org/view/en/Z876, but instead of using 1 as a starting value, it uses the first number https://www.wikifunctions.org/view/en/Z811 in the list as the starting value, and then reduces the rest of the list https://www.wikifunctions.org/view/en/Z812 using multiplication https://www.wikifunctions.org/view/en/Z13539. In order to be able to do so it first needs to check whether the list is empty https://www.wikifunctions.org/view/en/Z813, in which case it returns 1 directly. - The fourth composition https://www.wikifunctions.org/view/en/Z13567 (and final one, for now) first checks for the empty list https://www.wikifunctions.org/view/en/Z813, in which case it returns 1, and uses the right fold function https://www.wikifunctions.org/view/en/Z12753 with multiplication https://www.wikifunctions.org/view/en/Z13539 on the list otherwise. Fold https://en.wikipedia.org/wiki/Fold_(higher-order_function) and reduce https://en.wikipedia.org/wiki/Reduction_operator are two very similar functions, sometimes even used synonymously. In Wikifunctions, the right fold function is the same as the reduce function with the difference that the reduce function gets a starting value as an argument, whereas right 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. - The second implementation in Python https://www.wikifunctions.org/view/en/Z19106 uses Python’s reduce function https://docs.python.org/3/library/functools.html#functools.reduce and multiplication operator https://docs.python.org/3/library/operator.html#operator.mul, basically the same as the first composition but in Python - The second implementation in JavaScript https://www.wikifunctions.org/view/en/Z19107 uses JavaScript Array’s reduce method https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce, but since the language has no built-in multiplication function uses a lambda function https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions to express the multiplication
We invite you to play around with the function, and particularly the flow for typed lists. And thanks to 99of9 https://www.wikifunctions.org/wiki/User: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 https://www.wikifunctions.org/wiki/Wikifunctions:Function_of_the_Week#Suggest_your_own_Function_of_the_Week yourself.