use of com.hp.hpl.jena.query.QueryExecution in project stanbol by apache.
the class ClerezzaAdapter method main.
public static void main(String[] args) {
RuleAdapter ruleAdapter = new ClerezzaAdapter();
try {
KB kb = RuleParserImpl.parse("http://sssw.org/2012/rules/", new FileInputStream("/Users/mac/Documents/CNR/SSSW2012/construct/exercise3"));
System.out.println("Rules: " + kb.getRuleList().size());
Recipe recipe = new RecipeImpl(new IRI("http://sssw.org/2012/rules/"), "Recipe", kb.getRuleList());
//List<ConstructQuery> jenaRules = (List<ConstructQuery>) ruleAdapter.adaptTo(recipe, ConstructQuery.class);
String rules = "[ Exercise1: (http://dbpedia.org/resource/Madrid http://dbpedia.org/ontology/locationOf ?location) (?location rdf:type http://dbpedia.org/ontology/Museum) (?location http://dbpedia.org/ontology/numberOfVisitors ?visitors) greaterThan(?visitors '2000000'^^http://www.w3.org/2001/XMLSchema#integer) -> (?location rdf:type http://www.mytravels.com/Itinerary/MadridItinerary) ]";
//List<com.hp.hpl.jena.reasoner.rulesys.Rule> jenaRules = com.hp.hpl.jena.reasoner.rulesys.Rule.parseRules(rules);
String spqral = "CONSTRUCT " + "{ ?city a <http://www.mytravels.com/Itinerary/MovieCityItinerary> . " + " ?city <http://www.w3.org/2000/01/rdf-schema#label> ?cLabel . " + " ?event a <http://linkedevents.org/ontology/Event> . " + " ?event <http://linkedevents.org/ontology/atPlace> ?location . " + " ?location <http://www.w3.org/2000/01/rdf-schema#label> ?lLabel . " + " ?location <http://www.w3.org/2002/07/owl#sameAs> ?city" + "} " + "WHERE " + "{ " + " ?city a <http://www.mytravels.com/Itinerary/MovieCityItinerary> . " + " ?city <http://www.w3.org/2000/01/rdf-schema#label> ?cLabel . " + " ?event a <http://linkedevents.org/ontology/Event> . " + " ?event <http://linkedevents.org/ontology/atPlace> ?location . " + " ?location <http://www.w3.org/2000/01/rdf-schema#label> ?lLabel . " + " FILTER(?lLabel = ?cLabel) " + "}";
Model m = ModelFactory.createDefaultModel();
Model model = FileManager.get().loadModel("/Users/mac/Documents/CNR/SSSW2012/datasets_new/Exercise5_tmp.rdf");
//for(ConstructQuery constructQuery : jenaRules){
//Query query = QueryFactory.create(constructQuery.toString(), Syntax.syntaxARQ);
Query query = QueryFactory.create(spqral, Syntax.syntaxARQ);
QueryExecution queryExecution = QueryExecutionFactory.create(query, model);
//System.out.println(constructQuery.toString());
m.add(queryExecution.execConstruct());
//}
FileOutputStream max = new FileOutputStream("/Users/mac/Documents/CNR/SSSW2012/datasets_new/example5.rdf");
m.write(max);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
/*catch (RuleAtomCallExeption e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnavailableRuleObjectException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnsupportedTypeForExportException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}*/
}
Aggregations