Project:SPARQL/admin: Difference between revisions

(moved admin/QC queries into a new page)
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Other queries ==
[[Project:SPARQL/examples|main queries page]]
==Admin==
==Admin==


Line 106: Line 110:
</sparql>
</sparql>


=== Compare uses of item v free text ===
=== Married names and Marriage dates ===


<sparql tryit="1">
<sparql tryit="1">
# A number of properties have "item" and "free text" versions; a query to fetches both versions in each case to facilitate comparison of their uses.
#title:Query for married name/married dates discrepancies.
# some women have a married name but no marriage date, or vice versa. This query should help with checking for the missing information...
# most have very few statements and/or are just "Mrs". But there are some with 20+ statements.
# so there's a FILTER statements line that can be adjusted; it's currently at 10


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 121: Line 128:
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/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
SELECT distinct ?person ?personLabel ?statements ?married_name ?married_in
 
# 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 {
WHERE {
  ?person bnwdt:P3 bnwd:Q3 ;
        wikibase:statements ?statements .
    
    
   ?item ?p ?s .  
   FILTER (?statements > 10) .
    
    
   ?prop wikibase:claim ?p;     
   OPTIONAL {?person bnwdt:P141 ?married_name .} #look for married name  (bnwdt:P130 | bnwdt: P132)  
        rdfs:label ?prop_label. filter(lang(?prop_label)="en-gb")
   optional {?person (bnwdt:P130 | bnwdt:P132) ?married_in . }
   
   ?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 .  
   FILTER  (
    ?qual_prop wikibase:qualifier ?qual_p;
    (NOT EXISTS { ?person bnwdt:P141 ?marriedname .} && EXISTS { ?person (bnwdt:P130 | bnwdt:P132 ) ?married .  } )
          wikibase:propertyType ?qual_prop_type ;
      ||
          rdfs:label ?qual_label. filter(lang(?qual_label)='en-gb') .
    (EXISTS { ?person bnwdt:P141 ?marriedname .} && NOT EXISTS { ?person (bnwdt:P130 | bnwdt:P132 ) ?married .  } )         
          ) .
 
  SERVICE wikibase:label {
      bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb".
  }
    
    
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
} # /where
}
order by ?qual_label ?prop_label ?itemLabel


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


=== Missing language labels ===
=== Missing language labels ===
Line 192: Line 194:


</sparql>
</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>
=== Questions ===
<sparql tryit="1">
#title:asking questions
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 ?personLabel ?propLabel ?link ?question
WHERE { 
  ?person bnwdt:P3 bnwd:Q3 .
 
  ?person ?p ?s .
      ?prop wikibase:claim ?p;     
        wikibase:statementProperty ?ps.     
         
  # direct link to relevant part of page
        BIND (REPLACE(STR(?prop), "^.*/([^/]*)$", "$1") as ?pid).
        bind(iri(concat(str(?person), "#", ?pid)) as ?link ) .
 
  # the question
    ?s bnpq:P157 ?question . 
       
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
}
order by ?personLabel
</sparql>
== Place ==
=== 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>
=== 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>
=== Reviewing instance of locality ===
<sparql tryit="1">
# how many i/o locality don't have a wikidata id?
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/>
#title:i/o locality
SELECT distinct ?itemLabel ?item ?wd_id ?adminLabel ?bn_geo
WHERE { 
 
  ?item bnwdt:P12 bnwd:Q2147 . # has i/o locality (could have other i/o as well?)
 
  #optional { ?item bnwdt:P12 ?io .
  #        #filter not exists { ?item bnwdt:P12 bnwd:Q2147 . } # this doesn't work... ??? should be only a handful.
  #        } # check io other than locality
 
  # what props do they have: 945 P117 wikidata id; 919 P33 admin territory; 9 P153 coord location
  #?item ?p ?s .
  #    ?prop wikibase:claim ?p.
 
  optional { ?item bnwdt:P117 ?wd_id . }
  optional { ?item bnwdt:P14 ?described . } # to check for described at url instead of wd.
  optional { ?item bnwdt:P33 ?admin . } # admin territory; some multi
  optional { ?item bnwdt:P153 ?bn_geo . }
 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
}
ORDER BY ?itemLabel ?item
</sparql>
== Dates ==


=== Statements that contain both a date *and* an unknown value date===
=== Statements that contain both a date *and* an unknown value date===
Line 379: Line 546:
</sparql>
</sparql>


=== Places of residence that lack instance of locality===
 
 
=== Oxford and Cambridge academic degrees potential date problems ===


<sparql tryit="1">
<sparql tryit="1">
#title:academic degree Oxford/Cambridge date issues
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 389: Line 559:
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/>
SELECT distinct ?personLabel ?degreeLabel ?byLabel ?subjectLabel
?date ?date_label  ?s ?person #?subject ?degree ?by ?university


SELECT distinct ?residence ?residenceLabel ?inst ?instLabel
WHERE {   
WHERE {   
   ?resident bnwdt:P29 ?residence . # resided at
   ?person bnwdt:P3 bnwd:Q3 . #select women
  filter not exists { ?residence bnwdt:P12 bnwd:Q2147 . } # that doesn't have instance of locality
 
 
  # academic degree = P59.
  optional {?residence bnwdt:P12 ?inst .} # does it have instance of anything?   
  ?person bnp:P59 ?s . 
       ## Note: some have Q618 territory of the British Empire, which also lacks any instance of at present
    ?s bnps:P59 ?degree . # type of degree
 
 
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }  
  # 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 ?residenceLabel
order by ?byLabel ?personLabel ?date ?degreeLabel
</sparql>
</sparql>


=== Locations that don't have Wikidata links or their Wikidata pages lack geocoordinates===
==== More potential problems with dates ====


<sparql tryit="1">
<sparql tryit="1">
#title:academic degree Oxford/Cambridge potential date issues (again)
# looking for cases where there might be a date problem but there isn't a queryable date
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 413: Line 608:
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/>


SELECT distinct ?personLabel ?degreeLabel ?note ?byLabel ?link


SELECT distinct ?locationLabel ?location ?wikidata ?wd_geo ?instanceLabel ?bn_geo
WHERE {   
WHERE {   
  ?person bnwdt:P3 bnwd:Q3 . #select women
 
  # academic degree = P59.
  ?person bnp:P59 ?s . 
    ?s bnps:P59 ?degree . # type of degree
    
    
   {?item bnwdt:P29  ?location . } # resided at
   # optional qualifiers for degree
  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
   # P60 subject
  #  optional { ?s bnpq:P60 ?subject}
    
    
  optional {      
  # P61 conferred by
      ?location bnwdt:P117 ?ws # wikidata id       
     ?s bnpq:P61 ?by .   
       
        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...
   filter ( ?by=bnwd:Q1181 || ?by=bnwd:Q364 ).
    
    
   optional { ?location bnwdt:P153 ?bn_geo . } # so check for coords in BN
   # date
   ##filter (!bound(?bn_geo)) . # uncomment to filter those out as well
  optional { ?s (bnpq:P1 | bnpq:P27 | bnpq:P28 ) ?date . }
   filter not exists { ?s (bnpq:P1 | bnpq:P27 | bnpq:P28 ) ?date .}
 
  ?s bnpq:P47 ?note .
    
    
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }  
  # direct link to relevant statement
  BIND (REPLACE(STR(?s), "^.*/([^/]*)$", "$1") as ?sid).
    # for some grrr reason the first dash is replaced with a $ in the html id.
  bind(replace(?sid, "^(Q\\d+)-", "$1\\$") as ?pid) .
  bind(iri(concat(str(?person), "#", ?pid)) as ?link )
       
   SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en".}
}
}
ORDER BY ?wikidata ?locationLabel
order by ?personLabel ?date ?degreeLabel
</sparql>
 


</sparql>
== Item / free text ==


=== Archaeological sites that don't have National Heritage England list numbers ===
=== Compare uses of item v free text ===


<sparql tryit="1">
<sparql tryit="1">
#title:archaeological sites without National Heritage numbers
# 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 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 460: Line 661:
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
SELECT distinct ?itemLabel ?prop_label ?qual_label ?qual_value ?qual_valueLabel ?item ?qual_prop
(if(bound(?locEngland), "yes", "") as ?inEngland)
 
# 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 {   
WHERE {
   ?item bnwdt:P12 bnwd:Q86 . # item instance of archaeological site
 
  ?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 .
    
    
   filter not exists {?item bnwdt:P129 ?thing . } # without NH list number
   ?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') .
    
    
  optional { ?item bnwdt:P2 ?location . } # location if it has one
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
  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 ?qual_label ?prop_label ?itemLabel


order by ?itemLabel
</sparql>


</sparql>


=== Date of latest edit for every item, according to WQS ===
=== Position held: item v free text ===


<sparql tryit="1">
<sparql tryit="1">
#title:latest edits dates for wikibase items
# 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)


## because of WQS disappearing data bugs this may not always match the latest edit in the page history
WHERE {


SELECT ?item ?date ?dateLabel
  ?person bnwdt:P3 bnwd:Q3 . # women
WHERE {
 
  ?item wikibase:timestamp ?date .
  # get work activities: held position / held position (free text) /  employed as
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
  ?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". }  
}
}
order by ?date
group by ?work_label  ?positionLabel ?position
 
order by lcase(str(?positionLabel))
</sparql>
</sparql>


=== Wikidata ID is a URL ===
=== Women with position held free text ===


<sparql tryit="1">
<sparql tryit="1">
 
# held position free text job titles
#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 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 511: Line 749:
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 ?positionLabel


SELECT distinct ?item ?itemLabel ?wd_http
WHERE {  
WHERE {
 
  ?person bnwdt:P3 bnwd:Q3 . # women
    
    
   ?item bnwdt:P117 ?wd_http # wikidata id       
  # held position (free text)
 
   ?person bnwdt:P48  ?position .   
  filter(strstarts(str(?wd_http), "http")).
 
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 ?itemLabel
order by ?personLabel ?positionLabel
</sparql>
</sparql>


=== Wikidata URL is not a URL ===
 
== Wikidata ==
 
=== Places that link to wikidata AND have wikidata P625 geo coordinates ===


<sparql tryit="1">
<sparql tryit="1">
#title:check for wikidata URLs that don't start with http. could still be other problems!
#title:wikidata geo coords P625
## 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 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 539: Line 781:
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/>


 
SELECT distinct ?locationLabel ?location ?wikidata ?wd_geo # ?bn_geo
SELECT distinct ?item ?itemLabel ?wd_url
WHERE {   
WHERE {   
    
    
   ?item bnp:P117 ?ws .  # wikidata id         
   {?item bnwdt:P29  ?location . } # resided at
    ?ws bnpq:P14 ?wd_url .
  union
  filter(!strstarts(str(?wd_url), "http")).
  {?location bnwdt:P12 bnwd:Q2147 .} # OR has instance of locality
  union
  {?item bnwdt:P2  ?location . } # OR location P2
  # any other possibles ?  "P33 but only if i/o arch site or historic house" historic house Q2961  arch site Q86
  union
  {?item bnwdt:P33 ?location .} # admin territory ADDS ONE ROW. lol.
   
      ?location bnwdt:P117 ?ws .  # wikidata id         
       
        bind(iri(concat("http://www.wikidata.org/entity/", str(?ws))) as ?wikidata) .
        SERVICE <https://query.wikidata.org/sparql> {
            ?wikidata wdt:P625 ?wd_geo .  # does the wikidata page have geocoords?
        } # /wikidata service 
    
    
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }  
}
}
ORDER BY ?itemLabel
ORDER BY ?wikidata ?locationLabel
</sparql>
</sparql>


=== Oxford and Cambridge academic degrees potential date problems ===
=== Locations that don't have Wikidata links or their Wikidata pages lack geocoordinates===


<sparql tryit="1">
<sparql tryit="1">
#title:academic degree Oxford/Cambridge date issues
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 563: Line 815:
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/>


SELECT distinct ?personLabel ?degreeLabel ?byLabel ?subjectLabel
?date ?date_label  ?s ?person #?subject ?degree ?by ?university


SELECT distinct ?locationLabel ?location ?wikidata ?wd_geo ?instanceLabel ?bn_geo
WHERE {   
WHERE {   
  ?person bnwdt:P3 bnwd:Q3 . #select women
    
    
   # academic degree = P59.
   {?item bnwdt:P29  ?location . } # resided at
   ?person bnp:P59 ?s .
  union
    ?s bnps:P59 ?degree . # type of degree
   {?location bnwdt:P12 bnwd:Q2147 .} # OR has instance of locality
  union
  {?item bnwdt:P2  ?location . } # OR location P2
  # any other possibles ?
    
    
   # optional qualifiers for degree
   optional { ?location bnwdt:P12 ?instance .  } # check instance of
    
    
  # P60 subject
  optional {   
    optional { ?s bnpq:P60 ?subject}
      ?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
    
    
   # P61 conferred by
   filter (!bound(?wd_geo) ). # no geocoords in wikidata. some may have coords in BN...
    ?s bnpq:P61 ?by .
    
    
   # date with type
   optional { ?location bnwdt:P153 ?bn_geo . } # so check for coords in BN
    ?s ?pq ?date .      
  ##filter (!bound(?bn_geo)) . # uncomment to filter those out as well
      ?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,en-gb". }  
   SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en".}
}
}
order by ?byLabel ?personLabel ?date ?degreeLabel
ORDER BY ?wikidata ?locationLabel
 
</sparql>
</sparql>


=== Position held: item v free text ===
 
===All places (by coordinate location on wikidata), filtering out places already listed as instance of locality===


<sparql tryit="1">
<sparql tryit="1">
# held position job titles item v held position free text
# 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 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 610: Line 864:
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/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX pr: <http://www.wikidata.org/prop/reference/>
PREFIX prov: <http://www.w3.org/ns/prov#>


SELECT  
SELECT ?place ?placeLabel ?WDitem ?WDcoordinate_location
?work_label  ?positionLabel ?position (count(*) as ?count)


WHERE {  
WHERE {
 
  ?place bnwdt:P33 ?admin_area .  #select items with 'located in the administrative territorial entity' statements
   ?person bnwdt:P3 bnwd:Q3 . # women
  ?place bnwdt:P117 ?Qnumber .    #get wikidata ID
   FILTER NOT EXISTS {?place bnwdt:P12 bnwd:Q2147 .}      #filter out places already listed as instance of locality
    
    
   # get work activities: held position / held position (free text) /  employed as
   #create reference to Wikibase entity
   ?person ( bnp:P17|bnp:P48 ) ?s .
  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
      }
    
    
   ?person ?work_p ?s . # for work type label
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
  ?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
GROUP BY ?place ?placeLabel ?WDitem ?WDcoordinate_location
order by lcase(str(?positionLabel))
ORDER BY ?placeLabel
</sparql>
</sparql>


==== Women with position held free text ====
 
=== Wikidata ID is a URL ===


<sparql tryit="1">
<sparql tryit="1">
# held position free text job titles
 
#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 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 650: Line 905:
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 ?positionLabel


WHERE {  
SELECT distinct ?item ?itemLabel ?wd_http
 
WHERE {
   ?person bnwdt:P3 bnwd:Q3 . # women
 
   ?item bnwdt:P117 ?wd_http . # wikidata id       
 
  filter(strstarts(str(?wd_http), "http")).
    
    
   # held position (free text)
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }  
  ?person bnwdt:P48  ?position . 
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }  
}
}
order by ?personLabel ?positionLabel
ORDER BY ?itemLabel
</sparql>
</sparql>


=== Questions ===
=== Wikidata URL is not a URL ===


<sparql tryit="1">
<sparql tryit="1">
 
#title:check for wikidata URLs that don't start with http. could still be other problems!
#title:asking questions
## 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 bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 680: Line 932:
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 ?personLabel ?propLabel ?link ?question
SELECT distinct ?item ?itemLabel ?wd_url
 
WHERE {   
WHERE {   
  ?person bnwdt:P3 bnwd:Q3 .
 
  ?person ?p ?s .
      ?prop wikibase:claim ?p;     
        wikibase:statementProperty ?ps.     
         
  # direct link to relevant part of page
        BIND (REPLACE(STR(?prop), "^.*/([^/]*)$", "$1") as ?pid).
        bind(iri(concat(str(?person), "#", ?pid)) as ?link ) .
    
    
   # the question
   ?item bnp:P117 ?ws .  # wikidata id       
     ?s bnpq:P157 ?question .   
     ?ws bnpq:P14 ?wd_url .
 
   filter(!strstarts(str(?wd_url), "http")).
       
 
   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 ?itemLabel
</sparql>


order by ?personLabel
</sparql>


== Reference queries ==


=== Reference query for Blue Papers ===
=== Reference query for Blue Papers ===
Line 823: Line 1,067:
</sparql>
</sparql>


==Tools for batch processing and quality assurance work==
=== Reference query for RHS ===
 
===All people (by assigned gender), filtering out those already listed as instance of human===


<sparql tryit="1">
<sparql tryit="1">
# All people (by assigned gender), filtering out those already listed as instance of human
#title:statements with references to RHS archive
 
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 837: Line 1,078:
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 bnpr: <https://beyond-notability.wikibase.cloud/prop/reference/>
PREFIX wd: <http://www.wikidata.org/entity/>
 
# for QAing work done on enhancement
# stated in (P56) /  
# RHS Q2519 (see eg Katherine Routledge academic degree)
# looking for all Q315 references for person EXCEPT the ones in the election statement itself [P155]
# nb there can be more than one item in the reference (as well as information that doesn't have a reference)
# so stuff returned might not have anything to do with the Q315, but the referencing isn't specific enough to know which does.
# added evidence text from election statement. group_concat as there's often more than one. however this is not as useful as the blue papers
 
SELECT distinct ?personLabel ?propLabel ?valueLabel
(group_concat(?evidence; separator=" | ") as ?evidence_text)
?link 
#?s


SELECT ?person ?personLabel ?assigned_genderLabel
WHERE {   
WHERE {   
   ?person bnwdt:P3 ?assigned_gender .                       #select person
   ?person bnwdt:P3 bnwd:Q3 .
   FILTER NOT EXISTS {?person bnwdt:P12 bnwd:Q2137 .}        #filter out people already listed as instance of human
  ?person ?p ?s .
   FILTER NOT EXISTS {?person bnwdt:P12 bnwd:Q12 .}           #filter out project team
      ?prop wikibase:claim ?p;     
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
        wikibase:statementProperty ?ps.     
 
  # *not* in p155 rhs election 
   filter not exists { ?s bnps:P155 ?anything . }
 
    ?s ?ps ?value .
 
        # direct link to relevant statement
  BIND (REPLACE(STR(?s), "^.*/([^/]*)$", "$1") as ?sid).
    # for some grrr reason the first dash is replaced with a $ in the html id.
  bind(replace(?sid, "^(Q\\d+)-", "$1\\$") as ?pid) .
  bind(iri(concat(str(?person), "#", ?pid)) as ?link ) . 
 
 
  # references: stated in = p56. blue papers q315  RHS Q2519
    ?s prov:wasDerivedFrom ?refnode.
        ?refnode bnpr:P56 bnwd:Q2519 .  
    
 
  optional { ?person bnp:P155 ?ss.
              ?ss bnps:P155 ?proposed .
              ?ss bnpq:P21 ?evidence .
          }
   
     
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }  
}
}
ORDER BY ?personLabel
 
group by ?person ?personLabel ?propLabel ?valueLabel ?link 
order by ?personLabel ?propLabel
</sparql>
</sparql>


===All places (by coordinate location on wikidata), filtering out places already listed as instance of locality===
==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">
<sparql tryit="1">
# All places (by coordinate location on wikidata), filtering out places already listed as instance of locality
# All people (by assigned gender), filtering out those already listed as instance of human


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 864: Line 1,145:
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 ?place ?placeLabel ?WDitem ?WDcoordinate_location


SELECT ?person ?personLabel ?assigned_genderLabel
WHERE {   
WHERE {   
   ?place bnwdt:P33 ?admin_area . #select items with 'located in the administrative territorial entity' statements
   ?person bnwdt:P3 ?assigned_gender .                       #select person
  ?place bnwdt:P117 ?Qnumber .    #get wikidata ID
   FILTER NOT EXISTS {?person bnwdt:P12 bnwd:Q2137 .}         #filter out people already listed as instance of human
   FILTER NOT EXISTS {?place bnwdt:P12 bnwd:Q2147 .}       #filter out places already listed as instance of locality
   FILTER NOT EXISTS {?person bnwdt:P12 bnwd:Q12 .}            #filter out project team
    
  #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". }  
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". }  
}
}
GROUP BY ?place ?placeLabel ?WDitem ?WDcoordinate_location
ORDER BY ?personLabel
ORDER BY ?placeLabel
</sparql>
</sparql>


===All items without a P12 (instance of) triple===
===All items without a P12 (instance of) triple===
590

edits