Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PREFIX entity: <http://www.wikidata.org/entity/>
- SELECT ?entity ?propNumber ?propLabel ?val WHERE {
- {
- BIND(entity:Q42 AS ?entity)
- {
- BIND(?entity AS ?valUrl)
- BIND("N/A" AS ?propUrl)
- BIND("Label"@en AS ?propLabel)
- ?entity rdfs:label ?val.
- FILTER((LANG(?val)) = "en")
- }
- UNION
- {
- BIND(?entity AS ?valUrl)
- BIND("AltLabel"@en AS ?propLabel)
- OPTIONAL { ?entity skos:altLabel ?val. }
- FILTER((LANG(?val)) = "en")
- }
- UNION
- {
- BIND(?entity AS ?valUrl)
- BIND("Description"@en AS ?propLabel)
- OPTIONAL { ?entity schema:description ?val. }
- FILTER((LANG(?val)) = "en")
- }
- UNION
- {
- # get the value of each property on this entity
- ?entity ?propUrl ?valUrl.
- ?property ?ref ?propUrl.
- ?property rdf:type wikibase:Property.
- ?property rdfs:label ?propLabel.
- BIND(?valUrl AS ?val)
- FILTER((LANG(?val)) = "en")
- FILTER((LANG(?propLabel)) = "en")
- FILTER(ISLITERAL(?valUrl))
- }
- UNION
- {
- # special case: get the quantity amount and unit
- ?entity ?propUrl ?valUrl.
- ?property ?ref ?propUrl.
- ?property rdf:type wikibase:Property.
- ?property rdfs:label ?propLabel.
- ?property wikibase:claim ?p;
- wikibase:statementValue ?pv.
- ?entity ?p [
- ?pv [
- wikibase:quantityAmount ?qm ;
- wikibase:quantityUnit ?qu
- ]
- ].
- ?qu rdfs:label ?quLabel.
- BIND(CONCAT(STR(?qm), " ", STR(?quLabel)) AS ?val)
- FILTER((LANG(?propLabel)) = "en")
- FILTER((LANG(?quLabel)) = "en")
- FILTER(ISLITERAL(?valUrl))
- }
- UNION
- {
- # special case: get the time value.
- ?entity ?propUrl ?valUrl.
- ?property ?ref ?propUrl.
- ?property rdf:type wikibase:Property.
- ?property rdfs:label ?propLabel.
- ?property wikibase:claim ?p;
- wikibase:statementValue ?pv.
- ?entity ?p [?pv [wikibase:timeValue ?tm ;]].
- BIND(?tm AS ?val)
- FILTER((LANG(?propLabel)) = "en")
- FILTER(ISLITERAL(?valUrl))
- }
- UNION
- {
- # special case: keep IRIs that aren't wikidata IRIs (eg, commons media)
- ?entity ?propUrl ?valUrl.
- ?property ?ref ?propUrl.
- ?property rdf:type wikibase:Property.
- ?property rdfs:label ?propLabel.
- BIND(?valUrl AS ?val)
- FILTER((LANG(?propLabel)) = "en")
- FILTER(ISIRI(?valUrl))
- FILTER(!CONTAINS(STR(?valUrl), "wikidata.org"))
- }
- UNION
- {
- # special case: get Wolfram Entity IDs for values, if they exist
- ?entity ?propUrl ?valUrl.
- ?property ?ref ?propUrl.
- ?property rdf:type wikibase:Property.
- ?property rdfs:label ?propLabel.
- ?valUrl rdfs:label ?valLabel.
- OPTIONAL { ?valUrl wdt:P4839 ?wlEntity. }
- BIND(IF((BOUND(?wlEntity)) && ((STRLEN(?wlEntity)) > 0), CONCAT(?wlEntity), CONCAT(?valLabel)) AS ?val)
- FILTER((LANG(?valLabel)) = "en")
- FILTER((LANG(?propLabel)) = "en")
- }
- BIND(SUBSTR(STR(?propUrl), 38, 250) AS ?propNumber)
- }
- } ORDER BY xsd:integer(?propNumber)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement