Refining a SPARQL Query with ChatGPT: Counting Archbishops Without Photos on Wikipedia at Wikimania

I had the privilege to travel to Katowice, Poland, this summer thanks to a scholarship from Wikimedia Nederland. This year, Wikimania took place there—the global annual conference where Wikipedians come together to attend presentations, workshops, and discussions focused on free knowledge, collaboration, and the future of the Wikimedia projects.

Vera smiling next to the 2.5-meter-high Wikipedia Monument. The monument is a bronze sculpture of the Wikipedia logo, carried by four nude female figures, standing on a one-meter-high pedestal. Vera is wearing a t-shirt and jeans.
I traveled by train and was able to visit the Wikipedia Monument in the Polish border town of Słubice.

The best story I can tell about this edition of Wikimania is meeting Rev. Cary Bass-Deschênes, a Wikipedian from California who has been active since 2004. When I saw them sitting in the recreation area in his priestly robes, I thought I might have found a few shoulders to help carry a project I had envisioned years ago: securing photos for Wikipedia articles about archbishops of the Catholic Church. If the world’s largest hierarchical organization were to release images under a free license, it could help fill many gaps in the world’s largest encyclopedia.

Vera standing behind Cary, who is focused on his laptop screen. Next to him sits Josh, also concentrating on the screen. Vera is wearing a green medical mask and the Wikimania conference lanyard. Cary is dressed in a black priestly robe, and Josh is wearing a black jacket.
Vera, Cary, and Josh trying to determine how many archbishops still lack a photo in their Wikipedia articles. Photo: Mike Bass-Deschênes, CC-BY 4.0

Cary is a Lutheran pastor, but that didn’t stop them from being interested in how ChatGPT could help answer the question of how many archbishops are described on Wikipedia without a photo. To do this, you need to understand that every person described on Wikipedia has an item on Wikidata, which describes them in a way that can be queried using SPARQL (pronounced: sparkle).

If you ask ChatGPT to write such a query, you can then use the Wikidata Query Service to retrieve data. Unfortunately, ChatGPT isn’t smart enough to get everything right with a simple prompt:

Write a SPARQL query to count the number of archbishops with a Wikipedia article but without a photo.

There are only 153 items where the property position held (P39) has the value Catholic archbishop (Q48629921). This is because the position is modeled differently in Wikidata. You can guide ChatGPT more effectively by first finding an example of what you need.

Using the Wikipedia article on Wim Eijk, the Archbishop of Utrecht, you can find his Wikidata item under the tools menu in the desktop version: Q45176. Looking at this item, under position held, it refers to Archbishop of Utrecht (Q105421802). That item is a subclass of Metropolitan Archbishop (Q105393558). To find all Catholic archbishops, we must use the subclass property.

Write a SPARQL query to count the number of people holding a position that is a subclass of Catholic archbishop, has no photo, and has an article in any language version of Wikipedia.

This query returns 4,511 items, but many of them were archbishops centuries ago. I asked ChatGPT to filter out individuals who lived before photography. It interpreted this as filtering birth years before 1800 and death dates after 1839, reducing the total to 2,303.

Meanwhile, Josh Lim, a Filipino-American Wikipedian I’ve known for years, joined us. He found the idea interesting and mentioned that he has a distant relative who holds a high position in the Vatican. So who knows, maybe this project will happen one day!

Cary wasn’t wearing their priestly robes in order to advertise being a “man of the cloth”—it’s also just their only black shirt. They told me they needed black clothing for the first performance of the WikiOrchestra at the closing ceremony that evening. If you follow me on YouTube, you’ve probably seen that I extracted their performance so it can be watched separately:

Chopin’s Nocturne in E-flat major, performed by the WikiOrchestra during the closing ceremony of Wikimania, with Cary on the flute.
The Silesian folk song Karliku, performed by the WikiOrchestra during the closing ceremony of Wikimania.

I spoke with many other people during the four days of the Wikimania conference. It was fantastic to see everyone again. For many, it had been five years since they last met, during Wikimania 2019 in Stockholm. I am very grateful to Wikimedia Nederland for awarding me a scholarship to make this trip possible. Thanks to their support, I was able to strengthen the many international connections I have within the Wikimedia community, which will hopefully lead to even more great projects.

×