Reputation: 21
I have an starting page in dbpedia(https://dbpedia.org/page/Hassan_Rouhani) and I want to traverse his graph only using some specific properties(like dbo:party or dbp:office) until ith depth. I also want to record the connections between entities so i can visualize the graph later. I'm not that skilled in sparql so i'd aprreciate if you can help me.
This is the query that I wrote:
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbp: <http://dbpedia.org/property/>
CONSTRUCT {
?entity ?property ?target
}
WHERE {
{
<https://dbpedia.org/page/Hassan_Rouhani> ?property ?entity .
FILTER(?property IN (dbo:party, dbp:office))
OPTIONAL { ?entity ?property ?target . }
}
UNION
{
?entity ?property ?target .
FILTER(?property IN (dbo:party, dbp:office))
OPTIONAL { ?target ?property ?next . }
}
}
LIMIT 100
Upvotes: 0
Views: 22