Project:SPARQL/examples: Difference between revisions

m
(3 intermediate revisions by the same user not shown)
Line 170: Line 170:
</sparql>
</sparql>


===Women who are listed as Fellows of the Society of Antiquaries of London (FSAs) on our wikibase and who are on Wikidata, but are not listed as FSAs on Wikidata===


<sparql tryit="1">
# Women who are listed as Fellows of the Society of Antiquaries of London (FSAs) on our wikibase and who are on Wikidata, but are not listed as FSAs on Wikidata
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/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd:  <http://www.wikidata.org/entity/>
SELECT ?person ?personLabel
WHERE { 
  ?person bnwdt:P3 bnwd:Q3 . #select women
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
 
  ?person bnwdt:P75 bnwd:Q8. # find only BN subjects having a FSA (h/t @Tagishsimon)
  ?person bnwdt:P117 ?wikidata_ID . #look for wikidata ID on person page
  bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_ID))) as ?item) .
  SERVICE <https://query.wikidata.org/sparql> {
        ?item wdt:P21 ?WD_gender. #get gender of person
        FILTER NOT EXISTS {?item wdt:P166 wd:Q26196499 . } #not FSA on Wikidata
      }
 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en". }
}
ORDER BY ?personLabel
</sparql>


=== Women's interactions with SAL (Q1 and Q8)===
=== Women's interactions with SAL (Q1 and Q8)===
Line 247: Line 214:
<sparql tryit="1">
<sparql tryit="1">
#title:Women's interactions with RAI (Q35 and Q29)
#title:Women's interactions with RAI (Q35 and Q29)
# CAVEAT: this query may overlook a significant number of interactions and should probably not be reference/archived in its current state
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 446: Line 414:
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>


SELECT distinct ?personLabel ?workLabel ?positionLabel ?date_pLabel ?date  
SELECT distinct ?personLabel ?workLabel ?positionLabel ?date_propLabel ?date  
?employerLabel ?organisedLabel ?ofLabel ?person
?employerLabel ?organisedLabel ?ofLabel ?locationLabel ?person
#?s  ?position  ?of  ?work ?employer ?organised
#?s  ?position  ?of  ?work ?employer ?organised ?location ?date_prop


WHERE {
WHERE {
Line 462: Line 430:
     # more about the position
     # more about the position
     ?s ( bnps:P17|bnps:P48|bnps:P105 ) ?position .   
     ?s ( bnps:P17|bnps:P48|bnps:P105 ) ?position .   
     # employer / organised by / of (incl free text). TODO: check whether these are mutually exclusive; could make this a union.
     # employer / organised by / of (incl free text).  
     # for position held, employer>of [ontology day discussion 13/9/23]
     # for position held, employer>of [ontology day discussion 13/9/23]
     OPTIONAL { ?s bnpq:P18 ?employer .}   
     OPTIONAL { ?s bnpq:P18 ?employer .}   
Line 468: Line 436:
     OPTIONAL { ?s ( bnpq:P78 | bnpq:P66 ) ?of .}
     OPTIONAL { ?s ( bnpq:P78 | bnpq:P66 ) ?of .}
   
   
  # optional { ?s bnpq:P2 ?location . } # sometimes there is location and no employer/org/of
    optional { ?s bnpq:P2 ?location . }
      
      
   # dates
   # dates with property labels.
     optional {
     optional {
     ?s ?pq ?date .  
     ?s ?pq ?date .
     
       ?date_prop wikibase:qualifier ?pq;       
       ?date_p wikibase:qualifier ?pq;       
               wikibase:propertyType wikibase:Time .
              #wikibase:propertyType ?date_prop_type; # can check date property types if needed
               wikibase:propertyType wikibase:Time . # nb *does not* include edtf dates but AFAICT there are none in qualifiers.
              #rdfs:label ?date_label . filter(lang(?date_label)="en-gb") . # what kind of date is it.
       } # /dates
       } # /dates
    
    
727

edits