Project:SPARQL/examples: Difference between revisions

Line 1,718: Line 1,718:
              
              
order by ?personLabel ?id_no
order by ?personLabel ?id_no
</sparql>
=== Which BN properties map on to Wikidata properties? ===
<sparql tryit="1">
## **NOTE** a few has_wikidata="yes" have a wikidata "Q" rather than "P" ID. Not sure if this is intentional; I can try to make the query exclude the Qs if preferred.
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 ?property  ?label
(if(bound(?wikidata_id), "yes", "no") as ?has_wikidata) ?wikidata_id ?propertyType
WHERE {
  ?property a wikibase:Property ;
              wikibase:propertyType ?propertyType . # datatype
  # nb to get round slight inconsistencies in use of en and en-gb language labels
  # optional to fetch en-gb (and/or) en labels separately, then coalesce to pick just one. #win.
  optional { ?property rdfs:label ?en . filter(lang(?en)="en").  }
  optional { ?property rdfs:label ?engb . filter(lang(?engb)="en-gb").  } 
  BIND(COALESCE(?en, ?engb) AS ?label).
 
  # wikidata P117
  optional { ?property bnwdt:P117 ?wikidata_id . }
 
}
order by ?property
</sparql>
</sparql>


579

edits