Search code examples
rdfsparqldbpedia

getting all dbpedia predicate list


I am trying to get all dbpedia predicate (labels of property). Check this link

http://dbpedia.org/page/Akshay_Kumar

I wan to get,

dbpedia-owl:abstract
dbpedia-owl:birthDate
dcterms:subject
dc:description
rdfs:label
owl:sameAs
foaf:givenName

in short, all properties on left column. Not for this entity only but entire list.

Please see, only properties can be retrived using:

select distinct ?property where {
         ?instance a <http://dbpedia.org/ontology/Person> . 
         ?instance ?property ?obj . }

or

SELECT * { ?x a rdf:Property }

but I want with prefix like dbpedia-owl, dc, foaf, rdfs etc


Solution

  • This is based on a modification of my answer to SPARQL query to get all class label with namespace prefix defined.

    select distinct ?prettyName ?property where {
    
      #-- get distinct properties that are used on Persons
      { select distinct ?property where {
          [ a dbpedia-owl:Person ; ?property [] ]
        } }
    
      #-- specify some URIs that are used as 
      #-- prefixes and the prefix name that 
      #-- gets used
      values (?prefixURI ?prefixName) {
        (dbpedia-owl: "dbpedia-owl")
        (dbpprop:     "dbpprop")
        (foaf:        "foaf")
        #-- ...more...
      }
    
      #-- only consider those properties that
      #-- begin with one of the prefixes
      filter strstarts(str(?property),str(?prefixURI))
    
      #-- generate the pretty name
      bind(concat(?prefixName,":",strafter(str(?property),str(?prefixURI))) as ?prettyName)
    }
    limit 1000
    

    SPARQL results

    prettyName                        property
    -------------------------------------------------------
    dbpprop:hasPhotoCollection        http://dbpedia.org/property/hasPhotoCollection
    dbpprop:subWins                   http://dbpedia.org/property/subWins
    foaf:homepage                     http://xmlns.com/foaf/0.1/homepage
    dbpedia-owl:wikiPageExternalLink  http://dbpedia.org/ontology/wikiPageExternalLink
    ...