Jump to content

WikiGap/Wikidata guide

From Meta, a Wikimedia project coordination wiki

The following is an instruction on how to initialize automatically generated (from Wikidata) lists of females in technical professions who have an article on Wikipedia in X language but not in N language.

The lists are meant to be published on Swedish Wikipedia, as they are using a template called Wikidatalista, which is specific to Swedish Wikipedia. Unfortunately the system for generating these lists is not functional here on the Meta Wiki – but similar templates exist on many wikis, such as Wikidata list in English, Wikidata-lista in Finnish or Wikidane lista in Polish.

If you need more inspiration, WikiProject Women in Red has resources and lists of missing women from various areas of society on English Wikipedia. On the left-hand side of that page, you'll find links to similar projects in other languages, such as Norwegian or German.

Prepare the source code

[edit]

The following code is used to generate a list of females in technical professions who have an article on Swedish Wikipedia but not on Spanish Wikipedia. Furthermore, the list is ordered by the number of articles in different language versions of Wikipedia. For example, if a person has an article in 20 languages, including Swedish, but not in Spanish, they will be placed high up on the list. Additionally, some basic information about the person, such as their birth/death date, occupation etc. are fetched from Wikidata – if available.

By making small changes in this code, you can make it work for other language combinations.

{{Wikidatalista
|sparql=SELECT DISTINCT ?item ?linkcount WHERE {
  ?item wdt:P106 ?occ .
  ?article schema:about ?item .
  ?article schema:isPartOf <https://sv.wikipedia.org/>.
  VALUES ?occ {
    wd:Q42973 # architect
    wd:Q81096 # engineer
    wd:Q13582652 # civil engineer
    wd:Q7888586 # chemical engineer
    wd:Q1326886 # electrical engineer
    wd:Q5482740 # programmer
    wd:Q183888 # software developer
    wd:Q169470 # physicist
  }
  FILTER NOT EXISTS {
    ?wen schema:about ?item .
    ?wen schema:isPartOf <https://es.wikipedia.org/> .
  }
  ?item wdt:P21 wd:Q6581072 .                      # gender: female
  ?item wdt:P31 wd:Q5 .                            # human
  OPTIONAL {?item wikibase:sitelinks ?linkcount .} # count of sitelinks  
} ORDER BY DESC (?linkcount) LIMIT 50
|columns=number:#,label:name,P18,description,P106,P27,P569,P570,P19,P20,item,?linkcount:sitelinks
|thumb=40
}}
{{Wikidatalistavslut}}
[edit]

In lists generated by the code above, if an article does not exist on the wiki, the label will link to the person's Wikidata item. See here (links to Wikidata are in cursive).

If you want red links instead (so that a user can click on them and create a new article directly), such as here, you need to add links=red to the Wikidata list template (diff).

So the last lines in the template will look like this:

|columns=number:#,label:name,P18,description,P106,P27,P569,P570,P19,P20,item,?linkcount:sitelinks
|thumb=40
|links=red
}}

How to use other language combinations

[edit]

The following line defines which Wikipedia should have an article. I.e. we require that an article exists in Swedish.

?article schema:isPartOf <https://sv.wikipedia.org/>.

Change sv to the language prefix of the Wikipedia version that should have an article.

The following line defines which Wikipedia should be missing an article. I.e. we are looking for topics that are not described in Spanish.

?wen schema:isPartOf <https://es.wikipedia.org/> .

Change es to the language prefix of the Wikipedia version that should not have an article.

Other adjustments

[edit]

The following line, specifically the digit 50, defines how many results to show. You can change 50 to another digit to get more or fewer results:

} ORDER BY DESC (?linkcount) LIMIT 50

Selecting occupations from Wikidata

[edit]

If you're familiar with Wikidata, you can also change the occupations to search for. In the following lines, the occupations are defined using their entity ID's on Wikidata:

  VALUES ?occ {
    wd:Q39631 # architect
    wd:Q81096 # engineer
    wd:Q13582652 # civil engineer
    wd:Q7888586 # chemical engineer
    wd:Q1326886 # electrical engineer
    wd:Q5482740 # programmer
    wd:Q183888 # software developer
    wd:Q169470 # physicist
  }

By using the search function on Wikidata, you can find the ID's of other professions. For example, this is how you can modify the code to search for physicians (Q39631), dentists (Q27349) and nurses (Q186360):

  VALUES ?occ {
    wd:Q39631
    wd:Q27349
    wd:Q186360
  }

Put the source code on a page

[edit]

Paste the source code, with your adjustments, on a new page on Swedish Wikipedia, e.g. in your Sandbox or a subpage to Wikipedia:Skrivstuga/WikiGap 2019.

Using this code on other language versions of Wikipedia

[edit]

The template used to generate this code exists on many other language versions of Wikipedia. In English, it's called Wikidata list, but in several other langauges it's localized. Here's how to use it in your language:

  1. Go to the English page of the template, Wikidata list, and find your language in the list of the left-hand side.
  2. Make a note of what the template is called in your language. In the source code above, replace Wikidatalista in the first line with that name.
  3. Read the documentation of the template to find out what the ending statement is called. In English it's {{Wikidata list end}} and in Swedish it's {{Wikidatalistavslut}}. In the source code above, replace Wikidatalistavslut with the correct statement.

Fill the table with content

[edit]

After saving the page, you will only see a table header, but there will not be any content yet. Normally, this sort of lists are updated by an automated script, about once a day. However, since we don't want to wait for the initial content, we can trigger an update manually. It is done by clicking on Uppdatera listan manuellt on the right-hand side of the page. After a couple seconds, up to a minute, the page will be filled with content.