I want to know how to download/ extract a list of predicates from RDF/ ontology file using SPARQL?
For example, say we are talking about the "rdfs" URI. I want to get all properties (predicates) such as range, domain, type etc. to be listed. Is this possible? Or am I making a conceptual mistake here?
You can use the DISTINCT
operator along with a SPARQL query that lists all the statements from a graph. You can also use ORDER BY
to make long lists easier to browse.
SELECT DISTINCT ?p WHERE {
?s ?p ?o
}
ORDER BY ?p
If the graph you're querying against is an ontology, you might want to select all entities that have the rdf:Property
type rather than the predicates in the graph.
When performing this request, make sure inference is enabled since most predicates are typed owl:ObjectProperty
or owl:DatatypeProperty
, which are subclasses of rdf:Property
.
SELECT DISTINCT ?property WHERE {
?property a rdf:Property
}
ORDER BY ?property