From 9ce65c5a963b03ee97fe9cb6c5aa65a3c04a80a8 Mon Sep 17 00:00:00 2001 From: yzhou Date: Tue, 21 Apr 2015 10:34:27 +0100 Subject: initial version --- example/simpleExample.java | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 example/simpleExample.java (limited to 'example') diff --git a/example/simpleExample.java b/example/simpleExample.java new file mode 100644 index 0000000..9a6f0a7 --- /dev/null +++ b/example/simpleExample.java @@ -0,0 +1,38 @@ +import org.semanticweb.owlapi.model.OWLOntology; + +import uk.ac.ox.cs.pagoda.query.AnswerTuple; +import uk.ac.ox.cs.pagoda.query.AnswerTuples; +import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner; + + +public class simpleExample { + + OWLOntology ontology; + String dataPath; // splited by ; (i.e. path1;path2) + String[] queryTexts; + + public boolean test() { + QueryReasoner r = QueryReasoner.getInstance(ontology); + try { + r.loadOntology(ontology); + r.importData(dataPath); + if (!r.preprocess()) return false; + AnswerTuples answers; + AnswerTuple answer; + for (String queryText: queryTexts) { + answers = r.evaluate(queryText); + for (int arity = answers.getArity(); answers.isValid(); answers.moveNext()) { + answer = answers.getTuple(); + for (int i = 0; i < arity; ++i) + System.out.println(answer.getGroundTerm(i) + " "); + System.out.println(); + answers.dispose(); + } + } + } finally { + r.dispose(); + } + return true; + } + +} -- cgit v1.2.3