blob: 9a6f0a788db622edb5e19d754c919fcd84ac7947 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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;
}
}
|