Wikidata:WikiProject every politician/Sweden/Riksdag/prompts/official

From Wikidata
Jump to navigation Jump to search

This compares Wikidata's list of current members against the API of members from the Riksdag.

Amineh Kakabaveh (Q3675519) and Emma Carlsson Löfdahl (Q4941925) are expected to return false positives, as the official data only records current party, and not that they left their party mid-term (so here Wikidata is more correct than the official data, rather than less).


Comparison

@@ id (SPARQL) id (CSV) name (SPARQL) name (CSV) area (SPARQL) area (CSV) party (SPARQL) party (CSV) start (SPARQL) start (CSV)
--- 0737073162411 Emma Carlsson Löfdahl Jönköpings län partilös 2019-03-11
-> 0545353563812 Amineh Kakabaveh Stockholms län V- 2019-08-282018-09-24

Stats

  • Items only found in SPARQL (--- in the first column): 1
  • Items only found in CSV (+++ in the first column): 0
  • Items that differ between sources (→ in the first column): 1
  • Total items in SPARQL: 350
  • Total items in CSV: 349

External source

https://raw.githubusercontent.com/every-politician-scrapers/sweden-riksdag-api-current/master/data/official.csv

SPARQL query

SELECT ?id ?item ?name ?area ?group ?party ?start WHERE { 
    ?item p:P1214 ?idstatement ; p:P39 ?ps . 
    ?idstatement ps:P1214 ?id FILTER(STRLEN(?id) < 20) .
    OPTIONAL { ?idstatement pq:P1810 ?riksdagName }
    
    ?ps ps:P39 wd:Q10655178 ; pq:P580 ?startDate .
    BIND(SUBSTR(STR(?startDate),1,10) AS ?start) 
  
    OPTIONAL { ?ps pq:P582 ?end }
    FILTER(!BOUND(?end) || ?end > NOW())
  
    OPTIONAL {
      ?ps pq:P4100 ?group .
      OPTIONAL {
        ?group wdt:P1813 ?groupShort FILTER(LANG(?groupShort) = "sv")
      }
    }
    BIND(COALESCE(?groupShort, '-') AS ?party)

    OPTIONAL { 
      ?ps pq:P768 ?district . 
      # TODO: ONLY ?districts that are actual constituencies?
      ?district rdfs:label ?districtLabel FILTER(LANG(?districtLabel) = "sv") .
      BIND(REPLACE(STR(?districtLabel), "s? valkrets", "") AS ?area) 
    }
  
    ?item rdfs:label ?svname FILTER(LANG(?svname) = "sv") .
  
    BIND(COALESCE(?riksdagName, ?svname) AS ?name)
  }
Try it!

Refresh prompt

Refresh this comparison Purge the cache

Customize (optional)