query-a03213eefce4f03fbde9b9b63c75e4c0

rq turtle/ttl

Everyone with summary seat/party data, but these values may not be the same as the party they were associated with in Parliament. Caveat lector. (P102)member of political party This query gives a summary list for each MP listing their seats, "known parties", and "inferred parties". Known are those explicitly associated with a given seat and period in Parliament (mostly 1996 onwards), inferred are those where we know the MP has a value set for Coverage is notionally 1803-2005, in practice 1832-2005 (as detailed seat information is not currently available before that date). Data on constituencies is comprehensive 1886-date, and broadly reliable 1832-86. Constituencies may not be named with the exact format used at the time (eg Ceredigion/Cardiganshire); this will hopefully be corrected in future data cleaning.

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
select distinct ?person ?personLabel 
(GROUP_CONCAT(distinct ?seatLabel; separator="; ") as ?seats)
(GROUP_CONCAT(distinct ?known_partyLabel; separator="; ") as ?known_parties) 
(GROUP_CONCAT(distinct ?inferred_partyLabel; separator="; ") as ?inferred_parties) 
WHERE {
    ?position wdt:P279 wd:Q16707842 . ?person p:P39 ?positionStatement .
    ?positionStatement ps:P39 ?position ; pq:P580 ?start . 
    bind(year(?start) as ?startyear) . filter (?startyear < 2005 ) . filter (?startyear > 1802 ) 
  # anyone who served as an MP between 1803 and 2005
    optional { ?positionStatement pq:P768 ?seat } .
    optional { ?positionStatement pq:P4100 ?known_party } .
    optional { ?person wdt:P102 ?inferred_party } .
  # seats and parties
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . 
                           ?person rdfs:label ?personLabel .  
                           ?inferred_party rdfs:label ?inferred_partyLabel .  
                           ?known_party rdfs:label ?known_partyLabel .  
                           ?seat rdfs:label ?seatLabel . }
  # labels

} group by ?person ?personLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v15("?inferred_parties") v8("?inferred_party") v10("?inferred_partyLabel"):::projected v14("?known_parties") v7("?known_party") v11("?known_partyLabel"):::projected v3("?person"):::projected v9("?personLabel"):::projected v2("?position") v4("?positionStatement") v6("?seat") v12("?seatLabel"):::projected v13("?seats") v5("?start") v6("?startyear") c4(["wd:Q16707842"]):::iri c14(["en"]):::literal c12(["bd:serviceParam"]):::iri f0[["?startyear > '1802^^xsd:integer'"]] f0 --> v6 f1[["?startyear < '2005^^xsd:integer'"]] f1 --> v6 v2 --"p:direct/P279"--> c4 v3 --"p:P39"--> v4 v4 --"p:statement/P39"--> v2 v4 --"p:qualifier/P580"--> v5 bind2[/"year-from-dateTime(?start)"/] v5 --o bind2 bind2 --as--o v6 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v4 -."p:qualifier/P768".-> v6 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v4 -."p:qualifier/P4100".-> v7 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:direct/P102".-> v8 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c12 --"wikibase:language"--> c14 v3 --"rdfs:label"--> v9 v8 --"rdfs:label"--> v10 v7 --"rdfs:label"--> v11 v6 --"rdfs:label"--> v12 end bind6[/"?seatLabel"/] v12 --o bind6 bind6 --as--o v13 bind7[/"?known_partyLabel"/] v11 --o bind7 bind7 --as--o v14 bind8[/"?inferred_partyLabel"/] v10 --o bind8 bind8 --as--o v15