Project:SPARQL/examples: Difference between revisions

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


Line 216: Line 218:
PREFIX wd:  <http://www.wikidata.org/entity/>
PREFIX wd:  <http://www.wikidata.org/entity/>


SELECT distinct ?person ?personLabel  ?prop ?propLabel  ?pq_value  ?qual_prop_label ?sal  
SELECT distinct ?person ?personLabel  ?prop ?propLabel  ?pq_value  ?qual_propLabel ?sal  


WHERE {   
WHERE {   
Line 235: Line 237:
          
          
         ?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 rdfs:label ?qual_prop_label. filter(lang(?qual_prop_label)="en-gb") .  
         ?qual_prop wikibase:propertyType ?qual_prop_type
         #?qual_prop wikibase:propertyType ?qual_prop_type
          
          
       } # /qualifiers
       } # /qualifiers


   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }  
}
}
ORDER BY ?personLabel ?propLabel ?s
ORDER BY ?personLabel ?propLabel ?s
Line 258: Line 260:
PREFIX wd:  <http://www.wikidata.org/entity/>
PREFIX wd:  <http://www.wikidata.org/entity/>


SELECT distinct ?person ?personLabel  ?prop ?propLabel ?prop_type  ?pq_value ?pq_valueLabel ?qual_prop_label ?qual_prop_type ?rai ?s
SELECT distinct ?person ?personLabel  ?prop ?propLabel ?prop_type  ?pq_value ?pq_valueLabel ?qual_propLabel ?qual_prop_type ?rai ?s


WHERE {   
WHERE {   
Line 278: Line 280:
          
          
         ?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 rdfs:label ?qual_prop_label. filter(lang(?qual_prop_label)="en-gb") .  
         ?qual_prop wikibase:propertyType ?qual_prop_type .
         ?qual_prop wikibase:propertyType ?qual_prop_type .
          
          
       } # /qualifiers
       } # /qualifiers


   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }  
}
}
ORDER BY ?personLabel
ORDER BY ?personLabel
Line 453: Line 455:
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>


SELECT distinct ?personLabel ?work_label ?positionLabel ?date_label ?date  
SELECT distinct ?personLabel ?workLabel ?positionLabel ?date_pLabel ?date  
?employerLabel ?organisedLabel ?ofLabel  
?employerLabel ?organisedLabel ?ofLabel ?person
?s ?person ?work ?position ?employer ?organised ?of
#?s ?position  ?of  ?work ?employer ?organised


WHERE {
WHERE {
Line 465: Line 467:
    
    
   ?person ?work_p ?s . # for activity type label
   ?person ?work_p ?s . # for activity type label
   ?work wikibase:claim ?work_p;     
   ?work wikibase:claim ?work_p .   
        rdfs:label ?work_label. filter(lang(?work_label)="en-gb") .   
      
      
     # more about the position
     # more about the position
Line 482: Line 483:
     ?s ?pq ?date .  
     ?s ?pq ?date .  
        
        
       ?qual_prop wikibase:qualifier ?pq;       
       ?date_p wikibase:qualifier ?pq;       
               #wikibase:propertyType ?date_prop_type; # can check date property types if needed
               #wikibase:propertyType ?date_prop_type; # can check date property types if needed
               wikibase:propertyType wikibase:Time ; # nb *does not* include edtf dates but AFAICT there are none in qualifiers.
               wikibase:propertyType wikibase:Time . # nb *does not* include edtf dates but AFAICT there are none in qualifiers.
               rdfs:label ?date_label . filter(lang(?date_label)="en-gb") . # what kind of date is it.
               #rdfs:label ?date_label . filter(lang(?date_label)="en-gb") . # what kind of date is it.
       } # /dates
       } # /dates
    
    
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }  
    
    
} # /where
} # /where
Line 553: Line 554:
</sparql>
</sparql>


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


<sparql tryit="1">
<sparql tryit="1">
 
#title:lecturers
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
Line 567: Line 565:
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  ?positionLabel
?organisedLabel ?ofLabel
?qual_propLabel ?qualLabel
#?position ?of  ?work ?organised  ?date_precision ?qual_prop ?date ?qual ?workLabel
?s
WHERE {
   
  ?person bnwdt:P3 bnwd:Q3 . # women
 
  # work activities: held position / held position (free text) /  employed as
  #?person ( bnp:P17|bnp:P48|bnp:P105 ) ?s . 
 
  ?person ?work_p ?s . # for activity type label
    ?work wikibase:claim ?work_p . 


SELECT distinct ?personLabel ?serviceLabel ?qual_propLabel ?qualLabel  ?service ?qual ?person #?s
    ?s ?bnps ?position .  
WHERE { 
    # freelance and extension lecturing (q701 and q3021)
  ?person bnwdt:P3 bnwd:Q3 . # select women
    { ?s ?bnps bnwd:Q701  . } union { ?s ?bnps bnwd:Q3021 . }
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
 
  ?person bnp:P102 ?s .  # served on P102
  ?person ?p ?s .    # for claim
    
    
  ?claim wikibase:claim ?p;     
    # employer / organised by / of (incl free text).
        wikibase:statementProperty ?ps;
    OPTIONAL { ?s bnpq:P109 ?organised .}
        wikibase:propertyType ?prop_type.  
    OPTIONAL { ?s ( bnpq:P78 | bnpq:P66 ) ?of .}
  # optional { ?s bnpq:P2 ?location . } # do locations separately.
      
      
    ?s ?ps ?service . # service on what
  # dates with precision
      
#  optional {
  optional { #qualifiers, if any
#    ?s (bnpqv:P1 | bnpqv:P27 | bnpqv:P28  ) ?pqv.
    ?s ?pq ?qual .    
#    ?s ?pqq ?pqv . # just gets the uri but doesnt seem to cause dups
        ?qual_prop wikibase:qualifier ?pq.    
#        ?pqv wikibase:timeValue ?date . 
        SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en".  
#        ?pqv wikibase:timePrecision ?date_precision .
        ?qual_prop rdfs:label ?qual_propLabel . # what kind of thing
#     }
        } # /label service
     
       } # /quals
     # qualifiers
    optional {
      ?s ?pq ?qual .  
        ?qual_prop wikibase:qualifier ?pq .
     
      } # /dates
 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
 
} # /where
 
ORDER BY ?person ?
</sparql>
 
== Professional Activities and Organisations ==
 
=== Women's service on committees etc (P102) ===
 
<sparql tryit="1">
 
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
PREFIX bnwdv: <https://beyond-notability.wikibase.cloud/value/>
PREFIX bnwdt: <https://beyond-notability.wikibase.cloud/prop/direct/>
PREFIX bnp: <https://beyond-notability.wikibase.cloud/prop/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
 
 
SELECT distinct ?personLabel ?serviceLabel ?qual_propLabel ?qualLabel  ?qual ?person ?s # ?service
WHERE { 
  ?person bnwdt:P3 bnwd:Q3 . # select women
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
 
  ?person bnp:P102 ?s .  # served on P102
    ?s bnps:P102 ?service .
   
  optional {  #qualifiers, if any
    ?s ?pq ?qual .     
        ?qual_prop wikibase:qualifier ?pq.     
       } # /quals


   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb, en". }  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb, en". }  
Line 594: Line 648:


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


Line 755: Line 810:
</sparql>
</sparql>


=== PPA Buckets ===
=== PPA Buckets for Women ===


<sparql tryit="1">
<sparql tryit="1">
#title:first draft of ppa buckets January 2024
#title:ppa buckets (revised February 2024)
# broad PPA grouping categories to use for overviews and analysis within categories
 
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
Line 775: Line 832:
   
   
       ?ppa wikibase:claim ?p;       
       ?ppa wikibase:claim ?p;       
         wikibase:statementProperty ?ps.    
         wikibase:statementProperty ?ps.  
         
 
      # note: i think you need rdfs:label (*Label won't work) for the bind()
 
       SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb".  
       SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb".  
                       ?ppa rdfs:label ?ppa_label.       # what kind of thing
                       ?ppa rdfs:label ?ppa_label.  
                 } # /label service
                 } # /label service
    
    
Line 786: Line 845:
       ?s ?ps ?ppa_value.
       ?s ?ps ?ppa_value.
    
    
  bind(
    # note: it would be possible to write this to use ppa rather than ppa_label
      if( str(?ppa_label) in ("attended", "exhibited at", "organiser of", "performed at", "spoke at", "was delegate at (free text)", "was delegate at (item)" ), "events",
    # BUT then it would be much more opaque and difficult to edit if (when!) we make any changes to the buckets.
          if( str(?ppa_label) in ("curated (item)", "donor to", "loaner to", "recovered (free text)", "seller to", "was collector of", "was donor of" ), "collections",
    bind(
            if( str(?ppa_label) in ("educated at"),  "education" ,
      if( str(?ppa_label) in ("attended", "exhibited at", "organiser of", "performed at", "spoke at", "was delegate at (free text)", "was delegate at (item)" ), "events",
                if( str(?ppa_label) in ("election to Council of CAS proposed by", "election to RAI proposed by", "election to SAL proposed by", "proposed election to RHS signed by (personal)"),  "elections" ,
        if( str(?ppa_label) in ("curated (item)", "donor to", "loaner to", "recovered (free text)", "seller to", "was collector of", "was donor of" ), "collections",
                      if( str(?ppa_label) in ("Member of Committee for Archaeological Fieldwork", "President of Committee for Archaeological Fieldwork", "director of archaeological fieldwork", "director of expedition", "member of excavation during archaeological fieldwork", "member of expedition", "travelled overseas for"
          if( str(?ppa_label) in ("educated at"),  "education" ,
            if( str(?ppa_label) in ("election to Council of CAS proposed by", "election to RAI proposed by", "election to SAL proposed by", "proposed election to RHS signed by (personal)"),  "elections" ,
              if( str(?ppa_label) in ("Member of Committee for Archaeological Fieldwork", "President of Committee for Archaeological Fieldwork", "director of archaeological fieldwork", "director of expedition", "member of excavation during archaeological fieldwork", "member of expedition", "travelled overseas for"
),  "fieldwork" ,
),  "fieldwork" ,
                        if( str(?ppa_label) in ("applicant to", "employed as", "held position", "held position (free text)"),  "positions" ,
                if( str(?ppa_label) in ("acknowledged for role", "applicant to", "employed as", "held position", "held position (free text)", "served on"),  "positions" ,
                            if( str(?ppa_label) in ("contributed to", "editor", "illustrated in", "published with", "work(s) published in"),   "publishing" ,
                  if( str(?ppa_label) in ("contributed to", "illustrated in", "work(s) published in"), "publishing",
                              if( str(?ppa_label) in ("served on", "was fellow of", "was member of"),   "societies",
                    if( str(?ppa_label) in ("corresponded with", "was fellow of", "was member of"), "societies",
                                  if( str(?ppa_label) in ("benefactor to", "fundraiser for"),  "charity" ,
                      if( str(?ppa_label) in ("benefactor to", "fundraiser for", "founded"),  "charitable" ,
       "tbd")))))))))
       "none")))))))))
     as ?bucket).
     as ?bucket).
          
          
Line 807: Line 868:
</sparql>
</sparql>


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


===People not in London linked as a graph by a NUTS region or country (excluding England) at which they were once resident in the UK===
===People not in London linked as a graph by a NUTS region or country (excluding England) at which they were once resident in the UK===
Line 1,970: Line 2,103:
</sparql>
</sparql>


==People==
=== IWD 2024 Map of five women's places ===


===Women with their family name at birth and family name after marriage===
<sparql tryit="1">
 
## how many places for the five women can I get on a map? a slightly ridiculous query.
<sparql tryit="1">
# Women with their family name at birth and family name after marriage


#title:Four stories, five women, many places for #IWD2024
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
Line 1,985: Line 2,117:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


#defaultView:Map{"hide":["?geo"],"layer":"?person", "markercluster":true }
SELECT distinct ?person ?personLabel  ?propLabel ?placeLabel  ?geo  ?loc2Label (year(?date) as ?year)


SELECT ?person ?personLabel ?birthname ?marriedname
WHERE {   
WHERE {   
   ?person bnwdt:P3 bnwd:Q3 . #select women
 
   FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
  VALUES (?person) {(bnwd:Q894) (bnwd:Q462) (bnwd:Q549) (bnwd:Q921) (bnwd:Q1053) }  #
   OPTIONAL {?person bnwdt:P140 ?birthname .} #look for birth name
  ?person ( bnp:P29 | bnp:P94  | bnp:P23 | bnp:P13 | bnp:P120   ) ?s .
   OPTIONAL {?person bnwdt:P141 ?marriedname .} #look for married name
 
  ?s  ( bnps:P29 | bnps:P94  | bnps:P23 | bnps:P13 | bnps:P120  )  ?place .
 
  ?person ?p ?s .
      ?prop wikibase:claim ?p;     
        wikibase:statementProperty ?ps. 
 
      optional { ?s ( bnpq:P1 | bnpq:P27 ) ?date . }
      #optional { ?s bnpq:P31 ?street . }
  # LOLplaces
  #1 geocoords in quals for place itself - should be detailed geo added manually, cf London district geocoords which =main P153
  #2 wikdiata geocoords for place
  #3 geocoords in quals for linked place
  #4 wikidata geocoords for linked place
  #5 wikidata geocoords in place P2 qual
  #6 `of` qual geocoords
  #7 `of` P2 wikidata geocoords
  #8 `of` wikidata geocoords
  #9 place main geocoords - likely to be broad london postal districts so should be last resort
  #10 linked place main geocoords
 
 
      optional { ?s bnpq:P153 ?geo1 . } # place has geocoords directly *in qualifier*
 
      optional { ?place bnwdt:P2 ?linked_p1 . # linked place has geocoords *in qualifier* (this is primarily for SAL?)
                    ?linked_p1 bnp:P2 ?llp_s .
                        ?llp_s bnps:P2 ?llp_p1.
                        ?llp_s bnpq:P153 ?geo2 .
                }
 
      optional { ?place bnwdt:P117 ?pws . # place has wikidata page that has geoocords (main P625, not anywhere else)
                  bind(iri(concat("http://www.wikidata.org/entity/", str(?pws))) as ?pwikidata) .
                  SERVICE <https://query.wikidata.org/sparql> {
                    ?pwikidata wdt:P625 ?geo3 .
                  }       
                } 
    
      optional { ?place bnwdt:P2 ?linked_p2 .  # linked place has wikidata geocoords
                    ?linked_p2 bnwdt:P117 ?lws .  # wikidata id P117
                    bind(iri(concat("http://www.wikidata.org/entity/", str(?lws))) as ?lwikidata) .
                    SERVICE <https://query.wikidata.org/sparql> {
                      ?lwikidata wdt:P625 ?geo4 .
                    }
                }
 
      optional { ?s bnpq:P2 ?qp1 . # P2 qualifier location has wikidata geocoords
                    ?qp1 bnwdt:P117 ?qws .
                    bind(iri(concat("http://www.wikidata.org/entity/", str(?qws))) as ?qwikidata) .
                    SERVICE <https://query.wikidata.org/sparql> {
                      ?qwikidata wdt:P625 ?geo5 .  
                    }
                }
 
      optional { ?s bnpq:P78 ?ofp1 . # 'of' (organisation) has geocoords in P2 qualifier
                    ?ofp1 bnp:P2 ?ofp1_s .
                    ?ofp1_s bnps:P2 ?ofp1_p .
                    ?ofp1_s bnpq:P153 ?geo6 . } 
    
      optional { ?s bnpq:P78 ?ofp2 . # 'of' (organisation) P2 location has wikidata geocoords
                    ?ofp2 bnwdt:P2 ?ofp2_p .
                      ?ofp2_p bnwdt:P117 ?ofl2ws .
                      bind(iri(concat("http://www.wikidata.org/entity/", str(?ofl2ws))) as ?ofl2wikidata) .
                      SERVICE <https://query.wikidata.org/sparql> {
                      ?ofl2wikidata wdt:P625 ?geo7 .  }           
              }
 
      optional { ?s bnpq:P78 ?ofp3 .  # 'of' (organisation) has wikidata geocoords
                    ?ofp3 bnwdt:P117 ?ofpws .  # wikidata id P117
                    bind(iri(concat("http://www.wikidata.org/entity/", str(?ofpws))) as ?ofpwikidata) .
                    SERVICE <https://query.wikidata.org/sparql> {
                      ?ofpwikidata wdt:P625 ?geo8 .  }
                }
    
      optional { ?place bnwdt:P153 ?geo9 .  } # main geocoords  (mainly london postal districts - should be last resort as v broad.)
 
 
      optional { ?place bnwdt:P2 ?linked_p10 . # linked place main geocoords
                    ?linked_p10 bnwdt:P153 ?geo10 .
                }
 
  BIND(COALESCE(?geo1, ?geo2, ?geo3, ?geo4, ?geo5, ?geo6, ?geo7, ?geo8, ?geo9, ?geo10) AS ?geo).  # if geo1 available use that, then geo2, etc, in order of preference
 
  bind(coalesce(?linked_p1, ?linked_p2, ?qp1, ?ofp1, ?ofp2, ?ofp3 ) as ?loc2). # hopefully get extra context where place is just sthg like "meeting". though exactly what will be variable!
    
    
   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
 
order by ?personLabel ?date ?placeLabel
 
</sparql>
</sparql>


=== Women with family name at birth, married name and count of married names===
==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, family name after marriage and count of married names
# Women with their family name at birth and family name after marriage
 
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
PREFIX bnwdv: <https://beyond-notability.wikibase.cloud/value/>
PREFIX bnwdt: <https://beyond-notability.wikibase.cloud/prop/direct/>
PREFIX bnp: <https://beyond-notability.wikibase.cloud/prop/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
 
 
SELECT ?person ?personLabel ?birthname ?marriedname
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". }
}
ORDER BY ?personLabel
</sparql>
 
=== Women with family name at birth, married name and count of married names===
 
<sparql tryit="1">
# Women with their family name at birth, family name after marriage and count of married names


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 2,937: Line 3,184:
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 ?wd_dob ?wd_dod ?odnb_url ?wikipedia ?wd_statements
SELECT distinct ?person ?personLabel ?wikidata ?whos_who ?odnb_url ?wikipedia ?wd_dob ?wd_dod ?wd_stmts


WHERE {
WHERE {
Line 2,947: Line 3,194:
     SERVICE <https://query.wikidata.org/sparql> {
     SERVICE <https://query.wikidata.org/sparql> {


       ?wikidata  wikibase:statements ?wd_statements .
       ?wikidata  wikibase:statements ?wd_stmts .


       optional {   
       optional {   
Line 2,963: Line 3,210:
           FILTER (SUBSTR(str(?wikipedia), 1, 25) = 'https://en.wikipedia.org/')
           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
         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,319: Line 3,571:




===Working with property paths: organisations and locations===
=== One woman ===


<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


#title:All About a Woman
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
Line 3,334: Line 3,583:
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpsv: <https://beyond-notability.wikibase.cloud/prop/statement/value/>
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>


SELECT  ?item ?itemLabel ?location ?locationLabel (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 bnwd:Q2316 .  # instance of organisation.
# ?prop ?sps ?pqs ?pq
   ?item bnwdt:P2* ?tmp .
 
   ?tmp bnwdt:P2+ ?location . # P2=30. P2+=34
WHERE
{
  VALUES (?person) {(bnwd:Q569)}  # add (bnwd:Qxxx) if you want more than one person. 
  ?person ?p ?s . 
 
    ?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 .
      }
 
    # qualifiers.
 
      optional {
        ?s ?pq ?pqs .         
          ?qual_prop wikibase:qualifier ?pq . 
          ?qual_prop wikibase:qualifierValue ?pqp .
       
          optional {
            # full date via ?pqp
            ?s ?pqp ?qv .
            ?qv wikibase:timeValue ?qual_date.
            ?qv wikibase:timePrecision ?qual_precision.
          }
    }
 
  # direct link to property
        BIND (REPLACE(STR(?prop), "^.*/([^/]*)$", "$1") as ?pid).
        bind(iri(concat(str(?person), "#", ?pid)) as ?link ) .
 
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
       
}
order by ?propLabel ?s
 
</sparql>
 
===Working with property paths: organisations and locations===
 
<sparql tryit="1">
## problem: sometimes you need to follow property paths using */+ for (eg) locations. BUT this can lead to several results to choose between and they aren't necessarily returned in the "right" order.
## how to determine the "distance" along the path of each result?
## https://stackoverflow.com/questions/61984052/wikidata-get-the-full-subhierachy-of-one-class-as-well-as-all-nodes
## > you can get the distance of a class with SELECT ?cls (count(?tmp) as ?distance) WHERE {  ?cls wdt:P279* ?tmp .  ?tmp wdt:P279+ wd:Q2095 . } group by ?cls order by asc(?distance) - though there might be corner cases like cycles in the hierarchy resp. multiple paths
 
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
PREFIX bnwdv: <https://beyond-notability.wikibase.cloud/value/>
PREFIX bnwdt: <https://beyond-notability.wikibase.cloud/prop/direct/>
PREFIX bnp: <https://beyond-notability.wikibase.cloud/prop/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
 
SELECT  ?item ?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". }  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb, en". }  
Line 3,724: Line 4,042:
</sparql>
</sparql>


==Admin==
=== Women having children ===
 
===Women about whom we have recorded fewer than 3 pieces of information===


<sparql tryit="1">
<sparql tryit="1">
#title:women having children
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,737: Line 4,054:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


SELECT ?person ?personLabel ?statements WHERE {
# lol defaultView:Timeline{"hide":["?s", "?date_prec", ""]}  
  ?person bnwdt:P3 bnwd:Q3 ;
 
        wikibase:statements ?statements .
# P131 had child in / P45 child
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .}
# a handful of P45 named children don't have dob though probably have dob in wikidata
  FILTER (?statements <3)
  SERVICE wikibase:label {
      bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb".
  }
}
</sparql>


===People for whom their item records is given as 'Mrs'===
SELECT distinct ?person ?personLabel ?childLabel ?date_value ?date_prec ?had_child_edtf ?note 
?s


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


===All triples in the wiki, limited to 1000===
  ?person bnwdt:P3 bnwd:Q3 . # select women
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .} #filter out project team
 
  # had child in (unnamed children)
  ?person bnp:P131 ?s .
      ?s bnps:P131 ?had_child_edtf . # keep the edtf date for reference, though i think you can just use the time value/prec with these.


<sparql tryit="1">
  # get dates detail via ?s and psv
SELECT ?a ?aLabel ?b ?c WHERE {
  # gets edtf dates in std wiki date format
    ?a ?b ?c
  # https://github.com/ProfessionalWiki/WikibaseEdtf 
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }
      ?s ?psv ?wdv .
}
        ?wdv wikibase:timeValue ?date_value .
LIMIT 1000 #please don't make this number too big as it will slow down the site!
        ?wdv wikibase:timePrecision ?date_prec .
</sparql>
 
  # filter edtf date.
  FILTER ( datatype(?had_child_edtf) = xsd:edtf ) . #shows only the raw EDTF string from the query results


===All triples in the wiki, represented as a crude graph===
  # 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 .  } #


<sparql tryit="1">
  }
#defaultView:Graph
  union
SELECT ?a ?aLabel ?c ?cLabel WHERE {
  {
    ?a ?b ?c
  # named children (are any in both sections??? from dates looks possible a couple might be [wherry / hodgson])
     SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }
  ?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". }
}
}
#note query returns every connection in the wikibase so it may fall over!
</sparql>


===People whose assigned gender we have been unable to determine and/or confirm===
order by ?person ?date_value
 
<sparql tryit="1">
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
PREFIX bnwdv: <https://beyond-notability.wikibase.cloud/value/>
PREFIX bnwdt: <https://beyond-notability.wikibase.cloud/prop/direct/>
PREFIX bnp: <https://beyond-notability.wikibase.cloud/prop/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd:  <http://www.wikidata.org/entity/>
 
SELECT ?person ?personLabel
WHERE { 
  ?person bnwdt:P3 ?gender .                             
  FILTER NOT EXISTS {?person bnwdt:P3 bnwd:Q3 .}          #filter out people identified as women
  FILTER NOT EXISTS {?person bnwdt:P3 bnwd:Q10 .}          #filter out people identified as men
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }
}
ORDER BY ?personLabel
</sparql>
 
===People who have a spouse statement and - optionally - marriage date statements for checking if there is any misalignment with 'Spouse not in wikibase' statements===
 
<sparql tryit="1">
# people who have a spouse statement and - optionally - marriage date statements for checking if there is any misalignment with 'Spouse not in wikibase' statements
 
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
PREFIX bnwdv: <https://beyond-notability.wikibase.cloud/value/>
PREFIX bnwdt: <https://beyond-notability.wikibase.cloud/prop/direct/>
PREFIX bnp: <https://beyond-notability.wikibase.cloud/prop/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
 
SELECT ?person ?personLabel ?spouse ?spouseLabel ?edtfmarriagespouse ?edtfmarriagespouseLabel ?PITmarriagespouse ?PITmarriagespouseLabel WHERE {
  ?person bnwdt:P41 ?spouse .
  OPTIONAL {?person bnp:P132 ?edtfmarriagestatement .
  ?edtfmarriagestatement bnps:P132 ?edtfmarriagedate .
  ?edtfmarriagestatement bnpq:P41 ?edtfmarriagespouse .}
  OPTIONAL {?person bnp:P130 ?PITmarriagestatement .
  ?PITmarriagestatement bnps:P130 ?PITmarriagedate .
  ?PITmarriagestatement bnpq:P41 ?PITmarriagespouse .}
    SERVICE wikibase:label {
      bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb".
    }
}
ORDER BY DESC(?edtfmarriagespouseLabel) DESC(?PITmarriagespouseLabel)
</sparql>
 
=== Compare uses of item v free text ===
 
<sparql tryit="1">
# A number of properties have "item" and "free text" versions; a query to fetches both versions in each case to facilitate comparison of their uses.
 
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 ?itemLabel ?prop_label ?qual_label ?qual_value ?qual_valueLabel ?item ?qual_prop
 
# most of these are used in qualifiers - only P72, P71 and P88 found in main (and only a handful of uses of free text?)
#?item (  bnp:P88|bnp:P91 | bnp:P72|bnp:P71) ?s .
 
## the pairs
#P21 evidence (free text) / P20 evidence (item)
#P79 item exhibited / P80 item exhibited (free text)
#P78 of / P66 of (free text)
#P91 specific reference information / P88 specific reference information (free text)
#P31 street address (free text) / P100 street address (item)
#P72 was delegate at (free text) / P71 was delegate at (item)
 
WHERE {
 
  ?item ?p ?s .
 
  ?prop wikibase:claim ?p;     
        rdfs:label ?prop_label. filter(lang(?prop_label)="en-gb") . 
   
  ?s ( bnpq:P21|bnpq:P20 | bnpq:P80|bnpq:P79 | bnpq:P66|bnpq:P78 | bnpq:P88|bnpq:P91 | bnpq:P31|bnpq:P100 | bnpq:P72|bnpq:P71 ) ?qual_value .
 
  ?s ?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') .
 
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }
}
order by ?qual_label ?prop_label ?itemLabel
 
</sparql>
 
=== Missing language labels ===
 
<sparql tryit="1">
 
# query to check for any items/properties which don't have "en" labels. [currently not an issue but retained for reference.]
 
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
  ?item  ?itemLabel
  (group_concat(distinct ?language) as ?languages)
  (count(distinct ?rdfs_label) as ?count) # TIL: where you put distinct matters! 
 
WHERE {
 
  ?item ?p ?s.
  ?item rdfs:label ?rdfs_label .  # rdfs item label (1 per language).
 
  BIND(LANG(?rdfs_label) as ?language) .  # get 2 letter language codes
 
  #optional { ?item rdfs:label ?engb . filter(lang(?engb)="en-gb").  }
  #optional { ?item rdfs:label ?en . filter(lang(?en)="en").  } 
 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE], en-gb, en". }
}
group by ?item  ?itemLabel
HAVING (?count<2)
order by ?item
 
</sparql>
 
=== Statements that contain both a date *and* an unknown value date===
 
<sparql tryit="1">
# A query to look for statements containing an <unknown value> date *and* a date
# caveat: not yet completely sure if it will work in all cases for main 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/>
 
SELECT  ?item ?itemLabel ?main_label ?qualLabel ?subLabel
(group_concat(distinct ?date_prop) as ?dates) 
(count (distinct(isBLANK(?t))) as ?tcount) 
?s
 
# using isBlank() in select creates true/false, then count distinct finds any in a group having >1.
 
WHERE
{
  {
  # qualifiers. [qualifiers need to include ?s in the group by]
  ?item ?p ?s.
 
  # labels
  ?s ?subp ?sub .
  ?qual wikibase:claim ?p;
        wikibase:statementProperty ?subp. 
 
    ?s ?pq ?t .
 
    ?date_prop wikibase:qualifier ?pq ;
            wikibase:propertyType ?date_prop_type .
    filter(?date_prop_type in (wikibase:Time, wikibase:Edtf) ).
  }
  UNION
  {
  # main [excluding ?s from group by this time]
  ?item ?p ?sm.
  ?sm ?ps ?t .
   
  ?date_prop wikibase:claim ?p.
  ?date_prop wikibase:statementProperty ?ps.
  ?date_prop wikibase:propertyType ?date_prop_type .
  ?date_prop rdfs:label ?main_label .  filter(lang(?main_label)="en-gb") .
   
  filter(?date_prop_type in (wikibase:Time, wikibase:Edtf) ).
  }
 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en_gb" }
}
 
group by ?item ?itemLabel ?s ?qualLabel ?subLabel  ?main_label
having (?tcount >1 )  # comment out to get everything
 
ORDER BY ?itemLabel ?main_label ?qualLabel ?subLabel ?date_prop
 
</sparql>
 
 
=== Women with no dates===
 
<sparql tryit="1">
 
# Query for women with no dates
# WIP: at present this includes <unknown value> dates as well as no dates at all [eg Miss Keyser Q2622]
# CAVEAT: the WQS bug means there are likely to be some women in results who do, in fact, have at least one date.
 
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX 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 ?person ?personLabel  (count(?date_value) as ?count)
 
WHERE {
{  # main dates
 
  ?person bnwdt:P3 bnwd:Q3 . # women 
  optional {
    ?person ?p ?s .       
      ?s ?date_prop ?wdv .
        ?wdv wikibase:timeValue ?date_value . } 
 
} # /main dates
 
  UNION
 
  { # qualifier dates
   
    ?person bnwdt:P3 bnwd:Q3 . 
  optional {
    ?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=0)
ORDER BY ?person
 
</sparql>
 
 
=== Women with more than X statements but no date of birth/death===
 
<sparql tryit="1">
 
#title:women with n>X statements but no date of birth/death
# CAVEAT this currently finds some women who do in fact have dates, because of WQS bug
# updated to add extra info
 
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
(if(bound(?SALproposed), "yes", "") as ?FSA)
(if(bound(?RAIproposed), "yes", "") as ?RAI)
(if(bound(?resided), "yes", "") as ?residence) 
(if(bound(?main_date), "yes", "") as ?other_maindate)
(if(bound(?qual_d), "yes", "") as ?qual_date)
 
WHERE {
  ?person bnwdt:P3 bnwd:Q3 ;
        wikibase:statements ?statements .
  FILTER NOT EXISTS {?person bnwdt:P4 bnwd:Q12 .}
 
  optional { ?person bnwdt:P15 ?dod .  }
  optional { ?person bnwdt:P26 ?dob .  }
 
  optional { # was elected FSA. comment out optional lines to get FSAs only...
    ?person bnp:P16 ?s .
        ?s bnps:P16 ?SALproposed .
        ?s bnpq:P22 bnwd:Q36 .  # successful Q36. will you end up with 2 rows if there's a successful and unsuccessful?
  } #/optional fsa
 
  optional { # was elected RAI. only one unsuccessful, so just ignore that bit.
    ?person bnwdt:P7 ?RAIproposed .
  }
 
  optional { ?person bnwdt:P29 ?resided . } # place of residence
 
  optional {
    # main dates, apart from birth and death: P133 (widowed) P132 (married edtf) P131 (had child) P130 (married pit)   
    ?person ( bnwdt:P130 | bnwdt:P131 | bnwdt:P132 | bnwdt:P133 ) ?main_date .
    } # /optional main dates
 
  optional {
    # qualifier dates 
    ?person ?p ?s .   
      ?s ?date_prop ?pqv .
        ?pqv wikibase:timeValue ?qual_d.
    } #/ optional qual dates
 
  FILTER (?statements >10) . # can adjust n statements here...
 
  FILTER (NOT EXISTS { ?person bnwdt:P15 ?dod .} || NOT EXISTS { ?person bnwdt:P26 ?dob .  } ) . # EITHER no date of birth OR no date of death. or swap with following line...
  #FILTER (NOT EXISTS { ?person bnwdt:P15 ?dod .} && NOT EXISTS { ?person bnwdt:P26 ?dob .  } ) . # no date of birth AND no date of death
   
  SERVICE wikibase:label {
      bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb".
  }
}
order by ?personLabel
 
</sparql>
 
=== Places of residence that lack instance of locality===
 
<sparql tryit="1">
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
PREFIX bnwdv: <https://beyond-notability.wikibase.cloud/value/>
PREFIX bnwdt: <https://beyond-notability.wikibase.cloud/prop/direct/>
PREFIX bnp: <https://beyond-notability.wikibase.cloud/prop/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
 
SELECT distinct ?residence ?residenceLabel ?inst ?instLabel
WHERE { 
  ?resident bnwdt:P29 ?residence . # resided at
  filter not exists { ?residence bnwdt:P12 bnwd:Q2147 . } # that doesn't have instance of locality
 
  optional {?residence bnwdt:P12 ?inst .} # does it have instance of anything? 
      ## Note: some have Q618 territory of the British Empire, which also lacks any instance of at present
 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
}
ORDER BY ?residenceLabel
</sparql>
 
=== Locations that don't have Wikidata links or their Wikidata pages lack geocoordinates===
 
<sparql tryit="1">
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
PREFIX bnwdv: <https://beyond-notability.wikibase.cloud/value/>
PREFIX bnwdt: <https://beyond-notability.wikibase.cloud/prop/direct/>
PREFIX bnp: <https://beyond-notability.wikibase.cloud/prop/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
 
 
SELECT distinct ?locationLabel ?location ?wikidata ?wd_geo ?instanceLabel ?bn_geo
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
  # any other possibles ?
 
  optional { ?location bnwdt:P12 ?instance .  } # check instance of
 
  optional {   
      ?location bnwdt:P117 ?ws .  # wikidata id       
       
        bind(iri(concat("http://www.wikidata.org/entity/", str(?ws))) as ?wikidata) .
 
 
        SERVICE <https://query.wikidata.org/sparql> {
          optional {?wikidata wdt:P625 ?wd_geo .}  # does the wikidata page have geocoords?
        } # /wikidata service 
    } #/wikidata optional
 
  filter (!bound(?wd_geo) ). # no geocoords in wikidata. some may have coords in BN...
 
  optional { ?location bnwdt:P153 ?bn_geo .  } # so check for coords in BN
  ##filter (!bound(?bn_geo)) . # uncomment to filter those out as well
 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
}
ORDER BY ?wikidata ?locationLabel
 
</sparql>
 
=== Archaeological sites that don't have National Heritage England list numbers ===
 
<sparql tryit="1">
#title:archaeological sites without National Heritage numbers
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
PREFIX bnwdv: <https://beyond-notability.wikibase.cloud/value/>
PREFIX bnwdt: <https://beyond-notability.wikibase.cloud/prop/direct/>
PREFIX bnp: <https://beyond-notability.wikibase.cloud/prop/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
 
SELECT ?item ?itemLabel ?location ?locationLabel
(if(bound(?locEngland), "yes", "") as ?inEngland)
 
WHERE { 
  ?item bnwdt:P12 bnwd:Q86 . # item instance of archaeological site
 
  filter not exists {?item bnwdt:P129 ?thing .  } # without NH list number
 
  optional { ?item bnwdt:P2 ?location .  } # location if it has one
  optional { ?item bnwdt:P2 ?locEngland .
              ?locEngland bnwdt:P33+ bnwd:Q617.
          } # is the location in England
 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }
}
 
order by ?itemLabel
 
</sparql>
 
=== Date of latest edit for every item, according to WQS ===
 
<sparql tryit="1">
#title:latest edits dates for wikibase items
 
## because of WQS disappearing data bugs this may not always match the latest edit in the page history
 
SELECT ?item ?date ?dateLabel
WHERE {
  ?item wikibase:timestamp ?date .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
}
order by ?date
 
</sparql>
 
=== Wikidata ID is a URL ===
 
<sparql tryit="1">
 
#title:check for accidental use of URL instead of wikidata ID
## all checked and fixed at 18/12/23 but adding the query in case it recurs
 
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 ?item ?itemLabel ?wd_http
WHERE { 
 
  ?item bnwdt:P117 ?wd_http .  # wikidata id       
 
  filter(strstarts(str(?wd_http), "http")).
 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
}
ORDER BY ?itemLabel
</sparql>
 
=== Wikidata URL is not a URL ===
 
<sparql tryit="1">
#title:check for wikidata URLs that don't start with http. could still be other problems!
## all checked and fixed at 18/12/23 but adding the query in case of any recurring issues
 
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 ?item ?itemLabel ?wd_url
WHERE { 
 
  ?item bnp:P117 ?ws .  # wikidata id       
    ?ws bnpq:P14 ?wd_url .
  filter(!strstarts(str(?wd_url), "http")).
 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
}
ORDER BY ?itemLabel
</sparql>
 
=== Oxford and Cambridge academic degrees potential date problems ===
 
<sparql tryit="1">
#title:academic degree Oxford/Cambridge date issues
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 bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>
 
SELECT distinct ?personLabel ?degreeLabel ?byLabel ?subjectLabel
?date ?date_label  ?s ?person #?subject ?degree ?by ?university
 
WHERE { 
  ?person bnwdt:P3 bnwd:Q3 . #select women
 
  # academic degree = P59.
  ?person bnp:P59 ?s . 
    ?s bnps:P59 ?degree . # type of degree
 
  # optional qualifiers for degree
 
  # P60 subject
    optional { ?s bnpq:P60 ?subject}
 
  # P61 conferred by
    ?s bnpq:P61 ?by . 
 
  # date with type
    ?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") . # what kind of date is it.
     
# filter: (cambridge (Q1181) and before 1948) OR (oxford (Q364) and before 1920)
 
  filter( ( year(?date)<1920 && ?by=bnwd:Q364 ) || ( year(?date)<1948 && ?by=bnwd:Q1181 ) )
 
     
  SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en".}
}
order by ?byLabel ?personLabel ?date ?degreeLabel
</sparql>
 
=== Position held: item v free text ===
 
<sparql tryit="1">
# held position job titles item v held position free text
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
?work_label  ?positionLabel ?position (count(*) as ?count)
 
WHERE {
 
  ?person bnwdt:P3 bnwd:Q3 . # women
 
  # get work activities: held position / held position (free text) /  employed as
  ?person ( bnp:P17|bnp:P48 ) ?s . 
 
  ?person ?work_p ?s . # for work type label
  ?work wikibase:claim ?work_p;     
        rdfs:label ?work_label. filter(lang(?work_label)="en") . 
   
    # more about the position
    ?s ( bnps:P17|bnps:P48 ) ?position . 
 
  FILTER( !isBLANK(?position)  ) . # filter out <unknown value>
 
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
}
group by ?work_label  ?positionLabel ?position
order by lcase(str(?positionLabel))
</sparql>
 
==== Women with position held free text ====
 
<sparql tryit="1">
# held position free text job titles
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 ?person ?personLabel ?positionLabel
 
WHERE {
 
  ?person bnwdt:P3 bnwd:Q3 . # women
 
  # held position (free text)
  ?person bnwdt:P48  ?position . 
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
}
order by ?personLabel ?positionLabel
</sparql>
 
==Tools for batch processing and quality assurance work==
 
===All people (by assigned gender), filtering out those already listed as instance of human===
 
<sparql tryit="1">
# All people (by assigned gender), filtering out those already listed as instance of human
 
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 ?assigned_genderLabel
WHERE { 
  ?person bnwdt:P3 ?assigned_gender .                        #select person
  FILTER NOT EXISTS {?person bnwdt:P12 bnwd:Q2137 .}        #filter out people already listed as instance of human
  FILTER NOT EXISTS {?person bnwdt:P12 bnwd:Q12 .}            #filter out project team
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }
}
ORDER BY ?personLabel
</sparql>
 
===All places (by coordinate location on wikidata), filtering out places already listed as instance of locality===
 
<sparql tryit="1">
# All places (by coordinate location on wikidata), filtering out places already listed as instance of locality
 
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
PREFIX bnwdv: <https://beyond-notability.wikibase.cloud/value/>
PREFIX bnwdt: <https://beyond-notability.wikibase.cloud/prop/direct/>
PREFIX bnp: <https://beyond-notability.wikibase.cloud/prop/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd:  <http://www.wikidata.org/entity/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX pr: <http://www.wikidata.org/prop/reference/>
PREFIX prov: <http://www.w3.org/ns/prov#>
 
SELECT ?place ?placeLabel ?WDitem ?WDcoordinate_location
 
WHERE { 
  ?place bnwdt:P33 ?admin_area .  #select items with 'located in the administrative territorial entity' statements
  ?place bnwdt:P117 ?Qnumber .    #get wikidata ID
  FILTER NOT EXISTS {?place bnwdt:P12 bnwd:Q2147 .}      #filter out places already listed as instance of locality
 
  #create reference to Wikibase entity
  BIND(IRI(concat("http://www.wikidata.org/entity/", ?Qnumber)) as ?WDitem )
  #on Wikibase do
  SERVICE <https://query.wikidata.org/sparql> {
        ?WDitem wdt:P625 ?WDcoordinate_location . #get coordinate location on wikidata
      }
 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }
}
GROUP BY ?place ?placeLabel ?WDitem ?WDcoordinate_location
ORDER BY ?placeLabel
</sparql>
 
===All items without a P12 (instance of) triple===
 
<sparql tryit="1">
#title:nearly all items without P12 (instance of)
#NB: the query will only find items that have at least one statement; this excludes a small number of Qs and a larger number (~35) of Ps.
#see separate query to find items without any statements
 
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 ?item ?itemLabel
WHERE {
  ?item ?b ?c .
      ?prop wikibase:claim ?b;   
            wikibase:statementProperty ?ps.
      # ?prop wikibase:propertyType wikibase:WikibaseItem. # limit to P & Q Items. not necessary; only the claim is needed.
      # weirdness: it still causes some things that are definitely WikibaseItem to be dropped and idk why.
 
  FILTER NOT EXISTS {?item bnwdt:P12 ?instance .}
 
## FILTER(STRSTARTS(STR(?item), "https://beyond-notability.wikibase.cloud/entity/P")) . # uncomment to limit to P Properties
## FILTER(STRSTARTS(STR(?item), "https://beyond-notability.wikibase.cloud/entity/Q")) .  # or limit to Q items
 
  SERVICE wikibase:label {
      bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb".
  }
}
</sparql>
 
===Counts of items for each value of the property "instance of" (P12)===
 
<sparql tryit="1">
 
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
PREFIX bnwdv: <https://beyond-notability.wikibase.cloud/value/>
PREFIX bnwdt: <https://beyond-notability.wikibase.cloud/prop/direct/>
PREFIX bnp: <https://beyond-notability.wikibase.cloud/prop/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
 
 
SELECT  ?value ?valueLabel  (count(*) as ?count)
WHERE { 
 
  VALUES (?p) { (bnwdt:P12) } 
 
  ?s ?p ?value.
 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
 
}
GROUP BY ?value ?valueLabel
 
ORDER BY lcase(?valueLabel) # order by is case sensitive
# or to order by count
# order by ?count
 
</sparql>
 
===Get all items (with 'instance of' statement) for duplicate checking in OpenRefine===
 
<sparql tryit="1">
# Get all items (with 'instance of' statement) for duplicate checking in OpenRefine
 
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwds: <https://beyond-notability.wikibase.cloud/entity/statement/>
PREFIX bnwdv: <https://beyond-notability.wikibase.cloud/value/>
PREFIX bnwdt: <https://beyond-notability.wikibase.cloud/prop/direct/>
PREFIX bnp: <https://beyond-notability.wikibase.cloud/prop/>
PREFIX bnps: <https://beyond-notability.wikibase.cloud/prop/statement/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
 
SELECT ?item ?itemLabel WHERE {
  ?item bnwdt:P12 ?anything .
  SERVICE wikibase:label {
      bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb".
  }
}
 
ORDER BY ?itemLabel
</sparql>
 
===All uses of <unknown value>===
 
<sparql tryit="1">
# Query to look for uses of <unknown value> (now including qualifiers)
 
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  ?item ?itemLabel  ?mainLabel ?sub_Label ?unknown_value_forLabel  ?unknown_value_for ?t
WHERE
{
{
  # qualifiers
  ?item ?p ?s.
 
  ?s ?sub ?sub_ .
  ?main wikibase:claim ?p.
  ?main wikibase:statementProperty ?sub. 
 
  ?s ?pq ?t .
 
  ?unknown_value_for wikibase:qualifier ?pq . 
  FILTER( isBLANK(?t)  ) . # filter for <unknown value>
  }
  UNION
  {
  # top level
  ?item ?p ?s.
  ?s ?ps ?t .
 
  ?unknown_value_for wikibase:claim ?p.
  ?unknown_value_for wikibase:statementProperty ?ps.
   
  FILTER( isBLANK(?t) ) .
  }
 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
 
}
ORDER BY ?itemLabel ?unknown_value_forLabel
</sparql>
 
 
=== Items without any statements ===
 
<sparql tryit="1">
#title:items with 0 statements
# NB: because of the WQS disappearing data bugs, a few of the items might in reality have n>0 statements. Some may be intentionally empty.
 
SELECT distinct ?item  ?itemLabel
WHERE {
  ?item wikibase:statements 0 .
 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
 
}
order by ?item
</sparql>
</sparql>
579

edits