diff options
Diffstat (limited to 'example/simpleExample.java')
| -rw-r--r-- | example/simpleExample.java | 38 |
1 files changed, 38 insertions, 0 deletions
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 @@ | |||
| 1 | import org.semanticweb.owlapi.model.OWLOntology; | ||
| 2 | |||
| 3 | import uk.ac.ox.cs.pagoda.query.AnswerTuple; | ||
| 4 | import uk.ac.ox.cs.pagoda.query.AnswerTuples; | ||
| 5 | import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner; | ||
| 6 | |||
| 7 | |||
| 8 | public class simpleExample { | ||
| 9 | |||
| 10 | OWLOntology ontology; | ||
| 11 | String dataPath; // splited by ; (i.e. path1;path2) | ||
| 12 | String[] queryTexts; | ||
| 13 | |||
| 14 | public boolean test() { | ||
| 15 | QueryReasoner r = QueryReasoner.getInstance(ontology); | ||
| 16 | try { | ||
| 17 | r.loadOntology(ontology); | ||
| 18 | r.importData(dataPath); | ||
| 19 | if (!r.preprocess()) return false; | ||
| 20 | AnswerTuples answers; | ||
| 21 | AnswerTuple answer; | ||
| 22 | for (String queryText: queryTexts) { | ||
| 23 | answers = r.evaluate(queryText); | ||
| 24 | for (int arity = answers.getArity(); answers.isValid(); answers.moveNext()) { | ||
| 25 | answer = answers.getTuple(); | ||
| 26 | for (int i = 0; i < arity; ++i) | ||
| 27 | System.out.println(answer.getGroundTerm(i) + " "); | ||
| 28 | System.out.println(); | ||
| 29 | answers.dispose(); | ||
| 30 | } | ||
| 31 | } | ||
| 32 | } finally { | ||
| 33 | r.dispose(); | ||
| 34 | } | ||
| 35 | return true; | ||
| 36 | } | ||
| 37 | |||
| 38 | } | ||
