User:Ainali/WikiProject mainpage analysis

Proof of concept: https://github.com/Ainali/wikiproject-mainpage-analysis

Analyze how often articles related to some WikiProjects appear on the mainpage.

Check all links from the mainpage, probably through something like this API call:

https://sv.wikipedia.org/w/api.php?action=query&format=json&prop=pageprops&titles=Portal%3AHuvudsida&generator=links&formatversion=2&ppcontinue=&ppprop=wikibase_item&gplnamespace=0&gpllimit=max

From the JSON, extract all Wikidata items so that they can be plugged into the VALUES of a SPARQL query like this:

SELECT DISTINCT ?page ?pageLabel ?item ?itemLabel WHERE {
VALUES ?page { wd:Q6534 wd:Q5113  wd:Q2211 wd:Q49 wd:Q9027 wd:Q84 } #This is the list to plugin the API result to
?page wdt:P5008 | wdt:P6104 ?item
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY ?page

Try it!

Store this and run this daily so that data over time and aggregated per year can be shown.

Do this for each Wikipedia. Here is a SPARQL query to get the language code and the name of the main page so that the API call can be constructed:

SELECT ?lang ?wiki ?mainpage ?link  WHERE {
  hint:Query hint:optimizer "None".
  ?link schema:about wd:Q5296 ;
        schema:name ?mainpage ;
        schema:inLanguage ?lang ;
        schema:isPartOf ?wiki .
  ?wiki wikibase:wikiGroup "wikipedia".
} ORDER BY ?lang

Try it!

Make a nice page to visualize the results. Make it possible to inspect either from the perspective of a Wikipedia or a WikiProject. It should be possible to view either the combination of one Wikipedia / all WikiProjects, or one WikiProject / all Wikipedias, or a specific Wikipedia and a specific WikiProject. All combinations above for either per year or all time.