Add namespace prefixes (rdfs, migrants, person, personp, work, workp, location, locationp) to query files. Use --prettify in Rake tasks so example files use abbreviated IRIs. Fix 2hop task to use graph-02.
40 lines
1 KiB
SPARQL
40 lines
1 KiB
SPARQL
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
|
PREFIX migrants: <http://example.org/migrants/>
|
|
PREFIX person: <http://example.org/migrants/person/>
|
|
PREFIX personp: <http://example.org/migrants/person#>
|
|
PREFIX work: <http://example.org/migrants/work/>
|
|
PREFIX workp: <http://example.org/migrants/work#>
|
|
PREFIX location: <http://example.org/migrants/location/>
|
|
PREFIX locationp: <http://example.org/migrants/location#>
|
|
|
|
CONSTRUCT {
|
|
?s ?p ?o .
|
|
}
|
|
WHERE {
|
|
{
|
|
# Hop 0: Triples about Irene Abendroth (as subject)
|
|
?s ?p ?o .
|
|
FILTER(?s = person:AbeIre-00)
|
|
}
|
|
UNION
|
|
{
|
|
# Hop 1 (incoming): Triples about nodes referencing the anchor
|
|
?s ?p ?o .
|
|
?s ?ref person:AbeIre-00 .
|
|
}
|
|
UNION
|
|
{
|
|
# Hop 1 (outgoing): Triples about IRI nodes referenced by the anchor
|
|
?s ?p ?o .
|
|
person:AbeIre-00 ?ref ?s .
|
|
FILTER(isIRI(?s))
|
|
}
|
|
UNION
|
|
{
|
|
# Hop 2: Triples about IRI nodes referenced by hop-1 nodes
|
|
?s ?p ?o .
|
|
?hop1 ?r1 person:AbeIre-00 .
|
|
?hop1 ?r2 ?s .
|
|
FILTER(isIRI(?s) && ?s != person:AbeIre-00)
|
|
}
|
|
}
|