I am trying to extract a subgraph from a large dataset (namely Wikidata, through their Query Service ). I have found pairs of nodes that are of my interest (uses a certain property) and now I would like to CONSTRUCT
a new graph, that would contain these pairs including a chain of properties and nodes, which joins them together (subclass chain).
So I have something like:
CONSTRUCT { #todo }
WHERE {
?s1 ex:p1 ?o1 .
?s2 ex:p2 ?o2 .
#OPTIONAL {?s1 rdfs:subClassOf* ?s2.} #something-like
}
Although, my actual query is a bit more complicated because I am also extracting different information from the same property (based on its string value), but it should not affect the problem.
Now I would like to copy the propertyPaths
of rdfs:subClassOf
, which joins those pairs, into the new graph. So I would like to put something like --
?s1 rdfs:subClassOf* ?s2 .
-- into the CONSTRUCT{}
part but, of course, it's not allowed syntax.