Project:SPARQL/examples: Difference between revisions
From Beyond Notability
Line 3,401: | Line 3,401: | ||
<sparql tryit="1"> | <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 | # 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 bnwd: <https://beyond-notability.wikibase.cloud/entity/> | ||
Line 3,412: | Line 3,413: | ||
PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/> | PREFIX bnpq: <https://beyond-notability.wikibase.cloud/prop/qualifier/> | ||
SELECT ?person ?personLabel ?statements ?dob ?dod | |||
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 { | WHERE { | ||
Line 3,421: | Line 3,428: | ||
optional { ?person bnwdt:P15 ?dod . } | optional { ?person bnwdt:P15 ?dod . } | ||
optional { ?person bnwdt:P26 ?dob . } | 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 (?statements >10) . # can adjust n statements here... | ||
FILTER (NOT EXISTS { ?person bnwdt:P15 ?dod .} || NOT EXISTS { ?person bnwdt:P26 ?dob . } ) . # | 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 { | SERVICE wikibase:label { | ||
bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". | bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb". |