Based on an initial URI from DBPedia (Ex: dbpedia.org/resource/Barack_Obama), I need to perform a depth search following these steps:
1 - Dereference a RDF link from DBPedia [OK]
2 - Take all triples that asserts this pattern [OK]
<givenURI> <property> <someObject> .
3 - Insert the result back into the initial graph [?]
4 - To navigate through new data, I need to find new triples that satisfy these two patterns [?]:
<URI> owl:sameAs <resourceObject> .
<subjectResource> owl:sameAs <URI> .
5 - Than get back to first step, doing it recursively, saving visited URI's to avoid infity loops.
So, there is the resultSet from step 2. At this point, it's all property/Object from initial URI (dbpedia.org/resource/Barack_Obama).
select ?property ?resource where {
<http://dbpedia.org/resource/Barack_Obama> ?property ?resource
}
property,resource
http://www.w3.org/1999/02/22-rdf-syntax-ns#type,http://xmlns.com/foaf/0.1/Person
http://www.w3.org/1999/02/22-rdf-syntax-ns#type,http://schema.org/Person
http://www.w3.org/1999/02/22-rdf-syntax-ns#type,http://dbpedia.org/class/yago/UnitedStatesSenatorsFromIllinois
http://www.w3.org/1999/02/22-rdf-syntax-ns#type,http://wikidata.dbpedia.org/resource/Q215627
http://www.w3.org/1999/02/22-rdf-syntax-ns#type,http://www.w3.org/2002/07/owl#Thing
http://www.w3.org/1999/02/22-rdf-syntax-ns#type,http://wikidata.dbpedia.org/resource/Q5
...
I'm really confused about how could I insert the resultSet from this query to initial graph, than deep search into it again..
There's the actual code on Java, using Jena and Sparql:
public class SemanticCrawlerImpl implements SemanticCrawler {
public void search(Model graph, String resourceURI) {
graph.read(resourceURI);
ParameterizedSparqlString queryString = new ParameterizedSparqlString( "" +
"select ?property ?resource where {\n" +
" <"+resourceURI+"> ?property ?resource\n" +
"}" );
System.out.println( queryString );
QueryExecution exec = QueryExecutionFactory.sparqlService( "http://dbpedia.org/sparql", queryString.asQuery() );
com.hp.hpl.jena.query.ResultSet results = ResultSetFactory.copyResults( exec.execSelect() );
ResultSetFormatter.outputAsCSV( results );
}
}
So, there it is. Any help would be appreciated!
insert { graph <graph> { <givenURI> ?p ?o } } where { service <http:/dbpedia.org/sparql> { <givenURI> ?p ?o } }. - Joshua Taylor<givenURI>as a subject, or anything that is owl:sameAs it, right? That's not too hard to do (writing an answer...). - Joshua Taylor