Project:SPARQL/examples: Difference between revisions

Line 810: Line 810:
<sparql tryit="1">
<sparql tryit="1">
#title:initial query for suffrage activities
#title:initial query for suffrage activities
# caveat: THIS IS SLOOOW
 
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
Line 820: Line 820:


SELECT distinct ?person ?personLabel ?mainLabel ?sub_Label ?qualLabel ?locationLabel ?date  
SELECT distinct ?person ?personLabel ?mainLabel ?sub_Label ?qualLabel ?locationLabel ?date  
# ?pq ?sub_ ?qual ?main ?qual_dateLabel
# ?pq ?sub_ ?qual ?main  
?s
?s


Line 832: Line 832:
       ?s ?sub ?sub_ .
       ?s ?sub ?sub_ .
         ?main wikibase:claim ?p.
         ?main wikibase:claim ?p.
         #?main wikibase:statementProperty ?sub.   
         ?main wikibase:statementProperty ?sub.   
    
    
   # sub_ i/o and yes some do have suffrage activity
   # sub_ i/o - some do have suffrage activity
   #  optional { ?sub_ bnwdt:P12 ?sub_io . ?sub_ bnwdt:P12 bnwd:Q1166 . }
   #  optional { ?sub_ bnwdt:P12 ?sub_io . ?sub_ bnwdt:P12 bnwd:Q1166 . }
    
 
   {
   # union
   {  
     # a qualifier (anywhere) has i/o suffrage activity
     # a qualifier (anywhere) has i/o suffrage activity
       ?s bnpq:P12 bnwd:Q1166.
       ?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.
 
# what about a main rather than qualifier having i/o suffrage activity? i don't think there are any atm but could be.
# union
# union
  #  { # this might find extra linked i/o suffrage but i'm not sure it works.
  #  { # this might find extra linked i/o suffrage but i'm not sure it works.
  #    ?sub_ bnwdt:P12 bnwd:Q1166 .
  #    ?sub_ bnwdt:P12 bnwd:Q1166 .
  #    }
  #    }
   union
   union
     {
     {
     # does *not* have i/o suffrage activity in any qualifiers  ...  
     # does *not* have i/o suffrage activity in any qualifiers  ... slows things right down and doesn't seem to make any difference to results?
     filter not exists { ?s bnpq:P12 bnwd:Q1166. }
     #filter not exists { ?s bnpq:P12 bnwd:Q1166. }
    
    
     # ... but a qualifier *does* have i/o suffrage activity. i think!
     # ... but a qualifier *does* have i/o suffrage activity. i think!
       ?s ?pq ?qual .
       ?s ?pq ?qual .
         ?qual bnwdt:P12 bnwd:Q1166 .
         ?qual bnwdt:P12 bnwd:Q1166 .
       }
 
       } # /union
    
    
   optional {  
   optional {  
     # date qualifiers. [assumes no edtf in quals. ] all seem to be p.i.t. ?
     # date qualifiers. [assumes no edtf in quals. ] all seem to be p.i.t.  
         ?s ?dpq ?date .   
         ?s ?dpq ?date .   
           ?qual_date wikibase:qualifier ?dpq .
           ?qual_date wikibase:qualifier ?dpq .
           ?qual_date wikibase:propertyType wikibase:Time.  
           ?qual_date wikibase:propertyType wikibase:Time.  
   }
   }
 
  optional { ?s bnpq:P78 ?of. }  # outside the union seems much speedier
    
    
   optional { ?s bnpq:P2 ?location . }
   optional { ?s bnpq:P2 ?location . }
579

edits