Project:SPARQL/examples: Difference between revisions

From Beyond Notability
Line 981: Line 981:


<sparql tryit="1">
<sparql tryit="1">
# query for information about properties that are being used in the wikibase


## most of these [except skos for alt labels] not needed? to check.
## fyi: not actually necessary to declare these properties
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
Line 993: Line 994:
   ?property
   ?property
   ?propertyType
   ?propertyType
   ?propertyLabel # ?propertyAltLabel
   ?propertyLabel ?propertyAltLabel
   ?propertyDescription
   ?propertyDescription


WHERE {
WHERE {
   ?property a wikibase:Property ;
   ?property a wikibase:Property ;
               rdfs:label ?propertyLabel ;
               rdfs:label ?propertyLabel ; # label
               wikibase:propertyType ?propertyType .
               wikibase:propertyType ?propertyType . # datatype


# add alternative labels if you like, but not many of them
  # add alternative labels (though there are few for properties)
# OPTIONAL { ?property skos:altLabel ?propertyAltLabel . }  
  OPTIONAL { ?property skos:altLabel ?propertyAltLabel . }  


  # add description if present
   OPTIONAL {  
   OPTIONAL {  
         SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en".
         SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en-gb,en".
Line 1,010: Line 1,012:
   }  
   }  
    
    
   FILTER(LANG(?propertyLabel) = 'en')  
   FILTER(LANG(?propertyLabel) = 'en-gb')  
   # fix label language dups; but Q why doesn't SERVICE work?  
   # fix label language dups; but Q why doesn't SERVICE work?  
   # A: https://en.wikibooks.org/wiki/SPARQL/FILTER#FILTER_on_values_in_Labels
   # A: https://en.wikibooks.org/wiki/SPARQL/FILTER#FILTER_on_values_in_Labels
  # nb a few objects found with en-gb label missing


}
}
3,427

edits