Project:SPARQL/examples: Difference between revisions

From Beyond Notability
(19 intermediate revisions by the same user not shown)
Line 170: Line 170:
</sparql>
</sparql>


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


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


=== Women's interactions with SAL (Q1 and Q8)===
=== Women's interactions with SAL (Q1 and Q8)===


<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 215: 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_propLabel  ?sal
SELECT distinct ?person ?personLabel   ?propLabel  ?qual_value ?qual_propLabel  ?bnwdLabel # ?s ?prop ?qual_prop ?bnwd


WHERE {   
WHERE {   
Line 225: 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
Line 250: 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 257: 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_propLabel ?qual_prop_type ?rai ?s
SELECT distinct ?person ?personLabel  ?propLabel  ?qual_value ?qual_propLabel ?bnwdLabel # ?s ?prop ?qual_prop


WHERE {   
WHERE {   
Line 267: 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
Line 296: 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 344: 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 616: Line 575:
</sparql>
</sparql>


== Professional Activities and Organisations ==
=== Excavations ===
 
<sparql tryit="1">
#title:BN excavations
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 ?excavationLabel ?excavation ?locationLabel ?start ?end ?pit
?partLabel ?funderLabel ?organisedLabel ?facilitatedLabel ?directorLabel ?memberLabel
# ?member ?director  ?location ?part ?funder ?facilitated ?organised
 
WHERE { 
  # instance of excavation  128
  ?excavation bnwdt:P12 bnwd:Q38 .
 
    optional { ?excavation bnwdt:P2 ?location .}
 
    optional { ?excavation bnwdt:P27 ?start . }
 
    optional { ?excavation bnwdt:P28 ?end . }
 
    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 { ?excavation bnwdt:P145 ?funder . }
 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
}
 
ORDER BY ?excavationLabel
</sparql>
 
== Professional Activities and Organisations ==


=== Women's service on committees etc (P102) ===
=== Women's service on committees etc (P102) ===
Line 845: Line 850:
       ?s ?ps ?ppa_value.
       ?s ?ps ?ppa_value.
    
    
     # note: it would be possible to write this to use ppa rather than ppa_label
     # 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.
     # BUT then it would be much more opaque and difficult to edit if (when!) we make any changes to the buckets.
     bind(
     bind(
Line 867: Line 872:
order by ?personLabel ?ppa_label
order by ?personLabel ?ppa_label
</sparql>
</sparql>


=== Suffrage-related activities ===
=== Suffrage-related activities ===
Line 942: Line 946:
==Place==
==Place==


=== All the wikibase places that can be mapped ===
=== All the things in BN that can be mapped ===


<sparql tryit="1">
<sparql tryit="1">
#title:map of BN places using wikidata P625
#title:map of BN locations using wikidata P625
#defaultView:Map
#defaultView:Map
#this will take a little while to run...
#this will take a little while to run...
Line 960: Line 964:
WHERE {   
WHERE {   
    
    
  {?item bnwdt:P29  ?location . } # resided at
  union
  {?location bnwdt:P12 bnwd:Q2147 .} # OR has instance of locality
  union
  {?item bnwdt:P2  ?location . } # OR location P2
  union
  {?item bnwdt:P33 ?location .} # OR admin territory
   
       ?location bnwdt:P117 ?ws .  # wikidata id         
       ?location bnwdt:P117 ?ws .  # wikidata id         
          
          
Line 1,348: Line 1,344:
#title:Counties of residence for women recorded in CAS Indexes of Archaeological Papers
#title:Counties of residence for women recorded in CAS Indexes of Archaeological Papers


SELECT distinct ?person ?personLabel ?county ?countyLabel ?wikidata ?geo   
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
Line 1,354: Line 1,350:
   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
      optional { ?county bnwdt:P153 ?geo2 .  } # for geocoords added to BN
   ?district bnwdt:P33 ?next . #select p33 of district, mostly counties but a few region/outside uk
    
    
       optional {     
  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         
       ?county bnp:P117 ?ws .  # wikidata id P117         
         ?ws bnpq:P14 ?wikidata_url .
         ?ws bnpq:P14 ?wikidata_url .
Line 2,255: Line 2,271:
</sparql>
</sparql>


==People==
=== Wikidata categories for BN instance of locality in the UK ===
 
===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 2,269: 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 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 ?wd_io ?wd_io_label  (count(*) as ?count)


SELECT ?person ?personLabel ?birthname ?marriedname
where {
WHERE {  
   
   ?person bnwdt:P3 bnwd:Q3 . #select women
   ?item bnwdt:P12 bnwd:Q2147 . # BN io locality
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
   ?item bnwdt:P33* bnwd:Q1741 . # in UK
   OPTIONAL {?person bnwdt:P140 ?birthname .} #look for birth name
 
  OPTIONAL {?person bnwdt:P141 ?marriedname .} #look for married name
   ?item bnwdt:P117 ?wd.
      bind(iri(concat("http://www.wikidata.org/entity/", str(?wd))) as ?wikidata) .
      SERVICE <https://query.wikidata.org/sparql> {  
          ?wikidata wdt:P31 ?wd_io.
              ## p31 Q48091 region of england.
            SERVICE wikibase:label { bd:serviceParam wikibase:language "en". 
                                    ?wikidata rdfs:label ?wd_label .
                                    ?wd_io rdfs:label ?wd_io_label .  
                                  }       
        }
    
    
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }  
}
}
ORDER BY ?personLabel
group by ?wd_io ?wd_io_label
order by ?wd_io_label
</sparql>
</sparql>


=== Women with family name at birth, married name and count of married names===
 
=== Localities not in the UK ===


<sparql tryit="1">
<sparql tryit="1">
# Women with their family name at birth, family name after marriage and count of married names
##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,295: 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/>
#title:localities not in the UK


SELECT ?person ?personLabel ?birthname 
select  ?item ?itemLabel (group_concat(distinct ?admin_label; separator=", " ) as ?admin_path)
        (GROUP_CONCAT(DISTINCT ?marriedname; SEPARATOR=", ") AS ?marriednames)  
where {
        (COUNT(?marriedname) AS ?marriedcount)
  ?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


WHERE { 
  ?person bnwdt:P3 bnwd:Q3 . #select women
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
 
  OPTIONAL {?person bnwdt:P140 ?birthname .} #look for birth name
  OPTIONAL {?person bnwdt:P141 ?marriedname .} #look for married name
 
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }  
}
}
group by ?person ?personLabel ?birthname
group by ?item ?itemLabel
ORDER BY ?personLabel
order by ?itemLabel
</sparql>
</sparql>


===Where women in our data are in wikidata, their spouses, fathers, and mothers according to wikidata===
==People==
 
===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 2,323: 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 wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd:  <http://www.wikidata.org/entity/>


SELECT ?person ?personLabel ?item ?WD_spouse ?WD_father ?WD_mother
 
SELECT ?person ?personLabel ?birthname ?marriedname
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
   OPTIONAL {?person bnwdt:P140 ?birthname .} #look for birth name
   ?wikidata_ID bnpq:P14 ?wikidata_url .
   OPTIONAL {?person bnwdt:P141 ?marriedname .} #look for married name
  BIND(IRI(REPLACE(?wikidata_url,"https://www.wikidata.org/wiki/","http://www.wikidata.org/entity/")) as ?item )
    
    
  SERVICE <https://query.wikidata.org/sparql> {
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }  
        ?item wdt:P21 ?WD_gender. #get gender of person
        OPTIONAL {?item wdt:P22 ?WD_father . } #recall father
        OPTIONAL {?item wdt:P25 ?WD_mother . } #recall mother
        OPTIONAL {?item wdt:P26 ?WD_spouse . } #recall spouse
      }
 
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
}
}
ORDER BY ?personLabel
ORDER BY ?personLabel
# 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===
=== Women with family name at birth, married name and count of married names===


<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)
# Women with their family name at birth, family name after marriage and count of married names
## Sorted by total PPAs


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


select ?person ?personLabel
SELECT ?person ?personLabel ?birthname 
(count(distinct ?exhibitor) as ?exhibitions)
        (GROUP_CONCAT(DISTINCT ?marriedname; SEPARATOR=", ") AS ?marriednames)  
(count(distinct ?position) as ?positions)
        (COUNT(?marriedname) AS ?marriedcount)
(count(distinct ?speaker) as ?spoke)
 
(count(distinct ?attended) as ?attendance)
WHERE { 
(count(distinct ?donorof) as ?donated)
  ?person bnwdt:P3 bnwd:Q3 . #select women
(count(distinct ?wasdelegate) as ?delegate)
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
(count(distinct ?correspondent) as ?correspondents)
 
(count(distinct ?fellow) as ?fellowships)
  OPTIONAL {?person bnwdt:P140 ?birthname .} #look for birth name
(count(distinct ?collab) as ?collaborations)
  OPTIONAL {?person bnwdt:P141 ?marriedname .} #look for married name
(count(distinct ?found) as ?founded)
 
(count(distinct ?loaned) as ?loans)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
(count(distinct ?illustrated) as ?illustrations)
}
(count(distinct ?sold) as ?sales)
group by ?person ?personLabel ?birthname
(count(distinct ?served) as ?service)
ORDER BY ?personLabel
(count(distinct ?job) as ?employed)
</sparql>
(count(distinct ?fundraiser) as ?fundraisers)
 
(count(distinct ?publish) as ?published)
===Where women in our data are in wikidata, their spouses, fathers, and mothers according to wikidata===
(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">
{
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
  ?person bnwdt:P3 bnwd:Q3 .
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
  optional { ?person bnp:P13 ?exhibitor }
PREFIX bnwdv: <https://beyond-notability.wikibase.cloud/value/>
  optional { ?person bnp:P17 ?position }
PREFIX bnwdt: <https://beyond-notability.wikibase.cloud/prop/direct/>
  optional { ?person bnp:P23 ?speaker }
PREFIX bnp: <https://beyond-notability.wikibase.cloud/prop/>
  optional { ?person bnp:P24 ?attended }
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
  optional { ?person bnp:P65 ?donorof }
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
  optional { ?person bnp:P71 ?wasdelegate }
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
  optional { ?person bnp:P73 ?correspondent }
PREFIX wd: <http://www.wikidata.org/entity/>
  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". }
}
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 ?person ?personLabel ?item ?WD_spouse ?WD_father ?WD_mother
 
<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 . #select women
   FILTER NOT EXISTS {?linkTo bnwdt:P4 bnwd:Q12 .}         #filter out project team
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
   ?linkTo bnwdt:P67 ?org
   ?person bnp:P117 ?wikidata_ID . #look for wikidata ID on person page
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en". }  
  ?wikidata_ID bnpq:P14 ?wikidata_url .
  BIND( "7C4DCD" AS ?rgb ) .
  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
        OPTIONAL {?item wdt:P22 ?WD_father . } #recall father
        OPTIONAL {?item wdt:P25 ?WD_mother . } #recall mother
        OPTIONAL {?item wdt:P26 ?WD_spouse . } #recall spouse
      }
 
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
}
}
ORDER BY ?personLabel
ORDER BY ?personLabel
# with thanks to @tagishsimon for writing this one initially!
</sparql>
</sparql>


===Membership of organisations by women, sorted by how many women were members of a given organisation===
===Women in our data alongside counts of their public and professional activities, sorted by total===


<sparql tryit="1">
<sparql tryit="1">
# Membership of organisations by women, sorted by how many women were members of a given organisation
## Women in our data alongside counts of their public and professional activities (https://beyond-notability.wikibase.cloud/wiki/Item:Q151)
## Sorted by total PPAs


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 2,448: Line 2,443:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
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
select ?person ?personLabel
WHERE { 
(count(distinct ?exhibitor) as ?exhibitions)
  ?person bnwdt:P3 bnwd:Q3 . # select women
(count(distinct ?position) as ?positions)
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
(count(distinct ?speaker) as ?spoke)
  ?person bnwdt:P67 ?organisation . # selection people who were members of organisations and what those organisations were
(count(distinct ?attended) as ?attendance)
  FILTER NOT EXISTS {?person bnwdt:P67 bnwd:Q35 .} # filter out Royal Archaeological Institute
(count(distinct ?donorof) as ?donated)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }
(count(distinct ?wasdelegate) as ?delegate)
}
(count(distinct ?correspondent) as ?correspondents)
GROUP BY ?organisation ?organisationLabel
(count(distinct ?fellow) as ?fellowships)
ORDER BY DESC(?organisation_count)
(count(distinct ?collab) as ?collaborations)
</sparql>
(count(distinct ?found) as ?founded)
(count(distinct ?loaned) as ?loans)
(count(distinct ?illustrated) as ?illustrations)
(count(distinct ?sold) as ?sales)
(count(distinct ?served) as ?service)
(count(distinct ?job) as ?employed)
(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)


 
where
 
{
==Education==
  ?person bnwdt:P3 bnwd:Q3 .
 
  optional { ?person bnp:P13 ?exhibitor }
===Women educated at a tertiary educational institution located in Oxford or Cambridge===
  optional { ?person bnp:P17 ?position }
 
  optional { ?person bnp:P23 ?speaker }
<sparql tryit="1">
  optional { ?person bnp:P24 ?attended }
# Women educated at a tertiary educational institution located in Oxford or Cambridge
  optional { ?person bnp:P65 ?donorof }
 
  optional { ?person bnp:P71 ?wasdelegate }
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
  optional { ?person bnp:P73 ?correspondent }
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
   optional { ?person bnp:P75 ?fellow }
PREFIX bnwdv: <https://beyond-notability.wikibase.cloud/value/>
   optional { ?person bnp:P83 ?collab }
PREFIX bnwdt: <https://beyond-notability.wikibase.cloud/prop/direct/>
   optional { ?person bnp:P85 ?found }
PREFIX bnp: <https://beyond-notability.wikibase.cloud/prop/>
   optional { ?person bnp:P87 ?loaned }
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
   optional { ?person bnp:P89 ?illustrated }
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
   optional { ?person bnp:P99 ?sold }
 
   optional { ?person bnp:P102 ?served }
SELECT ?woman ?womanLabel ?educationalinstitution ?educationalinstitutionLabel ?location ?locationLabel
   optional { ?person bnp:P105 ?job }
WHERE {
   optional { ?person bnp:P106 ?fundraiser }
   {?woman bnwdt:P3 bnwd:Q3 . #filter women
   optional { ?person bnp:P107 ?publish }
   ?woman bnwdt:P94 ?educationalinstitution . #find 'educated at' statement
   optional { ?person bnp:P110 ?benefact }
   ?educationalinstitution bnwdt:P12 bnwd:Q2914 . #filter to tertiary educational institutions
   optional { ?person bnp:P111 ?donor }
   ?educationalinstitution bnwdt:P2 ?location . #find location of educational institution
   optional { ?person bnp:P114 ?collect }
   ?location rdfs:label ?locationLabel .
   optional { ?person bnp:P120 ?performance }
   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". }
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
}
}
ORDER BY ?womanLabel
group by ?person ?personLabel
ORDER BY DESC (?PPA_total)
</sparql>
</sparql>


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


=== Women who were FSAs who went to Oxford or Cambridge colleges ===
<sparql tryit="1">
 
## Women in our data arranged as a network graph by the organisations they were members of
<sparql tryit="1">
#defaultView:Graph
#how many women who were FSAs went to Oxford or Cambridge colleges?
 
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
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/>
 
SELECT ?person ?personLabel ?college ?collegeLabel ?universityLabel
WHERE {   
WHERE {   
   ?person bnwdt:P3 bnwd:Q3 . #select women
   ?linkTo bnwdt:P3 bnwd:Q3 .                               #select women
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
   FILTER NOT EXISTS {?linkTo bnwdt:P4 bnwd:Q12 .}         #filter out project team
    
   ?linkTo bnwdt:P67 ?org
   ?person bnwdt:P75 bnwd:Q8. # only BN subjects having a FSA
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en". }
    
   BIND( "7C4DCD" AS ?rgb ) .
  # educated at (P94) part of (P4) cambridge (Q1181) oxford (Q364)  


  ?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".}
}
}
order by ?personLabel ?collegeLabel
ORDER BY ?personLabel
</sparql>
</sparql>


=== All women who went to tertiary education institutions and dates where available ===
===Membership of organisations by women, sorted by how many women were members of a given organisation===


<sparql tryit="1">
<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 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,545: Line 2,529:
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 ?college ?collegeLabel ?university ?universityLabel ?date ?date_label


SELECT ?organisation ?organisationLabel (count(?organisation) as ?organisation_count) #count number of organisations that women were members of
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:P67 ?organisation . # selection people who were members of organisations and what those organisations were
  # note: academic degree is P59. possible extra info?
  FILTER NOT EXISTS {?person bnwdt:P67 bnwd:Q35 .} # filter out Royal Archaeological Institute
   ?person bnp:P94 ?s .  # educated at
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
    ?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 wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en".}
}
}
order by ?personLabel ?collegeLabel ?date
GROUP BY ?organisation ?organisationLabel
ORDER BY DESC(?organisation_count)
</sparql>
 


</sparql>


==Education==


=== Academic degrees ===
===Women educated at a tertiary educational institution located in Oxford or Cambridge===


<sparql tryit="1">
<sparql tryit="1">
# Fetch academic degrees for women, with date and conferring institution where available
# Women educated at a tertiary educational institution located in Oxford or Cambridge
 
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,587: 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 distinct ?person ?personLabel ?degree ?degreeLabel ?by ?byLabel ?date ?date_label
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?
 
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/>


SELECT ?person ?personLabel ?college ?collegeLabel ?universityLabel
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
    
    
   # academic degree = P59.
   ?person bnwdt:P75 bnwd:Q8. # only BN subjects having a FSA
   ?person bnp:P59 ?s .   
 
    ?s bnps:P59 ?degree . # type of degree
  # educated at (P94) part of (P4) cambridge (Q1181) oxford (Q364)
 
   ?person bnwdt:P94 ?college .   
  ?college bnwdt:P4 ?university .  
 
  FILTER ( ?university in ( bnwd:Q1181 , bnwd:Q364 ) )
    
    
  # optional qualifiers for degree
 
  # P61 conferred by
    optional { ?s bnpq:P61 ?by . }
 
  # date with type
    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".}
   SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en".}
}
}
order by ?personLabel ?date ?degreeLabel
order by ?personLabel ?collegeLabel
</sparql>
</sparql>


==IDs==
=== All women who went to tertiary education institutions and dates where available ===
 
===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">
Line 2,630: 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 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/>
 
SELECT ?person ?personLabel ?college ?collegeLabel ?university ?universityLabel ?date ?date_label


SELECT ?person ?personLabel ?wikidata_ID ?viaf_ID ?ads_ID ?worldcat_ID
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:P117 ?wikidata_ID .}            #return wikidata ID
 
     OPTIONAL {?person bnwdt:P119 ?viaf_ID .}                 #return VIAF ID
  # note: academic degree is P59. possible extra info?
    OPTIONAL {?person bnwdt:P34 ?ads_ID .}                  #return Archaeological Data Service ID
  ?person bnp:P94 ?s . # educated at
     OPTIONAL {?person bnwdt:P118 ?worldcat_ID .}             #return WorldCat Identities ID
     ?s bnps:P94 ?college .
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
    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 wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en".}
}
}
ORDER BY ?personLabel
order by ?personLabel ?collegeLabel ?date
 
</sparql>
</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===
 
=== Academic degrees ===


<sparql tryit="1">
<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 2,656: 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 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/>
 
SELECT distinct ?person ?personLabel ?degree ?degreeLabel ?by ?byLabel ?date ?date_label


SELECT ?person ?personLabel ?wikidata_ID ?viaf_ID ?ads_ID ?worldcat_ID
WHERE {   
WHERE {   
   ?person bnwdt:P3 bnwd:Q3 .                                 #select women
   ?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
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .}           #filter out project team
 
    OPTIONAL {?person bnwdt:P117 ?wikidata_ID .}            #return wikidata ID
  # academic degree = P59.
     OPTIONAL {?person bnwdt:P119 ?viaf_ID .}                #return VIAF ID
  ?person bnp:P59 ?s .
     OPTIONAL {?person bnwdt:P34 ?ads_ID .}                   #return Archaeological Data Service ID
     ?s bnps:P59 ?degree . # type of degree
     OPTIONAL {?person bnwdt:P118 ?worldcat_ID .}             #return WorldCat Identities ID
 
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
  # optional qualifiers for degree
 
  # P61 conferred by
     optional { ?s bnpq:P61 ?by . }
 
  # date with type
     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
order by ?personLabel ?date ?degreeLabel
</sparql>
</sparql>


===People with IDs on wikidata, their date of birth on wikidata, and the source(s) of that information===
==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">
Line 2,685: Line 2,714:
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd:  <http://www.wikidata.org/entity/>
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#>


SELECT ?woman ?womanLabel ?WDitem ?WDdateOfBirth (GROUP_CONCAT(?BirthStatedInEnglish;separator=" | ") AS ?sources)
SELECT ?person ?personLabel ?wikidata_ID ?viaf_ID ?ads_ID ?worldcat_ID
WHERE {   
WHERE {   
  #Select all women
   ?person bnwdt:P3 bnwd:Q3 .                                 #select women
   ?woman bnwdt:P3 bnwd:Q3 .
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .}            #filter out project team
  #select all women that have a Wikidata link
    OPTIONAL {?person bnwdt:P117 ?wikidata_ID .}            #return wikidata ID
   ?woman bnwdt:P117 ?Qnumber .   
    OPTIONAL {?person bnwdt:P119 ?viaf_ID .}                #return VIAF ID
 
    OPTIONAL {?person bnwdt:P34 ?ads_ID .}                  #return Archaeological Data Service ID
  #create reference to Wikibase entity
    OPTIONAL {?person bnwdt:P118 ?worldcat_ID .}             #return WorldCat Identities ID
  BIND(IRI(concat("http://www.wikidata.org/entity/", ?Qnumber)) as ?WDitem )
  #on Wikibase do
  SERVICE <https://query.wikidata.org/sparql> {
        #get the date of birth
        ?WDitem wdt:P569 ?WDdateOfBirth .
        #get the statement of birth
        ?WDitem p:P569 ?Birthstatement .
        #get its node
        ?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-gb". }  
}
}
GROUP BY ?woman ?womanLabel ?WDitem ?WDdateOfBirth
ORDER BY ?personLabel
ORDER BY ?womanLabel
# Credit to Maarten Zeinstra for developing this query
</sparql>
</sparql>


=== Which women in the wikibase have Wikipedia articles, according to Wikidata?===
===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===


<sparql tryit="1">
<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 2,734: Line 2,741:
PREFIX wd:  <http://www.wikidata.org/entity/>
PREFIX wd:  <http://www.wikidata.org/entity/>


SELECT ?person ?personLabel ?wikidata ?wikipedia
SELECT ?person ?personLabel ?wikidata_ID ?viaf_ID ?ads_ID ?worldcat_ID
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
  ?person bnwdt:P16 ?FSA .                                  #select FSA
 
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .}           #filter out project team
  ?person bnwdt:P117 ?wikidata_ID . #look for wikidata ID on person page
    OPTIONAL {?person bnwdt:P117 ?wikidata_ID .}            #return wikidata ID
     bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_ID))) as ?wikidata) .
    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>


 
===People with IDs on wikidata, their date of birth on wikidata, and the source(s) of that information===
  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
 
</sparql>
 
 
=== 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
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,772: Line 2,767:
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd:  <http://www.wikidata.org/entity/>
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#>


SELECT ?person ?personLabel  ?wd_dod
SELECT ?woman ?womanLabel ?WDitem ?WDdateOfBirth (GROUP_CONCAT(?BirthStatedInEnglish;separator=" | ") AS ?sources)
WHERE {   
WHERE {   
   ?person bnwdt:P3 bnwd:Q3 . #select women
   #Select all women
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
   ?woman bnwdt:P3 bnwd:Q3 .
   #select all women that have a Wikidata link
   filter not exists {?person bnwdt:P15 ?bn_dod . } # *don't* have P15 date of death
   ?woman bnwdt:P117 ?Qnumber .  
 
   ?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) .
 
    
    
  #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> {
         ?item wdt:P21 ?WD_gender. #get gender of person
        #get the date of birth
         ?item wdt:P570 ?wd_dod . #date of death on Wikidata P570
         ?WDitem wdt:P569 ?WDdateOfBirth .
       }
        #get the statement of birth
        ?WDitem p:P569 ?Birthstatement .
        #get its node
        ?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-gb". }  
}
}
ORDER BY ?personLabel
GROUP BY ?woman ?womanLabel ?WDitem ?WDdateOfBirth
ORDER BY ?womanLabel
# Credit to Maarten Zeinstra for developing this query
</sparql>
</sparql>


=== Women with no date of birth in our wikibase who have a date of birth in Wikidata===
=== Which women in the wikibase have Wikipedia articles, according to Wikidata?===


<sparql tryit="1">
<sparql tryit="1">
# Women who have no date of birth in our wikibase and have a date of birth on Wikidata


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 2,809: Line 2,816:
PREFIX wd:  <http://www.wikidata.org/entity/>
PREFIX wd:  <http://www.wikidata.org/entity/>


SELECT ?person ?personLabel ?wd_dob
SELECT ?person ?personLabel ?wikidata ?wikipedia
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
 
  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
   ?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) .
     bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_ID))) as ?wikidata) .
 


   SERVICE <https://query.wikidata.org/sparql> {
   SERVICE <https://query.wikidata.org/sparql> {
         ?item wdt:P21 ?WD_gender. #get gender of person
      # get English language wikipedia articles in wikidata entries, where listed
        ?item wdt:P569 ?wd_dob #date of birth on Wikidata P569
         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". }  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
}
}
ORDER BY ?personLabel
ORDER BY ?personLabel
</sparql>
</sparql>


=== All external IDs on Wikidata for Women ===
 
=== Women with no date of death in our wikibase who have a date of death on Wikidata===


<sparql tryit="1">
<sparql tryit="1">
# Query to fetch all available External IDs on Wikidata for FSAs
# Women who have no date of death in our wikibase and have a date of death on Wikidata  
# 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,841: 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 bnpsv: <https://beyond-notability.wikibase.cloud/prop/statement/value/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>
PREFIX wd: <http://www.wikidata.org/entity/>


SELECT distinct ?person ?personLabel ?wikidata ?p ?id_no ?id_label
SELECT ?person ?personLabel ?wd_dod
WHERE { 
  ?person bnwdt:P3 bnwd:Q3 . #select women
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
  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) .


WHERE {
 
    ?person bnwdt:P3 bnwd:Q3 . #select women 
  SERVICE <https://query.wikidata.org/sparql> {
    #?person bnwdt:P75 bnwd:Q8. # limit to FSAs if the full set times out.
        ?item wdt:P21 ?WD_gender. #get gender of person
 
        ?item wdt:P570 ?wd_dod . #date of death on Wikidata P570
    ?person bnwdt:P117 ?wikidata_ID . #get wikidata ID
      }
    bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_ID))) as ?wikidata) .
 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }
}
ORDER BY ?personLabel
</sparql>


    SERVICE <https://query.wikidata.org/sparql> {
=== Women with no date of birth in our wikibase who have a date of birth in Wikidata===
   
    ?wikidata ?p ?s .   
      ?prop wikibase:claim ?p;   
            wikibase:statementProperty ?ps; # NB rather than statementValue
            wikibase:propertyType wikibase:ExternalId. # quicker than filter.
     
      ?prop rdfs:label ?id_label. filter(lang(?id_label)="en") . # ident name
     
          ?s ?ps ?id_no . # id value


      # filter by property type
<sparql tryit="1">
      #filter(?prop_type in (wikibase:ExternalId ) ) .
# Women who have no date of birth in our wikibase and have a date of birth on Wikidata
    } 
     
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en, en-gb". }
}
           
order by ?personLabel ?id_label ?id_no


</sparql>
=== What external IDs are available in Wikidata for women in the BN database? ===
<sparql tryit="1">
# All the external IDs on BN women's Wikidata pages, with counts and descriptions
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,889: Line 2,891:
PREFIX wd:  <http://www.wikidata.org/entity/>
PREFIX wd:  <http://www.wikidata.org/entity/>


SELECT ?p ?id_label ?id_description (count(?p) as ?count)
SELECT ?person ?personLabel ?wd_dob
 
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
  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) .


   ?person bnwdt:P117 ?wikidata_ID . # wikidata ID
   SERVICE <https://query.wikidata.org/sparql> {
    bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_ID))) as ?wikidata) .
        ?item wdt:P21 ?WD_gender. #get gender of person
        ?item wdt:P569 ?wd_dob . #date of birth on Wikidata P569
      }
    
    
    SERVICE <https://query.wikidata.org/sparql> {
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
    ?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 ?personLabel
ORDER BY desc(?count)
 
</sparql>
</sparql>


=== Women with ODNB IDs in Wikidata ===
=== All external IDs on Wikidata for Women ===


<sparql tryit="1">
<sparql tryit="1">
# BN women with ODNB biography IDs on Wikidata, with links to the bios
# 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,929: 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 ?wikidata ?url
SELECT distinct ?person ?personLabel ?wikidata ?p ?id_no ?id_label


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:P117 ?wikidata_ID . #get wikidata ID
     ?person bnwdt:P117 ?wikidata_ID . #get wikidata ID
     bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_ID))) as ?wikidata) .
     bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_ID))) as ?wikidata) .
 
 
     SERVICE <https://query.wikidata.org/sparql> {
     SERVICE <https://query.wikidata.org/sparql> {
      
      
     # P1415 Oxford Dictionary of National Biography ID | P6829 Dictionary of Irish Biography ID | P1648 Dictionary of Welsh Biography ID
     ?wikidata ?p ?s .   
    ?wikidata wdt:P1415 ?id
      ?prop wikibase:claim ?p;   
            wikibase:statementProperty ?ps; # NB rather than statementValue
            wikibase:propertyType wikibase:ExternalId. # quicker than filter.
     
      ?prop rdfs:label ?id_label. filter(lang(?id_label)="en") . # ident name
     
          ?s ?ps ?id_no . # id value


    # odnb link
      # filter by property type
    BIND(IRI(concat("https://doi.org/10.1093/ref:odnb/", ?id)) as ?url ) .
      #filter(?prop_type in (wikibase:ExternalId ) ) .  
   
     }   
     }   
        
        
Line 2,950: Line 2,953:
}
}
              
              
order by ?personLabel ?id
order by ?personLabel ?id_label ?id_no
 
</sparql>
</sparql>


=== Women with National Portrait Gallery links via Wikidata ===
=== What external IDs are available in Wikidata for women in the BN database? ===


<sparql tryit="1">
<sparql tryit="1">
# Query to fetch National Portrait Gallery IDs on Wikidata for BN women, with links
# All the external IDs on BN women's Wikidata pages, with counts and descriptions
# 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,965: 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 bnpsv: <https://beyond-notability.wikibase.cloud/prop/statement/value/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>
PREFIX wd: <http://www.wikidata.org/entity/>
 
SELECT ?p ?id_label ?id_description  (count(?p) as ?count)


SELECT distinct ?person ?personLabel ?wikidata ?id_no ?npg_url
WHERE { 
  ?person bnwdt:P3 bnwd:Q3 . #select women
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team


WHERE {
  ?person bnwdt:P117 ?wikidata_ID . # wikidata ID
    ?person bnwdt:P3 bnwd:Q3 . #select women   
    bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_ID))) as ?wikidata) .
    
    
    ?person bnwdt:P117 ?wikidata_ID . #get wikidata ID
    SERVICE <https://query.wikidata.org/sparql> {
    bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_ID))) as ?wikidata) .
    ?wikidata ?p ?s .
 
          ?prop wikibase:claim ?p;     
    SERVICE <https://query.wikidata.org/sparql> {
              wikibase:propertyType wikibase:ExternalId
   
              rdfs:label ?id_label. filter(lang(?id_label)="en") .  
    ?wikidata ?p ?s .  
      ?prop schema:description ?id_description .  
      ?prop wikibase:claim ?p;     
      filter(lang(?id_description) = "en") .  
            wikibase:statementProperty ?ps;
      }   
            wikibase:propertyType wikibase:ExternalId.  
        
   
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en, en-gb". }  
          ?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". }  
}
}
           
group by ?p ?id_label ?id_description
order by ?personLabel ?id_no
ORDER BY desc(?count)
 
</sparql>
</sparql>


=== Which BN properties map on to Wikidata properties? ===
=== 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
## **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 3,009: Line 3,008:
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 ?property (if(bound(?wikidata_id), "yes", "no") as ?has_wikidata)  ?bn_label ?wd_label ?bn_description
SELECT distinct ?person ?personLabel ?wikidata ?url
  ?wd_description ?wikidata ?bn_propertyType


WHERE {
WHERE {
  ?property a wikibase:Property ;
    ?person bnwdt:P3 bnwd:Q3 . #select women 
              wikibase:propertyType ?bn_propertyType . # datatype
      
     ?person bnwdt:P117 ?wikidata_ID . #get wikidata ID
  service wikibase:label { 
    bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_ID))) as ?wikidata) .
            bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en".
 
            ?property rdfs:label ?bn_label .
    SERVICE <https://query.wikidata.org/sparql> {
            ?property schema:description ?bn_description .
   
                            }
    # P1415 Oxford Dictionary of National Biography ID | P6829 Dictionary of Irish Biography ID | P1648 Dictionary of Welsh Biography ID
     # wikidata P117 
    ?wikidata wdt:P1415 ?id . 
     optional {
            ?property bnwdt:P117 ?wikidata_id .  
                bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_id))) as ?wikidata) .


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


==== Of these, which are properties for public and professional activities? ====
=== Women with National Portrait Gallery links via Wikidata ===


<sparql tryit="1">
<sparql tryit="1">
# which properties have corresponding wikidata IDs, restricted to instance of PPA (P12 / Q151)
# Query to fetch National Portrait Gallery IDs on Wikidata for BN women, with links
 
# NB this may be a bit slow...
## **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 3,054: Line 3,047:
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 ?property (if(bound(?wikidata_id), "yes", "no") as ?has_wikidata)  ?bn_label ?wd_label ?bn_description
SELECT distinct ?person ?personLabel ?wikidata ?id_no ?npg_url
  ?wd_description ?wikidata ?bn_propertyType


WHERE {
WHERE {
  ?property a wikibase:Property ;
    ?person bnwdt:P3 bnwd:Q3 . #select women    
              wikibase:propertyType ?bn_propertyType . # datatype
 
    ?person bnwdt:P117 ?wikidata_ID . #get wikidata ID
   service wikibase:label { 
     bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_ID))) as ?wikidata) .
            bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en".
            ?property rdfs:label ?bn_label .
            ?property schema:description ?bn_description .
                            }
    # wikidata P117 
     optional { ?property bnwdt:P117 ?wikidata_id .
                bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_id))) 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
    
    
     ?property bnwdt:P12 bnwd:Q151. # instance of PPA
     SERVICE <https://query.wikidata.org/sparql> {
   
    ?wikidata ?p ?s .   
      ?prop wikibase:claim ?p;   
            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 ?bn_label
           
order by ?personLabel ?id_no
</sparql>
</sparql>


 
=== Which BN properties map on to Wikidata properties? ===
 
=== Archaeological sites/Historic houses and their owners/operators in Wikidata ===


<sparql tryit="1">
<sparql tryit="1">
#title:archaeological sites/historic houses in wikidata
 
## **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 3,099: Line 3,092:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
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
SELECT DISTINCT ?property (if(bound(?wikidata_id), "yes", "no") as ?has_wikidata)  ?bn_label ?wd_label ?bn_description
  ?wd_description ?wikidata ?bn_propertyType
 
WHERE {
  ?property a wikibase:Property ;
              wikibase:propertyType ?bn_propertyType . # datatype
  service wikibase:label {  
            bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en".
            ?property rdfs:label ?bn_label .
            ?property schema:description ?bn_description .
                            }
    # wikidata P117 
    optional {
            ?property bnwdt:P117 ?wikidata_id .
                bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_id))) as ?wikidata) .


WHERE { 
             SERVICE <https://query.wikidata.org/sparql> {
 
                    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en".  
  { ?item bnwdt:P12 bnwd:Q86 . } # instance of archaeological site
                            ?wikidata schema:description ?wd_description .
  union
                            ?wikidata rdfs:label ?wd_label .  
  { ?item bnwdt:P12 bnwd:Q2961 . } # instance of historic house
                    } # / label service
 
              } # /wikidata service 
  ?item bnwdt:P12 ?instance .  # which instance of is it
          } #/wikidata optional
  filter ( ?instance in (bnwd:Q86, bnwd:Q2961) ) . # (need filter as a few have multiple instance of)
 
    ?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  .} # 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
order by ?bn_label
 
</sparql>
</sparql>


==== And which are owned/operated by English Heritage/National Trust or belong to Historic Houses Association ====
==== Of these, which are properties for public and professional activities? ====


<sparql tryit="1">
<sparql tryit="1">
# which properties have corresponding wikidata IDs, restricted to instance of PPA (P12 / Q151)


# archaeological site or historic house.  
## **NOTES**
# pull together via Wikidata which ones are owned/operated by 1) English Heritage 2) National Trust  or 3) affiliated to Historic Houses association
## 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 3,154: Line 3,137:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
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
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 ;
  { ?item bnwdt:P12 bnwd:Q86 . }
              wikibase:propertyType ?bn_propertyType . # datatype
  union
  { ?item bnwdt:P12 bnwd:Q2961 . }
  service wikibase:label {
            bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en".
            ?property rdfs:label ?bn_label .
            ?property schema:description ?bn_description .
                            }
    # wikidata P117 
    optional { ?property bnwdt:P117 ?wikidata_id .
                bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_id))) 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
    
    
  ?item bnwdt:P12 ?instance .
    ?property bnwdt:P12 bnwd:Q151. # instance of PPA
  filter ( ?instance in (bnwd:Q86, bnwd:Q2961) ) .
}
order by ?bn_label
  ?item bnwdt:P117 ?wikidata_id .
</sparql>
    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
=== Archaeological sites/Historic houses and their owners/operators in Wikidata ===
        filter ( ?wd_owner in (wd:Q936287, wd:Q333515) ||
                ?wd_operator in (wd:Q936287, wd:Q333515) ||
                ?wd_member = wd:Q5773523 ) .


      ## owned by P127 / operator P137 
<sparql tryit="1">
      ## ENglish Heritage Q936287  National Trust (Q333515)
#title:archaeological sites/historic houses in wikidata
      ## 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,en-gb". }
}
 
order by ?itemLabel
 
</sparql>
 
 
 
== Men ==
 
 
=== BN Men in Wikidata ===
 
<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/>
Line 3,219: 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 ?person ?personLabel ?wikidata ?whos_who ?odnb_url ?wikipedia ?wd_dob ?wd_dod ?wd_stmts
SELECT distinct ?item ?itemLabel ?instanceLabel ?wikidata ?wd_owner_label ?wd_operator_label ?wd_member_label  #?wd_owner ?wd_operator


WHERE {
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> {
  { ?item bnwdt:P12 bnwd:Q86 . } # instance of archaeological site
  union
  { ?item bnwdt:P12 bnwd:Q2961 . } # instance of historic house
 
  ?item bnwdt:P12 ?instance .  # which instance of is it
  filter ( ?instance in (bnwd:Q86, bnwd:Q2961) ) . # (need filter as a few have multiple instance of)
 
    ?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  .} # 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


      ?wikidata  wikibase:statements ?wd_stmts .
</sparql>


      optional { 
==== And which are owned/operated by English Heritage/National Trust or belong to Historic Houses Association ====
        # 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
<sparql tryit="1">
        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:P4789 ?whos .
                  bind(iri(concat("https://www.ukwhoswho.com/view/article/oupww/whoswho/", ?whos)) as ?whos_who) .
                } # P4789 Who's Who


        optional { ?wikidata wdt:P569 ?wd_dob . } #date of birth on Wikidata P569
# archaeological site or historic house.  
        optional { ?wikidata wdt:P570 ?wd_dod . }  #date of death on Wikidata P570
# pull together via Wikidata which ones are owned/operated by 1) English Heritage 2) National Trust  or 3) affiliated to Historic Houses association
    }  #/ 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">
 
#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 3,280: Line 3,235:
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 distinct ?item ?itemLabel ?instanceLabel ?wikidata ?wd_owner_label ?wd_operator_label ?wd_member_label  #?wd_owner ?wd_operator


WHERE {
WHERE {
    ?person bnwdt:P3 bnwd:Q10 . #select men 211.
 
 
  { ?item bnwdt:P12 bnwd:Q86 . }
    ?person bnwdt:P117 ?wikidata_ID . #get wikidata ID
  union
    bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_ID))) as ?wikidata) .
  { ?item bnwdt:P12 bnwd:Q2961 . }
    
    
    SERVICE <https://query.wikidata.org/sparql> {     
  ?item bnwdt:P12 ?instance .  
        ?wikidata ?p ?s .
  filter ( ?instance in (bnwd:Q86, bnwd:Q2961) ) .
            ?prop wikibase:claim ?p;
                wikibase:propertyType ?prop_type ;
  ?item bnwdt:P117 ?wikidata_id .  
                wikibase:statementProperty ?ps.   
    bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_id))) as ?wikidata) .
            ?prop rdfs:label ?prop_label. filter(lang(?prop_label)="en") .
               
        filter(?prop_type in (wikibase:Time, wikibase:WikibaseItem ) ) .  
     SERVICE <https://query.wikidata.org/sparql> {
      # 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>
      optional { ?wikidata wdt:P127 ?wd_owner .}
      optional { ?wikidata wdt:P137 ?wd_operator . }
      optional { ?wikidata wdt:P463 ?wd_member . }


=== BN Men in Wikidata: men who proposed elections to SAL/RAI ===
      # 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 ) .


<sparql tryit="1">
      ## owned by P127 / operator P137 
#title:Men who proposed for SAL/RAI elections who are in Wikidata
      ## 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,en-gb". }
}
 
order by ?itemLabel
 
</sparql>
 
 
 
== Men ==
 
 
=== BN Men in Wikidata ===
 
<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/>
Line 3,321: 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 distinct ?person ?personLabel ?wikidata ?whos_who ?odnb_url ?wikipedia ?wd_dob ?wd_dod ?wd_stmts


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
    ?person bnwdt:P3 bnwd:Q10 . #select men 
  ?s (bnps:P16 | bnps:P7) ?proposer .
 
    ?proposer bnwdt:P3 bnwd:Q10 .
     ?person bnwdt:P117 ?wikidata_ID . #get wikidata ID
 
     bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_ID))) as ?wikidata) .
     ?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> {
     SERVICE <https://query.wikidata.org/sparql> {
   
 
      ?wikidata  wikibase:statements ?wd_stmts .
 
       optional {   
       optional {   
         # P1415 Oxford Dictionary of National Biography ID  
         # 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 .   
        ?wikidata wdt:P1415 ?odnb_id .   
        BIND(IRI(concat("https://doi.org/10.1093/ref:odnb/", ?odnb_id)) as ?odnb_url ) . # make odnb link
 
        } #/ odnb
        # odnb link
     
        BIND(IRI(concat("https://doi.org/10.1093/ref:odnb/", ?odnb_id)) as ?odnb_url ) .
        # could also add:    P6829 Dictionary of Irish Biography ID | P1648 Dictionary of Welsh Biography ID
        } #/ odnb
        
        
         # English language wikipedia articles in wikidata entries, where listed
         # English language wikipedia articles in wikidata entries, where listed
Line 3,347: Line 3,330:
           FILTER (SUBSTR(str(?wikipedia), 1, 25) = 'https://en.wikipedia.org/')
           FILTER (SUBSTR(str(?wikipedia), 1, 25) = 'https://en.wikipedia.org/')
         }   
         }   
     
       
        # there will be a few duplicates here...
             
      optional { ?wikidata wdt:P4789 ?whos .
                  bind(iri(concat("https://www.ukwhoswho.com/view/article/oupww/whoswho/", ?whos)) as ?whos_who) .
                } # P4789 Who's Who
 
         optional { ?wikidata wdt:P569 ?wd_dob . } #date of birth on Wikidata P569
         optional { ?wikidata wdt:P569 ?wd_dob . } #date of birth on Wikidata P569
         optional { ?wikidata wdt:P570 ?wd_dod . }  #date of death on Wikidata P570  
         optional { ?wikidata wdt:P570 ?wd_dod . }  #date of death on Wikidata P570  
   
   
     }  #/ wikidata service
     }  #/ wikidata
        
        
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en, en-gb". }  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en, en-gb". }  
}
}
ORDER BY  ?proposerLabel
           
order by ?personLabel
</sparql>
</sparql>


==== Male proposers who have occupations data in Wikidata====
=== What sort of info Wikidata has about BN men ===


<sparql tryit="1">
<sparql tryit="1">
#title:Men who proposed for SAL/RAI elections who have occupation(s) in wikidata
# with occupation labels, which was slightly trickier than expected


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
#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 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 3,372: 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 ?prop_label ?prop (count(?prop) as ?count)


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
    ?person bnwdt:P3 bnwd:Q10 . #select men 211.
  ?s (bnps:P16 | bnps:P7) ?proposer .
 
     ?proposer bnwdt:P3 bnwd:Q10 .
    ?person bnwdt:P117 ?wikidata_ID . #get wikidata ID
     bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_ID))) as ?wikidata) .
    
    
    ?proposer bnwdt:P117 ?wikidata_ID . #get wikidata ID
     SERVICE <https://query.wikidata.org/sparql> {    
    bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_ID))) as ?wikidata) .
        ?wikidata ?p ?s .
 
            ?prop wikibase:claim ?p;  
     SERVICE <https://query.wikidata.org/sparql> {
                wikibase:propertyType ?prop_type ;
        ?wikidata wdt:P106 ?wd_occupation .  
                wikibase:statementProperty ?ps.   
        # automatic *Label doesn't work with a federated query; this works instead.     
            ?prop rdfs:label ?prop_label. filter(lang(?prop_label)="en") .  
        SERVICE wikibase:label {
        filter(?prop_type in (wikibase:Time, wikibase:WikibaseItem ) ) .  
              bd:serviceParam wikibase:language "en".  
      # also a few quantity, string, monolingualtext
              ?wd_occupation rdfs:label ?wd_label.  
     
              }
     }  #/ wikidata
     }  #/ wikidata service
        
        
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en, en-gb". }  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en, en-gb". }  
}
}
group by ?personLabel ?proposerLabel ?wikidata ?person ?proposer
group by ?prop_label  ?prop     
ORDER BY  ?proposerLabel ?person
order by ?prop_label
 
</sparql>
</sparql>


=== BN Men in Wikidata: Spouses ===
=== BN Men in Wikidata: men who proposed elections to SAL/RAI ===


<sparql tryit="1">
<sparql tryit="1">
#title: BN spouses who are in Wikidata
#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,413: Line 3,404:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


SELECT distinct ?spouse ?spouseLabel  ?wikidata ?odnb_url ?wikipedia ?wd_dob ?wd_dod
SELECT distinct ?proposerLabel ?proposer ?wikidata ?odnb_url ?wikipedia ?wd_dob ?wd_dod
WHERE {
WHERE {
   ?person bnwdt:P3 bnwd:Q3.
   ?person (bnp:P16 | bnp:P7) ?s . # proposed to either SAL or RAI
   ?person bnwdt:P41 ?spouse .
   ?s (bnps:P16 | bnps:P7) ?proposer .
 
    ?proposer bnwdt:P3 bnwd:Q10 .
     ?spouse bnwdt:P117 ?wikidata_ID . #get wikidata ID
 
     ?proposer bnwdt:P117 ?wikidata_ID . #get wikidata ID
     bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_ID))) as ?wikidata) .  
     bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_ID))) as ?wikidata) .  
    
    
Line 3,425: Line 3,417:
       optional {   
       optional {   
         # P1415 Oxford Dictionary of National Biography ID  
         # P1415 Oxford Dictionary of National Biography ID  
       
         ?wikidata wdt:P1415 ?odnb_id .   
         ?wikidata wdt:P1415 ?odnb_id .   
         BIND(IRI(concat("https://doi.org/10.1093/ref:odnb/", ?odnb_id)) as ?odnb_url ) . # make odnb link
         BIND(IRI(concat("https://doi.org/10.1093/ref:odnb/", ?odnb_id)) as ?odnb_url ) . # make odnb link
         } #/ odnb
         } #/ odnb
        
        
         # couls also add:    P6829 Dictionary of Irish Biography ID | P1648 Dictionary of Welsh Biography ID
         # could also add:    P6829 Dictionary of Irish Biography ID | P1648 Dictionary of Welsh Biography ID
        
        
         # English language wikipedia articles in wikidata entries, where listed
         # English language wikipedia articles in wikidata entries, where listed
Line 3,439: Line 3,430:
         }   
         }   
        
        
        # there will be a few duplicates here...
         optional { ?wikidata wdt:P569 ?wd_dob . } #date of birth on Wikidata P569
         optional { ?wikidata wdt:P569 ?wd_dob . } #date of birth on Wikidata P569
         optional { ?wikidata wdt:P570 ?wd_dod . }  #date of death on Wikidata P570  
         optional { ?wikidata wdt:P570 ?wd_dod . }  #date of death on Wikidata P570  
Line 3,445: Line 3,437:
        
        
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en, en-gb". }  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en, en-gb". }  
}
}
ORDER BY  ?proposerLabel
ORDER BY  ?proposerLabel
</sparql>
</sparql>


 
==== Male proposers who have occupations data in Wikidata====
=== 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
#title:Men who proposed for SAL/RAI elections who have occupation(s) in wikidata
# 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,464: Line 3,455:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


# p155, p156 - signed rhs
SELECT distinct ?personLabel ?proposerLabel
# p32, p82  - signed sal|
(group_concat(distinct ?wd_label; SEPARATOR="; ") as ?proposer_occupations)  
# p8 rai seconded
?wikidata ?person ?proposer
 
SELECT ?supporterLabel ?supporter  ?wikidata (count(?supporter) as ?supported)
 
WHERE {
WHERE {
 
  ?person (bnp:P16 | bnp:P7) ?s . # proposed to either SAL or RAI
   ?person bnwdt:P3 bnwd:Q3 .  
   ?s (bnps:P16 | bnps:P7) ?proposer .
    ?proposer bnwdt:P3 bnwd:Q10 .
    
    
  { 
     ?proposer bnwdt:P117 ?wikidata_ID . #get wikidata ID
     ?person (  bnp:P155 | bnp:P156 | bnp:P16 | bnp:P7 ) ?s . #
    bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_ID))) as ?wikidata) .  
      ?s ( bnps:P155 | bnps:P156 | bnps:P16 | bnps:P7 ) ?supporter  . # proposed SAL/RAI / signed RHS
      #?s ?prop ?supporter .  
    }
  #  union for qualifiers
  union
  {
  ?person ?p ?s .
    ?s (  bnpq:P156 | bnpq:P155 | bnpq:P32 | bnpq:P82 | bnpq:P8 ) ?supporter .  
    #?s ?prop ?supporter .
  }
    
    
     ?supporter bnwdt:P3 bnwd:Q10 . # male
     SERVICE <https://query.wikidata.org/sparql> {
 
        ?wikidata wdt:P106 ?wd_occupation .  
    optional {
        # automatic *Label doesn't work with a federated query; this works instead.     
      ?supporter bnwdt:P117 ?wikidata_ID . #get wikidata ID
        SERVICE wikibase:label {
      bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_ID))) as ?wikidata) .  
              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". }  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en, en-gb". }  
}
}
group by ?supporterLabel ?supporter ?wikidata
group by ?personLabel ?proposerLabel ?wikidata ?person ?proposer
having (?supported>2)
ORDER BY ?proposerLabel ?person
ORDER BY desc(?supported) desc(?wikidata)
</sparql>
</sparql>


==Fishing Expeditions==
=== BN Men in Wikidata: Spouses ===
 
===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: BN spouses who are in Wikidata


## fyi: not actually necessary to declare these properties
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bnwdv: <https://beyond-notability.wikibase.cloud/value/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX bnwdt: <https://beyond-notability.wikibase.cloud/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX bnp: <https://beyond-notability.wikibase.cloud/prop/>
PREFIX schema: <http://schema.org/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
 
SELECT DISTINCT
  ?property
  ?propertyType
  ?propertyLabel 
  (group_concat(?propertyAltLabel; separator=" | ") as ?propertyAltLabels)
  ?propertyDescription


SELECT distinct ?spouse ?spouseLabel  ?wikidata ?odnb_url ?wikipedia ?wd_dob ?wd_dod
WHERE {
WHERE {
   ?property a wikibase:Property ;
   ?person bnwdt:P3 bnwd:Q3.
              rdfs:label ?propertyLabel ; # label
  ?person bnwdt:P41 ?spouse .
              wikibase:propertyType ?propertyType . # datatype


  # add alternative labels if present (can be multiple)
    ?spouse bnwdt:P117 ?wikidata_ID . #get wikidata ID
  OPTIONAL { ?property skos:altLabel ?propertyAltLabel . }
    bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_ID))) as ?wikidata) .  
 
  # 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 <https://query.wikidata.org/sparql> {
  # fix label language dups; but Q why doesn't SERVICE work?  
   
  # A: https://en.wikibooks.org/wiki/SPARQL/FILTER#FILTER_on_values_in_Labels
      optional { 
   # nb a few objects found with en-gb label missing
        # P1415 Oxford Dictionary of National Biography ID
       
        ?wikidata wdt:P1415 ?odnb_id .    
        BIND(IRI(concat("https://doi.org/10.1093/ref:odnb/", ?odnb_id)) as ?odnb_url ) . # make odnb link
        } #/ 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". }


}
}
group by ?property ?propertyLabel ?propertyType ?propertyDescription
ORDER BY  ?proposerLabel
order by ?propertyLabel
 
</sparql>
</sparql>




=== All the Things for Organisations ===
=== 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


# 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 3,564: Line 3,546:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


select distinct ?item ?itemLabel
# p155, p156 - signed rhs
?prop ?propLabel ?prop_type
# p32, p82  - signed sal|
?stmt_value ?stmt_valueLabel
# p8 rai seconded
?qual_prop ?qual_value ?qual_label ?qual_prop_type
 
?statement
SELECT  ?supporterLabel ?supporter ?wikidata (count(?supporter) as ?supported)


where {
WHERE {


?item bnwdt:P12+ bnwd:Q2316  . # instance of organisation or descendants of (excluding instance of organisation itself)
  ?person bnwdt:P3 bnwd:Q3 .  
 
  # get all the things about ?item 
    ?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") .
    ?person (  bnp:P155 | bnp:P156 | bnp:P16 | bnp:P7 ) ?s . #
 
      ?s ( bnps:P155 | bnps:P156 | bnps:P16 | bnps:P7 ) ?supporter  . # proposed SAL/RAI / signed RHS
 
      #?s ?prop ?supporter .  
  # 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') .  
     }
     }
  #  union for qualifiers
  union
  {
  ?person ?p ?s .
    ?s (  bnpq:P156 | bnpq:P155 | bnpq:P32 | bnpq:P82 | bnpq:P8 ) ?supporter .
    #?s ?prop ?supporter .
  }
    
    
#  OPTIONAL { ?item skos:altLabel ?alt_label . }  
    ?supporter bnwdt:P3 bnwd:Q10 # male
 
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }
    
    
    optional {
      ?supporter bnwdt:P117 ?wikidata_ID . #get wikidata ID
      bind(iri(concat("http://www.wikidata.org/entity/", str(?wikidata_ID))) as ?wikidata) .
      }
     
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en, en-gb". }
}
}
 
group by ?supporterLabel ?supporter ?wikidata
order by ?item_label ?prop_label
having (?supported>2)
 
ORDER BY desc(?supported) desc(?wikidata)
</sparql>
</sparql>


==Fishing Expeditions==


=== One woman ===
===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:All About a Woman
## fyi: not actually necessary to declare these properties
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bnwdv: <https://beyond-notability.wikibase.cloud/value/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX bnwdt: <https://beyond-notability.wikibase.cloud/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX bnp: <https://beyond-notability.wikibase.cloud/prop/>
PREFIX schema: <http://schema.org/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
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 ?propLabel ?spsLabel ?qual_propLabel ?pqsLabel ?link ?s
SELECT DISTINCT
# ?main_date ?main_precision ?qual_date ?qual_precision   
  ?property
# ?prop ?sps ?pqs ?pq
  ?propertyType
  ?propertyLabel 
  (group_concat(?propertyAltLabel; separator=" | ") as ?propertyAltLabels)
  ?propertyDescription
 
WHERE {
  ?property a wikibase:Property ;
              rdfs:label ?propertyLabel ; # label
              wikibase:propertyType ?propertyType . # datatype


WHERE
  # add alternative labels if present (can be multiple)
{
  OPTIONAL { ?property skos:altLabel ?propertyAltLabel . }
  VALUES (?person) {(bnwd:Q569)}  # add (bnwd:Qxxx) if you want more than one person. 
  ?person ?p ?s .


    ?prop wikibase:claim ?p;   
  # add description if present
        wikibase:statementProperty ?ps;  #  simple value
  OPTIONAL {
        wikibase:statementValue ?psv. #  full value    
        SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en".
          ?property schema:description ?propertyDescription .
        }
   }
    
    
  # exclude external IDs
  FILTER(LANG(?propertyLabel) = 'en')
  # filter not exists { ?prop wikibase:propertyType wikibase:ExternalId . }
  # fix label language dups; but Q why doesn't SERVICE work?
 
  # A: https://en.wikibooks.org/wiki/SPARQL/FILTER#FILTER_on_values_in_Labels
      ?s ?ps ?sps.
 
    # full date via ?psv
      OPTIONAL {
          ?s ?psv ?spsv .
              ?spsv wikibase:timeValue ?main_date .
              ?spsv wikibase:timePrecision ?main_precision .
      }


    # qualifiers.
}
 
group by ?property ?propertyLabel ?propertyType ?propertyDescription
      optional {
order by ?propertyLabel
        ?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 ?propLabel ?s


</sparql>
</sparql>


===Working with property paths: organisations and locations===
=== All the Things for Organisations ===


<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


# 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 3,691: Line 3,644:
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 ?item ?itemLabel  
WHERE {  
?prop ?propLabel ?prop_type
  ?item bnwdt:P12 bnwd:Q2316 .  # instance of organisation.
?stmt_value ?stmt_valueLabel
  ?item bnwdt:P2* ?tmp .
?qual_prop ?qual_value ?qual_label ?qual_prop_type
  ?tmp bnwdt:P2+ ?location . # P2=30. P2+=34
?statement


   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb, en". }  
where {
 
?item bnwdt:P12+ bnwd:Q2316  . # instance of organisation or descendants of (excluding instance of organisation itself)
 
  # get all the things about ?item 
    ?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". }  
 
}
}
group by ?item ?itemLabel  ?location ?locationLabel
 
ORDER BY ?item ?distance
order by ?item_label ?prop_label
 
</sparql>
</sparql>


=== Working with property paths: instance of [CAVEAT: experimental, probably wrong]===
 
=== One woman ===


<sparql tryit="1">
<sparql tryit="1">
# 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
#title:All About a Woman
# 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/>
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
Line 3,717: 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 ?item ?itemLabel ?instance_of ?instance_ofLabel  (count(?item) as ?distance)
SELECT distinct ?propLabel ?spsLabel ?qual_propLabel ?pqsLabel ?link ?s
WHERE { 
# ?main_date ?main_precision ?qual_date ?qual_precision   
  ?item bnwdt:P12* ?tmp .  # instance of anything.
# ?prop ?sps ?pqs ?pq
  ?tmp bnwdt:P12+ ?instance_of . # P2=30. P2+=34


  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb, en". }
WHERE
}
{
group by ?item ?itemLabel ?instance_of ?instance_ofLabel
  VALUES (?person) {(bnwd:Q569)}  # add (bnwd:Qxxx) if you want more than one person.
ORDER BY ?item ?distance
  ?person ?p ?s .  


</sparql>
    ?prop wikibase:claim ?p;   
        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 .
      }


==Dates==
    # qualifiers.
 
 
===All the Dates for Women FSAs===
      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 ?propLabel ?s
 
</sparql>
 
===Working with property paths: organisations and locations===


<sparql tryit="1">
<sparql tryit="1">
#title:fishing for dates for FSAs
## 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.
# union query to get [hopefully] every date associated with women FSAs including main dates and qualifier dates
## 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 3,745: Line 3,770:
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 ?prop_label ?qualLabel ?qual_dateLabel ?date_value  ?s 
#?prop ?qual


SELECT  ?item ?itemLabel ?location ?locationLabel (count(?item) as ?distance)
WHERE { 
  ?item bnwdt:P12 bnwd:Q2316 .  # instance of organisation.
  ?item bnwdt:P2* ?tmp .
  ?tmp bnwdt:P2+ ?location . # P2=30. P2+=34
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb, en". }
}
group by ?item ?itemLabel  ?location ?locationLabel
ORDER BY ?item ?distance
</sparql>
=== Traversing instance of with GAS ===
<sparql tryit="1">
#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
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 ?depth  ?ioLabel ?itemLabel ?io ?item
WHERE {
WHERE {
 
      SERVICE gas:service {
  ?person bnwdt:P3 bnwd:Q3 . #select women
          gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.BFS" ;
  ?person bnwdt:P75 bnwd:Q8. # find only BN subjects having a FSA
                      gas:in bnwd:Q3099 ;  
 
                      gas:linkType bnwdt:P12 ;
  # get stuff about ?person 
                      gas:traversalDirection "Reverse";
  ?person ?p ?s .  
                      gas:out ?item ;
 
                      gas:out1 ?depth ;
      # get stuff about ?p .
                      gas:out2 ?io .  
      ?prop wikibase:claim ?p;   
       }
        wikibase:statementProperty ?ps ;
    SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
        wikibase:statementValue ?psv .   
    }  
      ?prop wikibase:propertyType ?date_prop_type .
order by ?depth ?ioLabel ?itemLabel
      ?prop rdfs:label ?prop_label. filter(lang(?prop_label)="en-gb") .
</sparql>
 
 
 
 
{  # main dates
=== Working with property paths: instance of [CAVEAT: experimental, probably wrong]===
 
  # 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>
 
===Fetch any of multiple kinds of EDTF date for a woman===


<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
# an attempt to adapt the query above following paths for locations of organisations for (more complex) instance of
# main dates only; pretty sure there are no EDTF in qualifiers.  
# ref https://stackoverflow.com/questions/61984052/wikidata-get-the-full-subhierachy-of-one-class-as-well-as-all-nodes
# updated to get date property labels
# 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,815: Line 3,832:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


SELECT  ?person ?personLabel ?date_edtf ?date_prop ?date_label ?s
SELECT ?item ?itemLabel ?instance_of ?instance_ofLabel (count(?item) as ?distance)
WHERE { 
  ?item bnwdt:P12* ?tmp .  # instance of anything.
  ?tmp bnwdt:P12+ ?instance_of . # P2=30. P2+=34


WHERE { ?person bnwdt:P3 bnwd:Q3 .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb, en". }  
      FILTER NOT EXISTS { ?person bnwdt:P4 bnwd:Q12 . }  
}
   
group by ?item ?itemLabel ?instance_of ?instance_ofLabel
      ## can do this union first but makes no difference to results except possibly a bit slower.
ORDER BY ?item ?distance
      #?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
</sparql>
          ?claim wikibase:claim ?p;     
                rdfs:label ?date_label. filter(lang(?date_label)="en") .       


          ?s ?date_prop ?date_edtf .
==Dates==
             
    ## filter for edtf dates
    ## docs: https://github.com/ProfessionalWiki/WikibaseEdtf


    FILTER ( datatype(?date_edtf) = xsd:edtf  ) .
===All the Dates for Women FSAs===
           
    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">
#title:fishing for dates for FSAs
# union query to get [hopefully] every date associated with women FSAs including main dates and qualifier dates


# query for full values to access the timeValue and timePrecision of a date, in this case a date of birth.
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
 
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
## why is a more complex query needed?
PREFIX bnwdv: <https://beyond-notability.wikibase.cloud/value/>
## 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)
PREFIX bnwdt: <https://beyond-notability.wikibase.cloud/prop/direct/>
## 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 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 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 bnpsv: <https://beyond-notability.wikibase.cloud/prop/statement/value/>
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>
SELECT distinct ?person ?personLabel ?prop_label ?qualLabel ?qual_dateLabel ?date_value  ?s 
#?prop ?qual


SELECT DISTINCT ?item ?itemLabel ?date ?precision
WHERE {
WHERE {
  ?item bnp:P26  ?statement. # date of birth (precision of these varies quite a bit)
  ?statement bnpsv:P26 ?valueNode.
  ?valueNode wikibase:timeValue ?date.
  ?valueNode wikibase:timePrecision ?precision.
    
    
   SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
   ?person bnwdt:P3 bnwd:Q3 . #select women
}
  ?person bnwdt:P75 bnwd:Q8. # find only BN subjects having a FSA
ORDER BY ?date
 
  # 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") .  
 


</sparql>
{  # main dates
 
 
=== Any main level date for women ===
  # 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>
 
===Fetch any of multiple kinds of EDTF date for a woman===


<sparql tryit="1">
<sparql tryit="1">
# a query to get all types of main date for women
# 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,888: Line 3,928:
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 ?person ?personLabel ?date_label  ?date ?date_prop_type ?date_prop ?link_prop
SELECT ?person ?personLabel ?date_edtf ?date_prop ?date_label ?s


WHERE {
WHERE { ?person bnwdt:P3 bnwd:Q3 .  
 
      FILTER NOT EXISTS { ?person bnwdt:P4 bnwd:Q12 . }  
  ?person bnwdt:P3 bnwd:Q3 . # women
      
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .}       
      ## can do this union first but makes no difference to results except possibly a bit slower.
 
      #?person ( bnp:P131 | bnp:P132 | bnp:P133  ) ?s .
  ?person ?p ?s .
      #  ?s ( bnps:P131 | bnps:P132 | bnps:P133 ) ?date_edtf .
 
      ?date_prop wikibase:claim ?p;   
        wikibase:statementValue ?psv ;  
        wikibase:propertyType ?date_prop_type; # property type = wikibase:Time OR wikibase:Edtf
        rdfs:label ?date_label. filter(lang(?date_label)="en-gb") . # what kind of date it is


        # direct link to relevant section of page
      ?person ?p ?s . # so you can get the statement id and date prop label
        BIND (REPLACE(STR(?date_prop), "^.*/([^/]*)$", "$1") as ?pid).
          ?claim wikibase:claim ?p;     
        bind(iri(concat(str(?person), "#", ?pid)) as ?link_prop ) . 
                rdfs:label ?date_label. filter(lang(?date_label)="en") .      
     
      ?s ?psv ?wdv . # for the date value
        ?wdv wikibase:timeValue ?date .  #timeValue gets pit and edtf
    #  ?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


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


=== Counting Dates===
    FILTER ( datatype(?date_edtf) = xsd:edtf  ) .
           
    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">
# count distinct dates for women (who have at least one)
 
# uncomment HAVING line for women with only one
# query for full values to access the timeValue and timePrecision of a date, in this case a date of birth.
# CAVEAT: there may be some discrepancies between dates shown on wiki pages and dates returned by sparql
 
## 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/>
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
Line 3,935: Line 3,976:
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 ?person ?personLabel (COUNT(DISTINCT ?date_value) as ?count)


SELECT DISTINCT ?item ?itemLabel ?date ?precision
WHERE {
WHERE {
   
  ?item bnp:P26 ?statement. # date of birth (precision of these varies quite a bit)
{  # main dates
   ?statement bnpsv:P26 ?valueNode.
 
  ?valueNode wikibase:timeValue ?date.
  ?person bnwdt:P3 bnwd:Q3 . # women    
  ?valueNode wikibase:timePrecision ?precision.
  ?person ?p ?s .        
      ?s ?date_prop ?wdv .
        ?wdv wikibase:timeValue ?date_value .
  } # /main dates
    
    
  UNION
   SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
 
}
  { # qualifier dates
ORDER BY ?date
   
 
    ?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>
</sparql>


=== Start dates that might not have accompanying end dates ===
=== Any main level date for women ===


<sparql tryit="1">
<sparql tryit="1">
#title:Women with start dates that might not have accompanying end dates
# 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/>
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
Line 3,980: Line 4,003:
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 ?personLabel ?prop_label ?start_date (if(bound(?end_date), "yes", "no") as ?has_end_date) ?person ?s 
SELECT DISTINCT ?person ?personLabel ?date_label ?date ?date_prop_type ?date_prop ?link_prop
#(group_concat(?other_date_label; SEPARATOR=" | ") as ?other_dates)


WHERE {
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
  ?person bnwdt:P3 bnwd:Q3 . # women
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .}     
    
    
    optional {?s bnpq:P28 ?end_date .} # check for end dates
  ?person ?p ?s .
 
      ?date_prop wikibase:claim ?p;   
        wikibase:statementValue ?psv ; 
        wikibase:propertyType ?date_prop_type; # property type = wikibase:Time OR wikibase:Edtf
        rdfs:label ?date_label. filter(lang(?date_label)="en-gb") . # what kind of date it is


#   optional {
        # direct link to relevant section of page
#      ?s ?pq ?other_date . # could there be any other associated dates?
        BIND (REPLACE(STR(?date_prop), "^.*/([^/]*)$", "$1") as ?pid).
        bind(iri(concat(str(?person), "#", ?pid)) as ?link_prop ) . 
        
        
#       ?qual_prop wikibase:qualifier ?pq;     
      ?s ?psv ?wdv . # for the date value
  #             wikibase:propertyType wikibase:Time ; # nb *does not* include edtf dates but AFAICT there are none in qualifiers.
        ?wdv wikibase:timeValue ?date . #timeValue gets pit and edtf
  #            rdfs:label ?other_date_label . filter(lang(?other_date_label)="en-gb") . # what kind of date is it.
    # ?wdv wikibase:timePrecision ?date_precision . # optional
    
    
        # drop both start and end this time. idk if there could be a faster way to do this?
  # nb also possible to filter either/or time/edtf by property type
#       filter not exists { ?s (bnpq:P27 | bnpq:P28) ?other_date }
  # filter(?date_prop_type in (wikibase:Edtf, wikibase:Time ) ) .   
    
    
#  } # / optional other dates
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
 
}
  # filter(!bound(?end_date)). # to filter out rows with an end date
ORDER BY ?personLabel ?date
 
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en". }  
 
}


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


 
=== Counting Dates===
=== End dates that might not accompanying start dates ===


<sparql tryit="1">
<sparql tryit="1">
#title:Women with end dates that might not have accompanying start dates
# count distinct dates for women (who have at least one)
# uncomment HAVING line for women with only one
# 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/>
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 4,039: Line 4,051:
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>


SELECT distinct ?personLabel ?prop_label ?end_date 
SELECT ?person ?personLabel (COUNT(DISTINCT ?date_value) as ?count)  
(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 .  
{  # main dates
  ?claim wikibase:claim ?p;     
 
        rdfs:label ?prop_label. filter(lang(?prop_label)="en") .
  ?person bnwdt:P3 bnwd:Q3 . # women 
   
  ?person ?p ?s .        
# get end dates  
      ?s ?date_prop ?wdv .
# then optional start dates
        ?wdv wikibase:timeValue ?date_value .
# 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.
  } # /main dates
# 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
  UNION
    
    
    optional {?s bnpq:P27 ?start_date .} # check for start dates
  { # FIXME? qualifier dates. hmm... how is this different from above? I think something is missing.  
 
   
     optional {
     ?person bnwdt:P3 bnwd:Q3 . 
        ?s ?pq ?other_date . # could there be any other associated dates?
    ?person ?p ?s .  
        ?qual_prop wikibase:qualifier ?pq;     
      ?s ?date_prop ?pqv .
              wikibase:propertyType wikibase:Time ; # nb *does not* include edtf dates but AFAICT there are none in qualifiers.
        ?pqv wikibase:timeValue ?date_value.
              rdfs:label ?other_date_label . filter(lang(?other_date_label)="en-gb") . # what kind of date
    } # /qual dates
        # 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". }  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en". }  
    
    
}  
} # /where
GROUP BY ?person ?personLabel
# HAVING(?count=1)


group by  ?personLabel ?prop_label ?end_date ?start_date ?has_start_date ?person ?s 
ORDER BY ?count ?person
 
ORDER BY ?personLabel ?prop_label ?end_date
</sparql>
</sparql>


=== Women having children ===
=== Start dates that might not have accompanying end dates ===


<sparql tryit="1">
<sparql tryit="1">
#title:women having children
#title:Women with start dates that might not have accompanying end dates
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 4,091: Line 4,093:
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/>


# lol defaultView:Timeline{"hide":["?s", "?date_prec", ""]}
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)


# P131 had child in / P45 child
WHERE {
# a handful of P45 named children don't have dob though probably have dob in wikidata
  ?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


SELECT distinct ?person ?personLabel ?childLabel ?date_value ?date_prec ?had_child_edtf ?note   
#  optional {
?s
#      ?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 {
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
    
    
{   
{   
   # had child in (unnamed children)
   # had child in (unnamed children)
   ?person bnp:P131 ?s .
   ?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.
       ?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
 
  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 ?personLabel


  # 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>
</sparql>
726

edits