Project:SPARQL/examples: Difference between revisions

Line 4,679: Line 4,679:


order by ?personLabel
order by ?personLabel
</sparql>
=== Reference query for Blue Papers ===
<sparql tryit="1">
#title:statements with references to Blue Papers (except SAL election/was fellow of)
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 bnpr: <https://beyond-notability.wikibase.cloud/prop/reference/>
# for QAing work done on SAL Blue Papers enhancement
# stated in (P56) / blue papers Q315
# TODO RHS Q2519 (see eg Katherine Routledge educated at is from RHS)
# looking for all Q315 references for person EXCEPT the ones in the election statement itself [P16]
# 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.
SELECT distinct ?person ?personLabel ?propLabel ?valueLabel ?link 
# ?ref_stated  ?ref_text ?ref_itemLabel 
#?prop ?qual_prop ?val  ?qual_value
#?s
WHERE { 
  ?person bnwdt:P3 bnwd:Q3 .
  ?person ?p ?s .
      ?prop wikibase:claim ?p;     
        wikibase:statementProperty ?ps.     
 
  # *not* in p16 sal election.  also p75  was fellow of - a handful not sal but may as well exclude that too.
  filter not exists { ?s (bnps:P16 | bnps:P75 ) ?anything . }
 
    ?s ?ps ?value .
 
  # qualifiers
  # optional {
  #  ?s ?qual_p ?qual_value . 
  #  ?qual_prop wikibase:qualifier ?qual_p .
  #  }
 
        # 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
    ?s prov:wasDerivedFrom ?refnode.
        ?refnode bnpr:P56 bnwd:Q315 .
        #?refnode bnpr:P56 ?ref_stated . # you'll get extras if multi in the same reference...
 
  # a few q315 have additional stuff in the reference: p91 specific reference information (item) / p88 specific (text) - unrelated to the p56 i think
    #optional {?refnode bnpr:P88 ?ref_text.}
    #optional {?refnode bnpr:P91 ?ref_item.}
 
     
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,en-gb". }
}
order by ?personLabel ?propLabel
</sparql>
</sparql>


579

edits