query-1023716ae22d2ba5c921fb127e7ea3f7

rq turtle/ttl

Worldwide

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?office ?officeLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
  {
    ?item wdt:P39 ?office.
    VALUES ?office {
      wd:Q13218630 # United States representative
      wd:Q4416090  # United States senator
      wd:Q48011080 # Member of the Landtag of South Tyrol
      wd:Q62083474 # member of the Legislative Assembly of the Azores
      wd:Q62032637 # member of the Legislative Assembly of Madeira
    }
  }
  UNION {
    ?item wdt:P39 ?office. # Members of Parliament (UK)
    ?office wdt:P279 ?position.
    VALUES ?position {
      wd:Q106079967 # member of United States state lower house
      wd:Q7603534   # state senator
      wd:Q486839    # member of parliament
    }
  }
  UNION {
    ?item wdt:P39 ?office.
    ?office wdt:P279 ?position1.
    ?position1 wdt:P279 ?position.
    VALUES ?position {
      wd:Q486839 # member of parliament
    }
  }

  # REMOVE ENTRIES THAT DON'T COUNT
  MINUS { ?item wdt:P31 wd:Q15632617. } # remove anyone who is fictional
  MINUS { # remove values that don't meet WP:NSUBPOL through P1001 (applies to jurisdiction)
    ?item wdt:P39 ?office.
    ?office wdt:P1001 ?position.
    VALUES ?position {
      wd:Q15630895 # district of the German Democratic Republic
      wd:Q194203   # arrondissement of France
    }
  }
  MINUS { # remove values that don't meet WP:NSUBPOL through P279 (subclass of)
    ?item wdt:P39 ?office2.
    ?office2 wdt:P279 ?subclass.
    VALUES ?subclass {
      wd:Q382617   # mayor of a place in France
      wd:Q55400987 # community councillor
      wd:Q15113603 # municipal councillor
      wd:Q96208019 # member of municipal council
      wd:Q21705031 # Provincial Deputy
    }
  }
  MINUS { # remove extra stuff
    ?item wdt:P39 ?office.
    VALUES ?office {
      wd:Q65494735 # Special Guest of the Parliamentary Assembly of the Council of Europe
    }
  }

  # CHECK FOR ENWIKI PAGE
  OPTIONAL { ?item wikibase:sitelinks ?linkcount }.
  FILTER NOT EXISTS { ?wen schema:about ?item; schema:isPartOf <https://en.wikipedia.org/> }.
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v2("?item"):::projected v8("?linkcount") v8("?office"):::projected v6("?office2") v6("?position") v5("?position1") v8("?subclass") v1("?wen") c3([https://en.wikipedia.org/]):::iri c5(["bd:serviceParam"]):::iri c7(["#91;AUTO_LANGUAGE#93;"]):::literal c11(["wd:Q15632617"]):::iri f0[["not "]] subgraph f0e0["Exists Clause"] e0v1 --"schema:about"--> e0v2 e0v1 --"schema:isPartOf"--> e0c3 e0v2("?item"):::projected e0v1("?wen"):::projected e0c3([https://en.wikipedia.org/]):::iri end f0--EXISTS--> f0e0 f0 --> v1 f0 --> c1 f0 --> v2 f0 --> c2 f0 --> c3 v1 --"schema:about"--> v2 v1 --"schema:isPartOf"--> c3 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c5 --"wikibase:language"--> c7 end subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; subgraph union1[" Union "] subgraph union1l[" "] style union1l fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P39"--> v8 v8 --"wdt:P279"--> v5 v5 --"wdt:P279"--> v6 bind1[/VALUES ?position/] bind1-->v6 bind10(["wd:Q486839"]) bind10 --> bind1 end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P39"--> v8 v8 --"wdt:P279"--> v6 bind2[/VALUES ?position/] bind2-->v6 bind20(["wd:Q106079967"]) bind20 --> bind2 bind21(["wd:Q7603534"]) bind21 --> bind2 bind22(["wd:Q486839"]) bind22 --> bind2 end union1r <== or ==> union1l end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P39"--> v8 bind3[/VALUES ?office/] bind3-->v8 bind30(["wd:Q13218630"]) bind30 --> bind3 bind31(["wd:Q4416090"]) bind31 --> bind3 bind32(["wd:Q48011080"]) bind32 --> bind3 bind33(["wd:Q62083474"]) bind33 --> bind3 bind34(["wd:Q62032637"]) bind34 --> bind3 end union0r <== or ==> union0l end subgraph minus4["MINUS"] style minus4 stroke-width:6px,fill:pink,stroke:red; v2 --"wdt:P31"--> c11 end subgraph minus5["MINUS"] style minus5 stroke-width:6px,fill:pink,stroke:red; v2 --"wdt:P39"--> v8 v8 --"wdt:P1001"--> v6 bind6[/VALUES ?position/] bind6-->v6 bind60(["wd:Q15630895"]) bind60 --> bind6 bind61(["wd:Q194203"]) bind61 --> bind6 end subgraph minus7["MINUS"] style minus7 stroke-width:6px,fill:pink,stroke:red; v2 --"wdt:P39"--> v6 v6 --"wdt:P279"--> v8 bind8[/VALUES ?subclass/] bind8-->v8 bind80(["wd:Q382617"]) bind80 --> bind8 bind81(["wd:Q55400987"]) bind81 --> bind8 bind82(["wd:Q15113603"]) bind82 --> bind8 bind83(["wd:Q96208019"]) bind83 --> bind8 bind84(["wd:Q21705031"]) bind84 --> bind8 end subgraph minus9["MINUS"] style minus9 stroke-width:6px,fill:pink,stroke:red; v2 --"wdt:P39"--> v8 bind10[/VALUES ?office/] bind10-->v8 bind100(["wd:Q65494735"]) bind100 --> bind10 end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v2 -."wikibase:sitelinks".-> v8 end