What the asterisk mean in this SPARQL query?
SELECT ?uri ?type
WHERE{
?uri a ?type.
?type rdfs:subClassOf* example:Device.
}
Does it mean "subclass of a subclass"? Can I use it with other predicates?
What the asterisk mean in this SPARQL query?
SELECT ?uri ?type
WHERE{
?uri a ?type.
?type rdfs:subClassOf* example:Device.
}
Does it mean "subclass of a subclass"? Can I use it with other predicates?
An asterisk (*) after a path element means “zero or more of this element”.
If there are no other elements in the path, ?a something* ?b
means that ?b
might also just be ?a
directly, with no path elements between them at all.
?item wdt:P31/wdt:P279* ?class.
# means:
?item wdt:P31 ?class
# or
?item wdt:P31/wdt:P279 ?class
# or
?item wdt:P31/wdt:P279/wdt:P279 ?class
# or
?item wdt:P31/wdt:P279/wdt:P279/wdt:P279 ?class
See here for more detailed answer.
The asterisk after a predicate means that you want to follow a property path with zero or more occurrences of rdfs:subClassOf.
Your phrase "subclass of a subclass" is about right, although I would say "subclasses of subclasses," because the * property path is recursive. As you can see from the technical document in AKSW's comment, there are several other property path operators that go in either direction, with or without a limit on the number of occerances (or depth.)
Here's a pretty good example from Marklogic... I think this should work within any 1.1 endpoint.
https://developer.marklogic.com/features/semantics/path-examples
Yes, property paths are applicable to any predicate/property, not just rdfs:subClassOf.
© 2022 - 2024 — McMap. All rights reserved.
p*
is the transitive closure of the propertyp
, in your casep = rdfs:subClassOf
– Onassis