Skip to content

Instantly share code, notes, and snippets.

@kinow
Created November 27, 2014 01:58
Show Gist options
  • Save kinow/f36c7cf989a4ee1b5478 to your computer and use it in GitHub Desktop.
Save kinow/f36c7cf989a4ee1b5478 to your computer and use it in GitHub Desktop.
Yesterday Jena error
public class T {
public static void main(String args[]) throws Exception {
// create an empty model
Model model = ModelFactory.createDefaultModel();
String queryString = "PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>"
+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>"
+ "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>"
+ "PREFIX res: <http://www.w3.org/2005/sparql-results#>"
+ "selectan * where {"
+ "?movie rdf:type dbpedia-owl:Film."
+ "?movie rdfs:label ?label."
+ "?movie rdfs:label ?movie_title."
+ "FILTER langMatches(lang(?movie_title), \"EN\") ."
+ "filter regex( ?label, \"Inglourious Basterds\", \"i\")."
+ "}";
System.out.println(queryString);
// now creating query object
Query query = QueryFactory.create(queryString);
QueryExecution qexec = QueryExecutionFactory.sparqlService(
"http://dbpedia.org/sparql", query);
try {
ResultSet results = qexec.execSelect();
// Output query results
ResultSetFormatter.out(System.out, results, query);
} finally {
qexec.close();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment