/** Runs the pellet reasoner on the aligned ontology */ private void runPellet() { Reasoner reasoner = PelletReasonerFactory.theInstance().create(); reasoner = reasoner.bindSchema(schema); inferredModel = (InfModel) ModelFactory.createInfModel(reasoner, schema); StmtIterator stmts = inferredModel.listStatements(); inferences = (OntModel) ModelFactory.createOntologyModel().add(stmts); } // runPellet
// This is the inference method for getting data from OWL file public String sparqlInferenceMethod(String qry) { OntModel ont = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_MICRO_RULE_INF, null); try { ont.read( new FileInputStream( // "D:/AI Project/harsh/myNew.owl"), "SmartHospital.owl"), null, "RDF"); } catch (FileNotFoundException e) { e.printStackTrace(); } Reasoner reasoner = ReasonerRegistry.getOWLMicroReasoner(); reasoner = reasoner.bindSchema(ont); Dataset dataset = TDBFactory.createDataset(); Model model = dataset.getDefaultModel(); InfModel infModel = ModelFactory.createInfModel(reasoner, model); String disease = null; String hospital = null; String hospitalCode = null; StringBuilder res = new StringBuilder(); Query query = QueryFactory.create(qry); QueryExecution exec = QueryExecutionFactory.create(query, infModel); try { System.out.println("here"); ResultSet rs = exec.execSelect(); while (rs.hasNext()) { QuerySolution soln = rs.nextSolution(); disease = soln.get("dn").toString(); hospital = soln.get("hn").toString(); hospitalCode = soln.get("hc").toString(); } } finally { exec.close(); } res.append(disease); res.append("::"); res.append(hospital); res.append("::"); res.append(hospitalCode); return res.toString(); }