Project:SPARQL/examples: Difference between revisions

From Beyond Notability
Line 803: Line 803:


order by ?personLabel ?ppa_label
order by ?personLabel ?ppa_label
</sparql>
=== Suffrage-related activities ===
<sparql tryit="1">
#title:initial query for suffrage activities
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
PREFIX bnwdv: <https://beyond-notability.wikibase.cloud/value/>
PREFIX bnwdt: <https://beyond-notability.wikibase.cloud/prop/direct/>
PREFIX bnp: <https://beyond-notability.wikibase.cloud/prop/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
SELECT distinct ?person ?personLabel ?mainLabel ?sub_Label ?qualLabel ?locationLabel ?date
# ?pq ?sub_ ?qual ?main ?qual_dateLabel
?s
WHERE { 
    ?person bnwdt:P3 bnwd:Q3 . #select women
    FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
    ?person ?p ?s .
 
      ?s ?sub ?sub_ .
        ?main wikibase:claim ?p.
        ?main wikibase:statementProperty ?sub. 
 
  # sub_ i/o and yes some do have suffrage activity
  #  optional { ?sub_ bnwdt:P12 ?sub_io . ?sub_ bnwdt:P12 bnwd:Q1166 . }
 
  {
    # a qualifier (anywhere) has i/o suffrage activity
      ?s bnpq:P12 bnwd:Q1166.
      optional { ?s bnpq:P78 ?qual .}
    }
    # what about a main rather than qualifier having i/o suffrage activity? i don't think there are any atm but could be.
# union
#  { # this might find extra linked i/o suffrage but i'm not sure it works.
#    ?sub_ bnwdt:P12 bnwd:Q1166 .
#    }
  union
    {
    # does *not* have i/o suffrage activity in any qualifiers  ...
    filter not exists { ?s bnpq:P12 bnwd:Q1166. }
 
    # ... but a qualifier *does* have i/o suffrage activity. i think!
      ?s ?pq ?qual .
        ?qual bnwdt:P12 bnwd:Q1166 .
      }
 
  optional {
    # date qualifiers. [assumes no edtf in quals. ] all seem to be p.i.t. ?
        ?s ?dpq ?date . 
          ?qual_date wikibase:qualifier ?dpq .
          ?qual_date wikibase:propertyType wikibase:Time.
  }
 
  optional { ?s bnpq:P2 ?location . }
 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
}
order by ?personLabel ?mainLabel
</sparql>
</sparql>


579

edits