Project:SPARQL/examples: Difference between revisions

(97 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Project:SPARQL/admin | Admin/batch tools queries]]
==SAL and RAI==
==SAL and RAI==


Line 168: 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 bnp:P117 ?wikidata_ID . #look for wikidata ID on person page
  ?wikidata_ID bnpq:P14 ?wikidata_url .
  BIND(IRI(REPLACE(?wikidata_url,"https://www.wikidata.org/wiki/","http://www.wikidata.org/entity/")) 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)===


<sparql tryit="1">
<sparql tryit="1">
#title:Women's interactions with SAL (Q1 and Q8)
# 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 214: Line 184:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
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 distinct ?person ?personLabel ?prop ?propLabel  ?pq_value ?qual_prop_label ?sal
SELECT distinct ?person ?personLabel   ?propLabel  ?qual_value ?qual_propLabel ?bnwdLabel # ?s ?prop ?qual_prop ?bnwd


WHERE {   
WHERE {   
Line 224: Line 192:


       ?prop wikibase:claim ?p;       
       ?prop wikibase:claim ?p;       
         wikibase:statementProperty ?ps
         wikibase:statementProperty ?ps.     
        wikibase:statementValue ?psv;
        wikibase:propertyType ?prop_type.     
      
      
       # union query to get both q8 and q1  
       # union query to get both q8 and q1  
       { ?s ?ps bnwd:Q8 . }  union { ?s ?ps bnwd:Q1 . }
       { ?s ?ps bnwd:Q8 . }  union { ?s ?ps bnwd:Q1 . }
       ?s ?ps ?sal.
       ?s ?ps ?bnwd. #which type
    
    
      optional {  
      optional {  
         ?s ?pq ?pq_value .   
         ?s ?pq ?qual_value .   
          
          
         ?qual_prop wikibase:qualifier ?pq .  
         ?qual_prop wikibase:qualifier ?pq .
        ?qual_prop rdfs:label ?qual_prop_label. filter(lang(?qual_prop_label)="en-gb") .
        ?qual_prop wikibase:propertyType ?qual_prop_type
          
          
       } # /qualifiers
       } # /qualifiers


   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }  
}
}
ORDER BY ?personLabel ?propLabel ?s
ORDER BY ?personLabel ?propLabel ?s
Line 249: Line 213:


<sparql tryit="1">
<sparql tryit="1">
#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 256: Line 222:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
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 distinct ?person ?personLabel  ?prop ?propLabel ?prop_type ?pq_value ?pq_valueLabel ?qual_prop_label ?qual_prop_type ?rai ?s
SELECT distinct ?person ?personLabel  ?propLabel  ?qual_value ?qual_propLabel ?bnwdLabel # ?s ?prop ?qual_prop


WHERE {   
WHERE {   
Line 266: Line 230:


       ?prop wikibase:claim ?p;       
       ?prop wikibase:claim ?p;       
         wikibase:statementProperty ?ps
         wikibase:statementProperty ?ps.     
        wikibase:statementValue ?psv;
        wikibase:propertyType ?prop_type.     
      
      
       # to get both q35 and q29  
       # to get both q35 and q29  
       { ?s ?ps bnwd:Q35 . }  union { ?s ?ps bnwd:Q29 . }
       { ?s ?ps bnwd:Q35 . }  union { ?s ?ps bnwd:Q29 . }
       ?s ?ps ?rai.
       ?s ?ps ?bnwd.


       # qualifiers.  
       # qualifiers.  
       optional {  
       optional {  
         ?s ?pq ?pq_value .   
         ?s ?pq ?qual_value .   
          
          
         ?qual_prop wikibase:qualifier ?pq .   
         ?qual_prop wikibase:qualifier ?pq .   
        ?qual_prop rdfs:label ?qual_prop_label. filter(lang(?qual_prop_label)="en-gb") .
        ?qual_prop wikibase:propertyType ?qual_prop_type .
          
          
       } # /qualifiers
       } # /qualifiers


   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }  
}
}
ORDER BY ?personLabel
ORDER BY ?personLabel
Line 295: Line 255:
#title: FSAs with no record of interacting with SAL in Q1 / Q8
#title: FSAs with no record of interacting with SAL in Q1 / Q8
# only active engagements like spoke at, corresponded with, etc, and excluding P75 "was fellow of" and P5 "archives at".
# only active engagements like spoke at, corresponded with, etc, and excluding P75 "was fellow of" and P5 "archives at".
# WIP: to update with other SAL records as I work through queries for them. Plus caveat that there may be other sources of interaction not recorded in the database!
# CAVEATS: I think this is not working as intended and it shouldn't be referenced or archived


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 343: Line 303:
#title: RAIs with no record of interacting with RAI in Q29/Q35
#title: RAIs with no record of interacting with RAI in Q29/Q35
# only active engagements like spoke at, corresponded with, etc, and excluding P67 "was member of"  
# only active engagements like spoke at, corresponded with, etc, and excluding P67 "was member of"  
# WIP: to update with other RAI records as I work through queries for them. Plus caveat that there may be other sources of interaction not recorded in the database.
# CAVEATS: I think this may not be working as intended and it shouldn't be referenced or archived in its current state


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 454: 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 ?work_label ?positionLabel ?date_label ?date  
SELECT distinct ?personLabel ?workLabel ?positionLabel ?date_pLabel ?date  
?employerLabel ?organisedLabel ?ofLabel  
?employerLabel ?organisedLabel ?ofLabel ?person
?s ?person ?work ?position ?employer ?organised ?of
#?s ?position  ?of  ?work ?employer ?organised


WHERE {
WHERE {
Line 466: Line 426:
    
    
   ?person ?work_p ?s . # for activity type label
   ?person ?work_p ?s . # for activity type label
   ?work wikibase:claim ?work_p;     
   ?work wikibase:claim ?work_p .   
        rdfs:label ?work_label. filter(lang(?work_label)="en-gb") .   
      
      
     # more about the position
     # more about the position
Line 483: Line 442:
     ?s ?pq ?date .  
     ?s ?pq ?date .  
        
        
       ?qual_prop wikibase:qualifier ?pq;       
       ?date_p wikibase:qualifier ?pq;       
               #wikibase:propertyType ?date_prop_type; # can check date property types if needed
               #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.
               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.
               #rdfs:label ?date_label . filter(lang(?date_label)="en-gb") . # what kind of date is it.
       } # /dates
       } # /dates
    
    
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }  
    
    
} # /where
} # /where
Line 554: Line 513:
</sparql>
</sparql>


 
=== Lecturers ===
== Professional Activities and Organisations ==
 
=== Women's service on committees etc (P102) ===


<sparql tryit="1">
<sparql tryit="1">
 
#title:lecturers
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 568: Line 524:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpsv: <https://beyond-notability.wikibase.cloud/prop/statement/value/>
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>


SELECT distinct ?personLabel ?serviceLabel ?qual_propLabel  ?qualLabel  ?service ?qual ?person #?s
SELECT distinct ?person ?personLabel ?positionLabel
WHERE {
?organisedLabel ?ofLabel
   ?person bnwdt:P3 bnwd:Q3 . # select women
?qual_propLabel ?qualLabel
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
#?position ?of  ?work ?organised ?date_precision ?qual_prop ?date ?qual ?workLabel
 
?s
   ?person bnp:P102 ?s .  # served on P102
 
   ?person ?p ?s .   # for claim
WHERE {
   
   ?person bnwdt:P3 bnwd:Q3 . # women
    
  # work activities: held position / held position (free text) /  employed as
   #?person ( bnp:P17|bnp:P48|bnp:P105 ) ?s .
    
   ?person ?work_p ?s . # for activity type label
    ?work wikibase:claim ?work_p . 
 
    ?s ?bnps ?position . 
    # freelance and extension lecturing (q701 and q3021)
    { ?s ?bnps bnwd:Q701  . } union { ?s ?bnps bnwd:Q3021 .  }
    
    
  ?claim wikibase:claim ?p;     
    # employer / organised by / of (incl free text).
        wikibase:statementProperty ?ps;
    OPTIONAL { ?s bnpq:P109 ?organised .}
        wikibase:propertyType ?prop_type.  
    OPTIONAL { ?s ( bnpq:P78 | bnpq:P66 ) ?of .}
  # optional { ?s bnpq:P2 ?location . } # do locations separately.
      
      
    ?s ?ps ?service . # service on what
  # dates with precision
   
#  optional {
  optional { #qualifiers, if any
#    ?s (bnpqv:P1 | bnpqv:P27 | bnpqv:P28  ) ?pqv.
    ?s ?pq ?qual .    
  #     ?s ?pqq ?pqv . # just gets the uri but doesnt seem to cause dups
        ?qual_prop wikibase:qualifier ?pq.    
#        ?pqv wikibase:timeValue ?date .
        SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en".  
#        ?pqv wikibase:timePrecision ?date_precision .
        ?qual_prop rdfs:label ?qual_propLabel # what kind of thing
#    }
        } # /label service
     
       } # /quals
    # qualifiers
 
    optional {
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb, en". }  
      ?s ?pq ?qual .  
}
        ?qual_prop wikibase:qualifier ?pq .   
     
       } # /dates
 
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }  
 
} # /where


ORDER BY ?personLabel ?s
ORDER BY ?person ?s
</sparql>
</sparql>


=== Women's service: information about "of" qualifier, including alternatives for locations===
=== Excavations ===


<sparql tryit="1">
<sparql tryit="1">
#title: query for served on "of" info
#title:BN excavations
# where a women served on committee *of* organisation, need to link to info about the organisation, including location.
# geo data for the location may be in its BN page but is more likely to need to be fetched from wikidata
# todo: check whether there are orgs that don't have location info in BN but do have it in wikidata
 
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 613: Line 587:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


SELECT distinct ?personLabel ?serviceLabel ?of ?ofLabel ?of_location ?of_locationLabel ?of_geo ?of_long ?of_lat ?person #?s
SELECT ?excavationLabel ?excavation ?locationLabel ?start ?end ?pit
?partLabel ?funderLabel ?organisedLabel ?facilitatedLabel ?directorLabel ?memberLabel
# ?member ?director  ?location ?part ?funder ?facilitated ?organised


WHERE {   
WHERE {   
  ?person bnwdt:P3 bnwd:Q3 . # select women
  # instance of excavation  128
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .}
  ?excavation bnwdt:P12 bnwd:Q38 .
    
    
  ?person  bnp:P102 ?s . 
     optional { ?excavation bnwdt:P2 ?location .}
    ?s bnps:P102 ?service .
     ?s bnpq:P78 ?of .
    
    
      #optional { ?of bnwdt:P117 ?of_wikidata. }   #todo
    optional { ?excavation bnwdt:P27 ?start . }  


      optional { ?of bnwdt:P2 ?of_location.  
    optional { ?excavation bnwdt:P28 ?end . }


            optional { ?of_location bnwdt:P153 ?bn_of_geo . }
    optional { ?excavation bnwdt:P1 ?pit. }
 
    optional { ?excavation bnwdt:P4 ?part . }
 
    optional { ?excavation bnwdt:P36 ?director . } 
 
    optional { ?excavation bnwdt:P37 ?member . }
 
    optional { ?excavation bnwdt:P109 ?organised .}
 
    optional { ?excavation bnwdt:P121 ?facilitated . }  


            optional { ?of_location bnwdt:P117 ?wd_of_loc .
    optional { ?excavation bnwdt:P145 ?funder . }
                            bind(iri(concat("http://www.wikidata.org/entity/", str(?wd_of_loc))) as ?wd_of_loc_url) .
 
                           
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }  
                        SERVICE <https://query.wikidata.org/sparql> {
}
                        optional {?wd_of_loc_url wdt:P625 ?wd_of_geo .}   # wikidata geocoords
                        } # /wikidata service 
                    } #/optional location wikidata
              } #/optional P2 location.


      BIND(COALESCE(?bn_of_geo, ?wd_of_geo) AS ?of_geo).  # if we have bn_geo use that, then try wd_geo
ORDER BY ?excavationLabel
 
      BIND(geof:longitude(?of_geo) AS ?of_long)
      BIND(geof:latitude(?of_geo)  AS ?of_lat)
 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb, en". }
}
ORDER BY ?personLabel ?s
</sparql>
</sparql>


== Professional Activities and Organisations ==


=== All activities for women that have instance of public and professional activities===
=== Women's service on committees etc (P102) ===


<sparql tryit="1">
<sparql tryit="1">
#title:women and PPA
 
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 661: Line 635:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


SELECT ?person ?personLabel ?ppa_label ?ppa ?ppa_valueLabel ?ppa_value ?s  
 
SELECT distinct ?personLabel ?serviceLabel ?qual_propLabel  ?qualLabel  ?qual ?person ?s # ?service
WHERE {   
WHERE {   
   ?person bnwdt:P3 bnwd:Q3 .
   ?person bnwdt:P3 bnwd:Q3 . # select women
   ?person ?p ?s .
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
   
 
      ?ppa wikibase:claim ?p;      
  ?person bnp:P102 ?s .   # served on P102
        wikibase:statementProperty ?ps.       
    ?s bnps:P102 ?service .
         
   
      SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb".  
  optional { #qualifiers, if any
                ?ppa rdfs:label ?ppa_label.
    ?s ?pq ?qual .      
            } # /label service
        ?qual_prop wikibase:qualifier ?pq.       
 
      } # /quals
      ?ppa bnwdt:P12 bnwd:Q151 . # instance of PPA     
 
     
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb, en". }
      # get a bit of detail about the ppa
}
      ?s ?ps ?ppa_value.


  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }
ORDER BY ?personLabel ?s
}


order by ?personLabel ?ppa_label
</sparql>
</sparql>


=== Women corresponding with individuals ===


===Counts of PPAs for women===
<sparql tryit="1">
<sparql tryit="1">
#title:counting women's instance of PPA
#title:women corresponding with individuals
 
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 696: Line 669:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


SELECT  ?ppa_label ?ppa (count(?ppa) as ?count)
select ?person ?personLabel ?correspondent ?correspondentLabel ?qualifier_label
WHERE {
?qualifier ?qualifierLabel
 
where
{
   ?person bnwdt:P3 bnwd:Q3 .
   ?person bnwdt:P3 bnwd:Q3 .
   ?person ?p ?s .   
 
   
   ?person bnp:P73 ?s .
       ?ppa wikibase:claim ?p;     
    ?s bnps:P73 ?correspondent . # corresponded with  
        wikibase:statementProperty ?ps.    
    ?correspondent bnwdt:P12 bnwd:Q2137 . # correspondent is i/o human
         
 
      SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb".  
    optional
                      ?ppa rdfs:label ?ppa_label.       # what kind of thing
       { ?s ?qual_p ?qualifier .  
                } # /label service
        ?qual_prop wikibase:qualifier ?qual_p.
        ?qual_prop rdfs:label ?qualifier_label. filter(lang(?qualifier_label)='en') .
      }
    
    
      ?ppa bnwdt:P12 bnwd:Q151 . # ahhhh at last     
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
     
      # get stuff about ?s
      #?s ?ps ?ppa_value.
 
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
}
}
group by ?ppa_label ?ppa


order by desc(?count)
ORDER BY ?person
</sparql>
</sparql>


==Place==
=== Women's service: information about "of" qualifier, including alternatives for locations===
 
===People not in London linked as a graph by a NUTS region or country (excluding England) at which they were once resident in the UK===


<sparql tryit="1">
<sparql tryit="1">
# People not in London linked as a graph by a NUTS region or country (excluding England) at which they were once resident in the UK
#title: query for served on "of" info
# where a women served on committee *of* organisation, need to link to info about the organisation, including location.
# geo data for the location may be in its BN page but is more likely to need to be fetched from wikidata
# todo: check whether there are orgs that don't have location info in BN but do have it in wikidata


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 735: Line 708:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


#defaultView:Graph
SELECT distinct ?personLabel ?serviceLabel ?of ?ofLabel ?of_location ?of_locationLabel ?of_geo ?of_long ?of_lat ?person #?s
SELECT ?resident ?residentLabel ?region ?regionLabel
 
WHERE {   
WHERE {   
   ?resident bnwdt:P29 ?residence .
   ?person bnwdt:P3 bnwd:Q3 . # select women
    FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q2035 .}
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .}  
    FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q2036 .}
 
    FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q2037 .}
  ?person  bnp:P102 ?s .  
    FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q2038 .}
     ?s bnps:P102 ?service .
    FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q2039 .}
     ?s bnpq:P78 ?of .
    FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q2040 .}
    
    FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q2041 .}
      #optional { ?of bnwdt:P117 ?of_wikidata. }   #todo
     FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q2042 .}
    FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q39.}
     FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q2534.}
  ?residence bnwdt:P33 ?district .
   ?district bnwdt:P33 ?county .
  ?county bnwdt:P33 ?region .
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }
}
</sparql>


===People whose residence was at one time in the east or south east of England, excluding London===
      optional { ?of bnwdt:P2 ?of_location.
 
            optional { ?of_location bnwdt:P153 ?bn_of_geo . }
 
            optional { ?of_location bnwdt:P117 ?wd_of_loc .
                            bind(iri(concat("http://www.wikidata.org/entity/", str(?wd_of_loc))) as ?wd_of_loc_url) .
                           
                        SERVICE <https://query.wikidata.org/sparql> {
                        optional {?wd_of_loc_url wdt:P625 ?wd_of_geo .}  # wikidata geocoords
                        } # /wikidata service 
                    } #/optional location wikidata
              } #/optional P2 location.
 
      BIND(COALESCE(?bn_of_geo, ?wd_of_geo) AS ?of_geo).  # if we have bn_geo use that, then try wd_geo
 
      BIND(geof:longitude(?of_geo) AS ?of_long)
      BIND(geof:latitude(?of_geo)  AS ?of_lat)
 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb, en". }
}
ORDER BY ?personLabel ?s
</sparql>
 
 
=== All activities for women that have instance of public and professional activities===


<sparql tryit="1">
<sparql tryit="1">
#title:women and PPA
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 767: Line 756:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


SELECT ?resident ?residentLabel ?residenceLabel ?districtLabel ?countyLabel ?regionLabel
SELECT ?person ?personLabel ?ppa_label ?ppa ?ppa_valueLabel ?ppa_value ?s
WHERE {   
WHERE {   
   ?resident bnwdt:P29 ?residence .
   ?person bnwdt:P3 bnwd:Q3 .
   ?residence bnwdt:P33 ?district .
   ?person ?p ?s .
  ?district bnwdt:P33 ?county .
  ?county bnwdt:P33 ?region .
      ?ppa wikibase:claim ?p;     
    {?county bnwdt:P33 bnwd:Q67 .}
        wikibase:statementProperty ?ps.    
    UNION
         
    {?county bnwdt:P33 bnwd:Q85 .}
      SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb".
                ?ppa rdfs:label ?ppa_label.
            } # /label service
 
      ?ppa bnwdt:P12 bnwd:Q151 . # instance of PPA     
     
      # get a bit of detail about the ppa
      ?s ?ps ?ppa_value.
 
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
}
}
ORDER BY ?regionLabel ?countyLabel ?districtLabel ?residenceLabel
 
order by ?personLabel ?ppa_label
</sparql>
</sparql>


===People whose residence was at one time in North East England or Yorkshire and the Humber===


===Counts of PPAs for women===
<sparql tryit="1">
<sparql tryit="1">
# People whose residence was at one time in North East England or Yorkshire and the Humber
#title:counting women's instance of PPA
 
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 794: Line 791:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


SELECT ?resident ?residentLabel ?residenceLabel ?districtLabel ?countyLabel ?regionLabel
SELECT ?ppa_label ?ppa  (count(?ppa) as ?count)
WHERE {   
WHERE {   
   ?resident bnwdt:P29 ?residence .
   ?person bnwdt:P3 bnwd:Q3 .
   ?residence bnwdt:P33 ?district .
   ?person ?p ?s .
  ?district bnwdt:P33 ?county .
  ?county bnwdt:P33 ?region .
      ?ppa wikibase:claim ?p;     
    {?county bnwdt:P33 bnwd:Q72 .}
        wikibase:statementProperty ?ps.    
    UNION
         
    {?county bnwdt:P33 bnwd:Q200 .}
      SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb".
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
                      ?ppa rdfs:label ?ppa_label.       # what kind of thing
}
                } # /label service
ORDER BY ?regionLabel ?countyLabel ?districtLabel ?residenceLabel
 
      ?ppa bnwdt:P12 bnwd:Q151 . # ahhhh at last     
     
      # get stuff about ?s
      #?s ?ps ?ppa_value.
 
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
}
group by ?ppa_label ?ppa
 
order by desc(?count)
</sparql>
</sparql>


===People not in London with the district, county, and region at which they were once resident (in the UK) listed===
=== PPA Buckets for Women ===


<sparql tryit="1">
<sparql tryit="1">
# People not in London with the district, county, and region at which they were once resident (in the UK) listed
#title:ppa buckets (revised February 2024)
# broad PPA grouping categories to use for overviews and analysis within categories


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 821: Line 829:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


SELECT ?resident ?residentLabel ?district ?districtLabel ?county ?countyLabel ?region ?regionLabel
SELECT distinct ?person ?personLabel ?ppa_label ?ppa ?bucket
?ppa_value ?ppa_valueLabel
?s
WHERE {   
WHERE {   
   ?resident bnwdt:P29 ?residence .
   ?person bnwdt:P3 bnwd:Q3 .
    FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q2035 .}
  ?person ?p ?s .
    FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q2036 .}
    FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q2037 .}
      ?ppa wikibase:claim ?p;     
    FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q2038 .}
        wikibase:statementProperty ?ps.   
    FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q2039 .}
 
    FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q2040 .}
      # note: i think you need rdfs:label (*Label won't work) for the bind()
    FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q2041 .}
    FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q2042 .}
    FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q39.}
    FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q2534.}
   ?residence bnwdt:P33 ?district .
  ?district bnwdt:P33 ?county .
  ?county bnwdt:P33 ?region .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }
}
ORDER BY ?regionLabel ?countyLabel ?districtLabel ?residentLabel
</sparql>


===People sorted by the number of places they lived, including the number of cites/towns/villages they lived in===
      SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb".
                      ?ppa rdfs:label ?ppa_label.
                } # /label service
 
      ?ppa bnwdt:P12 bnwd:Q151 . # i/o ppa     
      # get stuff about ?s
      ?s ?ps ?ppa_value.
 
    # note: it would be possible to write this to use ppa rather than ppa_label. there's a slight risk that property names might change.
    # BUT then it would be much more opaque and difficult to edit if (when!) we make any changes to the buckets.
    bind(
      if( str(?ppa_label) in ("attended", "exhibited at", "organiser of", "performed at", "spoke at", "was delegate at (free text)", "was delegate at (item)" ), "events",
        if( str(?ppa_label) in ("curated (item)", "donor to", "loaner to", "recovered (free text)", "seller to", "was collector of", "was donor of" ), "collections",
          if( str(?ppa_label) in ("educated at"),  "education" ,
            if( str(?ppa_label) in ("election to Council of CAS proposed by", "election to RAI proposed by", "election to SAL proposed by", "proposed election to RHS signed by (personal)"),  "elections" ,
              if( str(?ppa_label) in ("Member of Committee for Archaeological Fieldwork", "President of Committee for Archaeological Fieldwork", "director of archaeological fieldwork", "director of expedition", "member of excavation during archaeological fieldwork", "member of expedition", "travelled overseas for"
),  "fieldwork" ,
                if( str(?ppa_label) in ("acknowledged for role", "applicant to", "employed as", "held position", "held position (free text)", "served on"),  "positions" ,
                  if( str(?ppa_label) in ("contributed to", "illustrated in", "work(s) published in"),  "publishing",
                    if( str(?ppa_label) in ("corresponded with", "was fellow of", "was member of"),  "societies",
                      if( str(?ppa_label) in ("benefactor to", "fundraiser for", "founded"),  "charitable" ,
      "none")))))))))
    as ?bucket).
       


<sparql tryit="1">
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
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 ?person ?personLabel (count(?resided) as ?residence_count) (count(distinct ?resided) as ?residence_distinct) WHERE {
order by ?personLabel ?ppa_label
  ?person bnwdt:P3 bnwd:Q3 ;
        wikibase:statements ?statements .
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
  ?person bnp:P29/bnps:P29 ?resided.
  SERVICE wikibase:label {
      bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb".
  }
} group by ?person ?personLabel ?statements order by desc(?residence_count)
# Credit to @Tagishsimon for helping me figure out the counting logic here
</sparql>
</sparql>


===Places at which women resided, sorted by how many residences all women had at a given village/town/city/London area===
=== Suffrage-related activities ===


<sparql tryit="1">
<sparql tryit="1">
# Places at which women resided, sorted by how many residences all women had at a given village/town/city/London area
#title:initial query for suffrage activities


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 878: Line 886:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


SELECT ?residence ?residenceLabel (count(?residence) as ?residence_count) #count number of places at which women lived
SELECT distinct ?person ?personLabel ?mainLabel ?sub_Label ?qualLabel ?locationLabel ?date
# ?pq ?sub_ ?qual ?main
?s
 
WHERE {   
WHERE {   
  ?person bnwdt:P3 bnwd:Q3 . # select women
 
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
    ?person bnwdt:P3 bnwd:Q3 . #select women
   ?person bnwdt:P29 ?residence . # select residences
    FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
 
    ?person ?p ?s .
    
      ?s ?sub ?sub_ .
        ?main wikibase:claim ?p.
        ?main wikibase:statementProperty ?sub. 
 
  # sub_ i/o - some do have suffrage activity
  #  optional { ?sub_ bnwdt:P12 ?sub_io . ?sub_ bnwdt:P12 bnwd:Q1166 . }
 
  # union
  {
    # a qualifier (anywhere) has i/o suffrage activity
      ?s bnpq:P12 bnwd:Q1166.
    }
 
# 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  ... slows things right down and doesn't seem to make any difference to results?
    #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 .
 
      } # /union
 
  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:P78 ?of. # outside the union seems much speedier
 
  optional { ?s bnpq:P2 ?location . }
 
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
 
}
}
GROUP BY ?residence ?residenceLabel
order by ?personLabel ?mainLabel
ORDER BY DESC(?residence_count)
</sparql>
</sparql>


===Districts in which women resided, sorted by how many residences all women had in that district (or equivalent sub-level for non-UK residences)===
==Place==
 
=== All the things in BN that can be mapped ===


<sparql tryit="1">
<sparql tryit="1">
# Districts in which women resided, sorted by how many residences all women had in that district (or equivalent sub-level for non-UK residences)
#title:map of BN locations using wikidata P625
 
#defaultView:Map
#this will take a little while to run...
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 902: Line 960:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


SELECT ?district ?districtLabel (count(?district) as ?district_count) #count number of districts in which women lived
SELECT distinct ?locationLabel ?location ?wikidata ?wd_geo
 
WHERE {   
WHERE {   
   ?person bnwdt:P3 bnwd:Q3 . # select women
    
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
      ?location bnwdt:P117 ?ws . # wikidata id       
  ?person bnwdt:P29 ?residence . # select residences
       
   ?residence bnwdt:P33 ?district . #select districts
        bind(iri(concat("http://www.wikidata.org/entity/", str(?ws))) as ?wikidata) .
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
        SERVICE <https://query.wikidata.org/sparql> {
            ?wikidata wdt:P625 ?wd_geo . # does the wikidata page have geocoords?
        } # /wikidata service 
    
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }  
}
}
GROUP BY ?district ?districtLabel
ORDER BY ?wikidata ?locationLabel
ORDER BY DESC(?district_count)
</sparql>
</sparql>


===Counties in which women resided, sorted by how many residences all women had in that county===
===People not in London linked as a graph by a NUTS region or country (excluding England) at which they were once resident in the UK===


<sparql tryit="1">
<sparql tryit="1">
# Counties in which women resided, sorted by how many residences all women had in that county
# People not in London linked as a graph by a NUTS region or country (excluding England) at which they were once resident in the UK


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 927: Line 989:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


SELECT ?county ?countyLabel (count(?county) as ?county_count) #count number of counties in which women lived
#defaultView:Graph
SELECT ?resident ?residentLabel ?region ?regionLabel
WHERE {   
WHERE {   
   ?person bnwdt:P3 bnwd:Q3 . # select women
   ?resident bnwdt:P29 ?residence .
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
    FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q2035 .}
  ?person bnwdt:P29 ?residence . # select residences
    FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q2036 .}
   ?residence bnwdt:P33 ?district . #select districts
    FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q2037 .}
   ?district bnwdt:P33 ?county . #select counties
    FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q2038 .}
    FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q2039 .}
    FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q2040 .}
    FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q2041 .}
    FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q2042 .}
    FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q39.}
    FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q2534.}
   ?residence bnwdt:P33 ?district .
   ?district bnwdt:P33 ?county .
  ?county bnwdt:P33 ?region .
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
}
}
GROUP BY ?county ?countyLabel
ORDER BY DESC(?county_count)
</sparql>
</sparql>


====Counties of residence for women recorded in CAS Indexes of Archaeological Papers, sorted by how many residences all women had in that county====
===People whose residence was at one time in the east or south east of England, excluding London===


<sparql tryit="1">
<sparql tryit="1">
# Counties of residence for women recorded in CAS Indexes of Archaeological Papers, sorted by how many residences all women had in that county
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 953: Line 1,021:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


SELECT ?county ?countyLabel (count(?county) as ?county_count) #count number of counties in which women lived
SELECT ?resident ?residentLabel ?residenceLabel ?districtLabel ?countyLabel ?regionLabel
WHERE {   
WHERE {   
   ?person bnwdt:P3 bnwd:Q3 . # select women
   ?resident bnwdt:P29 ?residence .
   ?person bnwdt:P76 bnwd:Q419 . #select women recorded in CAS Indexes of Archaeological Papers
   ?residence bnwdt:P33 ?district .
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
   ?district bnwdt:P33 ?county .
   ?person bnwdt:P29 ?residence . # select residences
   ?county bnwdt:P33 ?region .
  ?residence bnwdt:P33 ?district . #select districts
    {?county bnwdt:P33 bnwd:Q67 .}
  ?district bnwdt:P33 ?county . #select counties
    UNION
    {?county bnwdt:P33 bnwd:Q85 .}
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
}
}
GROUP BY ?county ?countyLabel
ORDER BY ?regionLabel ?countyLabel ?districtLabel ?residenceLabel
ORDER BY DESC(?county_count)
</sparql>
</sparql>


====Counties of residence for women nominated as FSAs, sorted by how many residences all women had in that county====
===People whose residence was at one time in North East England or Yorkshire and the Humber===


<sparql tryit="1">
<sparql tryit="1">
# Counties of residence for women nominated as FSAs, sorted by how many residences all women had in that county
# People whose residence was at one time in North East England or Yorkshire and the Humber


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 980: Line 1,048:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


SELECT ?county ?countyLabel (count(?county) as ?county_count) #count number of counties in which women lived
SELECT ?resident ?residentLabel ?residenceLabel ?districtLabel ?countyLabel ?regionLabel
WHERE {   
WHERE {   
   ?person bnwdt:P3 bnwd:Q3 . # select women
   ?resident bnwdt:P29 ?residence .
   ?person bnwdt:P16 ?signatory . #select women who were nominated for election to FSA
   ?residence bnwdt:P33 ?district .
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
   ?district bnwdt:P33 ?county .
   ?person bnwdt:P29 ?residence . # select residences
   ?county bnwdt:P33 ?region .
  ?residence bnwdt:P33 ?district . #select districts
    {?county bnwdt:P33 bnwd:Q72 .}
  ?district bnwdt:P33 ?county . #select counties
    UNION
    {?county bnwdt:P33 bnwd:Q200 .}
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
}
}
GROUP BY ?county ?countyLabel
ORDER BY ?regionLabel ?countyLabel ?districtLabel ?residenceLabel
ORDER BY DESC(?county_count)
</sparql>
</sparql>


====Counties of residence for women nominated to RAI, sorted by how many residences all women had in that county====
===People not in London with the district, county, and region at which they were once resident (in the UK) listed===


<sparql tryit="1">
<sparql tryit="1">
# Counties of residence for women nominated to RAI, sorted by how many residences all women had in that county
# People not in London with the district, county, and region at which they were once resident (in the UK) listed


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 1,007: Line 1,075:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


SELECT ?county ?countyLabel (count(?county) as ?county_count) #count number of counties in which women lived
SELECT ?resident ?residentLabel ?district ?districtLabel ?county ?countyLabel ?region ?regionLabel
WHERE {   
WHERE {   
   ?person bnwdt:P3 bnwd:Q3 . # select women
   ?resident bnwdt:P29 ?residence .
  ?person bnwdt:P7 ?signatory . #select women who were nominated for election to RAI
    FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q2035 .}
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
    FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q2036 .}
  ?person bnwdt:P29 ?residence . # select residences
    FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q2037 .}
   ?residence bnwdt:P33 ?district . #select districts
    FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q2038 .}
   ?district bnwdt:P33 ?county . #select counties
    FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q2039 .}
    FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q2040 .}
    FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q2041 .}
    FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q2042 .}
    FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q39.}
    FILTER NOT EXISTS {?resident bnwdt:P29 bnwd:Q2534.}
   ?residence bnwdt:P33 ?district .
   ?district bnwdt:P33 ?county .
  ?county bnwdt:P33 ?region .
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
}
}
GROUP BY ?county ?countyLabel
ORDER BY ?regionLabel ?countyLabel ?districtLabel ?residentLabel
ORDER BY DESC(?county_count)
</sparql>
</sparql>


====Counties of residence for women who spoke at RAI meetings, sorted by how many residences all women had in that county====
===People sorted by the number of places they lived, including the number of cites/towns/villages they lived in===


<sparql tryit="1">
<sparql tryit="1">
# Counties of residence for women who spoke at RAI meetings, sorted by how many residences all women had in that county
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 1,034: Line 1,107:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


SELECT ?county ?countyLabel (count(?county) as ?county_count) #count number of counties in which women lived
SELECT ?person ?personLabel (count(?resided) as ?residence_count) (count(distinct ?resided) as ?residence_distinct) WHERE {
WHERE {
  ?person bnwdt:P3 bnwd:Q3 ;
  ?person bnwdt:P3 bnwd:Q3 . # select women
        wikibase:statements ?statements .
  ?person bnwdt:P23 bnwd:Q29 . #select women who spoke at RAI Meeting
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
   ?person bnwdt:P29 ?residence . # select residences
   ?person bnp:P29/bnps:P29 ?resided.
  ?residence bnwdt:P33 ?district . #select districts
   SERVICE wikibase:label {
  ?district bnwdt:P33 ?county . #select counties
      bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb".
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
  }
}
} group by ?person ?personLabel ?statements order by desc(?residence_count)
GROUP BY ?county ?countyLabel
# Credit to @Tagishsimon for helping me figure out the counting logic here
ORDER BY DESC(?county_count)
</sparql>
</sparql>


====Counties of residence for women who exhibited at RAI meetings, sorted by how many residences all women had in that county====
===Places at which women resided, sorted by how many residences all women had at a given village/town/city/London area===


<sparql tryit="1">
<sparql tryit="1">
# Counties of residence for women who exhibited at RAI meetings, sorted by how many residences all women had in that county
# Places at which women resided, sorted by how many residences all women had at a given village/town/city/London area


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 1,061: Line 1,132:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


SELECT ?county ?countyLabel (count(?county) as ?county_count) #count number of counties in which women lived  
SELECT ?residence ?residenceLabel (count(?residence) as ?residence_count) #count number of places at which women lived  
WHERE {   
WHERE {   
   ?person bnwdt:P3 bnwd:Q3 . # select women
   ?person bnwdt:P3 bnwd:Q3 . # select women
  ?person bnwdt:P13 bnwd:Q29 . #select women who exhibited at RAI Meeting
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
   ?person bnwdt:P29 ?residence . # select residences
   ?person bnwdt:P29 ?residence . # select residences
  ?residence bnwdt:P33 ?district . #select districts
  ?district bnwdt:P33 ?county . #select counties
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
}
}
GROUP BY ?county ?countyLabel
GROUP BY ?residence ?residenceLabel
ORDER BY DESC(?county_count)
ORDER BY DESC(?residence_count)
</sparql>
</sparql>


====Counties of residence for women recorded in CAS Indexes of Archaeological Papers, on a map====
===Districts in which women resided, sorted by how many residences all women had in that district (or equivalent sub-level for non-UK residences)===


<sparql tryit="1">
<sparql tryit="1">
# Districts in which women resided, sorted by how many residences all women had in that district (or equivalent sub-level for non-UK residences)


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 1,087: Line 1,156:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


#defaultView:Map{"hide":["?geo", "?wikidata"]}
SELECT ?district ?districtLabel (count(?district) as ?district_count) #count number of districts in which women lived
#title:Counties of residence for women recorded in CAS Indexes of Archaeological Papers
 
SELECT distinct ?person ?personLabel ?county ?countyLabel ?wikidata ?geo 
WHERE {   
WHERE {   
   ?person bnwdt:P3 bnwd:Q3 . # select women
   ?person bnwdt:P3 bnwd:Q3 . # select women
  ?person bnwdt:P76 bnwd:Q419 . #select women recorded in CAS Indexes of Archaeological Papers
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
   ?person bnwdt:P29 ?residence . # select residences
   ?person bnwdt:P29 ?residence . # select residences
   ?residence bnwdt:P33 ?district . #select districts
   ?residence bnwdt:P33 ?district . #select districts
  ?district bnwdt:P33 ?county . #select counties
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
      optional { ?county bnwdt:P153 ?geo2 .  } # for geocoords added to BN
}
 
GROUP BY ?district ?districtLabel
      optional {   
ORDER BY DESC(?district_count)
      ?county bnp:P117 ?ws .  # wikidata id P117       
        ?ws bnpq:P14 ?wikidata_url .
        BIND(IRI(REPLACE(?wikidata_url, "https://www.wikidata.org/wiki/", "http://www.wikidata.org/entity/")) as ?wikidata )
 
      SERVICE <https://query.wikidata.org/sparql> {
   
        optional {
          ?wikidata wdt:P625 ?geo1 .
                  BIND(geof:longitude(?geo1) AS ?long)
                  BIND(geof:latitude(?geo1)  AS ?lat)
                } # geocoords if available     
      } # /wikidata service 
      } #/wikidata optional
 
    BIND(COALESCE(?geo1, ?geo2) AS ?geo).  # if geo1 available use that, then try geo2
 
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
}
</sparql>
</sparql>


====Counties of residence for women nominated as FSAs, on a map====
===Counties in which women resided, sorted by how many residences all women had in that county===


<sparql tryit="1">
<sparql tryit="1">
# Counties in which women resided, sorted by how many residences all women had in that county


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 1,133: Line 1,181:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


#defaultView:Map{"hide":["?geo", "?wikidata"]}
SELECT ?county ?countyLabel (count(?county) as ?county_count) #count number of counties in which women lived
#title:Counties of residence for women nominated as FSAs
 
SELECT distinct ?person ?personLabel ?county ?countyLabel ?wikidata ?geo 
WHERE {   
WHERE {   
   ?person bnwdt:P3 bnwd:Q3 . # select women
   ?person bnwdt:P3 bnwd:Q3 . # select women
  ?person bnwdt:P16 ?signatory . #select women who were nominated for election to FSA
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
   ?person bnwdt:P29 ?residence . # select residences
   ?person bnwdt:P29 ?residence . # select residences
   ?residence bnwdt:P33 ?district . #select districts
   ?residence bnwdt:P33 ?district . #select districts
   ?district bnwdt:P33 ?county . #select counties
   ?district bnwdt:P33 ?county . #select counties
      optional { ?county bnwdt:P153 ?geo2 .  } # for geocoords added to BN
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
 
}
      optional {   
GROUP BY ?county ?countyLabel
      ?county bnp:P117 ?ws .  # wikidata id P117       
ORDER BY DESC(?county_count)
        ?ws bnpq:P14 ?wikidata_url .
</sparql>
        BIND(IRI(REPLACE(?wikidata_url, "https://www.wikidata.org/wiki/", "http://www.wikidata.org/entity/")) as ?wikidata )
 
 
====Counties of residence for women recorded in CAS Indexes of Archaeological Papers, sorted by how many residences all women had in that county====
      SERVICE <https://query.wikidata.org/sparql> {
   
        optional { ?wikidata wdt:P625 ?geo1 . } # geocoords if available     
      } # /wikidata service 
      } #/wikidata optional
 
    BIND(COALESCE(?geo1, ?geo2) AS ?geo).  # if geo1 available use that, then try geo2
 
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
}
</sparql>


<sparql tryit="1">
# Counties of residence for women recorded in CAS Indexes of Archaeological Papers, sorted by how many residences all women had in that county


==== Counties of residence for women nominated to RAI, on a map ====
<sparql tryit="1">
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 1,176: Line 1,207:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


#defaultView:Map{"hide":["?geo", "?wikidata"]}
SELECT ?county ?countyLabel (count(?county) as ?county_count) #count number of counties in which women lived
#title:Counties of residence for women nominated to RAI
 
SELECT distinct ?person ?personLabel ?county ?countyLabel ?wikidata ?geo 
WHERE {   
WHERE {   
   ?person bnwdt:P3 bnwd:Q3 . # select women
   ?person bnwdt:P3 bnwd:Q3 . # select women
  ?person bnwdt:P76 bnwd:Q419 . #select women recorded in CAS Indexes of Archaeological Papers
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
  ?person bnwdt:P7 ?signatory . #select women who were nominated for election to RAI
   ?person bnwdt:P29 ?residence . # select residences
   ?person bnwdt:P29 ?residence . # select residences
   ?residence bnwdt:P33 ?district . #select districts
   ?residence bnwdt:P33 ?district . #select districts
   ?district bnwdt:P33 ?county . #select counties
   ?district bnwdt:P33 ?county . #select counties
      optional { ?county bnwdt:P153 ?geo2 . } # for geocoords added to BN
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
 
}
      optional {   
GROUP BY ?county ?countyLabel
      ?county bnp:P117 ?ws .  # wikidata id P117       
ORDER BY DESC(?county_count)
        ?ws bnpq:P14 ?wikidata_url .
</sparql>
        BIND(IRI(REPLACE(?wikidata_url, "https://www.wikidata.org/wiki/", "http://www.wikidata.org/entity/")) as ?wikidata )
 
 
====Counties of residence for women nominated as FSAs, sorted by how many residences all women had in that county====
      SERVICE <https://query.wikidata.org/sparql> {
 
   
<sparql tryit="1">
        optional { ?wikidata wdt:P625 ?geo1 . } # geocoords if available     
# Counties of residence for women nominated as FSAs, sorted by how many residences all women had in that county
      } # /wikidata service 
 
      } #/wikidata optional
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/>


    BIND(COALESCE(?geo1, ?geo2) AS ?geo). # if geo1 available use that, then try geo2
SELECT ?county ?countyLabel (count(?county) as ?county_count) #count number of counties in which women lived
    
WHERE { 
  ?person bnwdt:P3 bnwd:Q3 . # select women
  ?person bnwdt:P16 ?signatory . #select women who were nominated for election to FSA
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
  ?person bnwdt:P29 ?residence . # select residences
  ?residence bnwdt:P33 ?district . #select districts
   ?district bnwdt:P33 ?county . #select counties
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
}
}
GROUP BY ?county ?countyLabel
ORDER BY DESC(?county_count)
</sparql>
</sparql>


==== Counties of residence for women who spoke at RAI meetings, on a map====
====Counties of residence for women nominated to RAI, sorted by how many residences all women had in that county====


<sparql tryit="1">
<sparql tryit="1">
# Counties of residence for women nominated to RAI, sorted by how many residences all women had in that county
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 1,218: Line 1,261:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


#defaultView:Map{"hide":["?geo", "?wikidata"]}
SELECT ?county ?countyLabel (count(?county) as ?county_count) #count number of counties in which women lived
#title:Counties of residence for women who spoke at RAI meetings
 
SELECT distinct ?person ?personLabel ?county ?countyLabel ?wikidata ?geo 
WHERE {   
WHERE {   
   ?person bnwdt:P3 bnwd:Q3 . # select women
   ?person bnwdt:P3 bnwd:Q3 . # select women
  ?person bnwdt:P7 ?signatory . #select women who were nominated for election to RAI
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
  ?person bnwdt:P23 bnwd:Q29 . #select women who spoke at RAI Meeting
   ?person bnwdt:P29 ?residence . # select residences
   ?person bnwdt:P29 ?residence . # select residences
   ?residence bnwdt:P33 ?district . #select districts
   ?residence bnwdt:P33 ?district . #select districts
   ?district bnwdt:P33 ?county . #select counties
   ?district bnwdt:P33 ?county . #select counties
      optional { ?county bnwdt:P153 ?geo2 .  } # for geocoords added to BN
 
      optional {   
      ?county bnp:P117 ?ws .  # wikidata id P117       
        ?ws bnpq:P14 ?wikidata_url .
        BIND(IRI(REPLACE(?wikidata_url, "https://www.wikidata.org/wiki/", "http://www.wikidata.org/entity/")) as ?wikidata )
 
      SERVICE <https://query.wikidata.org/sparql> {
   
        optional { ?wikidata wdt:P625 ?geo1 . } # geocoords if available     
      } # /wikidata service 
      } #/wikidata optional
    BIND(COALESCE(?geo1, ?geo2) AS ?geo).  # if geo1 available use that, then try geo2
 
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
}
}
 
GROUP BY ?county ?countyLabel
ORDER BY DESC(?county_count)
</sparql>
</sparql>


==== Counties of residence for women who exhibited at RAI meetings, on a map ====
====Counties of residence for women who spoke at RAI meetings, sorted by how many residences all women had in that county====


<sparql tryit="1">
<sparql tryit="1">
#title:Counties of residence for women who exhibited at RAI meetings
# Counties of residence for women who spoke at RAI meetings, sorted by how many residences all women had in that county


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 1,263: Line 1,288:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


#defaultView:Map{"hide":["?geo", "?wikidata"]}
SELECT ?county ?countyLabel (count(?county) as ?county_count) #count number of counties in which women lived
 
SELECT distinct ?person ?personLabel ?county ?countyLabel ?wikidata ?geo 
WHERE {   
WHERE {   
   ?person bnwdt:P3 bnwd:Q3 . # select women
   ?person bnwdt:P3 bnwd:Q3 . # select women
  ?person bnwdt:P23 bnwd:Q29 . #select women who spoke at RAI Meeting
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
  ?person bnwdt:P13 bnwd:Q29 . #select women who exhibited at RAI Meeting
   ?person bnwdt:P29 ?residence . # select residences
   ?person bnwdt:P29 ?residence . # select residences
   ?residence bnwdt:P33 ?district . #select districts
   ?residence bnwdt:P33 ?district . #select districts
   ?district bnwdt:P33 ?county . #select counties
   ?district bnwdt:P33 ?county . #select counties
      optional { ?county bnwdt:P153 ?geo2 .  } # for geocoords added to BN
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
 
}
      optional {   
GROUP BY ?county ?countyLabel
      ?county bnp:P117 ?ws .  # wikidata id P117       
ORDER BY DESC(?county_count)
        ?ws bnpq:P14 ?wikidata_url .
        BIND(IRI(REPLACE(?wikidata_url, "https://www.wikidata.org/wiki/", "http://www.wikidata.org/entity/")) as ?wikidata )
 
      SERVICE <https://query.wikidata.org/sparql> {
   
        optional { ?wikidata wdt:P625 ?geo1 . } # geocoords if available     
      } # /wikidata service 
      } #/wikidata optional
 
    BIND(COALESCE(?geo1, ?geo2) AS ?geo).  # if geo1 available use that, then try geo2
 
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
}
</sparql>
</sparql>


==== Counties of residence for women in any of the above five categories, mapped====
====Counties of residence for women who exhibited at RAI meetings, sorted by how many residences all women had in that county====


<sparql tryit="1">
<sparql tryit="1">
 
# Counties of residence for women who exhibited at RAI meetings, sorted by how many residences all women had in that county
## IMPORTANT: LIMITATIONS OF THE MAP
## Only the top category of activity (layer) can be seen when all are selected (the default)
## To see each layer, you need to deselect all in the layers menu (diamond shaped icon, top right corner of the map) and view one layer at a time. Unfortunately this is the only way to compare them at the moment.
## (But I'll look into how I might be able to improve on this)


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 1,310: Line 1,315:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


#title:Counties of residence for women who were nominated for election or had publications recorded or spoke/exhibited at RAI
SELECT ?county ?countyLabel (count(?county) as ?county_count) #count number of counties in which women lived
#defaultView:Map{"hide":["?geo", "?wikidata"]}
 
SELECT distinct  ?county ?countyLabel ?wikidata ?geo  ?layer  #?person ?personLabel
WHERE {   
WHERE {   
   ?person bnwdt:P3 bnwd:Q3 . # select women
   ?person bnwdt:P3 bnwd:Q3 . # select women
  ?person bnwdt:P13 bnwd:Q29 . #select women who exhibited at RAI Meeting
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
   ?person bnwdt:P29 ?residence . # select residences
  {
   ?residence bnwdt:P33 ?district . #select districts
    #women who were nominated for election to FSA | RAI
   ?district bnwdt:P33 ?county . #select counties
    ?person ( bnp:P16 | bnp:P7 ) ?stmt . 
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
  }
}
  union
GROUP BY ?county ?countyLabel
  {
ORDER BY DESC(?county_count)
    # women with publications recorded in indexes of archaeological papers
    ?person bnp:P76 ?stmt .
        ?stmt bnps:P76 bnwd:Q419 .
  }
  union
  {
    # women who spoke|exhibited at RAI Meeting
    ?person (bnp:P23 | bnp:P13) ?stmt . 
      ?stmt (bnps:P23 | bnps:P13) bnwd:Q29 .
  }
 
  # get the p labels for layers
  ?person ?p ?stmt . 
  ?claim wikibase:claim ?p;
        rdfs:label ?layer. filter(lang(?layer)="en-gb").
 
  # get geo stuff
   ?person bnwdt:P29 ?residence . # select residences
   ?residence bnwdt:P33 ?district . #select districts
   ?district bnwdt:P33 ?county . #select counties
      optional { ?county bnwdt:P153 ?geo2 .  } # for geocoords added to BN
 
      optional {   
      ?county bnp:P117 ?ws .  # wikidata id P117       
        ?ws bnpq:P14 ?wikidata_url .
        BIND(IRI(REPLACE(?wikidata_url, "https://www.wikidata.org/wiki/", "http://www.wikidata.org/entity/")) as ?wikidata )
 
      SERVICE <https://query.wikidata.org/sparql> {
        optional { ?wikidata wdt:P625 ?geo1 . } # geocoords if available     
      } # /wikidata service 
      } #/wikidata optional
 
    BIND(COALESCE(?geo1, ?geo2) AS ?geo).  # if geo1 available use it, if not try geo2
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
}
order by ?layer
</sparql>
</sparql>


===Regions in which women resided, sorted by how many residences all women had in that region===
====Counties of residence for women recorded in CAS Indexes of Archaeological Papers, on a map====


<sparql tryit="1">
<sparql tryit="1">
# Regions in which women resided, sorted by how many residences all women had in that region


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 1,375: Line 1,341:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


SELECT ?region ?regionLabel (count(?region) as ?region_count) #count number of regions in which women lived
#defaultView:Map{"hide":["?geo", "?wikidata"]}
#title:Counties of residence for women recorded in CAS Indexes of Archaeological Papers
 
SELECT distinct ?person ?personLabel ?residence ?residenceLabel ?county ?countyLabel ?wikidata ?geo 
WHERE {   
WHERE {   
   ?person bnwdt:P3 bnwd:Q3 . # select women
   ?person bnwdt:P3 bnwd:Q3 . # select women
  ?person bnwdt:P76 bnwd:Q419 . #select women recorded in CAS Indexes of Archaeological Papers
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
   ?person bnwdt:P29 ?residence . # select residences
   ?person bnwdt:P29 ?residence . # select residences
   ?residence bnwdt:P33 ?district . #select districts
 
   ?district bnwdt:P33 ?county . #select counties
   ?residence bnwdt:P33 ?district . #select p33 of residence
   ?county bnwdt:P33 ?region . #select region
   ?district bnwdt:P33 ?next . #select p33 of district, mostly counties but a few region/outside uk
   FILTER NOT EXISTS {?region bnwdt:P117 "Q145" .} #filter out UK (where UK is sub-region of NI)
    
  optional {
    # is ?next a uk region?
    ?next bnwdt:P12 bnwd:Q4207 .
    BIND(BOUND(?next) AS ?region).
    }
  optional {
    # is ?next in the UK?
    ?next bnwdt:P33* bnwd:Q1741 .
    BIND(BOUND(?next) AS ?uk).
    }
 
  # if next=q4207 uk region, then use ?district for county, ifelse in uk use ?next, else not in uk use ?district.  
  bind(
      if( bound(?region), ?district, # region first (because also uk)
        if( bound(?uk), ?next, # then rest of uk 
      ?district)) # then anything not in uk.
    as ?county).
    
    optional { ?county bnwdt:P153 ?geo2 .  } # for geocoords added to BN
 
    optional {   
      ?county bnp:P117 ?ws .  # wikidata id P117      
        ?ws bnpq:P14 ?wikidata_url .
        BIND(IRI(REPLACE(?wikidata_url, "https://www.wikidata.org/wiki/", "http://www.wikidata.org/entity/")) as ?wikidata )
 
      SERVICE <https://query.wikidata.org/sparql> {
   
        optional {
          ?wikidata wdt:P625 ?geo1 .
                  BIND(geof:longitude(?geo1) AS ?long)
                  BIND(geof:latitude(?geo1)  AS ?lat)
                } # geocoords if available     
      } # /wikidata service 
      } #/wikidata optional
 
    BIND(COALESCE(?geo1, ?geo2) AS ?geo).  # if geo1 available use that, then try geo2
 
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
}
}
GROUP BY ?region ?regionLabel
ORDER BY DESC(?region_count)
</sparql>
</sparql>


====Counties of residence for women nominated as FSAs, on a map====


=== Women living in London during the 1890s ===
<sparql tryit="1">


<sparql tryit="1">
#title:Women living in 1890s London
# Query for women living in (greater) london in the 1890s
# 1 row per person per address per date, could be reduced to 1 row per person if preferred.
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 1,405: Line 1,407:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


SELECT distinct ?personLabel ?date_label ?date ?person ?address ?address_item ?londonLabel ?geo ?long ?lat
#defaultView:Map{"hide":["?geo", "?wikidata"]}
#title:Counties of residence for women nominated as FSAs


SELECT distinct ?person ?personLabel ?county ?countyLabel ?wikidata ?geo 
WHERE {   
WHERE {   
   ?person bnwdt:P3 bnwd:Q3 . # women
   ?person bnwdt:P3 bnwd:Q3 . # select women
   ?person bnp:P29 ?s .   # resided at
   ?person bnwdt:P16 ?signatory . #select women who were nominated for election to FSA
    ?s bnps:P29 ?london .
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
      ?london bnwdt:P33+ bnwd:Q322 . # in Q322 greater london.


    # optional street address (text)
  ?person bnwdt:P29 ?residence . # select residences
   optional {
   ?residence bnwdt:P33 ?district . #select districts
    ?s bnpq:P31 ?address .
   ?district bnwdt:P33 ?county . #select counties
    }
      optional { ?county bnwdt:P153 ?geo2 . } # for geocoords added to BN
   # optional street address (item)
    
  optional {
      optional {     
    ?s bnpq:P100 ?address_item .
      ?county bnp:P117 ?ws . # wikidata id P117       
    }  
        ?ws bnpq:P14 ?wikidata_url .
 
        BIND(IRI(REPLACE(?wikidata_url, "https://www.wikidata.org/wiki/", "http://www.wikidata.org/entity/")) as ?wikidata )
   # dates. About 30? not dated.
 
    #optional {
      SERVICE <https://query.wikidata.org/sparql> {
     ?s ?pq ?date .
      
    # ?date wikibase:timeValue ?date_value. # if you don't want date label this should work instead
        optional { ?wikidata wdt:P625 ?geo1 . } # geocoords if available     
     
      } # /wikidata service 
      ?qual_prop wikibase:qualifier ?pq;
      } #/wikidata optional
              wikibase:propertyType wikibase:Time ; # nb excludes edtf dates
              rdfs:label ?date_label . filter(lang(?date_label)="en-gb") . # what kind of date is it.
     # } # /dates
 
    # filter 1890-1899 
  FILTER("1890-01-01"^^xsd:dateTime <= ?date && ?date < "1899-12-31"^^xsd:dateTime).


    BIND(COALESCE(?geo1, ?geo2) AS ?geo).  # if geo1 available use that, then try geo2
    
    
  # address geocoordinates
  optional {
    ?s ?pqq ?geo .
        ?qual_geo wikibase:qualifier ?pqq;
                  wikibase:propertyType wikibase:GlobeCoordinate.
        BIND(geof:longitude(?geo) AS ?long)
        BIND(geof:latitude(?geo)  AS ?lat)
            }
  # todo booth codes
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
}
}
ORDER BY ?person ?date
</sparql>


</sparql>


=== Where did women who published in Folklore/Folk-lore Record live? ===
==== Counties of residence for women nominated to RAI, on a map ====


<sparql tryit="1">
<sparql tryit="1">
# Map of all places of residence for women who had publications in Folklore/Folk-lore Record
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 1,465: Line 1,450:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


#defaultView:Map{"hide":["?geo", "?count"]}
#defaultView:Map{"hide":["?geo", "?wikidata"]}
#title:Counties of residence for women nominated to RAI


SELECT ?person ?personLabel ?residenceLabel ?residence ?geo (count( ?person) as ?count) #(concat(str(?count), " publication") as ?count_lbl)
SELECT distinct ?person ?personLabel ?county ?countyLabel ?wikidata ?geo   
WHERE {   
WHERE {   
   ?person bnwdt:P3 bnwd:Q3 . # select women
   ?person bnwdt:P3 bnwd:Q3 . # select women
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
   ?person bnwdt:P76 bnwd:Q419 . # people with publications listed in indexes of archaeological papers. [262]
   ?person bnwdt:P7 ?signatory . #select women who were nominated for election to RAI
   ?person bnp:P76 ?s .   
 
  ?person bnwdt:P29 ?residence . # select residences
  ?residence bnwdt:P33 ?district . #select districts
   ?district bnwdt:P33 ?county . #select counties
      optional { ?county bnwdt:P153 ?geo2 } # for geocoords added to BN
    
    
  ## works published in P101. folklore / folk-lore record q487 q490
       optional {    
      ?s bnpq:P101 ?in .
       ?county bnp:P117 ?ws .  # wikidata id P117      
      {?s bnpq:P101 bnwd:Q487 } union { ?s bnpq:P101 bnwd:Q490 . }
      # why does above pick up these two journals as well?
      FILTER ( ?in not in ( bnwd:Q665 , bnwd:Q636 ) ) .
 
  ?person bnwdt:P29  ?residence .
       optional { ?residence bnwdt:P153 ?geo2 .  } # for geocoords added to BN
 
  optional {
   
       ?residence bnp:P117 ?ws .  # wikidata id P117
           
         ?ws bnpq:P14 ?wikidata_url .
         ?ws bnpq:P14 ?wikidata_url .
         BIND(IRI(REPLACE(?wikidata_url, "https://www.wikidata.org/wiki/", "http://www.wikidata.org/entity/")) as ?wikidata )  
         BIND(IRI(REPLACE(?wikidata_url, "https://www.wikidata.org/wiki/", "http://www.wikidata.org/entity/")) as ?wikidata )  
    
    
      SERVICE <https://query.wikidata.org/sparql> {
      SERVICE <https://query.wikidata.org/sparql> {
      
      
      optional {?wikidata wdt:P625 ?geo1 . } # geocoords if available
        optional { ?wikidata wdt:P625 ?geo1 . } # geocoords if available    
        
       } # /wikidata service   
      } # /wikidata service   
      } #/wikidata optional
    } #/wikidata optional


     BIND(COALESCE(?geo1, ?geo2) AS ?geo).  # if geo1 available use that, then try geo2
     BIND(COALESCE(?geo1, ?geo2) AS ?geo).  # if geo1 available use that, then try geo2
Line 1,501: Line 1,479:
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
}
}
group by ?person ?personLabel ?residenceLabel ?residence ?geo
ORDER BY ?geo
</sparql>
</sparql>


==People==
==== Counties of residence for women who spoke at RAI meetings, on a map====
 
===Women with their family name at birth and family name after marriage===


<sparql tryit="1">
<sparql tryit="1">
# Women with their family name at birth and family name after marriage
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 1,520: Line 1,492:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


#defaultView:Map{"hide":["?geo", "?wikidata"]}
#title:Counties of residence for women who spoke at RAI meetings


SELECT ?person ?personLabel ?birthname ?marriedname
SELECT distinct ?person ?personLabel ?county ?countyLabel ?wikidata ?geo 
WHERE {   
WHERE {   
   ?person bnwdt:P3 bnwd:Q3 . #select women
   ?person bnwdt:P3 bnwd:Q3 . # select women
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
   OPTIONAL {?person bnwdt:P140 ?birthname .} #look for birth name
  ?person bnwdt:P23 bnwd:Q29 . #select women who spoke at RAI Meeting
   OPTIONAL {?person bnwdt:P141 ?marriedname .} #look for married name
 
   ?person bnwdt:P29 ?residence . # select residences
  ?residence bnwdt:P33 ?district . #select districts
  ?district bnwdt:P33 ?county . #select counties
      optional { ?county bnwdt:P153 ?geo2 . } # for geocoords added to BN
 
      optional {   
      ?county bnp:P117 ?ws .  # wikidata id P117       
        ?ws bnpq:P14 ?wikidata_url .
        BIND(IRI(REPLACE(?wikidata_url, "https://www.wikidata.org/wiki/", "http://www.wikidata.org/entity/")) as ?wikidata )
    
      SERVICE <https://query.wikidata.org/sparql> {
   
        optional { ?wikidata wdt:P625 ?geo1 . } # geocoords if available     
      } # /wikidata service 
      } #/wikidata optional
 
    BIND(COALESCE(?geo1, ?geo2) AS ?geo).  # if geo1 available use that, then try geo2
    
    
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
}
}
ORDER BY ?personLabel
 
</sparql>
</sparql>


=== Women with family name at birth, married name and count of married names===
==== Counties of residence for women who exhibited at RAI meetings, on a map ====


<sparql tryit="1">
<sparql tryit="1">
# Women with their family name at birth, family name after marriage and count of married names
#title:Counties of residence for women who exhibited at RAI meetings 


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 1,546: Line 1,537:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


SELECT ?person ?personLabel ?birthname 
#defaultView:Map{"hide":["?geo", "?wikidata"]}
        (GROUP_CONCAT(DISTINCT ?marriedname; SEPARATOR=", ") AS ?marriednames)
        (COUNT(?marriedname) AS ?marriedcount)


SELECT distinct ?person ?personLabel ?county ?countyLabel ?wikidata ?geo 
WHERE {   
WHERE {   
   ?person bnwdt:P3 bnwd:Q3 . #select women
   ?person bnwdt:P3 bnwd:Q3 . # select women
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
  ?person bnwdt:P13 bnwd:Q29 . #select women who exhibited at RAI Meeting
  ?person bnwdt:P29 ?residence . # select residences
  ?residence bnwdt:P33 ?district . #select districts
  ?district bnwdt:P33 ?county . #select counties
      optional { ?county bnwdt:P153 ?geo2 .  } # for geocoords added to BN
 
      optional {   
      ?county bnp:P117 ?ws .  # wikidata id P117       
        ?ws bnpq:P14 ?wikidata_url .
        BIND(IRI(REPLACE(?wikidata_url, "https://www.wikidata.org/wiki/", "http://www.wikidata.org/entity/")) as ?wikidata )
    
    
  OPTIONAL {?person bnwdt:P140 ?birthname .} #look for birth name
      SERVICE <https://query.wikidata.org/sparql> {
   OPTIONAL {?person bnwdt:P141 ?marriedname .} #look for married name
   
        optional { ?wikidata wdt:P625 ?geo1 . } # geocoords if available     
      } # /wikidata service    
      } #/wikidata optional
 
    BIND(COALESCE(?geo1, ?geo2) AS ?geo). # if geo1 available use that, then try geo2
    
    
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
}
}
group by ?person ?personLabel ?birthname
ORDER BY ?personLabel
</sparql>
</sparql>


===Where women in our data are in wikidata, their spouses, fathers, and mothers according to wikidata===
==== Counties of residence for women in any of the above five categories, mapped====


<sparql tryit="1">
<sparql tryit="1">
## IMPORTANT: LIMITATIONS OF THE MAP
## Only the top category of activity (layer) can be seen when all are selected (the default)
## To see each layer, you need to deselect all in the layers menu (diamond shaped icon, top right corner of the map) and view one layer at a time. Unfortunately this is the only way to compare them at the moment.
## (But I'll look into how I might be able to improve on this)
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 1,573: Line 1,583:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
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 ?item ?WD_spouse ?WD_father ?WD_mother
#title:Counties of residence for women who were nominated for election or had publications recorded or spoke/exhibited at RAI
#defaultView:Map{"hide":["?geo", "?wikidata"]}
 
SELECT distinct  ?county ?countyLabel ?wikidata ?geo  ?layer  #?person ?personLabel
WHERE {   
WHERE {   
   ?person bnwdt:P3 bnwd:Q3 . #select women
   ?person bnwdt:P3 bnwd:Q3 . # select women
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
   ?person bnp:P117 ?wikidata_ID . #look for wikidata ID on person page
   ?wikidata_ID bnpq:P14 ?wikidata_url .
   {
   BIND(IRI(REPLACE(?wikidata_url,"https://www.wikidata.org/wiki/","http://www.wikidata.org/entity/")) as ?item )
    #women who were nominated for election to FSA | RAI
    
    ?person ( bnp:P16 | bnp:P7 ) ?stmt .   
   SERVICE <https://query.wikidata.org/sparql> {
   }
        ?item wdt:P21 ?WD_gender. #get gender of person
   union
         OPTIONAL {?item wdt:P22 ?WD_father . } #recall father
   {
        OPTIONAL {?item wdt:P25 ?WD_mother . } #recall mother
    # women with publications recorded in indexes of archaeological papers
        OPTIONAL {?item wdt:P26 ?WD_spouse . } #recall spouse
    ?person bnp:P76 ?stmt .  
      }
         ?stmt bnps:P76 bnwd:Q419 .
  }
  union
  {
    # women who spoke|exhibited at RAI Meeting
    ?person (bnp:P23 | bnp:P13) ?stmt .
      ?stmt (bnps:P23 | bnps:P13) bnwd:Q29 .  
  }
    
    
  # get the p labels for layers
  ?person ?p ?stmt . 
  ?claim wikibase:claim ?p;
        rdfs:label ?layer. filter(lang(?layer)="en-gb").
 
  # get geo stuff
  ?person bnwdt:P29 ?residence . # select residences
  ?residence bnwdt:P33 ?district . #select districts
  ?district bnwdt:P33 ?county . #select counties
      optional { ?county bnwdt:P153 ?geo2 .  } # for geocoords added to BN
 
      optional {   
      ?county bnp:P117 ?ws .  # wikidata id P117       
        ?ws bnpq:P14 ?wikidata_url .
        BIND(IRI(REPLACE(?wikidata_url, "https://www.wikidata.org/wiki/", "http://www.wikidata.org/entity/")) as ?wikidata )
 
      SERVICE <https://query.wikidata.org/sparql> {
        optional { ?wikidata wdt:P625 ?geo1 . } # geocoords if available     
      } # /wikidata service 
      } #/wikidata optional
    BIND(COALESCE(?geo1, ?geo2) AS ?geo).  # if geo1 available use it, if not try geo2
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
}
}
ORDER BY ?personLabel
order by ?layer
# with thanks to @tagishsimon for writing this one initially!
</sparql>
</sparql>


===Women in our data alongside counts of their public and professional activities, sorted by total===
===Regions in which women resided, sorted by how many residences all women had in that region===


<sparql tryit="1">
<sparql tryit="1">
## Women in our data alongside counts of their public and professional activities (https://beyond-notability.wikibase.cloud/wiki/Item:Q151)
# Regions in which women resided, sorted by how many residences all women had in that region
## Sorted by total PPAs


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 1,611: Line 1,649:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


select ?person ?personLabel
SELECT ?region ?regionLabel (count(?region) as ?region_count) #count number of regions in which women lived
(count(distinct ?exhibitor) as ?exhibitions)
WHERE { 
(count(distinct ?position) as ?positions)
  ?person bnwdt:P3 bnwd:Q3 . # select women
(count(distinct ?speaker) as ?spoke)
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
(count(distinct ?attended) as ?attendance)
  ?person bnwdt:P29 ?residence . # select residences
(count(distinct ?donorof) as ?donated)
  ?residence bnwdt:P33 ?district . #select districts
(count(distinct ?wasdelegate) as ?delegate)
  ?district bnwdt:P33 ?county . #select counties
(count(distinct ?correspondent) as ?correspondents)
  ?county bnwdt:P33 ?region . #select region
(count(distinct ?fellow) as ?fellowships)
  FILTER NOT EXISTS {?region bnwdt:P117 "Q145" .} #filter out UK (where UK is sub-region of NI)
(count(distinct ?collab) as ?collaborations)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }
(count(distinct ?found) as ?founded)
}
(count(distinct ?loaned) as ?loans)
GROUP BY ?region ?regionLabel
(count(distinct ?illustrated) as ?illustrations)
ORDER BY DESC(?region_count)
(count(distinct ?sold) as ?sales)
</sparql>
(count(distinct ?served) as ?service)
 
(count(distinct ?job) as ?employed)
 
(count(distinct ?fundraiser) as ?fundraisers)
=== Women living in London during the 1890s ===
(count(distinct ?publish) as ?published)
(count(distinct ?benefact) as ?benefactor)
(count(distinct ?donor) as ?donor_to)
(count(distinct ?collect) as ?collected)
(count(distinct ?performance) as ?performances)
((?exhibitions + ?positions + ?spoke + ?attendance + ?donated + ?delegate + ?correspondents + ?fellowships + ?collaborations + ?founded + ?loans + ?illustrations + ?sales
+ ?service + ?employed + ?fundraisers + ?published + ?benefactor + ?donor_to + ?collected + ?performances) AS ?PPA_total)


where
<sparql tryit="1">
{
#title:Women living in 1890s London
  ?person bnwdt:P3 bnwd:Q3 .
# Query for women living in (greater) london in the 1890s
  optional { ?person bnp:P13 ?exhibitor }
# 1 row per person per address per date, could be reduced to 1 row per person if preferred.
  optional { ?person bnp:P17 ?position }
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
  optional { ?person bnp:P23 ?speaker }
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
  optional { ?person bnp:P24 ?attended }
PREFIX bnwdv: <https://beyond-notability.wikibase.cloud/value/>
  optional { ?person bnp:P65 ?donorof }
PREFIX bnwdt: <https://beyond-notability.wikibase.cloud/prop/direct/>
  optional { ?person bnp:P71 ?wasdelegate }
PREFIX bnp: <https://beyond-notability.wikibase.cloud/prop/>
  optional { ?person bnp:P73 ?correspondent }
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
  optional { ?person bnp:P75 ?fellow }
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
  optional { ?person bnp:P83 ?collab }
  optional { ?person bnp:P85 ?found }
  optional { ?person bnp:P87 ?loaned }
  optional { ?person bnp:P89 ?illustrated }
  optional { ?person bnp:P99 ?sold }
  optional { ?person bnp:P102 ?served }
  optional { ?person bnp:P105 ?job }
  optional { ?person bnp:P106 ?fundraiser }
  optional { ?person bnp:P107 ?publish }
  optional { ?person bnp:P110 ?benefact }
  optional { ?person bnp:P111 ?donor }
  optional { ?person bnp:P114 ?collect }
  optional { ?person bnp:P120 ?performance }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
}
group by ?person ?personLabel
ORDER BY DESC (?PPA_total)
</sparql>


===Women in our data arranged as a network graph by the organisations they were members of===
SELECT distinct ?personLabel ?date_label ?date ?person ?address ?address_item ?londonLabel ?geo ?long ?lat


<sparql tryit="1">
## Women in our data arranged as a network graph by the organisations they were members of
#defaultView:Graph
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwdt: <https://beyond-notability.wikibase.cloud/prop/direct/>
SELECT  ?org ?orgLabel ?rgb ?linkTo ?linkToLabel
WHERE {   
WHERE {   
   ?linkTo bnwdt:P3 bnwd:Q3 .                               #select women
   ?person bnwdt:P3 bnwd:Q3 . # women
   FILTER NOT EXISTS {?linkTo bnwdt:P4 bnwd:Q12 .}          #filter out project team
   ?person bnp:P29 ?s .   # resided at
  ?linkTo bnwdt:P67 ?org
    ?s bnps:P29 ?london .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en". }
      ?london bnwdt:P33+ bnwd:Q322 . # in Q322 greater london.  
  BIND( "7C4DCD" AS ?rgb ) .


}
    # optional street address (text)
ORDER BY ?personLabel
  optional {
</sparql>
    ?s bnpq:P31 ?address .
    }
  # optional street address (item)
  optional {
    ?s bnpq:P100 ?address_item .
    }   


===Membership of organisations by women, sorted by how many women were members of a given organisation===
  # dates. About 30? not dated.
    #optional {
    ?s ?pq ?date .
    # ?date wikibase:timeValue ?date_value. # if you don't want date label this should work instead
     
      ?qual_prop wikibase:qualifier ?pq;
              wikibase:propertyType wikibase:Time ; # nb excludes edtf dates
              rdfs:label ?date_label . filter(lang(?date_label)="en-gb") . # what kind of date is it.
    #  } # /dates
 
    # filter 1890-1899 
  FILTER("1890-01-01"^^xsd:dateTime <= ?date && ?date < "1899-12-31"^^xsd:dateTime).


<sparql tryit="1">
 
# Membership of organisations by women, sorted by how many women were members of a given organisation
  # address geocoordinates
  optional {
    ?s ?pqq ?geo .
        ?qual_geo wikibase:qualifier ?pqq;
                  wikibase:propertyType wikibase:GlobeCoordinate.
        BIND(geof:longitude(?geo) AS ?long)
        BIND(geof:latitude(?geo)  AS ?lat)
            }


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
  # todo booth codes
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 ?organisation ?organisationLabel (count(?organisation) as ?organisation_count) #count number of organisations that women were members of
WHERE { 
  ?person bnwdt:P3 bnwd:Q3 . # select women
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
  ?person bnwdt:P67 ?organisation . # selection people who were members of organisations and what those organisations were
  FILTER NOT EXISTS {?person bnwdt:P67 bnwd:Q35 .} # filter out Royal Archaeological Institute
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
}
}
GROUP BY ?organisation ?organisationLabel
ORDER BY ?person ?date
ORDER BY DESC(?organisation_count)
 
</sparql>
</sparql>


 
==== Map of Women living in 1890s London ====
 
==Education==
 
===Women educated at a tertiary educational institution located in Oxford or Cambridge===


<sparql tryit="1">
<sparql tryit="1">
# Women educated at a tertiary educational institution located in Oxford or Cambridge
#title:Women living in 1890s London
 
# Query for women living in (greater) london in the 1890s
# 1 row per person per address per date, could be reduced to 1 row per person if preferred.
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 1,727: Line 1,741:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


SELECT ?woman ?womanLabel ?educationalinstitution ?educationalinstitutionLabel ?location ?locationLabel
#defaultView:Map
SELECT distinct ?personLabel ?date_label ?date ?person ?address ?address_item ?londonLabel ?geo ?long ?lat
 
WHERE {   
WHERE {   
   {?woman bnwdt:P3 bnwd:Q3 . #filter women
   ?person bnwdt:P3 bnwd:Q3 . # women
   ?woman bnwdt:P94 ?educationalinstitution . #find 'educated at' statement
   ?person bnp:P29 ?s .   # resided at
  ?educationalinstitution bnwdt:P12 bnwd:Q2914 . #filter to tertiary educational institutions
    ?s bnps:P29 ?london .  
  ?educationalinstitution bnwdt:P2 ?location . #find location of educational institution
      ?london bnwdt:P33+ bnwd:Q322 . # in Q322 greater london.  
  ?location rdfs:label ?locationLabel .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
  FILTER(LANG(?locationLabel) = "en") .
  FILTER(regex(?locationLabel, "oxford", "i")) .}
  UNION
  {?woman bnwdt:P3 bnwd:Q3 . #filter women
  ?woman bnwdt:P94 ?educationalinstitution . #find 'educated at' statement
  ?educationalinstitution bnwdt:P12 bnwd:Q2914 . #filter to tertiary educational institutions
  ?educationalinstitution bnwdt:P2 ?location . #find location of educational institution
  ?location rdfs:label ?locationLabel .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
  FILTER(LANG(?locationLabel) = "en") .
  FILTER(regex(?locationLabel, "Cambridge$", "i")) .}
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
}
ORDER BY ?womanLabel
</sparql>


    # optional street address (text)
  optional {
    ?s bnpq:P31 ?address .
    }
  # optional street address (item)
  optional {
    ?s bnpq:P100 ?address_item .
    }   


=== Women who were FSAs who went to Oxford or Cambridge colleges ===
  # dates. About 30? not dated.
    #optional {
    ?s ?pq ?date .
    # ?date wikibase:timeValue ?date_value. # if you don't want date label this should work instead
     
      ?qual_prop wikibase:qualifier ?pq;
              wikibase:propertyType wikibase:Time ; # nb excludes edtf dates
              rdfs:label ?date_label . filter(lang(?date_label)="en-gb") . # what kind of date is it.
    #  } # /dates
 
    # filter 1890-1899 
  FILTER("1890-01-01"^^xsd:dateTime <= ?date && ?date < "1899-12-31"^^xsd:dateTime).
 
 
  # address geocoordinates
  optional {
    ?s ?pqq ?geo .
        ?qual_geo wikibase:qualifier ?pqq;
                  wikibase:propertyType wikibase:GlobeCoordinate.
        BIND(geof:longitude(?geo) AS ?long)
        BIND(geof:latitude(?geo)  AS ?lat)
            }
 
  # todo booth codes
 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }
}
ORDER BY ?person ?date
</sparql>
 
=== Where did women who published in Folklore/Folk-lore Record live? ===


<sparql tryit="1">
<sparql tryit="1">
#how many women who were FSAs went to Oxford or Cambridge colleges?
# Map of all places of residence for women who had publications in Folklore/Folk-lore Record
 
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 1,764: Line 1,800:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpsv: <https://beyond-notability.wikibase.cloud/prop/statement/value/>


SELECT ?person ?personLabel ?college ?collegeLabel ?universityLabel
#defaultView:Map{"hide":["?geo", "?count"]}
 
SELECT ?person ?personLabel ?residenceLabel ?residence ?geo (count( ?person) as ?count)  #(concat(str(?count), " publication") as ?count_lbl)
WHERE {   
WHERE {   
   ?person bnwdt:P3 bnwd:Q3 . #select women
   ?person bnwdt:P3 bnwd:Q3 . # select women
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
  ?person bnwdt:P76 bnwd:Q419 . # people with publications listed in indexes of archaeological papers. [262]
  ?person bnp:P76 ?s . 
    
    
   ?person bnwdt:P75 bnwd:Q8. # only BN subjects having a FSA
   ## works published in P101. folklore / folk-lore record q487 q490
      ?s bnpq:P101 ?in .
      {?s bnpq:P101 bnwd:Q487 } union { ?s bnpq:P101 bnwd:Q490 . }
      # why does above pick up these two journals as well?
      FILTER ( ?in not in ( bnwd:Q665 , bnwd:Q636 ) ) .
    
    
   # educated at (P94) part of (P4) cambridge (Q1181) oxford (Q364)
   ?person bnwdt:P29  ?residence .
      optional { ?residence bnwdt:P153 ?geo2 .  } # for geocoords added to BN


  ?person bnwdt:P94 ?college .   
  optional {
   ?college bnwdt:P4 ?university .  
   
      ?residence bnp:P117 ?ws # wikidata id P117
           
        ?ws bnpq:P14 ?wikidata_url .
        BIND(IRI(REPLACE(?wikidata_url, "https://www.wikidata.org/wiki/", "http://www.wikidata.org/entity/")) as ?wikidata )
    
      SERVICE <https://query.wikidata.org/sparql> {
   
      optional {?wikidata wdt:P625 ?geo1 . } # geocoords if available
     
      } # /wikidata service 
    } #/wikidata optional


  FILTER ( ?university in ( bnwd:Q1181 , bnwd:Q364 ) )
    BIND(COALESCE(?geo1, ?geo2) AS ?geo).  # if geo1 available use that, then try geo2
    
    
   SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en".}
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
}
}
order by ?personLabel ?collegeLabel
group by ?person ?personLabel ?residenceLabel ?residence ?geo
ORDER BY ?geo
</sparql>
</sparql>


=== All women who went to tertiary education institutions and dates where available ===
 
=== BN people and other things located near Devizes ===


<sparql tryit="1">
<sparql tryit="1">
## testing use of geof:distance
#title:BN items located within 30 km of Devizes, Wiltshire
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 1,795: Line 1,854:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpsv: <https://beyond-notability.wikibase.cloud/prop/statement/value/>
#defaultView:Map
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>
SELECT distinct ?item ?itemLabel ?locationLabel ?location ?wikidata ?wd_geo ?wd_long ?wd_lat 
 
SELECT ?person ?personLabel ?college ?collegeLabel ?university ?universityLabel ?date ?date_label
 
WHERE {   
WHERE {   
  ?person bnwdt:P3 bnwd:Q3 . #select women
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
    
    
   # note: academic degree is P59. possible extra info?
   {?item bnwdt:P29  ?location . } # resided at location
  ?person bnp:P94 ?s . # educated at
  #union
    ?s bnps:P94 ?college .
  #{?location bnwdt:P12 bnwd:Q2147 .} # OR location has instance of locality. is there a way to get this in the same structure?
    optional {?college bnwdt:P4 ?university . } # a few ?college aren't part of (P4) a ?university
  union
  ?college bnwdt:P12 bnwd:Q2914 .  # tertiary ed inst
  {?item bnwdt:P2  ?location . } # item has property P2 location
 
  # any other possibles ?  
  # dates.  
 
    optional {
  ## limit to places in admin territory p33 england q617. (keep numbers down to avoid wikidata timing out)
    ?s ?pq ?date .      
  ?location bnwdt:P33+ bnwd:Q617.
      ?qual_prop wikibase:qualifier ?pq;
   ?location bnwdt:P117 ?ws .  # wikidata id 
              wikibase:propertyType wikibase:Time ; # nb excludes edtf dates
 
              rdfs:label ?date_label . filter(lang(?date_label)="en-gb") . # what kind of date is it.
    bind(iri(concat("http://www.wikidata.org/entity/", str(?ws))) as ?wikidata) .
      } # /dates
        SERVICE <https://query.wikidata.org/sparql> {
   
            wd:Q1026699 wdt:P625 ?start. # devizes coordinates
            ?wikidata wdt:P625 ?wd_geo .
                      #BIND(geof:longitude(?wd_geo) AS ?wd_long) .
                      #BIND(geof:latitude(?wd_geo)  AS ?wd_lat) .
              FILTER(geof:distance(?wd_geo, ?start) < 30). # < 30 km from ?start.  
        } # /wikidata service   
    
    
   SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en".}
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }  
}
}
order by ?personLabel ?collegeLabel ?date
ORDER BY ?locationLabel
</sparql>
 
=== BN items near a chosen location ===
 
<sparql tryit="1">
 
#title:a map of BN items near a chosen starting point in the UK
#defaultView:Map


</sparql>
## create a thingy for the start point change the Qxxx ID in the following PREFIX var_start line to chosen location. 
## **MUST** a) be in UK and b) have a wikidata item that has coordinate location!


PREFIX var_start: <https://beyond-notability.wikibase.cloud/entity/Q5>  # (Q5=sheffield)


=== Academic degrees ===
## to change the distance you can edit the filter(?distance < xx) line near the end of the query.


<sparql tryit="1">
# Fetch academic degrees for women, with date and conferring institution where available
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 1,837: Line 1,904:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpsv: <https://beyond-notability.wikibase.cloud/prop/statement/value/>
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>


SELECT distinct ?person ?personLabel ?degree ?degreeLabel ?by ?byLabel ?date ?date_label
## TODO is there a way to get the location itemLabel and use it in the map title...


SELECT distinct  ?item ?itemLabel ?locationLabel ?location ?wikidata ?wd_geo  ?distance #?wd_long ?wd_lat 
WHERE {   
WHERE {   
   ?person bnwdt:P3 bnwd:Q3 . #select women
   var_start: bnwdt:P117 ?start_wd_id .
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
  bind(iri(concat("http://www.wikidata.org/entity/", str(?start_wd_id))) as ?start_wd) .
 
  {?item bnwdt:P29  ?location . } # resided at location
  union
   {?item bnwdt:P2  ?location . } # item has property P2 location
  # other possibles ?
    
    
   # academic degree = P59.  
   ## limit to places in admin territory p33 uk q1741 seems ok. put it back to england q617 if there are any timeout problems. (keep numbers down to avoid wikidata timing out)
   ?person bnp:P59 ?s .   
  ?location bnwdt:P33+ bnwd:Q1741.
     ?s bnps:P59 ?degree . # type of degree
   ?location bnwdt:P117 ?ws # wikidata id 
     bind(iri(concat("http://www.wikidata.org/entity/", str(?ws))) as ?wikidata) .
    
    
  # optional qualifiers for degree
        SERVICE <https://query.wikidata.org/sparql> {
            ?start_wd wdt:P625 ?start. # start_wd coordinates.
            ?wikidata wdt:P625 ?wd_geo .
        } # /wikidata service 
    
    
  # P61 conferred by
    #BIND(geof:longitude(?wd_geo) AS ?wd_long) .
    optional { ?s bnpq:P61 ?by . }
    #BIND(geof:latitude(?wd_geo)  AS ?wd_lat) . 
    bind(geof:distance(?wd_geo, ?start) as ?distance).
 
    FILTER(?distance < 40). # < xx km from start_wd
    
    
  # date with type
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }  
    optional {
    ?s ?pq ?date .     
      ?qual_prop wikibase:qualifier ?pq;
              wikibase:propertyType wikibase:Time ; # nb excludes edtf dates
              rdfs:label ?date_label . filter(lang(?date_label)="en-gb") . # kind of date
      } # /dates
     
   SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en".}
}
}
order by ?personLabel ?date ?degreeLabel
ORDER BY ?locationLabel
 
</sparql>
</sparql>


==IDs==
=== Locations of BN excavations ===
 
===Women in the wiki (excluding the project team) and their corresponding IDs - where they exist - on wikidata, viaf, WorldCat Identities, and the Archaeology Data Service===


<sparql tryit="1">
<sparql tryit="1">
#title:Locations of BN excavations
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 1,880: Line 1,950:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
#defaultView:Map
PREFIX wd:  <http://www.wikidata.org/entity/>
SELECT distinct ?item ?itemLabel ?locationLabel ?location ?adminterr ?wikidata ?wd_geo
 
SELECT ?person ?personLabel ?wikidata_ID ?viaf_ID ?ads_ID ?worldcat_ID
WHERE {   
WHERE {   
   ?person bnwdt:P3 bnwd:Q3 .                                 #select women
   ?item bnwdt:P12 bnwd:Q38 .
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .}            #filter out project team
    OPTIONAL {?person bnwdt:P117 ?wikidata_ID .}            #return wikidata ID
    OPTIONAL {?person bnwdt:P119 ?viaf_ID .}                #return VIAF ID
    OPTIONAL {?person bnwdt:P34 ?ads_ID .}                  #return Archaeological Data Service ID
    OPTIONAL {?person bnwdt:P118 ?worldcat_ID .}            #return WorldCat Identities ID
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }
}
ORDER BY ?personLabel
</sparql>


===FSAs in the wiki (excluding the project team) and their corresponding IDs - where they exist - on wikidata, viaf, WorldCat Identities, and the Archaeology Data Service===
  {
 
  ?item bnwdt:P2  ?location .  # item has property P2 location
<sparql tryit="1">
 
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
  optional { ?location bnwdt:P33 ?adminterr .
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
              ?adminterr bnwdt:P117 ?wsa .  # and has wikidata id 
PREFIX bnwdv: <https://beyond-notability.wikibase.cloud/value/>
 
PREFIX bnwdt: <https://beyond-notability.wikibase.cloud/prop/direct/>
            bind(iri(concat("http://www.wikidata.org/entity/", str(?wsa))) as ?wikidataa) .
PREFIX bnp: <https://beyond-notability.wikibase.cloud/prop/>
              SERVICE <https://query.wikidata.org/sparql> {
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
              ?wikidataa wdt:P625 ?wd_geo2 .  
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
            } # /wikidata service   
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
          }
PREFIX wd:  <http://www.wikidata.org/entity/>
 
  optional {
  ?location bnwdt:P117 ?ws .  # and has wikidata id 
 
    bind(iri(concat("http://www.wikidata.org/entity/", str(?ws))) as ?wikidata) .
        SERVICE <https://query.wikidata.org/sparql> {
            ?wikidata wdt:P625 ?wd_geo1 .  
        } # /wikidata service   
    }
  }
  union
  {
 
  filter not exists {?item bnwdt:P2  ?location . } # item doesn't have property P2 location
 
  optional {
  ?item bnwdt:P117 ?wikidata_id . # but has wikidata id 
  bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_id))) as ?wikidata) .
 
  SERVICE <https://query.wikidata.org/sparql> {
              ?wikidata wdt:P625 ?wd_geo1 . 
            } # /wikidata service   
    }


SELECT ?person ?personLabel ?wikidata_ID ?viaf_ID ?ads_ID ?worldcat_ID
  }
WHERE { 
   BIND(COALESCE(?wd_geo1, ?wd_geo2) AS ?wd_geo). # if geo1 available use that, then try geo2
   ?person bnwdt:P3 bnwd:Q3 .                                #select women
    
  ?person bnwdt:P16 ?FSA .                                   #select FSA
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }  
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .}            #filter out project team
    OPTIONAL {?person bnwdt:P117 ?wikidata_ID .}            #return wikidata ID
    OPTIONAL {?person bnwdt:P119 ?viaf_ID .}                #return VIAF ID
    OPTIONAL {?person bnwdt:P34 ?ads_ID .}                  #return Archaeological Data Service ID
    OPTIONAL {?person bnwdt:P118 ?worldcat_ID .}            #return WorldCat Identities ID
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
}
}
ORDER BY ?personLabel
ORDER BY ?locationLabel
</sparql>
</sparql>


===People with IDs on wikidata, their date of birth on wikidata, and the source(s) of that information===
=== Locations of archaeological sites ===


<sparql tryit="1">
<sparql tryit="1">
#title:Locations of BN archaeological sites
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 1,933: Line 2,009:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
#defaultView:Map
PREFIX wd:  <http://www.wikidata.org/entity/>
SELECT distinct ?item ?itemLabel ?locationLabel ?location ?adminterrLabel ?adminterr ?wikidata ?wd_geo
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX pr: <http://www.wikidata.org/prop/reference/>
PREFIX prov: <http://www.w3.org/ns/prov#>
 
SELECT ?woman ?womanLabel ?WDitem ?WDdateOfBirth (GROUP_CONCAT(?BirthStatedInEnglish;separator=" | ") AS ?sources)
WHERE {   
WHERE {   
   #Select all women
   ?item bnwdt:P12 bnwd:Q86 .
   ?woman bnwdt:P3 bnwd:Q3 .
 
   #select all women that have a Wikidata link
  { 
   ?woman bnwdt:P117 ?Qnumber .  
    ?item bnwdt:P2  ?location .  # item has property P2 location
 
  optional { ?location bnwdt:P33 ?adminterr .
              ?adminterr bnwdt:P117 ?wsa .  # and has wikidata id 
 
            bind(iri(concat("http://www.wikidata.org/entity/", str(?wsa))) as ?wikidataa) .
              SERVICE <https://query.wikidata.org/sparql> {
              ?wikidataa wdt:P625 ?wd_geo2 . 
            } # /wikidata service   
          }
 
  optional {
   ?location bnwdt:P117 ?ws .  # and has wikidata id 
 
    bind(iri(concat("http://www.wikidata.org/entity/", str(?ws))) as ?wikidata) .
        SERVICE <https://query.wikidata.org/sparql> {
            ?wikidata wdt:P625 ?wd_geo1 .
        } # /wikidata service   
  }
   
    }
 
  union
 
   {
      filter not exists {?item bnwdt:P2  ?location . } # item doesn't have property P2 location
 
 
   ?item bnwdt:P117 ?wikidata_id .  # but has wikidata id 
  bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_id))) as ?wikidata) .
    
    
  #create reference to Wikibase entity
  BIND(IRI(concat("http://www.wikidata.org/entity/", ?Qnumber)) as ?WDitem )
  #on Wikibase do
   SERVICE <https://query.wikidata.org/sparql> {
   SERVICE <https://query.wikidata.org/sparql> {
        #get the date of birth
              ?wikidata wdt:P625 ?wd_geo1 .   # which has geo coords
        ?WDitem wdt:P569 ?WDdateOfBirth .
            } # /wikidata service   
        #get the statement of birth
  }
        ?WDitem p:P569 ?Birthstatement .
   
        #get its node
   BIND(COALESCE(?wd_geo1, ?wd_geo2) AS ?wd_geo). # if geo1 available use that, then try geo2
        ?Birthstatement prov:wasDerivedFrom ?BirthRefnode.
        #get the value of 'Stated in'
        ?BirthRefnode   pr:P248 ?BirthStatedIn.
        #get the english label of the referece 'stated in'
        OPTIONAL {?BirthStatedIn rdfs:label ?BirthStatedInEnglish
                  FILTER (LANG(?BirthStatedInEnglish) = "en")}.
      }
    
    
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }  
}
}
GROUP BY ?woman ?womanLabel ?WDitem ?WDdateOfBirth
ORDER BY ?locationLabel
ORDER BY ?womanLabel
# Credit to Maarten Zeinstra for developing this query
</sparql>
</sparql>


=== Which women in the wikibase have Wikipedia articles, according to Wikidata?===
=== Locations of historic houses ===


<sparql tryit="1">
<sparql tryit="1">
 
#title:locations of BN historic houses
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 1,981: Line 2,069:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
#defaultView:Map
PREFIX wd<http://www.wikidata.org/entity/>
SELECT distinct ?item ?itemLabel ?locationLabel ?location ?wikidata ?wd_geo 
WHERE { 
  ?item bnwdt:P12 bnwd:Q2961 .
  {
  ?item bnwdt:P2  ?location .  # item has property P2 location
 
 
  optional { ?location bnwdt:P33 ?adminterr .
              ?adminterr bnwdt:P117 ?wsa .  # and has wikidata id 
 
            bind(iri(concat("http://www.wikidata.org/entity/", str(?wsa))) as ?wikidataa) .
              SERVICE <https://query.wikidata.org/sparql> {
              ?wikidataa wdt:P625 ?wd_geo2 . 
            } # /wikidata service   
          }
 
  optional {
  ?location bnwdt:P117 ?ws . # and has wikidata id 
 
    bind(iri(concat("http://www.wikidata.org/entity/", str(?ws))) as ?wikidata) .
        SERVICE <https://query.wikidata.org/sparql> {
            ?wikidata wdt:P625 ?wd_geo1 . 
        } # /wikidata service   
  }


SELECT ?person ?personLabel ?wikidata ?wikipedia
  }
WHERE {
  union
   ?person bnwdt:P3 bnwd:Q3 . #select women
  {
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
    
   filter not exists {?item bnwdt:P2  ?location . } # item doesn't have property P2 location


   ?person bnp:P117 ?wikidata_ID . #look for wikidata ID on person page
   ?item bnwdt:P117 ?wikidata_id . # but has wikidata id    
   ?wikidata_ID bnpq:P14 ?wikidata_url .
   bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_id))) as ?wikidata) .
   BIND(IRI(REPLACE(?wikidata_url,"https://www.wikidata.org/wiki/","http://www.wikidata.org/entity/")) as ?wikidata )  
    
    
   SERVICE <https://query.wikidata.org/sparql> {
   SERVICE <https://query.wikidata.org/sparql> {
      # get English language wikipedia articles in wikidata entries, where listed
              ?wikidata wdt:P625 ?wd_geo1 . 
        OPTIONAL {
            } # /wikidata service   
          ?wikipedia schema:about ?wikidata .
          ?wikipedia schema:inLanguage 'en' .
 
          FILTER (SUBSTR(str(?wikipedia), 1, 25) = 'https://en.wikipedia.org/')
  }
        } 
 
      } 
  BIND(COALESCE(?wd_geo1, ?wd_geo2) AS ?wd_geo). # if geo1 available use that, then try geo2 
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
           
             
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }  
}
}
ORDER BY ?personLabel
ORDER BY ?locationLabel
 
</sparql>
</sparql>


 
=== Residences of women participants in Colchester excavations ===
=== Women with no date of death in our wikibase who have a date of death on Wikidata===


<sparql tryit="1">
<sparql tryit="1">
# Women who have no date of death in our wikibase and have a date of death on Wikidata
#title:Excavations at Colchester: where women participants lived
 
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 2,020: Line 2,130:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
#defaultView:Map
PREFIX wd:  <http://www.wikidata.org/entity/>
SELECT distinct ?item ?itemLabel ?locationLabel ?location ?person ?personLabel ?resided ?residedLabel ?wd_geo
 
SELECT ?person ?personLabel ?wd_dod
WHERE {   
WHERE {   
   ?person bnwdt:P3 bnwd:Q3 . #select women
   values (?item) { (bnwd:Q90) }  # q90 colchester 
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
 
  ?item bnwdt:P12 bnwd:Q38 .
   filter not exists {?person bnwdt:P15 ?bn_dod . } # *don't* have P15 date of death
  ?item bnwdt:P2  ?location . # item has property P2 location
    
  ?item (bnwdt:P36 | bnwdt:P37 ) ?person .
  #optional { ?item bnwdt:P36 ?director . }
  #optional { ?item bnwdt:P37 ?member . }
 
   optional { ?person bnwdt:P29 ?resided .
              ?resided bnwdt:P117 ?wsa . # and has wikidata id 
    
    
  ?person bnp:P117 ?wikidata_ID . #look for wikidata ID on person page
            bind(iri(concat("http://www.wikidata.org/entity/", str(?wsa))) as ?wikidataa) .
  ?wikidata_ID bnpq:P14 ?wikidata_url .
              SERVICE <https://query.wikidata.org/sparql> {
  BIND(IRI(REPLACE(?wikidata_url,"https://www.wikidata.org/wiki/","http://www.wikidata.org/entity/")) as ?item )
              ?wikidataa wdt:P625 ?wd_geo . 
            } # /wikidata service   
          }
    
    
  SERVICE <https://query.wikidata.org/sparql> {
        ?item wdt:P21 ?WD_gender. #get gender of person
        ?item wdt:P570 ?wd_dod .  #date of death on Wikidata P570
      }
    
    
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }  
}
}
ORDER BY ?personLabel
ORDER BY ?locationLabel
</sparql>
</sparql>


=== Women with no date of birth in our wikibase who have a date of birth in Wikidata===
=== IWD 2024 Map of five women's places ===


<sparql tryit="1">
<sparql tryit="1">
# Women who have no date of birth in our wikibase and have a date of birth on Wikidata
## how many places for the five women can I get on a map? a slightly ridiculous query.


#title:Four stories, five women, many places for #IWD2024
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 2,056: Line 2,170:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
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  ?wd_dob
#defaultView:Map{"hide":["?geo"],"layer":"?person", "markercluster":true }
 
SELECT distinct ?person ?personLabel  ?propLabel ?placeLabel  ?geo  ?loc2Label (year(?date) as ?year)
 
WHERE {   
WHERE {   
  ?person bnwdt:P3 bnwd:Q3 . #select women
 
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
  VALUES (?person) {(bnwd:Q894) (bnwd:Q462) (bnwd:Q549) (bnwd:Q921) (bnwd:Q1053) } #
  ?person ( bnp:P29 | bnp:P94  | bnp:P23 | bnp:P13 | bnp:P120  ) ?s .
  filter not exists {?person bnwdt:P26 ?bn_dob . } # *don't* have P15 date of death
    
    
   ?person bnp:P117 ?wikidata_ID . #look for wikidata ID on person page
  ?s  ( bnps:P29 | bnps:P94  | bnps:P23 | bnps:P13 | bnps:P120   )  ?place .
   ?wikidata_ID bnpq:P14 ?wikidata_url .
 
   BIND(IRI(REPLACE(?wikidata_url,"https://www.wikidata.org/wiki/","http://www.wikidata.org/entity/")) as ?item )  
  ?person ?p ?s .
      ?prop wikibase:claim ?p;     
        wikibase:statementProperty ?ps. 
 
      optional { ?s ( bnpq:P1 | bnpq:P27 ) ?date . }
      #optional { ?s bnpq:P31 ?street . }
  # LOLplaces
  #1 geocoords in quals for place itself - should be detailed geo added manually, cf London district geocoords which =main P153
  #2 wikdiata geocoords for place
  #3 geocoords in quals for linked place
  #4 wikidata geocoords for linked place
  #5 wikidata geocoords in place P2 qual
  #6 `of` qual geocoords
  #7 `of` P2 wikidata geocoords
  #8 `of` wikidata geocoords
  #9 place main geocoords - likely to be broad london postal districts so should be last resort
  #10 linked place main geocoords
 
 
      optional { ?s bnpq:P153 ?geo1 . } # place has geocoords directly *in qualifier*
    
      optional { ?place bnwdt:P2 ?linked_p1 . # linked place has geocoords *in qualifier* (this is primarily for SAL?)
                    ?linked_p1 bnp:P2 ?llp_s .
                        ?llp_s bnps:P2 ?llp_p1.
                        ?llp_s bnpq:P153 ?geo2 .
                }
    
      optional { ?place bnwdt:P117 ?pws .  # place has wikidata page that has geoocords (main P625, not anywhere else)
                  bind(iri(concat("http://www.wikidata.org/entity/", str(?pws))) as ?pwikidata) .
                  SERVICE <https://query.wikidata.org/sparql> {
                    ?pwikidata wdt:P625 ?geo3 .
                  }       
                } 
 
      optional { ?place bnwdt:P2 ?linked_p2 .  # linked place has wikidata geocoords
                    ?linked_p2 bnwdt:P117 ?lws .  # wikidata id P117
                    bind(iri(concat("http://www.wikidata.org/entity/", str(?lws))) as ?lwikidata) .
                    SERVICE <https://query.wikidata.org/sparql> {
                      ?lwikidata wdt:P625 ?geo4 .
                    }
                }
 
      optional { ?s bnpq:P2 ?qp1 . # P2 qualifier location has wikidata geocoords
                    ?qp1 bnwdt:P117 ?qws .
                    bind(iri(concat("http://www.wikidata.org/entity/", str(?qws))) as ?qwikidata) .
                    SERVICE <https://query.wikidata.org/sparql> {
                      ?qwikidata wdt:P625 ?geo5 .
                    }
                }
 
      optional { ?s bnpq:P78 ?ofp1 . # 'of' (organisation) has geocoords in P2 qualifier
                    ?ofp1 bnp:P2 ?ofp1_s .
                    ?ofp1_s bnps:P2 ?ofp1_p .
                    ?ofp1_s bnpq:P153 ?geo6 . } 
 
      optional { ?s bnpq:P78 ?ofp2 . # 'of' (organisation) P2 location has wikidata geocoords
                    ?ofp2 bnwdt:P2 ?ofp2_p .
                      ?ofp2_p bnwdt:P117 ?ofl2ws .
                      bind(iri(concat("http://www.wikidata.org/entity/", str(?ofl2ws))) as ?ofl2wikidata) .
                      SERVICE <https://query.wikidata.org/sparql> {
                      ?ofl2wikidata wdt:P625 ?geo7 .  }           
              } 
 
      optional { ?s bnpq:P78 ?ofp3 .  # 'of' (organisation) has wikidata geocoords
                    ?ofp3 bnwdt:P117 ?ofpws .  # wikidata id P117
                    bind(iri(concat("http://www.wikidata.org/entity/", str(?ofpws))) as ?ofpwikidata) .
                    SERVICE <https://query.wikidata.org/sparql> {
                      ?ofpwikidata wdt:P625 ?geo8 .  }
                }
 
      optional { ?place bnwdt:P153 ?geo9 .  } # main geocoords  (mainly london postal districts - should be last resort as v broad.)
 
 
      optional { ?place bnwdt:P2 ?linked_p10 . # linked place main geocoords
                    ?linked_p10 bnwdt:P153 ?geo10 .
                }
 
  BIND(COALESCE(?geo1, ?geo2, ?geo3, ?geo4, ?geo5, ?geo6, ?geo7, ?geo8, ?geo9, ?geo10) AS ?geo).  # if geo1 available use that, then geo2, etc, in order of preference
    
    
   SERVICE <https://query.wikidata.org/sparql> {
   bind(coalesce(?linked_p1, ?linked_p2, ?qp1, ?ofp1, ?ofp2, ?ofp3 ) as ?loc2). # hopefully get extra context where place is just sthg like "meeting". though exactly what will be variable!
        ?item wdt:P21 ?WD_gender. #get gender of person
        ?item wdt:P569 ?wd_dob . #date of birth on Wikidata P569
      }
    
    
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en, en-gb". }  
}
}
ORDER BY ?personLabel
 
order by ?personLabel ?date ?placeLabel
 
</sparql>
</sparql>


=== All external IDs on Wikidata for Women ===
=== Wikidata categories for BN instance of locality in the UK ===


<sparql tryit="1">
<sparql tryit="1">
# Query to fetch all available External IDs on Wikidata for FSAs
# NB this will take a while, but it should finish.
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 2,092: Line 2,281:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpsv: <https://beyond-notability.wikibase.cloud/prop/statement/value/>
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>
#title: counts of WD instance of (P31) for BN localities (instance of Q2147) in the UK


SELECT distinct ?person ?personLabel ?wikidata ?p ?id_no ?id_label
select ?wd_io ?wd_io_label  (count(*) as ?count)


WHERE {
where {
    ?person bnwdt:P3 bnwd:Q3 . #select women    
    #?person bnwdt:P75 bnwd:Q8. # limit to FSAs if the full set times out.
  ?item bnwdt:P12 bnwd:Q2147 . # BN io locality
 
   ?item bnwdt:P33* bnwd:Q1741 . # in UK
    ?person bnp:P117 ?wikidata_ID . #get wikidata ID
    ?wikidata_ID bnpq:P14 ?wikidata_url .
    BIND(IRI(REPLACE(?wikidata_url, "https://www.wikidata.org/wiki/", "http://www.wikidata.org/entity/")) as ?wikidata )
    
    
    SERVICE <https://query.wikidata.org/sparql> {
  ?item bnwdt:P117 ?wd.
   
      bind(iri(concat("http://www.wikidata.org/entity/", str(?wd))) as ?wikidata) .
    ?wikidata ?p ?s .  
      SERVICE <https://query.wikidata.org/sparql> {  
      ?prop wikibase:claim ?p;   
          ?wikidata wdt:P31 ?wd_io.
            wikibase:statementProperty ?ps; # NB rather than statementValue
              ## p31 Q48091 region of england.
            wikibase:propertyType wikibase:ExternalId. # quicker than filter.
            SERVICE wikibase:label { bd:serviceParam wikibase:language "en".
     
                                    ?wikidata rdfs:label ?wd_label .  
      ?prop rdfs:label ?id_label. filter(lang(?id_label)="en") . # ident name
                                    ?wd_io rdfs:label ?wd_io_label .  
     
                                  }        
          ?s ?ps ?id_no . # id value
        }
 
 
       # filter by property type
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }  
      #filter(?prop_type in (wikibase:ExternalId ) ) .
    }
     
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en, en-gb". }  
}
}
           
group by ?wd_io ?wd_io_label
order by ?personLabel ?id_label ?id_no
order by ?wd_io_label
</sparql>


</sparql>


=== What external IDs are available in Wikidata for women in the BN database? ===
=== Localities not in the UK ===


<sparql tryit="1">
<sparql tryit="1">
# All the external IDs on BN women's Wikidata pages, with counts and descriptions
##admin_paths lists the linked P33 for the item. Unfortunately, they aren't reliably returned in ascending order.
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 2,138: Line 2,320:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
#title:localities not in the UK
PREFIX wd<http://www.wikidata.org/entity/>
 
select  ?item ?itemLabel (group_concat(distinct ?admin_label; separator=", " ) as ?admin_path)
where {
  ?item bnwdt:P12 bnwd:Q2147 . # i/o locality
  ?item bnwdt:P33* ?admin.   
    ?admin rdfs:label ?admin_label. filter(lang(?admin_label)="en") .
 
  filter not exists { ?item bnwdt:P33* bnwd:Q1741. } # filter out anything in the UK
  filter (?item not in (bnwd:Q619, bnwd:Q2961, bnwd:Q4207, bnwd:Q86) ). # and a few things that are not specific places


SELECT ?p ?id_label ?id_description  (count(?p) as ?count)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
}
group by ?item ?itemLabel
order by ?itemLabel
</sparql>


WHERE { 
==People==
  ?person bnwdt:P3 bnwd:Q3 . #select women
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team


  ?person bnp:P117 ?wikidata_ID . # wikidata ID
===Women with their family name at birth and family name after marriage===
    ?wikidata_ID bnpq:P14 ?wikidata_url .
    BIND(IRI(REPLACE(?wikidata_url, "https://www.wikidata.org/wiki/", "http://www.wikidata.org/entity/")) as ?wikidata )
 
    SERVICE <https://query.wikidata.org/sparql> {
    ?wikidata ?p ?s .
          ?prop wikibase:claim ?p;   
              wikibase:propertyType wikibase:ExternalId; 
              rdfs:label ?id_label. filter(lang(?id_label)="en") .
      ?prop schema:description ?id_description .
      filter(lang(?id_description) = "en") .   
      } 
     
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en, en-gb". }
}
group by ?p ?id_label ?id_description
ORDER BY desc(?count)
 
</sparql>
 
=== Women with ODNB IDs in Wikidata ===


<sparql tryit="1">
<sparql tryit="1">
# BN women with ODNB biography IDs on Wikidata, with links to the bios
# Women with their family name at birth and family name after marriage


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 2,179: Line 2,351:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpsv: <https://beyond-notability.wikibase.cloud/prop/statement/value/>
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>


SELECT distinct ?person ?personLabel ?wikidata ?url


WHERE {
SELECT ?person ?personLabel ?birthname ?marriedname
    ?person bnwdt:P3 bnwd:Q3 . #select women   
WHERE {
   
  ?person bnwdt:P3 bnwd:Q3 . #select women
    ?person bnp:P117 ?wikidata_ID . #get wikidata ID
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
    ?wikidata_ID bnpq:P14 ?wikidata_url .
  OPTIONAL {?person bnwdt:P140 ?birthname .} #look for birth name
    BIND(IRI(REPLACE(?wikidata_url, "https://www.wikidata.org/wiki/", "http://www.wikidata.org/entity/")) as ?wikidata )
  OPTIONAL {?person bnwdt:P141 ?marriedname .} #look for married name
    
    
    SERVICE <https://query.wikidata.org/sparql> {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
   
}
    # P1415 Oxford Dictionary of National Biography ID | P6829 Dictionary of Irish Biography ID | P1648 Dictionary of Welsh Biography ID
ORDER BY ?personLabel
    ?wikidata wdt:P1415 ?id . 
</sparql>


    # odnb link
=== Women with family name at birth, married name and count of married names===
    BIND(IRI(concat("https://doi.org/10.1093/ref:odnb/", ?id)) as ?url ) .
   
    } 
     
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en, en-gb". }
}
           
order by ?personLabel ?id
</sparql>


=== Women with National Portrait Gallery links via Wikidata ===
<sparql tryit="1">
# Women with their family name at birth, family name after marriage and count of married names


<sparql tryit="1">
# Query to fetch National Portrait Gallery IDs on Wikidata for BN women, with links
# NB this may be a bit slow...
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 2,219: Line 2,377:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpsv: <https://beyond-notability.wikibase.cloud/prop/statement/value/>
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>


SELECT distinct ?person ?personLabel ?wikidata ?id_no ?npg_url
SELECT ?person ?personLabel ?birthname 
        (GROUP_CONCAT(DISTINCT ?marriedname; SEPARATOR=", ") AS ?marriednames)
        (COUNT(?marriedname) AS ?marriedcount)


WHERE {
WHERE {
    ?person bnwdt:P3 bnwd:Q3 . #select women    
  ?person bnwdt:P3 bnwd:Q3 . #select women
    ?person bnp:P117 ?wikidata_ID . #get wikidata ID
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
    ?wikidata_ID bnpq:P14 ?wikidata_url .
 
    BIND(IRI(REPLACE(?wikidata_url, "https://www.wikidata.org/wiki/", "http://www.wikidata.org/entity/")) as ?wikidata )
  OPTIONAL {?person bnwdt:P140 ?birthname .} #look for birth name
  OPTIONAL {?person bnwdt:P141 ?marriedname .} #look for married name
    
    
    SERVICE <https://query.wikidata.org/sparql> {
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }  
   
}
    ?wikidata ?p ?s .   
group by ?person ?personLabel ?birthname
      ?prop wikibase:claim ?p;   
ORDER BY ?personLabel
            wikibase:statementProperty ?ps;
            wikibase:propertyType wikibase:ExternalId.
   
          ?s ps:P1816 ?id_no . # id value
      # npg link
          BIND(IRI(concat("https://www.npg.org.uk/collections/search/person/", ?id_no)) as ?npg_url ) .
    } 
     
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en, en-gb". }  
}
           
order by ?personLabel ?id_no
</sparql>
</sparql>


=== Which BN properties map on to Wikidata properties? ===
===Where women in our data are in wikidata, their spouses, fathers, and mothers according to wikidata===


<sparql tryit="1">
<sparql tryit="1">
## **NOTES**
## a few properties have a linked wikidata "Q" rather than "P" ID. These will unfortunately not link correctly to Wikidata so wd_label/wd_description won't be present.
## a few other properties may have wikidata=yes but no wd_label and/or wd_description. This could be because the property on Wikidata has been deleted (eg performed at).
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 2,263: Line 2,405:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
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 DISTINCT ?property (if(bound(?wikidata_id), "yes", "no") as ?has_wikidata)  ?bn_label ?wd_label ?bn_description
SELECT ?person ?personLabel ?item ?WD_spouse ?WD_father ?WD_mother
  ?wd_description ?wikidata ?bn_propertyType
WHERE {
 
   ?person bnwdt:P3 bnwd:Q3 . #select women
WHERE {
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
   ?property a wikibase:Property ;
  ?person bnp:P117 ?wikidata_ID . #look for wikidata ID on person page
              wikibase:propertyType ?bn_propertyType . # datatype
  ?wikidata_ID bnpq:P14 ?wikidata_url .
  BIND(IRI(REPLACE(?wikidata_url,"https://www.wikidata.org/wiki/","http://www.wikidata.org/entity/")) as ?item )  
  service wikibase:label {
 
            bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en".
  SERVICE <https://query.wikidata.org/sparql> {
            ?property rdfs:label ?bn_label .
        ?item wdt:P21 ?WD_gender. #get gender of person
            ?property schema:description ?bn_description .
        OPTIONAL {?item wdt:P22 ?WD_father . } #recall father
                            }
        OPTIONAL {?item wdt:P25 ?WD_mother . } #recall mother
    # wikidata P117 
        OPTIONAL {?item wdt:P26 ?WD_spouse . } #recall spouse
    optional { ?property bnp:P117 ?wikidata_id .  
      }
                ?wikidata_id bnpq:P14 ?wikidata_url .  
 
            # the string to replace needs to be different for properties! 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
              BIND(IRI(REPLACE(?wikidata_url, "https://www.wikidata.org/wiki/Property:", "http://www.wikidata.org/entity/")) as ?wikidata )  
 
            SERVICE <https://query.wikidata.org/sparql> {
                    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en".  
                            ?wikidata schema:description ?wd_description .
                            ?wikidata rdfs:label ?wd_label .
                    } # / label service
              } # /wikidata service 
          } #/wikidata optional
}
}
order by ?bn_label
ORDER BY ?personLabel
# with thanks to @tagishsimon for writing this one initially!
</sparql>
</sparql>


==== Of these, which are properties for public and professional activities? ====
===Women in our data alongside counts of their public and professional activities, sorted by total===


<sparql tryit="1">
<sparql tryit="1">
# which properties have corresponding wikidata IDs, restricted to instance of PPA (P12 / Q151)
## Women in our data alongside counts of their public and professional activities (https://beyond-notability.wikibase.cloud/wiki/Item:Q151)
 
## Sorted by total PPAs
## **NOTES**
## a few properties have a linked wikidata "Q" rather than "P" ID. These will unfortunately not link correctly to Wikidata so wd_label/wd_description won't be present.
## a few other properties may have wikidata=yes but no wd_label and/or wd_description. This could be because the property on Wikidata has been deleted (eg performed at).


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 2,310: Line 2,443:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


SELECT DISTINCT ?property (if(bound(?wikidata_id), "yes", "no") as ?has_wikidata) ?bn_label ?wd_label ?bn_description
select ?person ?personLabel
  ?wd_description ?wikidata ?bn_propertyType
(count(distinct ?exhibitor) as ?exhibitions)
 
(count(distinct ?position) as ?positions)
WHERE {
(count(distinct ?speaker) as ?spoke)
  ?property a wikibase:Property ;
(count(distinct ?attended) as ?attendance)
              wikibase:propertyType ?bn_propertyType . # datatype
(count(distinct ?donorof) as ?donated)
(count(distinct ?wasdelegate) as ?delegate)
  service wikibase:label { 
(count(distinct ?correspondent) as ?correspondents)
            bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en".
(count(distinct ?fellow) as ?fellowships)
            ?property rdfs:label ?bn_label .
(count(distinct ?collab) as ?collaborations)
            ?property schema:description ?bn_description .
(count(distinct ?found) as ?founded)
                            }
(count(distinct ?loaned) as ?loans)
    # wikidata P117 
(count(distinct ?illustrated) as ?illustrations)
    optional { ?property bnp:P117 ?wikidata_id .
(count(distinct ?sold) as ?sales)
                ?wikidata_id bnpq:P14 ?wikidata_url .
(count(distinct ?served) as ?service)
            # the string to replace needs to be different for properties! 
(count(distinct ?job) as ?employed)
              BIND(IRI(REPLACE(?wikidata_url, "https://www.wikidata.org/wiki/Property:", "http://www.wikidata.org/entity/")) as ?wikidata )  
(count(distinct ?fundraiser) as ?fundraisers)
(count(distinct ?publish) as ?published)
(count(distinct ?benefact) as ?benefactor)
(count(distinct ?donor) as ?donor_to)
(count(distinct ?collect) as ?collected)
(count(distinct ?performance) as ?performances)
((?exhibitions + ?positions + ?spoke + ?attendance + ?donated + ?delegate + ?correspondents + ?fellowships + ?collaborations + ?founded + ?loans + ?illustrations + ?sales
+ ?service + ?employed + ?fundraisers + ?published + ?benefactor + ?donor_to + ?collected + ?performances) AS ?PPA_total)


            SERVICE <https://query.wikidata.org/sparql> {
where
                    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en".
{
                            ?wikidata schema:description ?wd_description .
  ?person bnwdt:P3 bnwd:Q3 .
                            ?wikidata rdfs:label ?wd_label .
  optional { ?person bnp:P13 ?exhibitor }
                    } # / label service
  optional { ?person bnp:P17 ?position }
              } # /wikidata service    
  optional { ?person bnp:P23 ?speaker }
          } #/wikidata optional
  optional { ?person bnp:P24 ?attended }
    
  optional { ?person bnp:P65 ?donorof }
    ?property bnwdt:P12 bnwd:Q151. # instance of PPA
  optional { ?person bnp:P71 ?wasdelegate }
  optional { ?person bnp:P73 ?correspondent }
  optional { ?person bnp:P75 ?fellow }
  optional { ?person bnp:P83 ?collab }
  optional { ?person bnp:P85 ?found }
  optional { ?person bnp:P87 ?loaned }
  optional { ?person bnp:P89 ?illustrated }
  optional { ?person bnp:P99 ?sold }
  optional { ?person bnp:P102 ?served }
  optional { ?person bnp:P105 ?job }
  optional { ?person bnp:P106 ?fundraiser }
   optional { ?person bnp:P107 ?publish }
  optional { ?person bnp:P110 ?benefact }
  optional { ?person bnp:P111 ?donor }
   optional { ?person bnp:P114 ?collect }
  optional { ?person bnp:P120 ?performance }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
}
}
order by ?bn_label
group by ?person ?personLabel
ORDER BY DESC (?PPA_total)
</sparql>
</sparql>


=== BN Men in Wikidata ===
===Women in our data arranged as a network graph by the organisations they were members of===


<sparql tryit="1">
<sparql tryit="1">
 
## Women in our data arranged as a network graph by the organisations they were members of
#title: BN men in Wikidata
#defaultView:Graph
# a starting point to get the basic query set up; can easily add more variables...
 
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 bnwdv: <https://beyond-notability.wikibase.cloud/value/>
PREFIX bnwdt: <https://beyond-notability.wikibase.cloud/prop/direct/>
PREFIX bnwdt: <https://beyond-notability.wikibase.cloud/prop/direct/>
PREFIX bnp: <https://beyond-notability.wikibase.cloud/prop/>
SELECT  ?org ?orgLabel ?rgb ?linkTo ?linkToLabel
WHERE { 
  ?linkTo bnwdt:P3 bnwd:Q3 .                                #select women
  FILTER NOT EXISTS {?linkTo bnwdt:P4 bnwd:Q12 .}          #filter out project team
  ?linkTo bnwdt:P67 ?org
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en". }
  BIND( "7C4DCD" AS ?rgb ) .
 
}
ORDER BY ?personLabel
</sparql>
 
===Membership of organisations by women, sorted by how many women were members of a given organisation===
 
<sparql tryit="1">
# Membership of organisations by women, sorted by how many women were members of a given organisation
 
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 bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpsv: <https://beyond-notability.wikibase.cloud/prop/statement/value/>
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>


SELECT distinct ?person ?personLabel ?wikidata ?wd_dob ?wd_dod ?odnb_url ?wikipedia
SELECT ?organisation ?organisationLabel (count(?organisation) as ?organisation_count) #count number of organisations that women were members of
WHERE { 
  ?person bnwdt:P3 bnwd:Q3 . # select women
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
  ?person bnwdt:P67 ?organisation . # selection people who were members of organisations and what those organisations were
  FILTER NOT EXISTS {?person bnwdt:P67 bnwd:Q35 .} # filter out Royal Archaeological Institute
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }
}
GROUP BY ?organisation ?organisationLabel
ORDER BY DESC(?organisation_count)
</sparql>
 
 


WHERE {
==Education==
    ?person bnwdt:P3 bnwd:Q10 . #select men 
 
    ?person bnp:P117 ?wikidata_ID . #get wikidata ID
    ?wikidata_ID bnpq:P14 ?wikidata_url .
    BIND(IRI(REPLACE(?wikidata_url, "https://www.wikidata.org/wiki/", "http://www.wikidata.org/entity/")) as ?wikidata )
 
    SERVICE <https://query.wikidata.org/sparql> {
   
      optional { 
        # P1415 Oxford Dictionary of National Biography ID | couls also add  P6829 Dictionary of Irish Biography ID | P1648 Dictionary of Welsh Biography ID
        ?wikidata wdt:P1415 ?odnb_id . 


        # odnb link
===Women educated at a tertiary educational institution located in Oxford or Cambridge===
        BIND(IRI(concat("https://doi.org/10.1093/ref:odnb/", ?odnb_id)) as ?odnb_url ) .
        } #/ odnb
     
        # English language wikipedia articles in wikidata entries, where listed
        OPTIONAL {
          ?wikipedia schema:about ?wikidata .
          ?wikipedia schema:inLanguage 'en' .
          FILTER (SUBSTR(str(?wikipedia), 1, 25) = 'https://en.wikipedia.org/')
        } 
     
        optional { ?wikidata wdt:P569 ?wd_dob . } #date of birth on Wikidata P569
        optional { ?wikidata wdt:P570 ?wd_dod . }  #date of death on Wikidata P570
    }  #/ wikidata
     
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en, en-gb". }
}
           
order by ?personLabel
</sparql>
 
=== What sort of info Wikidata has about BN men ===


<sparql tryit="1">
<sparql tryit="1">
 
# Women educated at a tertiary educational institution located in Oxford or Cambridge
#title: what info is there for BN men in Wikidata
#counts of properties (excluding external IDs, of which there are gazillions) (Counts are overall and some people might have more than one.)
#at time of writing there are 198 linked men.


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 2,410: Line 2,558:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpsv: <https://beyond-notability.wikibase.cloud/prop/statement/value/>
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>


SELECT ?prop_label ?prop (count(?prop) as ?count)
SELECT ?woman ?womanLabel ?educationalinstitution ?educationalinstitutionLabel ?location ?locationLabel
WHERE { 
  {?woman bnwdt:P3 bnwd:Q3 . #filter women
  ?woman bnwdt:P94 ?educationalinstitution . #find 'educated at' statement
  ?educationalinstitution bnwdt:P12 bnwd:Q2914 . #filter to tertiary educational institutions
  ?educationalinstitution bnwdt:P2 ?location . #find location of educational institution
  ?location rdfs:label ?locationLabel .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
  FILTER(LANG(?locationLabel) = "en") .
  FILTER(regex(?locationLabel, "oxford", "i")) .}
  UNION
  {?woman bnwdt:P3 bnwd:Q3 . #filter women
  ?woman bnwdt:P94 ?educationalinstitution . #find 'educated at' statement
  ?educationalinstitution bnwdt:P12 bnwd:Q2914 . #filter to tertiary educational institutions
  ?educationalinstitution bnwdt:P2 ?location . #find location of educational institution
  ?location rdfs:label ?locationLabel .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
  FILTER(LANG(?locationLabel) = "en") .
  FILTER(regex(?locationLabel, "Cambridge$", "i")) .}
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
}
ORDER BY ?womanLabel
</sparql>
 
 
=== Women who were FSAs who went to Oxford or Cambridge colleges ===
 
<sparql tryit="1">
#how many women who were FSAs went to Oxford or Cambridge colleges?


WHERE {
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
    ?person bnwdt:P3 bnwd:Q10 . #select men 211.
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
    ?person bnp:P117 ?wikidata_ID . #get wikidata ID
PREFIX bnwdv: <https://beyond-notability.wikibase.cloud/value/>
    ?wikidata_ID bnpq:P14 ?wikidata_url .
PREFIX bnwdt: <https://beyond-notability.wikibase.cloud/prop/direct/>
    BIND(IRI(REPLACE(?wikidata_url, "https://www.wikidata.org/wiki/", "http://www.wikidata.org/entity/")) as ?wikidata )
PREFIX bnp: <https://beyond-notability.wikibase.cloud/prop/>
 
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
    SERVICE <https://query.wikidata.org/sparql> {     
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
        ?wikidata ?p ?s .
PREFIX bnpsv: <https://beyond-notability.wikibase.cloud/prop/statement/value/>
            ?prop wikibase:claim ?p;
 
                wikibase:propertyType ?prop_type ;
SELECT ?person ?personLabel ?college ?collegeLabel ?universityLabel
                wikibase:statementProperty ?ps.    
WHERE { 
            ?prop rdfs:label ?prop_label. filter(lang(?prop_label)="en") .  
  ?person bnwdt:P3 bnwd:Q3 . #select women
        filter(?prop_type in (wikibase:Time, wikibase:WikibaseItem ) ) .
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
      # also a few quantity, string, monolingualtext
 
     
  ?person bnwdt:P75 bnwd:Q8. # only BN subjects having a FSA
    }  #/ wikidata
 
     
  # educated at (P94) part of (P4) cambridge (Q1181) oxford (Q364)  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en, en-gb". }  
 
  ?person bnwdt:P94 ?college . 
  ?college bnwdt:P4 ?university .  
 
  FILTER ( ?university in ( bnwd:Q1181 , bnwd:Q364 ) )
 
   SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en".}
}
}
group by ?prop_label  ?prop     
order by ?personLabel ?collegeLabel
order by ?prop_label
 
</sparql>
</sparql>


=== BN Men in Wikidata: men who proposed elections to SAL/RAI ===
=== All women who went to tertiary education institutions and dates where available ===


<sparql tryit="1">
<sparql tryit="1">
#title:Men who proposed for SAL/RAI elections who are in Wikidata
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 2,451: Line 2,627:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpsv: <https://beyond-notability.wikibase.cloud/prop/statement/value/>
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>


SELECT distinct ?proposerLabel ?proposer ?wikidata ?odnb_url ?wikipedia ?wd_dob ?wd_dod
SELECT ?person ?personLabel ?college ?collegeLabel ?university ?universityLabel ?date ?date_label
WHERE {
 
   ?person (bnp:P16 | bnp:P7) ?s . # proposed to either SAL or RAI
WHERE {
   ?s (bnps:P16 | bnps:P7) ?proposer .
   ?person bnwdt:P3 bnwd:Q3 . #select women
    ?proposer bnwdt:P3 bnwd:Q10 .
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
    
    
     ?proposer bnwdt:P117 ?wikidata_ID . #get wikidata ID
  # note: academic degree is P59. possible extra info?
     bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_ID))) as ?wikidata) .  
  ?person bnp:P94 ?s .  # educated at
     ?s bnps:P94 ?college .
    optional {?college bnwdt:P4 ?university . } # a few ?college aren't part of (P4) a ?university
  ?college bnwdt:P12 bnwd:Q2914 .  # tertiary ed inst
 
  # dates.
    optional {
     ?s ?pq ?date .     
      ?qual_prop wikibase:qualifier ?pq;
              wikibase:propertyType wikibase:Time ; # nb excludes edtf dates
              rdfs:label ?date_label . filter(lang(?date_label)="en-gb") . # what kind of date is it.
      } # /dates
   
    
    
    SERVICE <https://query.wikidata.org/sparql> {
   SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en".}
   
}
      optional { 
order by ?personLabel ?collegeLabel ?date
        # P1415 Oxford Dictionary of National Biography ID
 
        ?wikidata wdt:P1415 ?odnb_id . 
</sparql>
        BIND(IRI(concat("https://doi.org/10.1093/ref:odnb/", ?odnb_id)) as ?odnb_url ) . # make odnb link
 
        } #/ odnb
 
     
=== Academic degrees ===
        # could also add:    P6829 Dictionary of Irish Biography ID | P1648 Dictionary of Welsh Biography ID
     
        # English language wikipedia articles in wikidata entries, where listed
        OPTIONAL {
          ?wikipedia schema:about ?wikidata .
          ?wikipedia schema:inLanguage 'en' .
          FILTER (SUBSTR(str(?wikipedia), 1, 25) = 'https://en.wikipedia.org/')
        } 
     
        # there will be a few duplicates here...
        optional { ?wikidata wdt:P569 ?wd_dob . } #date of birth on Wikidata P569
        optional { ?wikidata wdt:P570 ?wd_dod . }  #date of death on Wikidata P570
    }  #/ wikidata service
     
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en, en-gb". }  
}
ORDER BY  ?proposerLabel
</sparql>
 
==== Male proposers who have occupations data in Wikidata====


<sparql tryit="1">
<sparql tryit="1">
#title:Men who proposed for SAL/RAI elections who have occupation(s) in wikidata
# Fetch academic degrees for women, with date and conferring institution where available
# with occupation labels, which was slightly trickier than expected
 
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 2,502: Line 2,669:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpsv: <https://beyond-notability.wikibase.cloud/prop/statement/value/>
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>


SELECT distinct ?personLabel ?proposerLabel
SELECT distinct ?person ?personLabel ?degree ?degreeLabel ?by ?byLabel ?date ?date_label
(group_concat(distinct ?wd_label; SEPARATOR="; ") as ?proposer_occupations)
 
?wikidata ?person ?proposer
WHERE {
WHERE {
   ?person bnwdt:P3 bnwd:Q3 . #select women
   ?person (bnp:P16 | bnp:P7) ?s . # proposed to either SAL or RAI
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
   ?s (bnps:P16 | bnps:P7) ?proposer .
 
     ?proposer bnwdt:P3 bnwd:Q10 .
  # academic degree = P59.
   ?person bnp:P59 ?s .
     ?s bnps:P59 ?degree . # type of degree
 
  # optional qualifiers for degree
    
    
    ?proposer bnwdt:P117 ?wikidata_ID . #get wikidata ID
  # P61 conferred by
     bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_ID))) as ?wikidata) .  
     optional { ?s bnpq:P61 ?by . }
    
    
     SERVICE <https://query.wikidata.org/sparql> {
  # date with type
        ?wikidata wdt:P106 ?wd_occupation .  
     optional {
        # automatic *Label doesn't work with a federated query; this works instead.     
    ?s ?pq ?date .      
        SERVICE wikibase:label {
      ?qual_prop wikibase:qualifier ?pq;
               bd:serviceParam wikibase:language "en".
               wikibase:propertyType wikibase:Time ; # nb excludes edtf dates
               ?wd_occupation rdfs:label ?wd_label.  
               rdfs:label ?date_label . filter(lang(?date_label)="en-gb") . # kind of date
              }  
      } # /dates
    }  #/ wikidata service
     
     
   SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en".}
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en, en-gb". }  
 
}
}
group by ?personLabel ?proposerLabel ?wikidata ?person ?proposer
order by ?personLabel ?date ?degreeLabel
ORDER BY  ?proposerLabel ?person
</sparql>
</sparql>


=== BN Men in Wikidata: Spouses ===
==IDs==
 
===Women in the wiki (excluding the project team) and their corresponding IDs - where they exist - on wikidata, viaf, WorldCat Identities, and the Archaeology Data Service===


<sparql tryit="1">
<sparql tryit="1">
#title: BN spouses who are in Wikidata
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 2,542: Line 2,712:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
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 ?wikidata_ID ?viaf_ID ?ads_ID ?worldcat_ID
WHERE { 
  ?person bnwdt:P3 bnwd:Q3 .                                #select women
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .}            #filter out project team
    OPTIONAL {?person bnwdt:P117 ?wikidata_ID .}            #return wikidata ID
    OPTIONAL {?person bnwdt:P119 ?viaf_ID .}                #return VIAF ID
    OPTIONAL {?person bnwdt:P34 ?ads_ID .}                  #return Archaeological Data Service ID
    OPTIONAL {?person bnwdt:P118 ?worldcat_ID .}            #return WorldCat Identities ID
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }
}
ORDER BY ?personLabel
</sparql>


SELECT distinct ?spouse ?spouseLabel  ?wikidata ?odnb_url ?wikipedia ?wd_dob ?wd_dod
===FSAs in the wiki (excluding the project team) and their corresponding IDs - where they exist - on wikidata, viaf, WorldCat Identities, and the Archaeology Data Service===
WHERE {
  ?person bnwdt:P3 bnwd:Q3.
  ?person bnwdt:P41 ?spouse .


    ?spouse bnwdt:P117 ?wikidata_ID . #get wikidata ID
<sparql tryit="1">
    bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_ID))) as ?wikidata) .
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
 
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
    SERVICE <https://query.wikidata.org/sparql> {
PREFIX bnwdv: <https://beyond-notability.wikibase.cloud/value/>
   
PREFIX bnwdt: <https://beyond-notability.wikibase.cloud/prop/direct/>
      optional { 
PREFIX bnp: <https://beyond-notability.wikibase.cloud/prop/>
        # P1415 Oxford Dictionary of National Biography ID
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
       
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
        ?wikidata wdt:P1415 ?odnb_id . 
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
        BIND(IRI(concat("https://doi.org/10.1093/ref:odnb/", ?odnb_id)) as ?odnb_url ) . # make odnb link
PREFIX wd: <http://www.wikidata.org/entity/>
        } #/ odnb
     
        # couls also add:     P6829 Dictionary of Irish Biography ID | P1648 Dictionary of Welsh Biography ID
     
        # English language wikipedia articles in wikidata entries, where listed
        OPTIONAL {
          ?wikipedia schema:about ?wikidata .
          ?wikipedia schema:inLanguage 'en' .
          FILTER (SUBSTR(str(?wikipedia), 1, 25) = 'https://en.wikipedia.org/')
        } 
     
        optional { ?wikidata wdt:P569 ?wd_dob . } #date of birth on Wikidata P569
        optional { ?wikidata wdt:P570 ?wd_dod . }  #date of death on Wikidata P570
   
    }  #/ wikidata service
     
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en, en-gb". }


SELECT ?person ?personLabel ?wikidata_ID ?viaf_ID ?ads_ID ?worldcat_ID
WHERE { 
  ?person bnwdt:P3 bnwd:Q3 .                                #select women
  ?person bnwdt:P16 ?FSA .                                  #select FSA
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .}            #filter out project team
    OPTIONAL {?person bnwdt:P117 ?wikidata_ID .}            #return wikidata ID
    OPTIONAL {?person bnwdt:P119 ?viaf_ID .}                #return VIAF ID
    OPTIONAL {?person bnwdt:P34 ?ads_ID .}                  #return Archaeological Data Service ID
    OPTIONAL {?person bnwdt:P118 ?worldcat_ID .}            #return WorldCat Identities ID
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }
}
}
ORDER BY ?proposerLabel
ORDER BY ?personLabel
</sparql>
</sparql>


==Fishing Expeditions==
===People with IDs on wikidata, their date of birth on wikidata, and the source(s) of that information===
 
===All properties in use in the wikibase with property type, label and description (if present)===


<sparql tryit="1">
<sparql tryit="1">
# query for information about properties that are being used in the wikibase
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/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX pr: <http://www.wikidata.org/prop/reference/>
PREFIX prov: <http://www.w3.org/ns/prov#>


## fyi: not actually necessary to declare these properties
SELECT ?woman ?womanLabel ?WDitem ?WDdateOfBirth (GROUP_CONCAT(?BirthStatedInEnglish;separator=" | ") AS ?sources)
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
WHERE { 
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
  #Select all women
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
  ?woman bnwdt:P3 bnwd:Q3 .
PREFIX wikibase: <http://wikiba.se/ontology#>
  #select all women that have a Wikidata link
PREFIX schema: <http://schema.org/>
  ?woman bnwdt:P117 ?Qnumber .  
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
 
 
  #create reference to Wikibase entity
SELECT DISTINCT
  BIND(IRI(concat("http://www.wikidata.org/entity/", ?Qnumber)) as ?WDitem )
  ?property
  #on Wikibase do
  ?propertyType
  SERVICE <https://query.wikidata.org/sparql> {
  ?propertyLabel 
        #get the date of birth
  (group_concat(?propertyAltLabel; separator=" | ") as ?propertyAltLabels)
        ?WDitem wdt:P569 ?WDdateOfBirth .
  ?propertyDescription
        #get the statement of birth
 
        ?WDitem p:P569 ?Birthstatement .
WHERE {
        #get its node
  ?property a wikibase:Property ;
        ?Birthstatement prov:wasDerivedFrom ?BirthRefnode.
              rdfs:label ?propertyLabel ; # label
        #get the value of 'Stated in'
              wikibase:propertyType ?propertyType . # datatype
        ?BirthRefnode   pr:P248 ?BirthStatedIn.
 
        #get the english label of the referece 'stated in'
  # add alternative labels if present (can be multiple)
        OPTIONAL {?BirthStatedIn rdfs:label ?BirthStatedInEnglish
   OPTIONAL { ?property skos:altLabel ?propertyAltLabel . }
                  FILTER (LANG(?BirthStatedInEnglish) = "en")}.
 
      }  
  # add description if present
  OPTIONAL {  
        SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en".
          ?property schema:description ?propertyDescription .
        }
  }  
    
    
   FILTER(LANG(?propertyLabel) = 'en-gb')
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }
  # fix label language dups; but Q why doesn't SERVICE work?
  # A: https://en.wikibooks.org/wiki/SPARQL/FILTER#FILTER_on_values_in_Labels
  # nb a few objects found with en-gb label missing
 
}
}
group by ?property ?propertyLabel ?propertyType ?propertyDescription
GROUP BY ?woman ?womanLabel ?WDitem ?WDdateOfBirth
order by ?propertyLabel
ORDER BY ?womanLabel
 
# Credit to Maarten Zeinstra for developing this query
</sparql>
</sparql>


 
=== Which women in the wikibase have Wikipedia articles, according to Wikidata?===
=== All the Things for Organisations ===


<sparql tryit="1">
<sparql tryit="1">


# Exploratory query to get all info on an item page including qualifiers (but not references) for each organisation (Q2316) in the wikibase
# Initially this *only* fetched organisations that specifically have the instance of Q2316: I didn't realise for a while how many organisations don't directly reference Q2316.
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 2,642: Line 2,813:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
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 ?wikidata ?wikipedia
WHERE { 
  ?person bnwdt:P3 bnwd:Q3 . #select women
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team


select distinct ?item ?itemLabel
  ?person bnwdt:P117 ?wikidata_ID . #look for wikidata ID on person page
?prop ?propLabel ?prop_type
    bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_ID))) as ?wikidata) .
?stmt_value ?stmt_valueLabel
?qual_prop  ?qual_value ?qual_label ?qual_prop_type
?statement


where {


?item bnwdt:P12+ bnwd:Q2316  . # instance of organisation or descendants of (excluding instance of organisation itself)
  SERVICE <https://query.wikidata.org/sparql> {
      # get English language wikipedia articles in wikidata entries, where listed
        OPTIONAL {
          ?wikipedia schema:about ?wikidata .
          ?wikipedia schema:inLanguage 'en' .
          FILTER (SUBSTR(str(?wikipedia), 1, 25) = 'https://en.wikipedia.org/')
        } 
      } 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }
}
ORDER BY ?personLabel


  # get all the things about ?item 
</sparql>
    ?item ?p ?statement . 
 
  # to get item Label without using service. couple of missing en-gb labels somewhere
  # ?item rdfs:label ?item_label . filter(lang(?item_label)="en-gb") .
 
 
  # get stuff about ?p
    ?prop wikibase:claim ?p; 
            wikibase:statementProperty ?ps;  # "Links property entity to statement simple value predicate"
        #wikibase:statementValue ?psv; # "Links property entity to statement full value predicate"   
            wikibase:propertyType ?prop_type.       


  # get stuff about ?statement
    ?statement ?ps ?stmt_value.
 
  # get any qualifiers
  optional {
    ?statement ?qual_p ?qual_value . 
    ?qual_prop wikibase:qualifier ?qual_p;
          wikibase:propertyType ?qual_prop_type ;
          rdfs:label ?qual_label. filter(lang(?qual_label)='en-gb') .
    }
 
#  OPTIONAL { ?item skos:altLabel ?alt_label . } 
 
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }
 
}


order by ?item_label ?prop_label
=== Women with no date of death in our wikibase who have a date of death on Wikidata===
 
</sparql>
 
 
===Working with property paths: organisations and locations===


<sparql tryit="1">
<sparql tryit="1">
## problem: sometimes you need to follow property paths using */+ for (eg) locations. BUT this can lead to several results to choose between and they aren't necessarily returned in the "right" order.
# Women who have no date of death in our wikibase and have a date of death on Wikidata
## how to determine the "distance" along the path of each result?
## https://stackoverflow.com/questions/61984052/wikidata-get-the-full-subhierachy-of-one-class-as-well-as-all-nodes
## > you can get the distance of a class with SELECT ?cls (count(?tmp) as ?distance) WHERE {  ?cls wdt:P279* ?tmp .  ?tmp wdt:P279+ wd:Q2095 . } group by ?cls order by asc(?distance) - though there might be corner cases like cycles in the hierarchy resp. multiple paths


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 2,703: Line 2,852:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
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 ?item ?itemLabel ?location ?locationLabel (count(?item) as ?distance)
SELECT ?person ?personLabel  ?wd_dod
WHERE {   
WHERE {   
   ?item bnwdt:P12 bnwd:Q2316 . # instance of organisation.
   ?person bnwdt:P3 bnwd:Q3 . #select women
   ?item bnwdt:P2* ?tmp .
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
   ?tmp bnwdt:P2+ ?location . # P2=30. P2+=34
   filter not exists {?person bnwdt:P15 ?bn_dod . } # *don't* have P15 date of death
 
   ?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 wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb, en". }  
 
  SERVICE <https://query.wikidata.org/sparql> {
        ?item wdt:P21 ?WD_gender. #get gender of person
        ?item wdt:P570 ?wd_dod .  #date of death on Wikidata P570
      }
 
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
}
}
group by ?item ?itemLabel  ?location ?locationLabel
ORDER BY ?personLabel
ORDER BY ?item ?distance
</sparql>
</sparql>


=== Working with property paths: instance of [CAVEAT: experimental, probably wrong]===
=== Women with no date of birth in our wikibase who have a date of birth in Wikidata===


<sparql tryit="1">
<sparql tryit="1">
# an attempt to adapt the query above following paths for locations of organisations for (more complex) instance of
# Women who have no date of birth in our wikibase and have a date of birth on Wikidata
# ref https://stackoverflow.com/questions/61984052/wikidata-get-the-full-subhierachy-of-one-class-as-well-as-all-nodes
# distance is in the right *order* so it should be usable for some purposes, but the starting number = number of levels rather than 1. also jumps if there are siblings somewhere along the path.


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 2,730: Line 2,888:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
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 ?item ?itemLabel ?instance_of ?instance_ofLabel (count(?item) as ?distance)
SELECT ?person ?personLabel ?wd_dob
WHERE {   
WHERE {   
   ?item bnwdt:P12* ?tmp .  # instance of anything.
   ?person bnwdt:P3 bnwd:Q3 . #select women
   ?tmp bnwdt:P12+ ?instance_of . # P2=30. P2+=34
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
   
  filter not exists {?person bnwdt:P26 ?bn_dob . } # *don't* have P15 date of death
 
   ?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 wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb, en". }  
  SERVICE <https://query.wikidata.org/sparql> {
        ?item wdt:P21 ?WD_gender. #get gender of person
        ?item wdt:P569 ?wd_dob .  #date of birth on Wikidata P569
      }
 
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
}
}
group by ?item ?itemLabel  ?instance_of ?instance_ofLabel
ORDER BY ?personLabel
ORDER BY ?item ?distance
 
</sparql>
</sparql>


==Dates==
=== All external IDs on Wikidata for Women ===
 
===All the Dates for Women FSAs===


<sparql tryit="1">
<sparql tryit="1">
#title:fishing for dates for FSAs
# Query to fetch all available External IDs on Wikidata for FSAs
# union query to get [hopefully] every date associated with women FSAs including main dates and qualifier dates
# NB this will take a while, but it should finish.
 
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 2,761: Line 2,926:
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>


SELECT distinct ?person ?personLabel ?prop_label ?qualLabel ?qual_dateLabel ?date_value  ?s 
SELECT distinct ?person ?personLabel ?wikidata ?p ?id_no ?id_label
#?prop ?qual


WHERE {
WHERE {
 
    ?person bnwdt:P3 bnwd:Q3 . #select women  
  ?person bnwdt:P3 bnwd:Q3 . #select women
    #?person bnwdt:P75 bnwd:Q8. # limit to FSAs if the full set times out.
  ?person bnwdt:P75 bnwd:Q8. # find only BN subjects having a FSA
 
  # get stuff about ?person 
  ?person ?p ?s . 
 
      # get stuff about ?p .
      ?prop wikibase:claim ?p;   
        wikibase:statementProperty ?ps ; 
        wikibase:statementValue ?psv .   
      ?prop wikibase:propertyType ?date_prop_type .
      ?prop rdfs:label ?prop_label. filter(lang(?prop_label)="en-gb") .  
    
    
    ?person bnwdt:P117 ?wikidata_ID . #get wikidata ID
    bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_ID))) as ?wikidata) .


{  # main dates
    SERVICE <https://query.wikidata.org/sparql> {
 
   
  # get dates detail via ?s and psv
    ?wikidata ?p ?s .  
  # gets edtf dates in simplified std wiki date format?
      ?prop wikibase:claim ?p;   
  # https://github.com/ProfessionalWiki/WikibaseEdtf 
            wikibase:statementProperty ?ps; # NB rather than statementValue
      ?s ?psv ?wdv .
            wikibase:propertyType wikibase:ExternalId. # quicker than filter.
        ?wdv wikibase:timeValue ?date_value .
     
 
      ?prop rdfs:label ?id_label. filter(lang(?id_label)="en") . # ident name
  } # /main dates
 
  UNION
 
  { # qualifier dates
   
  # direct value (usually item) for the property
        ?s ?ps ?qual.
   
  # date qualifiers. [assumes no edtf in quals. ]
        ?s ?pq ?date_value . 
          ?qual_date wikibase:qualifier ?pq .
          ?qual_date wikibase:propertyType wikibase:Time.  
          ?qual_date rdfs:label ?date_qual_label . filter(lang(?date_qual_label)="en") .  
        
        
  }  # /qual dates
          ?s ?ps ?id_no . # id value
 
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
 
} # /where


ORDER BY ?person ?prop_label ?date_value
      # filter by property type
      #filter(?prop_type in (wikibase:ExternalId ) ) .
    } 
     
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en, en-gb". }
}
           
order by ?personLabel ?id_label ?id_no


</sparql>
</sparql>


===Fetch any of multiple kinds of EDTF date for a woman===
=== What external IDs are available in Wikidata for women in the BN database? ===


<sparql tryit="1">
<sparql tryit="1">
# a union query to fetch stuff for multiple properties, in this case dates recorded in EDTF which need slightly different handling from PIT dates
# All the external IDs on BN women's Wikidata pages, with counts and descriptions
# main dates only; pretty sure there are no EDTF in qualifiers.
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
# updated to get date property labels
 
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/>
PREFIX bnwdv: <https://beyond-notability.wikibase.cloud/value/>
PREFIX bnwdv: <https://beyond-notability.wikibase.cloud/value/>
Line 2,827: Line 2,968:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
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 ?date_edtf ?date_prop ?date_label ?s
SELECT ?p ?id_label ?id_description  (count(?p) as ?count)


WHERE { ?person bnwdt:P3 bnwd:Q3 .  
WHERE {
      FILTER NOT EXISTS { ?person bnwdt:P4 bnwd:Q12 . }  
  ?person bnwdt:P3 bnwd:Q3 . #select women
   
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
      ## can do this union first but makes no difference to results except possibly a bit slower.
      #?person ( bnp:P131 | bnp:P132 | bnp:P133  ) ?s .
      #  ?s ( bnps:P131 | bnps:P132 | bnps:P133  ) ?date_edtf .


      ?person ?p ?s . # so you can get the statement id and date prop label
  ?person bnwdt:P117 ?wikidata_ID . # wikidata ID
          ?claim wikibase:claim ?p;      
    bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_ID))) as ?wikidata) .
                rdfs:label ?date_label. filter(lang(?date_label)="en") .         
 
    SERVICE <https://query.wikidata.org/sparql> {
    ?wikidata ?p ?s .
          ?prop wikibase:claim ?p;  
              wikibase:propertyType wikibase:ExternalId; 
              rdfs:label ?id_label. filter(lang(?id_label)="en") .
      ?prop schema:description ?id_description .  
      filter(lang(?id_description) = "en") .  
      
     
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en, en-gb". }
}
group by ?p ?id_label ?id_description
ORDER BY desc(?count)


          ?s ?date_prop ?date_edtf .
</sparql>
             
    ## filter for edtf dates
    ## docs: https://github.com/ProfessionalWiki/WikibaseEdtf


    FILTER ( datatype(?date_edtf) = xsd:edtf  ) .
=== Women with ODNB IDs in Wikidata ===
           
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en, en-gb". }
    }
 
ORDER BY ?personLabel
 
</sparql>
 
===Full values: dates ===


<sparql tryit="1">
<sparql tryit="1">
 
# BN women with ODNB biography IDs on Wikidata, with links to the bios
# query for full values to access the timeValue and timePrecision of a date, in this case a date of birth.
 
## why is a more complex query needed?
## simple value for a date doesn't differentiate between (eg) "1880" and "1 January 1880"; both are returned as 1 January 1880 (and SELECT DISTINCT will collapse them into a single result)
## there are 14 codes for precision from billion years to second. 7: century, 8: decade, 9: year, 10: month, 11: day
## NB additional bnpsv: prefix
## https://www.mediawiki.org/wiki/Wikibase/Indexing/RDF_Dump_Format#Value_representation


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 2,875: Line 3,009:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpsv: <https://beyond-notability.wikibase.cloud/prop/statement/value/>
PREFIX bnpsv: <https://beyond-notability.wikibase.cloud/prop/statement/value/>
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>
SELECT distinct ?person ?personLabel ?wikidata ?url


SELECT DISTINCT ?item ?itemLabel ?date ?precision
WHERE {
WHERE {
  ?item bnp:P26  ?statement. # date of birth (precision of these varies quite a bit)
    ?person bnwdt:P3 bnwd:Q3 . #select women 
  ?statement bnpsv:P26 ?valueNode.
   
  ?valueNode wikibase:timeValue ?date.
    ?person bnwdt:P117 ?wikidata_ID . #get wikidata ID
  ?valueNode wikibase:timePrecision ?precision.
    bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_ID))) as ?wikidata) .
    
    
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
    SERVICE <https://query.wikidata.org/sparql> {
}
   
ORDER BY ?date
    # P1415 Oxford Dictionary of National Biography ID | P6829 Dictionary of Irish Biography ID | P1648 Dictionary of Welsh Biography ID
    ?wikidata wdt:P1415 ?id . 


</sparql>
    # odnb link
    BIND(IRI(concat("https://doi.org/10.1093/ref:odnb/", ?id)) as ?url ) .
   
    } 
     
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en, en-gb". }
}
           
order by ?personLabel ?id
</sparql>


=== Any main level date for women ===
=== Women with National Portrait Gallery links via Wikidata ===


<sparql tryit="1">
<sparql tryit="1">
# a query to get all types of main date for women
# Query to fetch National Portrait Gallery IDs on Wikidata for BN women, with links
 
# NB this may be a bit slow...
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 2,902: Line 3,048:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpsv: <https://beyond-notability.wikibase.cloud/prop/statement/value/>
PREFIX bnpsv: <https://beyond-notability.wikibase.cloud/prop/statement/value/>
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>


SELECT DISTINCT ?person ?personLabel ?date_label  ?date ?date_prop_type ?date_prop ?link_prop
SELECT distinct ?person ?personLabel ?wikidata ?id_no ?npg_url


WHERE {
WHERE {
    ?person bnwdt:P3 bnwd:Q3 . #select women   
    
    
  ?person bnwdt:P3 bnwd:Q3 . # women
    ?person bnwdt:P117 ?wikidata_ID . #get wikidata ID
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .}     
    bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_ID))) as ?wikidata) .
    
    
  ?person ?p ?s .
    SERVICE <https://query.wikidata.org/sparql> {
    
   
      ?date_prop wikibase:claim ?p;  
    ?wikidata ?p ?s .     
        wikibase:statementValue ?psv ;
      ?prop wikibase:claim ?p;  
        wikibase:propertyType ?date_prop_type; # property type = wikibase:Time OR wikibase:Edtf
            wikibase:statementProperty ?ps;  
        rdfs:label ?date_label. filter(lang(?date_label)="en-gb") . # what kind of date it is
            wikibase:propertyType wikibase:ExternalId.
 
   
        # direct link to relevant section of page
          ?s ps:P1816 ?id_no . # id value
        BIND (REPLACE(STR(?date_prop), "^.*/([^/]*)$", "$1") as ?pid).
      # npg link
        bind(iri(concat(str(?person), "#", ?pid)) as ?link_prop ) .  
          BIND(IRI(concat("https://www.npg.org.uk/collections/search/person/", ?id_no)) as ?npg_url ) .
     
     }  
      ?s ?psv ?wdv . # for the date value
     
        ?wdv wikibase:timeValue ?date .  #timeValue gets pit and edtf
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en, en-gb". }  
     #  ?wdv wikibase:timePrecision ?date_precision . # optional
 
   # nb also possible to filter either/or time/edtf by property type
  # filter(?date_prop_type in (wikibase:Edtf, wikibase:Time ) ) . 
 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
}
ORDER BY ?personLabel ?date
           
 
order by ?personLabel ?id_no
</sparql>
</sparql>


=== Counting Dates===
=== Which BN properties map on to Wikidata properties? ===


<sparql tryit="1">
<sparql tryit="1">
# count distinct dates for women (who have at least one)
 
# uncomment HAVING line for women with only one
## **NOTES**
# CAVEAT: there may be some discrepancies between dates shown on wiki pages and dates returned by sparql
## a few properties have a linked wikidata "Q" rather than "P" ID. These will unfortunately not link correctly to Wikidata so wd_label/wd_description won't be present.
## a few other properties may have wikidata=yes but no wd_label and/or wd_description. This could be because the property on Wikidata has been deleted (eg performed at).
 
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 2,947: Line 3,091:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpsv: <https://beyond-notability.wikibase.cloud/prop/statement/value/>
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>


SELECT ?person ?personLabel (COUNT(DISTINCT ?date_value) as ?count)  
SELECT DISTINCT ?property (if(bound(?wikidata_id), "yes", "no") as ?has_wikidata) ?bn_label ?wd_label ?bn_description
  ?wd_description ?wikidata ?bn_propertyType


WHERE {
WHERE {
  ?property a wikibase:Property ;
              wikibase:propertyType ?bn_propertyType . # datatype
   
   
# main dates
  service wikibase:label {   
 
            bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en".  
  ?person bnwdt:P3 bnwd:Q3 . # women 
            ?property rdfs:label ?bn_label .
  ?person ?p ?s .       
            ?property schema:description ?bn_description .
      ?s ?date_prop ?wdv .
                            }
        ?wdv wikibase:timeValue ?date_value .
    # wikidata P117 
  } # /main dates
     optional {
 
            ?property bnwdt:P117 ?wikidata_id .  
  UNION
                bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_id))) as ?wikidata) .
 
  { # qualifier dates
      
    ?person bnwdt:P3 bnwd:Q3 . 
    ?person ?p ?s .  
      ?s ?date_prop ?pqv .
        ?pqv wikibase:timeValue ?date_value.
    }  # /qual dates
 
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en". }
 
} # /where
GROUP BY ?person ?personLabel
# HAVING(?count=1)


ORDER BY ?count ?person
            SERVICE <https://query.wikidata.org/sparql> {
                    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en".
                            ?wikidata schema:description ?wd_description .
                            ?wikidata rdfs:label ?wd_label .
                    } # / label service
              } # /wikidata service 
          } #/wikidata optional
}
order by ?bn_label
</sparql>
</sparql>


=== Start dates that might not have accompanying end dates ===
==== Of these, which are properties for public and professional activities? ====


<sparql tryit="1">
<sparql tryit="1">
#title:Women with start dates that might not have accompanying end dates
# which properties have corresponding wikidata IDs, restricted to instance of PPA (P12 / Q151)
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
 
## **NOTES**
## a few properties have a linked wikidata "Q" rather than "P" ID. These will unfortunately not link correctly to Wikidata so wd_label/wd_description won't be present.
## a few other properties may have wikidata=yes but no wd_label and/or wd_description. This could be because the property on Wikidata has been deleted (eg performed at).
 
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/>
PREFIX bnwdv: <https://beyond-notability.wikibase.cloud/value/>
PREFIX bnwdv: <https://beyond-notability.wikibase.cloud/value/>
Line 2,992: Line 3,136:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpsv: <https://beyond-notability.wikibase.cloud/prop/statement/value/>
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>


SELECT distinct ?personLabel ?prop_label ?start_date  (if(bound(?end_date), "yes", "no") as ?has_end_date) ?person ?
SELECT DISTINCT ?property (if(bound(?wikidata_id), "yes", "no") as ?has_wikidata) ?bn_label ?wd_label ?bn_description
#(group_concat(?other_date_label; SEPARATOR=" | ") as ?other_dates)
  ?wd_description ?wikidata ?bn_propertyType


WHERE {
WHERE {
   ?person bnwdt:P3 bnwd:Q3 .
   ?property a wikibase:Property ;
    
              wikibase:propertyType ?bn_propertyType . # datatype
  # need to find start times anywhere and get prop label so use claim.
  ?person ?p ?s .  
   service wikibase:label
  ?claim wikibase:claim ?p;     
            bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en".  
        rdfs:label ?prop_label. filter(lang(?prop_label)="en") .
            ?property rdfs:label ?bn_label .
      
            ?property schema:description ?bn_description .
# pretty sure start time is qualifier only... 
                            }
# get start dates
     # wikidata P117  
  # then optional end dates
    optional { ?property bnwdt:P117 ?wikidata_id .  
# can only see end time/pit associated, and the only pit with start time is not relevant, but can't be sure that'll always be true.
                bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_id))) as ?wikidata) .  
# optional other that excludes both start/end but lists any other date types
 
    ?s bnpq:P27 ?start_date . # get start dates
 
    optional {?s bnpq:P28 ?end_date .} # check for end dates


#  optional {
            SERVICE <https://query.wikidata.org/sparql> {
#      ?s ?pq ?other_date . # could there be any other associated dates?
                    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en".  
     
                            ?wikidata schema:description ?wd_description .
#      ?qual_prop wikibase:qualifier ?pq;     
                            ?wikidata rdfs:label ?wd_label .  
#            wikibase:propertyType wikibase:Time ; # nb *does not* include edtf dates but AFAICT there are none in qualifiers.
                    } # / label service
#            rdfs:label ?other_date_label . filter(lang(?other_date_label)="en-gb") . # what kind of date is it.
              } # /wikidata service 
          } #/wikidata optional
    
    
        # drop both start and end this time. idk if there could be a faster way to do this?
    ?property bnwdt:P12 bnwd:Q151. # instance of PPA
#      filter not exists { ?s (bnpq:P27 | bnpq:P28) ?other_date . }
}
 
order by ?bn_label
} # / optional other dates
</sparql>
 
  # filter(!bound(?end_date)). # to filter out rows with an end date
 
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en". }
 
}


ORDER BY ?personLabel ?prop_label ?start_date
</sparql>




=== End dates that might not accompanying start dates ===
=== Archaeological sites/Historic houses and their owners/operators in Wikidata ===


<sparql tryit="1">
<sparql tryit="1">
#title:Women with end dates that might not have accompanying start dates
#title:archaeological sites/historic houses in wikidata
 
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 3,049: Line 3,180:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpsv: <https://beyond-notability.wikibase.cloud/prop/statement/value/>
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>


SELECT distinct ?personLabel ?prop_label ?end_date 
SELECT distinct ?item ?itemLabel ?instanceLabel ?wikidata ?wd_owner_label ?wd_operator_label ?wd_member_label  #?wd_owner ?wd_operator
(if(bound(?start_date), "yes", "no") as ?has_start_date) 
(group_concat(?other_date_label; SEPARATOR=" | ") as ?other_dates)
?person ?s


WHERE {
WHERE {
   ?person bnwdt:P3 bnwd:Q3 .
 
   ?person ?p ?s .
   { ?item bnwdt:P12 bnwd:Q86 . } # instance of archaeological site
   ?claim wikibase:claim ?p;     
   union
        rdfs:label ?prop_label. filter(lang(?prop_label)="en") .
   { ?item bnwdt:P12 bnwd:Q2961 . } # instance of historic house
   
 
# get end dates
  ?item bnwdt:P12 ?instance .   # which instance of is it
# then optional start dates
  filter ( ?instance in (bnwd:Q86, bnwd:Q2961) ) . # (need filter as a few have multiple instance of)
# can only see start time/pit associated, and in fact the only pit with start time is not relevant, but can't be sure that'll always be true.
# so an optional other that excludes both start/end but lists any other date types with group_concat
    
    
     ?s bnpq:P28 ?end_date . # get end dates
    ?item bnwdt:P117 ?wikidata_id .
    
    bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_id))) as ?wikidata) .
    optional {?s bnpq:P27 ?start_date .} # check for start dates
           
     SERVICE <https://query.wikidata.org/sparql> {
     
      optional { ?wikidata wdt:P127 ?wd_owner  .} # can be individuals and multiple.
      optional { ?wikidata wdt:P137 ?wd_operator . }
     
      optional { ?wikidata wdt:P463 ?wd_member . }
     
      ## at least some had *both* owned by *and* operator, but not always the case.
      ## owned by P127 / operator P137 
      ## English Heritage Q936287  National Trust (Q333515)
      ## member of P463   Historic Houses Association (Q5773523)
     
      # automatic *Label doesn't work with a federated query; rdfs:label instead.     
        SERVICE wikibase:label {  
              bd:serviceParam wikibase:language "en".
              ?wd_owner rdfs:label ?wd_owner_label.  
              ?wd_operator rdfs:label ?wd_operator_label.
              ?wd_member rdfs:label ?wd_member_label.
              }
      } 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
}
order by ?itemLabel
 
</sparql>
 
==== And which are owned/operated by English Heritage/National Trust or belong to Historic Houses Association ====
 
<sparql tryit="1">
 
# archaeological site or historic house.
# pull together via Wikidata which ones are owned/operated by 1) English Heritage 2) National Trust  or 3) affiliated to Historic Houses association


    optional {
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
        ?s ?pq ?other_date . # could there be any other associated dates?
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
        ?qual_prop wikibase:qualifier ?pq;     
PREFIX bnwdv: <https://beyond-notability.wikibase.cloud/value/>
              wikibase:propertyType wikibase:Time ; # nb *does not* include edtf dates but AFAICT there are none in qualifiers.
PREFIX bnwdt: <https://beyond-notability.wikibase.cloud/prop/direct/>
              rdfs:label ?other_date_label . filter(lang(?other_date_label)="en-gb") . # what kind of date
PREFIX bnp: <https://beyond-notability.wikibase.cloud/prop/>
        # drop both start and end. idk if there could be a faster way to do this?
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
        filter not exists { ?s (bnpq:P27 | bnpq:P28) ?other_date . }
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
 
SELECT distinct ?item ?itemLabel ?instanceLabel ?wikidata ?wd_owner_label ?wd_operator_label ?wd_member_label  #?wd_owner ?wd_operator
 
WHERE {   
    
    
  } # / optional other dates
  { ?item bnwdt:P12 bnwd:Q86 . }
  union
  { ?item bnwdt:P12 bnwd:Q2961 . }
    
    
  # filter(!bound(?start_date)). # to filter out rows with a start date (77 atm)
  ?item bnwdt:P12 ?instance .
  filter ( ?instance in (bnwd:Q86, bnwd:Q2961) ) .
   
  ?item bnwdt:P117 ?wikidata_id .
    bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_id))) as ?wikidata) .
               
    SERVICE <https://query.wikidata.org/sparql> {
 
      optional { ?wikidata wdt:P127 ?wd_owner .}
      optional { ?wikidata wdt:P137 ?wd_operator . }
      optional { ?wikidata wdt:P463 ?wd_member . }
 
      # filter: owner or operator = EH/NT / member of HHA
        filter ( ?wd_owner in (wd:Q936287, wd:Q333515) ||
                ?wd_operator in (wd:Q936287, wd:Q333515) ||
                ?wd_member = wd:Q5773523 ) .
 
      ## owned by P127 / operator P137 
      ## ENglish Heritage Q936287  National Trust (Q333515)
      ## member of P463  Historic Houses Association (Q5773523)  
           
      SERVICE wikibase:label {
              bd:serviceParam wikibase:language "en".
              ?wd_owner rdfs:label ?wd_owner_label.
              ?wd_operator rdfs:label ?wd_operator_label.
              ?wd_member rdfs:label ?wd_member_label.
              }
      } 
           
  #} # /optional for wikidata ID
    
    
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en". }  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }  
 
}
}  


group by ?personLabel ?prop_label ?end_date ?start_date ?has_start_date ?person ?s 
order by ?itemLabel


ORDER BY ?personLabel ?prop_label ?end_date
</sparql>
</sparql>


==Admin==


===Women about whom we have recorded fewer than 3 pieces of information===
 
== Men ==
 
 
=== BN Men in Wikidata ===


<sparql tryit="1">
<sparql tryit="1">
#title: BN men in Wikidata
# a starting point to get the basic query set up; can easily add more variables...
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 3,105: Line 3,301:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpsv: <https://beyond-notability.wikibase.cloud/prop/statement/value/>
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>


SELECT ?person ?personLabel ?statements WHERE {
SELECT distinct ?person ?personLabel ?wikidata ?whos_who ?odnb_url ?wikipedia ?wd_dob ?wd_dod ?wd_stmts
  ?person bnwdt:P3 bnwd:Q3 ;
        wikibase:statements ?statements .
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .}
  FILTER (?statements <3)
  SERVICE wikibase:label {
      bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb".
  }
}
</sparql>


===People for whom their item records is given as 'Mrs'===
WHERE {
    ?person bnwdt:P3 bnwd:Q10 . #select men 
 
    ?person bnwdt:P117 ?wikidata_ID . #get wikidata ID
    bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_ID))) as ?wikidata) .
 
    SERVICE <https://query.wikidata.org/sparql> {


<sparql tryit="1">
      ?wikidata   wikibase:statements ?wd_stmts .
SELECT ?id ?name
WHERE { 
   ?id rdfs:label ?name .
  FILTER regex(?name, "mrs *", "i") #this line uses regular expression syntax, described at https://regexper.com/#mrs%5Cs*
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }
}
</sparql>


===All triples in the wiki, limited to 1000===
      optional { 
        # P1415 Oxford Dictionary of National Biography ID | couls also add  P6829 Dictionary of Irish Biography ID | P1648 Dictionary of Welsh Biography ID
        ?wikidata wdt:P1415 ?odnb_id . 


<sparql tryit="1">
        # odnb link
SELECT ?a ?aLabel ?b ?c WHERE {
        BIND(IRI(concat("https://doi.org/10.1093/ref:odnb/", ?odnb_id)) as ?odnb_url ) .
    ?a ?b ?c
        } #/ odnb
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }
     
}
        # English language wikipedia articles in wikidata entries, where listed
LIMIT 1000 #please don't make this number too big as it will slow down the site!
        OPTIONAL {
</sparql>
          ?wikipedia schema:about ?wikidata .
          ?wikipedia schema:inLanguage 'en' .
          FILTER (SUBSTR(str(?wikipedia), 1, 25) = 'https://en.wikipedia.org/')
        } 
       
             
      optional { ?wikidata wdt:P4789 ?whos .
                  bind(iri(concat("https://www.ukwhoswho.com/view/article/oupww/whoswho/", ?whos)) as ?whos_who) .
                } # P4789 Who's Who


===All triples in the wiki, represented as a crude graph===
        optional { ?wikidata wdt:P569 ?wd_dob . } #date of birth on Wikidata P569
 
        optional { ?wikidata wdt:P570 ?wd_dod . }  #date of death on Wikidata P570
<sparql tryit="1">
#defaultView:Graph
    }  #/ wikidata
SELECT ?a ?aLabel ?c ?cLabel WHERE {
     
    ?a ?b ?c
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en, en-gb". }  
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }
}
}
#note query returns every connection in the wikibase so it may fall over!
           
order by ?personLabel
</sparql>
</sparql>


===People whose assigned gender we have been unable to determine and/or confirm===
=== What sort of info Wikidata has about BN men ===


<sparql tryit="1">
<sparql tryit="1">
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
#title: what info is there for BN men in Wikidata
WHERE { 
#counts of properties (excluding external IDs, of which there are gazillions) (Counts are overall and some people might have more than one.)
  ?person bnwdt:P3 ?gender .                             
#at time of writing there are 198 linked men.
  FILTER NOT EXISTS {?person bnwdt:P3 bnwd:Q3 .}          #filter out people identified as women
  FILTER NOT EXISTS {?person bnwdt:P3 bnwd:Q10 .}          #filter out people identified as men
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }
}
ORDER BY ?personLabel
</sparql>
 
===People who have a spouse statement and - optionally - marriage date statements for checking if there is any misalignment with 'Spouse not in wikibase' statements===
 
<sparql tryit="1">
# people who have a spouse statement and - optionally - marriage date statements for checking if there is any misalignment with 'Spouse not in wikibase' statements


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 3,184: Line 3,362:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpsv: <https://beyond-notability.wikibase.cloud/prop/statement/value/>
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>


SELECT ?person ?personLabel ?spouse ?spouseLabel ?edtfmarriagespouse ?edtfmarriagespouseLabel ?PITmarriagespouse ?PITmarriagespouseLabel WHERE {
SELECT ?prop_label ?prop (count(?prop) as ?count)
  ?person bnwdt:P41 ?spouse .
  OPTIONAL {?person bnp:P132 ?edtfmarriagestatement .
  ?edtfmarriagestatement bnps:P132 ?edtfmarriagedate .
  ?edtfmarriagestatement bnpq:P41 ?edtfmarriagespouse .}
  OPTIONAL {?person bnp:P130 ?PITmarriagestatement .
  ?PITmarriagestatement bnps:P130 ?PITmarriagedate .
  ?PITmarriagestatement bnpq:P41 ?PITmarriagespouse .}
    SERVICE wikibase:label {
      bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb".
    }
}
ORDER BY DESC(?edtfmarriagespouseLabel) DESC(?PITmarriagespouseLabel)
</sparql>


=== Compare uses of item v free text ===
WHERE {
    ?person bnwdt:P3 bnwd:Q10 . #select men 211.
 
    ?person bnwdt:P117 ?wikidata_ID . #get wikidata ID
    bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_ID))) as ?wikidata) .
 
    SERVICE <https://query.wikidata.org/sparql> {     
        ?wikidata ?p ?s .
            ?prop wikibase:claim ?p;
                wikibase:propertyType ?prop_type ;
                wikibase:statementProperty ?ps.   
            ?prop rdfs:label ?prop_label. filter(lang(?prop_label)="en") .
        filter(?prop_type in (wikibase:Time, wikibase:WikibaseItem ) ) .
      # also a few quantity, string, monolingualtext
     
    }  #/ wikidata
     
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en, en-gb". }
}
group by ?prop_label  ?prop     
order by ?prop_label
 
</sparql>
 
=== BN Men in Wikidata: men who proposed elections to SAL/RAI ===


<sparql tryit="1">
<sparql tryit="1">
# A number of properties have "item" and "free text" versions; a query to fetches both versions in each case to facilitate comparison of their uses.
#title:Men who proposed for SAL/RAI elections who are in Wikidata


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 3,212: Line 3,403:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpsv: <https://beyond-notability.wikibase.cloud/prop/statement/value/>
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>
SELECT distinct ?itemLabel ?prop_label ?qual_label ?qual_value ?qual_valueLabel ?item ?qual_prop
# most of these are used in qualifiers - only P72, P71 and P88 found in main (and only a handful of uses of free text?)
#?item (  bnp:P88|bnp:P91 | bnp:P72|bnp:P71) ?s .
## the pairs
#P21 evidence (free text) / P20 evidence (item)
#P79 item exhibited / P80 item exhibited (free text)
#P78 of / P66 of (free text)
#P91 specific reference information / P88 specific reference information (free text)
#P31 street address (free text) / P100 street address (item)
#P72 was delegate at (free text) / P71 was delegate at (item)


SELECT distinct ?proposerLabel ?proposer ?wikidata ?odnb_url ?wikipedia ?wd_dob ?wd_dod
WHERE {
WHERE {
  ?person (bnp:P16 | bnp:P7) ?s . # proposed to either SAL or RAI
  ?s (bnps:P16 | bnps:P7) ?proposer .
    ?proposer bnwdt:P3 bnwd:Q10 .
    
    
  ?item ?p ?s .  
    ?proposer bnwdt:P117 ?wikidata_ID . #get wikidata ID
    bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_ID))) as ?wikidata) .  
    
    
  ?prop wikibase:claim ?p;     
    SERVICE <https://query.wikidata.org/sparql> {
        rdfs:label ?prop_label. filter(lang(?prop_label)="en-gb") .
      
      
   ?s ( bnpq:P21|bnpq:P20 | bnpq:P80|bnpq:P79 | bnpq:P66|bnpq:P78 | bnpq:P88|bnpq:P91 | bnpq:P31|bnpq:P100 | bnpq:P72|bnpq:P71 ) ?qual_value .
      optional {    
 
        # P1415 Oxford Dictionary of National Biography ID
  ?s ?qual_p ?qual_value . 
        ?wikidata wdt:P1415 ?odnb_id . 
    ?qual_prop wikibase:qualifier ?qual_p;
        BIND(IRI(concat("https://doi.org/10.1093/ref:odnb/", ?odnb_id)) as ?odnb_url ) . # make odnb link
          wikibase:propertyType ?qual_prop_type ;
        } #/ odnb
          rdfs:label ?qual_label. filter(lang(?qual_label)='en-gb') .
     
 
        # could also add:    P6829 Dictionary of Irish Biography ID | P1648 Dictionary of Welsh Biography ID
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
     
        # English language wikipedia articles in wikidata entries, where listed
        OPTIONAL {
          ?wikipedia schema:about ?wikidata .
          ?wikipedia schema:inLanguage 'en' .
          FILTER (SUBSTR(str(?wikipedia), 1, 25) = 'https://en.wikipedia.org/')
        } 
     
        # there will be a few duplicates here...
        optional { ?wikidata wdt:P569 ?wd_dob . } #date of birth on Wikidata P569
        optional { ?wikidata wdt:P570 ?wd_dod . }  #date of death on Wikidata P570
    } #/ wikidata service
     
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en, en-gb". }  
}
}
order by ?qual_label ?prop_label ?itemLabel
ORDER BY  ?proposerLabel
 
</sparql>
</sparql>


=== Missing language labels ===
==== Male proposers who have occupations data in Wikidata====


<sparql tryit="1">
<sparql tryit="1">
 
#title:Men who proposed for SAL/RAI elections who have occupation(s) in wikidata
# query to check for any items/properties which don't have "en" labels. [currently not an issue but retained for reference.]
# with occupation labels, which was slightly trickier than expected


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 3,261: Line 3,454:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpsv: <https://beyond-notability.wikibase.cloud/prop/statement/value/>
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>
SELECT
  ?item  ?itemLabel
  (group_concat(distinct ?language) as ?languages)
  (count(distinct ?rdfs_label) as ?count) # TIL: where you put distinct matters! 


SELECT distinct ?personLabel ?proposerLabel
(group_concat(distinct ?wd_label; SEPARATOR="; ") as ?proposer_occupations)
?wikidata ?person ?proposer
WHERE {
WHERE {
 
   ?person (bnp:P16 | bnp:P7) ?s . # proposed to either SAL or RAI
   ?item ?p ?s.  
   ?s (bnps:P16 | bnps:P7) ?proposer .
   ?item rdfs:label ?rdfs_label . # rdfs item label (1 per language).  
    ?proposer bnwdt:P3 bnwd:Q10 .
    
    
  BIND(LANG(?rdfs_label) as ?language) .  # get 2 letter language codes
    ?proposer bnwdt:P117 ?wikidata_ID . #get wikidata ID
    bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_ID))) as ?wikidata) .
 
    SERVICE <https://query.wikidata.org/sparql> {
        ?wikidata wdt:P106 ?wd_occupation .
        # automatic *Label doesn't work with a federated query; this works instead.     
        SERVICE wikibase:label {
              bd:serviceParam wikibase:language "en".
              ?wd_occupation rdfs:label ?wd_label.  
              }
    } #/ wikidata service
     
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en, en-gb". }


  #optional { ?item rdfs:label ?engb . filter(lang(?engb)="en-gb").  }
  #optional { ?item rdfs:label ?en . filter(lang(?en)="en").  } 
 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en-gb, en". }
}
}
group by ?item  ?itemLabel
group by ?personLabel ?proposerLabel ?wikidata ?person ?proposer
HAVING (?count<2)
ORDER BY  ?proposerLabel ?person
order by ?item
 
</sparql>
</sparql>


=== Statements that contain both a date *and* an unknown value date===
=== BN Men in Wikidata: Spouses ===


<sparql tryit="1">
<sparql tryit="1">
# A query to look for statements containing an <unknown value> date *and* a date
#title: BN spouses who are in Wikidata
# caveat: not yet completely sure if it will work in all cases for main dates


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 3,301: Line 3,495:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


SELECT  ?item ?itemLabel ?main_label ?qualLabel ?subLabel
SELECT distinct ?spouse ?spouseLabel ?wikidata ?odnb_url ?wikipedia ?wd_dob ?wd_dod
(group_concat(distinct ?date_prop) as ?dates) 
WHERE {
(count (distinct(isBLANK(?t))) as ?tcount) 
  ?person bnwdt:P3 bnwd:Q3.
?s
  ?person bnwdt:P41 ?spouse .


# using isBlank() in select creates true/false, then count distinct finds any in a group having >1.
     ?spouse bnwdt:P117 ?wikidata_ID . #get wikidata ID
 
     bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_ID))) as ?wikidata) .  
WHERE
    
{
    SERVICE <https://query.wikidata.org/sparql> {
  {
  # qualifiers. [qualifiers need to include ?s in the group by]
  ?item ?p ?s.
 
  # labels
  ?s ?subp ?sub .
  ?qual wikibase:claim ?p;
        wikibase:statementProperty ?subp. 
 
    ?s ?pq ?t .
 
     ?date_prop wikibase:qualifier ?pq ;
            wikibase:propertyType ?date_prop_type .
     filter(?date_prop_type in (wikibase:Time, wikibase:Edtf) ).  
   }
  UNION
  {
  # main [excluding ?s from group by this time]
  ?item ?p ?sm.
  ?sm ?ps ?t .
      
      
   ?date_prop wikibase:claim ?p.
      optional {    
  ?date_prop wikibase:statementProperty ?ps.
        # P1415 Oxford Dictionary of National Biography ID
  ?date_prop wikibase:propertyType ?date_prop_type .
       
  ?date_prop rdfs:label ?main_label . filter(lang(?main_label)="en-gb") .
        ?wikidata wdt:P1415 ?odnb_id .  
   
        BIND(IRI(concat("https://doi.org/10.1093/ref:odnb/", ?odnb_id)) as ?odnb_url ) . # make odnb link
  filter(?date_prop_type in (wikibase:Time, wikibase:Edtf) ).
        } #/ odnb
  }
     
 
        # couls also add:    P6829 Dictionary of Irish Biography ID | P1648 Dictionary of Welsh Biography ID
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en_gb" }
     
        # English language wikipedia articles in wikidata entries, where listed
        OPTIONAL {
          ?wikipedia schema:about ?wikidata .
          ?wikipedia schema:inLanguage 'en' .
          FILTER (SUBSTR(str(?wikipedia), 1, 25) = 'https://en.wikipedia.org/')
        } 
     
        optional { ?wikidata wdt:P569 ?wd_dob . } #date of birth on Wikidata P569
        optional { ?wikidata wdt:P570 ?wd_dod . }  #date of death on Wikidata P570
    } #/ wikidata service
     
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en, en-gb". }  
 
}
}
 
ORDER BY ?proposerLabel
group by ?item ?itemLabel ?s ?qualLabel ?subLabel  ?main_label
having (?tcount >1 )  # comment out to get everything
 
ORDER BY ?itemLabel ?main_label ?qualLabel ?subLabel ?date_prop
 
</sparql>
</sparql>




=== Women with no dates===
=== BN Men who proposed, seconded or signed for Women in SAL/RAI/RHS elections, with counts and wikidata IDs ===


<sparql tryit="1">
<sparql tryit="1">
 
#title:Men who supported women (at least twice) for SAL/RAI/RHS election with Wikidata IDs
# Query for women with no dates
# WIP: at present this includes <unknown value> dates as well as no dates at all [eg Miss Keyser Q2622]
# CAVEAT: the WQS bug means there are likely to be some women in results who do, in fact, have at least one date.


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 3,365: Line 3,545:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpsv: <https://beyond-notability.wikibase.cloud/prop/statement/value/>
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>


SELECT distinct ?person ?personLabel (count(?date_value) as ?count)
# p155, p156 - signed rhs
# p32, p82  - signed sal|
# p8 rai seconded
 
SELECT ?supporterLabel ?supporter ?wikidata (count(?supporter) as ?supported)


WHERE {
WHERE {
 
{  # main dates
  ?person bnwdt:P3 bnwd:Q3 .  
 
  ?person bnwdt:P3 bnwd:Q3 . # women 
  optional {
    ?person ?p ?s .       
      ?s ?date_prop ?wdv .
        ?wdv wikibase:timeValue ?date_value . } 
 
} # /main dates
    
    
  UNION
   {
 
     ?person (  bnp:P155 | bnp:P156 | bnp:P16 | bnp:P7 ) ?s .  #
   { # qualifier dates
      ?s ( bnps:P155 | bnps:P156 | bnps:P16 | bnps:P7 ) ?supporter  . # proposed SAL/RAI / signed RHS
      
      #?s ?prop ?supporter .  
    ?person bnwdt:P3 bnwd:Q3 .   
    }
  optional {  
   #  union for qualifiers
    ?person ?p ?s .  
  union
      ?s ?date_prop ?pqv .
  {
        ?pqv wikibase:timeValue ?date_value. }
  ?person ?p ?s .
   
    ?s (  bnpq:P156 | bnpq:P155 | bnpq:P32 | bnpq:P82 | bnpq:P8 ) ?supporter .  
   } # /qual dates
    #?s ?prop ?supporter .
   }
    
    
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en". }
    ?supporter bnwdt:P3 bnwd:Q10 . # male
    
    
} # /where
    optional {
group by ?person ?personLabel
      ?supporter bnwdt:P117 ?wikidata_ID . #get wikidata ID
having (?count=0)
      bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_ID))) as ?wikidata) .
ORDER BY ?person
      }
 
     
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en, en-gb". }
}
group by ?supporterLabel ?supporter ?wikidata
having (?supported>2)
ORDER BY desc(?supported) desc(?wikidata)
</sparql>
</sparql>


==Fishing Expeditions==


=== Women with more than X statements but no date of birth/death===
===All properties in use in the wikibase with property type, label and description (if present)===


<sparql tryit="1">
<sparql tryit="1">
# query for information about properties that are being used in the wikibase


#title:women with n>X statements but no date of birth/death
## fyi: not actually necessary to declare these properties
# CAVEAT this currently finds some women who do in fact have dates, because of WQS bug
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
# updated to add extra info
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX schema: <http://schema.org/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
SELECT DISTINCT
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
  ?property
  ?propertyType
  ?propertyLabel 
  (group_concat(?propertyAltLabel; separator=" | ") as ?propertyAltLabels)
  ?propertyDescription
 
WHERE {
  ?property a wikibase:Property ;
              rdfs:label ?propertyLabel ; # label
              wikibase:propertyType ?propertyType . # datatype
 
  # add alternative labels if present (can be multiple)
  OPTIONAL { ?property skos:altLabel ?propertyAltLabel . }
 
  # add description if present
  OPTIONAL {
        SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en".
          ?property schema:description ?propertyDescription .
        }
  }
 
  FILTER(LANG(?propertyLabel) = 'en')
  # fix label language dups; but Q why doesn't SERVICE work?
  # A: https://en.wikibooks.org/wiki/SPARQL/FILTER#FILTER_on_values_in_Labels
 
}
group by ?property ?propertyLabel ?propertyType ?propertyDescription
order by ?propertyLabel
 
</sparql>
 
=== All the Things for Organisations ===
 
<sparql tryit="1">
 
# Exploratory query to get all info on an item page including qualifiers (but not references) for each organisation (Q2316) in the wikibase
# Initially this *only* fetched organisations that specifically have the instance of Q2316: I didn't realise for a while how many organisations don't directly reference Q2316.
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 bnwdv: <https://beyond-notability.wikibase.cloud/value/>
PREFIX bnwdt: <https://beyond-notability.wikibase.cloud/prop/direct/>
PREFIX bnwdt: <https://beyond-notability.wikibase.cloud/prop/direct/>
Line 3,420: Line 3,644:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


select distinct ?item ?itemLabel
?prop ?propLabel ?prop_type
?stmt_value ?stmt_valueLabel
?qual_prop  ?qual_value ?qual_label ?qual_prop_type
?statement
where {
?item bnwdt:P12+ bnwd:Q2316  . # instance of organisation or descendants of (excluding instance of organisation itself)


SELECT distinct ?person ?personLabel ?statements ?dob ?dod
  # get all the things about ?item 
(if(bound(?SALproposed), "yes", "") as ?FSA)
    ?item ?p ?statement .   
(if(bound(?RAIproposed), "yes", "") as ?RAI)
(if(bound(?resided), "yes", "") as ?residence) 
(if(bound(?main_date), "yes", "") as ?other_maindate)
(if(bound(?qual_d), "yes", "") as ?qual_date)
 
WHERE {
  ?person bnwdt:P3 bnwd:Q3 ;
        wikibase:statements ?statements .
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .}
    
    
  optional { ?person bnwdt:P15 ?dod .   }
  # to get item Label without using service. couple of missing en-gb labels somewhere
  optional { ?person bnwdt:P26 ?dob .   }
  # ?item rdfs:label ?item_label . filter(lang(?item_label)="en-gb") .  
 
    
    
  optional { # was elected FSA. comment out optional lines to get FSAs only...
  # get stuff about ?p
    ?person bnp:P16 ?s .
    ?prop wikibase:claim ?p; 
        ?s bnps:P16 ?SALproposed .
            wikibase:statementProperty ?ps;  # "Links property entity to statement simple value predicate"
        ?s bnpq:P22 bnwd:Q36 .  # successful Q36. will you end up with 2 rows if there's a successful and unsuccessful?
        #wikibase:statementValue ?psv; # "Links property entity to statement full value predicate"   
  } #/optional fsa
            wikibase:propertyType ?prop_type.      
 
 
  optional { # was elected RAI. only one unsuccessful, so just ignore that bit.
  # get stuff about ?statement
    ?person bnwdt:P7 ?RAIproposed .  
    ?statement ?ps ?stmt_value.  
  }
    
    
   optional { ?person bnwdt:P29 ?resided . } # place of residence
   # get any qualifiers
  optional {  
    ?statement ?qual_p ?qual_value . 
    ?qual_prop wikibase:qualifier ?qual_p;
          wikibase:propertyType ?qual_prop_type ;
          rdfs:label ?qual_label. filter(lang(?qual_label)='en-gb') .  
    }
    
    
  optional {  
#  OPTIONAL { ?item skos:altLabel ?alt_label . }
    # main dates, apart from birth and death: P133 (widowed) P132 (married edtf) P131 (had child) P130 (married pit)   
    ?person ( bnwdt:P130 | bnwdt:P131 | bnwdt:P132 | bnwdt:P133 ) ?main_date .
    } # /optional main dates
    
    
  optional {
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
    # qualifier dates 
    ?person ?p ?s .   
      ?s ?date_prop ?pqv .
        ?pqv wikibase:timeValue ?qual_d.
    } #/ optional qual dates
    
    
  FILTER (?statements >10) . # can adjust n statements here...
}
 
 
  FILTER (NOT EXISTS { ?person bnwdt:P15 ?dod .} || NOT EXISTS { ?person bnwdt:P26 ?dob .  } ) . # EITHER no date of birth OR no date of death. or swap with following line...
order by ?item_label ?prop_label
  #FILTER (NOT EXISTS { ?person bnwdt:P15 ?dod .} && NOT EXISTS { ?person bnwdt:P26 ?dob .  } ) . # no date of birth AND no date of death
   
  SERVICE wikibase:label {
      bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb".
  }
}
order by ?personLabel


</sparql>
</sparql>


=== Places of residence that lack instance of locality===
 
=== One woman ===


<sparql tryit="1">
<sparql tryit="1">
#title:All About a Woman
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 3,483: Line 3,701:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpsv: <https://beyond-notability.wikibase.cloud/prop/statement/value/>
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>


SELECT distinct ?residence ?residenceLabel ?inst ?instLabel
SELECT distinct ?propLabel ?spsLabel ?qual_propLabel ?pqsLabel ?link ?s
WHERE {
# ?main_date ?main_precision ?qual_date ?qual_precision   
  ?resident bnwdt:P29 ?residence . # resided at
# ?prop ?sps ?pqs ?pq
   filter not exists { ?residence bnwdt:P12 bnwd:Q2147 . } # that doesn't have instance of locality
 
WHERE
{
  VALUES (?person) {(bnwd:Q569)}  # add (bnwd:Qxxx) if you want more than one person.
   ?person ?p ?s .


   optional {?residence bnwdt:P12 ?inst .} # does it have instance of anything?
    ?prop wikibase:claim ?p;   
       ## Note: some have Q618 territory of the British Empire, which also lacks any instance of at present
        wikibase:statementProperty ?ps;  #  simple value
        wikibase:statementValue ?psv. #  full value   
 
  # exclude external IDs
   # filter not exists { ?prop wikibase:propertyType wikibase:ExternalId . }
 
      ?s ?ps ?sps.
 
    # full date via ?psv
       OPTIONAL {
          ?s ?psv ?spsv .
              ?spsv wikibase:timeValue ?main_date .
              ?spsv wikibase:timePrecision ?main_precision .
      }


   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }  
    # qualifiers.
 
      optional {
        ?s ?pq ?pqs .         
          ?qual_prop wikibase:qualifier ?pq . 
          ?qual_prop wikibase:qualifierValue ?pqp .
       
          optional {
            # full date via ?pqp
            ?s ?pqp ?qv .
            ?qv wikibase:timeValue ?qual_date.
            ?qv wikibase:timePrecision ?qual_precision.
          }
    }
    
  # direct link to property
        BIND (REPLACE(STR(?prop), "^.*/([^/]*)$", "$1") as ?pid).
        bind(iri(concat(str(?person), "#", ?pid)) as ?link ) .
 
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }  
       
}
}
ORDER BY ?residenceLabel
order by ?propLabel ?s
 
</sparql>
</sparql>


=== Locations that don't have Wikidata links or their Wikidata pages lack geocoordinates===
===Working with property paths: organisations and locations===


<sparql tryit="1">
<sparql tryit="1">
## problem: sometimes you need to follow property paths using */+ for (eg) locations. BUT this can lead to several results to choose between and they aren't necessarily returned in the "right" order.
## how to determine the "distance" along the path of each result?
## https://stackoverflow.com/questions/61984052/wikidata-get-the-full-subhierachy-of-one-class-as-well-as-all-nodes
## > you can get the distance of a class with SELECT ?cls (count(?tmp) as ?distance) WHERE {  ?cls wdt:P279* ?tmp .  ?tmp wdt:P279+ wd:Q2095 . } group by ?cls order by asc(?distance) - though there might be corner cases like cycles in the hierarchy resp. multiple paths
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 3,508: Line 3,771:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


 
SELECT ?item ?itemLabel ?location ?locationLabel (count(?item) as ?distance)
SELECT distinct ?locationLabel ?location ?wikidata ?wd_geo ?instanceLabel ?bn_geo
WHERE {   
WHERE {   
    
   ?item bnwdt:P12 bnwd:Q2316 . # instance of organisation.
  {?item bnwdt:P29  ?location . } # resided at
   ?item bnwdt:P2* ?tmp .
  union
   ?tmp bnwdt:P2+ ?location . # P2=30. P2+=34
  {?location bnwdt:P12 bnwd:Q2147 .} # OR has instance of locality
 
  union
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb, en". }  
   {?item bnwdt:P2 ?location . } # OR location P2
   # any other possibles ?  
 
  optional { ?location bnwdt:P12 ?instance .  } # check instance of
 
  optional {   
      ?location bnp:P117 ?ws . # wikidata id       
        ?ws bnpq:P14 ?wikidata_url .  
        BIND(IRI(REPLACE(?wikidata_url, "https://www.wikidata.org/wiki/", "http://www.wikidata.org/entity/")) as ?wikidata )
        SERVICE <https://query.wikidata.org/sparql> {
          optional {?wikidata wdt:P625 ?wd_geo .}  # does the wikidata page have geocoords?
        } # /wikidata service 
    } #/wikidata optional
 
  filter (!bound(?wd_geo) ). # no geocoords in wikidata. some may have coords in BN...
 
  optional { ?location bnwdt:P153 ?bn_geo .  } # so check for coords in BN
  ##filter (!bound(?bn_geo)) . # uncomment to filter those out as well
 
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }  
}
}
ORDER BY ?wikidata ?locationLabel
group by ?item ?itemLabel  ?location ?locationLabel
 
ORDER BY ?item ?distance
</sparql>
</sparql>


=== Date of latest edit for every item, according to WQS ===
=== Traversing instance of with GAS ===


<sparql tryit="1">
<sparql tryit="1">
#title:latest edits dates for wikibase items
#title:GAS
# The Gather, Apply, and Scatter (GAS) service provides graph traversal, graph mining, and similar classes of algorithms for SPARQL.
# In practical terms, it enables a series of relations to be followed through the graph; for instance the chain of father, grandfather, great-grandfather &c - tracing the father (P22) line - of a subject item
# https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/query_optimization#GAS_Service
# https://github.com/blazegraph/database/wiki/RDF_GAS_API


## because of WQS disappearing data bugs this may not always match the latest edit in the page history
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 ?item ?date ?dateLabel
SELECT ?depth  ?ioLabel ?itemLabel ?io ?item
WHERE {
WHERE {
  ?item wikibase:timestamp ?date .
      SERVICE gas:service {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
          gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.BFS" ;
}
                      gas:in bnwd:Q3099 ;
order by ?date
                      gas:linkType bnwdt:P12 ;
 
                      gas:traversalDirection "Reverse";
                      gas:out ?item ;
                      gas:out1 ?depth ;
                      gas:out2 ?io .  
      }
    SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
    }  
order by ?depth ?ioLabel ?itemLabel
</sparql>
</sparql>


==Tools for batch processing and quality assurance work==


===All people (by assigned gender), filtering out those already listed as instance of human===
=== Working with property paths: instance of [CAVEAT: experimental, probably wrong]===


<sparql tryit="1">
<sparql tryit="1">
# All people (by assigned gender), filtering out those already listed as instance of human
# an attempt to adapt the query above following paths for locations of organisations for (more complex) instance of
# ref https://stackoverflow.com/questions/61984052/wikidata-get-the-full-subhierachy-of-one-class-as-well-as-all-nodes
# distance is in the right *order* so it should be usable for some purposes, but the starting number = number of levels rather than 1. also jumps if there are siblings somewhere along the path.


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 3,571: Line 3,831:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
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 ?assigned_genderLabel
SELECT ?item ?itemLabel ?instance_of ?instance_ofLabel  (count(?item) as ?distance)
WHERE {   
WHERE {   
   ?person bnwdt:P3 ?assigned_gender .                       #select person
   ?item bnwdt:P12* ?tmp . # instance of anything.
  FILTER NOT EXISTS {?person bnwdt:P12 bnwd:Q2137 .}        #filter out people already listed as instance of human
   ?tmp bnwdt:P12+ ?instance_of . # P2=30. P2+=34
   FILTER NOT EXISTS {?person bnwdt:P12 bnwd:Q12 .}            #filter out project team
 
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb, en". }  
}
}
ORDER BY ?personLabel
group by ?item ?itemLabel  ?instance_of ?instance_ofLabel
ORDER BY ?item ?distance
 
</sparql>
</sparql>


===All places (by coordinate location on wikidata), filtering out places already listed as instance of locality===
==Dates==
 
===All the Dates for Women FSAs===


<sparql tryit="1">
<sparql tryit="1">
# All places (by coordinate location on wikidata), filtering out places already listed as instance of locality
#title:fishing for dates for FSAs
# union query to get [hopefully] every date associated with women FSAs including main dates and qualifier dates


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 3,596: Line 3,859:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX bnpsv: <https://beyond-notability.wikibase.cloud/prop/statement/value/>
PREFIX wd:  <http://www.wikidata.org/entity/>
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX pr: <http://www.wikidata.org/prop/reference/>
PREFIX prov: <http://www.w3.org/ns/prov#>


SELECT ?place ?placeLabel ?WDitem ?WDcoordinate_location
SELECT distinct ?person ?personLabel ?prop_label ?qualLabel ?qual_dateLabel ?date_value  ?s 
#?prop ?qual


WHERE {
WHERE {
  ?place bnwdt:P33 ?admin_area .  #select items with 'located in the administrative territorial entity' statements
  ?place bnwdt:P117 ?Qnumber .    #get wikidata ID
  FILTER NOT EXISTS {?place bnwdt:P12 bnwd:Q2147 .}      #filter out places already listed as instance of locality
    
    
   #create reference to Wikibase entity
  ?person bnwdt:P3 bnwd:Q3 . #select women
  BIND(IRI(concat("http://www.wikidata.org/entity/", ?Qnumber)) as ?WDitem )
  ?person bnwdt:P75 bnwd:Q8. # find only BN subjects having a FSA
   #on Wikibase do
 
   SERVICE <https://query.wikidata.org/sparql> {
  # get stuff about ?person    
         ?WDitem wdt:P625 ?WDcoordinate_location . #get coordinate location on wikidata
  ?person ?p ?s . 
       }  
 
    
      # get stuff about ?p .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
      ?prop wikibase:claim ?p;   
}
        wikibase:statementProperty ?ps ; 
GROUP BY ?place ?placeLabel ?WDitem ?WDcoordinate_location
        wikibase:statementValue ?psv .   
ORDER BY ?placeLabel
      ?prop wikibase:propertyType ?date_prop_type .
      ?prop rdfs:label ?prop_label. filter(lang(?prop_label)="en-gb") .
 
 
{  # main dates
 
  # get dates detail via ?s and psv
   # gets edtf dates in simplified std wiki date format?
   # https://github.com/ProfessionalWiki/WikibaseEdtf 
      ?s ?psv ?wdv .
        ?wdv wikibase:timeValue ?date_value .
 
  } # /main dates
 
  UNION
 
  { # qualifier dates
   
  # direct value (usually item) for the property
         ?s ?ps ?qual.
   
  # date qualifiers. [assumes no edtf in quals. ]
        ?s ?pq ?date_value . 
          ?qual_date wikibase:qualifier ?pq .
          ?qual_date wikibase:propertyType wikibase:Time.
          ?qual_date rdfs:label ?date_qual_label . filter(lang(?date_qual_label)="en") .  
        
  } # /qual dates
    
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }  
 
} # /where
 
ORDER BY ?person ?prop_label ?date_value
 
</sparql>
</sparql>


===All items without a P12 (instance of) triple===
===Fetch any of multiple kinds of EDTF date for a woman===


<sparql tryit="1">
<sparql tryit="1">
#title:all items without P12 (instance of)
# a union query to fetch stuff for multiple properties, in this case dates recorded in EDTF which need slightly different handling from PIT dates
# main dates only; pretty sure there are no EDTF in qualifiers.
# updated to get date property labels


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 3,635: Line 3,929:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


SELECT distinct ?item ?itemLabel
SELECT ?person ?personLabel ?date_edtf ?date_prop ?date_label ?s
WHERE {
 
  ?item ?b ?c .
WHERE { ?person bnwdt:P3 bnwd:Q3 .  
       ?prop wikibase:claim ?b;   
       FILTER NOT EXISTS { ?person bnwdt:P4 bnwd:Q12 . }
            wikibase:statementProperty ?ps.  
   
      # ?prop wikibase:propertyType wikibase:WikibaseItem. # limit to P & Q Items. not necessary; only the claim is needed.  
      ## can do this union first but makes no difference to results except possibly a bit slower.
    # weirdness: it caused some things that are definitely WikibaseItem to be dropped and idk why.
      #?person ( bnp:P131 | bnp:P132 | bnp:P133  ) ?s .
      #   ?s ( bnps:P131 | bnps:P132 | bnps:P133  ) ?date_edtf .


  FILTER NOT EXISTS {?item bnwdt:P12 ?instance .}
      ?person ?p ?s . # so you can get the statement id and date prop label
          ?claim wikibase:claim ?p;     
                rdfs:label ?date_label. filter(lang(?date_label)="en") .      


## FILTER(STRSTARTS(STR(?item), "https://beyond-notability.wikibase.cloud/entity/P")) . # uncomment to limit to P Properties
          ?s ?date_prop ?date_edtf .
## FILTER(STRSTARTS(STR(?item), "https://beyond-notability.wikibase.cloud/entity/Q")) . # or limit to Q items
             
    ## filter for edtf dates
    ## docs: https://github.com/ProfessionalWiki/WikibaseEdtf
 
    FILTER ( datatype(?date_edtf) = xsd:edtf  ) .
           
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en, en-gb". }
    }
 
ORDER BY ?personLabel


  SERVICE wikibase:label {
      bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb".
  }
}
</sparql>
</sparql>


===Counts of items for each value of the property "instance of" (P12)===
===Full values: dates ===


<sparql tryit="1">
<sparql tryit="1">
# query for full values to access the timeValue and timePrecision of a date, in this case a date of birth.
## why is a more complex query needed?
## simple value for a date doesn't differentiate between (eg) "1880" and "1 January 1880"; both are returned as 1 January 1880 (and SELECT DISTINCT will collapse them into a single result)
## there are 14 codes for precision from billion years to second. 7: century, 8: decade, 9: year, 10: month, 11: day
## NB additional bnpsv: prefix
## https://www.mediawiki.org/wiki/Wikibase/Indexing/RDF_Dump_Format#Value_representation


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 3,665: Line 3,975:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpsv: <https://beyond-notability.wikibase.cloud/prop/statement/value/>


 
SELECT DISTINCT ?item ?itemLabel ?date ?precision
SELECT ?value ?valueLabel  (count(*) as ?count)
WHERE {
WHERE {   
  ?item bnp:P26 ?statement. # date of birth (precision of these varies quite a bit)
 
  ?statement bnpsv:P26 ?valueNode.
   VALUES (?p) { (bnwdt:P12) } 
  ?valueNode wikibase:timeValue ?date.
   ?valueNode wikibase:timePrecision ?precision.
    
    
  ?s ?p ?value.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
 
}
}
GROUP BY ?value ?valueLabel
ORDER BY ?date
 
ORDER BY lcase(?valueLabel) # order by is case sensitive
# or to order by count
# order by ?count


</sparql>
</sparql>


===Get all items (with 'instance of' statement) for duplicate checking in OpenRefine===
=== Any main level date for women ===


<sparql tryit="1">
<sparql tryit="1">
# Get all items (with 'instance of' statement) for duplicate checking in OpenRefine
# a query to get all types of main date for women


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 3,697: Line 4,002:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
 
PREFIX bnpsv: <https://beyond-notability.wikibase.cloud/prop/statement/value/>
SELECT ?item ?itemLabel WHERE {
 
   ?item bnwdt:P12 ?anything .
SELECT DISTINCT ?person ?personLabel ?date_label  ?date ?date_prop_type ?date_prop ?link_prop
   SERVICE wikibase:label {
 
       bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb".
WHERE {
   }
 
}
   ?person bnwdt:P3 bnwd:Q3 . # women
 
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .}     
ORDER BY ?itemLabel
    
</sparql>
  ?person ?p ?s .
 
 
===All uses of <unknown value>===
      ?date_prop wikibase:claim ?p;   
 
        wikibase:statementValue ?psv ; 
<sparql tryit="1">
        wikibase:propertyType ?date_prop_type; # property type = wikibase:Time OR wikibase:Edtf
# Query to look for uses of <unknown value> (now including qualifiers)
        rdfs:label ?date_label. filter(lang(?date_label)="en-gb") . # what kind of date it is
 
 
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
        # direct link to relevant section of page
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
        BIND (REPLACE(STR(?date_prop), "^.*/([^/]*)$", "$1") as ?pid).
PREFIX bnwdv: <https://beyond-notability.wikibase.cloud/value/>
        bind(iri(concat(str(?person), "#", ?pid)) as ?link_prop ) . 
PREFIX bnwdt: <https://beyond-notability.wikibase.cloud/prop/direct/>
     
PREFIX bnp: <https://beyond-notability.wikibase.cloud/prop/>
      ?s ?psv ?wdv . # for the date value
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
        ?wdv wikibase:timeValue ?date .  #timeValue gets pit and edtf
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
    #  ?wdv wikibase:timePrecision ?date_precision .  # optional
 
 
SELECT distinct ?item ?itemLabel ?mainLabel ?sub_Label ?unknown_value_forLabel ?unknown_value_for ?t
  # nb also possible to filter either/or time/edtf by property type
WHERE
  # filter(?date_prop_type in (wikibase:Edtf, wikibase:Time ) ) . 
{
 
{
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
   # qualifiers
}
   ?item ?p ?s.
ORDER BY ?personLabel ?date
 
 
   ?s ?sub ?sub_ .
</sparql>
   ?main wikibase:claim ?p.
 
   ?main wikibase:statementProperty ?sub.   
=== Counting Dates===
 
 
   ?s ?pq ?t .
<sparql tryit="1">
 
# count distinct dates for women (who have at least one)
   ?unknown_value_for wikibase:qualifier ?pq .   
# uncomment HAVING line for women with only one
   FILTER( isBLANK(?t) ) . # filter for <unknown value>
# CAVEAT: there may be some discrepancies between dates shown on wiki pages and dates returned by sparql
  }
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
   UNION
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
   {
PREFIX bnwdv: <https://beyond-notability.wikibase.cloud/value/>
   # top level
PREFIX bnwdt: <https://beyond-notability.wikibase.cloud/prop/direct/>
   ?item ?p ?s.
PREFIX bnp: <https://beyond-notability.wikibase.cloud/prop/>
   ?s ?ps ?t .
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
 
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
   ?unknown_value_for wikibase:claim ?p.
PREFIX bnpsv: <https://beyond-notability.wikibase.cloud/prop/statement/value/>
   ?unknown_value_for wikibase:statementProperty ?ps.
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>
      
 
   FILTER( isBLANK(?t) ) .
SELECT ?person ?personLabel (COUNT(DISTINCT ?date_value) as ?count)
   }
 
WHERE {
{  # main dates
 
  ?person bnwdt:P3 bnwd:Q3 . # women 
  ?person ?p ?s .       
      ?s ?date_prop ?wdv .
        ?wdv wikibase:timeValue ?date_value .
  } # /main dates
 
  UNION
 
  { # FIXME? qualifier dates. hmm... how is this different from above? I think something is missing.
   
    ?person bnwdt:P3 bnwd:Q3 . 
    ?person ?p ?s .   
       ?s ?date_prop ?pqv .
        ?pqv wikibase:timeValue ?date_value.
    }  # /qual dates
 
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en". }
    
} # /where
GROUP BY ?person ?personLabel
# HAVING(?count=1)
 
ORDER BY ?count ?person
</sparql>
 
=== Start dates that might not have accompanying end dates ===
 
<sparql tryit="1">
#title:Women with start dates that might not have accompanying end dates
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 bnpsv: <https://beyond-notability.wikibase.cloud/prop/statement/value/>
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>
 
SELECT distinct ?personLabel ?prop_label ?start_date (if(bound(?end_date), "yes", "no") as ?has_end_date) ?person ?s  
#(group_concat(?other_date_label; SEPARATOR=" | ") as ?other_dates)
 
WHERE {
  ?person bnwdt:P3 bnwd:Q3 .
    
  # need to find start times anywhere and get prop label so use claim.
   ?person ?p ?s .  
  ?claim wikibase:claim ?p;     
        rdfs:label ?prop_label. filter(lang(?prop_label)="en") . 
   
# pretty sure start time is qualifier only... 
# get start dates
# then optional end dates
# can only see end time/pit associated, and the only pit with start time is not relevant, but can't be sure that'll always be true.
# optional other that excludes both start/end but lists any other date types
    
    ?s bnpq:P27 ?start_date . # get start dates
 
    optional {?s bnpq:P28 ?end_date .} # check for end dates
 
#   optional {
#      ?s ?pq ?other_date . # could there be any other associated dates?
     
#      ?qual_prop wikibase:qualifier ?pq;     
#            wikibase:propertyType wikibase:Time ; # nb *does not* include edtf dates but AFAICT there are none in qualifiers.
#            rdfs:label ?other_date_label . filter(lang(?other_date_label)="en-gb") . # what kind of date is it.
 
        # drop both start and end this time. idk if there could be a faster way to do this?
#      filter not exists { ?s (bnpq:P27 | bnpq:P28) ?other_date . }
 
#  } # / optional other dates
    
  # filter(!bound(?end_date)). # to filter out rows with an end date
 
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en". }
 
}
 
ORDER BY ?personLabel ?prop_label ?start_date
</sparql>
 
 
=== End dates that might not accompanying start dates ===
 
<sparql tryit="1">
#title:Women with end dates that might not have accompanying start dates
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 bnpsv: <https://beyond-notability.wikibase.cloud/prop/statement/value/>
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>
 
SELECT distinct ?personLabel ?prop_label ?end_date 
(if(bound(?start_date), "yes", "no") as ?has_start_date)  
(group_concat(?other_date_label; SEPARATOR=" | ") as ?other_dates)
?person ?s
 
WHERE {
  ?person bnwdt:P3 bnwd:Q3 .
   ?person ?p ?s .
  ?claim wikibase:claim ?p;     
        rdfs:label ?prop_label. filter(lang(?prop_label)="en") . 
   
# get end dates
# then optional start dates
# can only see start time/pit associated, and in fact the only pit with start time is not relevant, but can't be sure that'll always be true.
# so an optional other that excludes both start/end but lists any other date types with group_concat
    
    ?s bnpq:P28 ?end_date . # get end dates
 
    optional {?s bnpq:P27 ?start_date .} # check for start dates
 
    optional {
        ?s ?pq ?other_date . # could there be any other associated dates?
        ?qual_prop wikibase:qualifier ?pq;     
              wikibase:propertyType wikibase:Time ; # nb *does not* include edtf dates but AFAICT there are none in qualifiers.
              rdfs:label ?other_date_label . filter(lang(?other_date_label)="en-gb") . # what kind of date
        # drop both start and end. idk if there could be a faster way to do this?
        filter not exists { ?s (bnpq:P27 | bnpq:P28) ?other_date }
    
  } # / optional other dates
 
#  filter(!bound(?start_date)). # to filter out rows with a start date (77 atm)
 
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en". }
 
}
 
group by  ?personLabel ?prop_label ?end_date ?start_date ?has_start_date ?person ?s 
 
ORDER BY ?personLabel ?prop_label ?end_date
</sparql>
 
=== Women having children ===
 
<sparql tryit="1">
#title:women having children
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/>
 
# lol defaultView:Timeline{"hide":["?s", "?date_prec", ""]}  
 
# P131 had child in / P45 child
# a handful of P45 named children don't have dob though probably have dob in wikidata
 
SELECT distinct ?person ?personLabel ?childLabel ?date_value ?date_prec ?had_child_edtf ?note 
?s
 
where {
 
   ?person bnwdt:P3 bnwd:Q3 . # select women
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
    
  # had child in (unnamed children)
   ?person bnp:P131 ?s .
      ?s bnps:P131 ?had_child_edtf . # keep the edtf date for reference, though i think you can just use the time value/prec with these.
 
   # get dates detail via ?s and psv
  # gets edtf dates in std wiki date format
  # https://github.com/ProfessionalWiki/WikibaseEdtf 
      ?s ?psv ?wdv .
        ?wdv wikibase:timeValue ?date_value .
        ?wdv wikibase:timePrecision ?date_prec .
 
  # filter edtf date.
   FILTER ( datatype(?had_child_edtf) = xsd:edtf ) . #shows only the raw EDTF string from the query results
 
  # interesting, when you put this after wikibase:timeValue it seems to get every timey-wimey statement for women who have had child in ? (but only one)
  #?person bnwdt:P131 ?had_child . 
   
  # not much added in quals for had child. only maybe note P47. some have sourcing circumstances.
  optional { ?s bnpq:P47 ?note .  } #
 
   }
  union
  {
  # named children (are any in both sections??? from dates looks possible a couple might be [wherry / hodgson])
  ?person bnp:P45 ?s.
        ?s bnps:P45 ?child .
      optional { ?child bnp:P26 ?ss .
                    ?ss bnps:P26 ?dob .
                    ?ss ?psv ?wdv .
                        ?wdv wikibase:timeValue ?date_value .
                        ?wdv wikibase:timePrecision ?date_prec .
              }
  }
 
     SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". } 
}
 
order by ?person ?date_value
</sparql>
 
=== Women who were adults in 1911 ===
 
<sparql tryit="1">
#title:Women who were adults in 1911 and their calculated ages
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 ?statements ?dob ?dod ?age1911
 
WHERE {
  ?person bnwdt:P3 bnwd:Q3 ;
        wikibase:statements ?statements .
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .}
  ?person bnwdt:P26 ?dob . 
 
  #optional {
      ?person bnwdt:P15 ?dod .    
  #}
 
  filter(year(?dod) > 1911 && year(?dob) <=1893 ) .
  #if dod is made optional a more complex filter to include some women who were likely to still be alive in 1911. but doesnt add very many.
  #filter( ( year(?dob) <= 1893  && year(?dod) > 1911 ) || ( year(?dob) <= 1893 && year(?dob) >1870 ) ) .
    
  #Date literals can be written by adding ^^xsd:dateTime to an ISO 8601 date string: "2012-10-29"^^xsd:dateTime
    
    
   SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
   bind(year("1911-07-01"^^xsd:dateTime) - year(?dob) as ?age1911 ).


    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
}
}
ORDER BY ?itemLabel ?unknown_value_forLabel
</sparql>


ORDER BY ?personLabel


=== Items without any statements ===
<sparql tryit="1">
#title:items with 0 statements
# NB: because of the WQS disappearing data bugs, a few of the items might in reality have n>0 statements. A few may be intentionally empty.
SELECT distinct ?item  ?itemLabel
WHERE {
  ?item wikibase:statements 0 .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
}
order by ?item
</sparql>
</sparql>
3,427

edits