aboutsummaryrefslogtreecommitdiff
path: root/test/uk/ac/ox/cs/pagoda/ore/PagodaOWLReasoner.java
diff options
context:
space:
mode:
authorRncLsn <rnc.lsn@gmail.com>2015-05-18 18:27:32 +0100
committerRncLsn <rnc.lsn@gmail.com>2015-05-18 18:27:32 +0100
commitc7dbc7c61c7094ea4ec49bd630023f23b92fd9d1 (patch)
tree45ff5a535e7d519b58d60c0c214a1f9ecc5a35ef /test/uk/ac/ox/cs/pagoda/ore/PagodaOWLReasoner.java
parent1b6a128137e5d7a6ff75566869232fc054afabef (diff)
downloadACQuA-c7dbc7c61c7094ea4ec49bd630023f23b92fd9d1.tar.gz
ACQuA-c7dbc7c61c7094ea4ec49bd630023f23b92fd9d1.zip
Configured Maven and improved executable class and tests.
Diffstat (limited to 'test/uk/ac/ox/cs/pagoda/ore/PagodaOWLReasoner.java')
-rw-r--r--test/uk/ac/ox/cs/pagoda/ore/PagodaOWLReasoner.java470
1 files changed, 0 insertions, 470 deletions
diff --git a/test/uk/ac/ox/cs/pagoda/ore/PagodaOWLReasoner.java b/test/uk/ac/ox/cs/pagoda/ore/PagodaOWLReasoner.java
deleted file mode 100644
index a07323d..0000000
--- a/test/uk/ac/ox/cs/pagoda/ore/PagodaOWLReasoner.java
+++ /dev/null
@@ -1,470 +0,0 @@
1package uk.ac.ox.cs.pagoda.ore;
2
3import java.util.HashMap;
4import java.util.HashSet;
5import java.util.List;
6import java.util.Map;
7import java.util.Set;
8
9import org.semanticweb.owlapi.model.AxiomType;
10import org.semanticweb.owlapi.model.IRI;
11import org.semanticweb.owlapi.model.OWLAxiom;
12import org.semanticweb.owlapi.model.OWLClass;
13import org.semanticweb.owlapi.model.OWLClassExpression;
14import org.semanticweb.owlapi.model.OWLDataFactory;
15import org.semanticweb.owlapi.model.OWLDataProperty;
16import org.semanticweb.owlapi.model.OWLDataPropertyExpression;
17import org.semanticweb.owlapi.model.OWLLiteral;
18import org.semanticweb.owlapi.model.OWLNamedIndividual;
19import org.semanticweb.owlapi.model.OWLObjectPropertyExpression;
20import org.semanticweb.owlapi.model.OWLOntology;
21import org.semanticweb.owlapi.model.OWLOntologyChange;
22import org.semanticweb.owlapi.reasoner.AxiomNotInProfileException;
23import org.semanticweb.owlapi.reasoner.BufferingMode;
24import org.semanticweb.owlapi.reasoner.ClassExpressionNotInProfileException;
25import org.semanticweb.owlapi.reasoner.FreshEntitiesException;
26import org.semanticweb.owlapi.reasoner.FreshEntityPolicy;
27import org.semanticweb.owlapi.reasoner.InconsistentOntologyException;
28import org.semanticweb.owlapi.reasoner.IndividualNodeSetPolicy;
29import org.semanticweb.owlapi.reasoner.InferenceType;
30import org.semanticweb.owlapi.reasoner.Node;
31import org.semanticweb.owlapi.reasoner.NodeSet;
32import org.semanticweb.owlapi.reasoner.OWLReasoner;
33import org.semanticweb.owlapi.reasoner.ReasonerInterruptedException;
34import org.semanticweb.owlapi.reasoner.TimeOutException;
35import org.semanticweb.owlapi.reasoner.UnsupportedEntailmentTypeException;
36import org.semanticweb.owlapi.reasoner.impl.OWLClassNodeSet;
37import org.semanticweb.owlapi.util.Version;
38
39import uk.ac.ox.cs.JRDFox.model.GroundTerm;
40import uk.ac.ox.cs.JRDFox.model.Individual;
41import uk.ac.ox.cs.pagoda.query.AnswerTuples;
42import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner;
43import uk.ac.ox.cs.pagoda.util.Utility;
44
45public class PagodaOWLReasoner implements OWLReasoner {
46
47 QueryReasoner reasoner;
48 OWLOntology ontology;
49 OWLDataFactory factory;
50 boolean sat;
51
52 public PagodaOWLReasoner(OWLOntology ontology) {
53 this.ontology = ontology;
54 factory = ontology.getOWLOntologyManager().getOWLDataFactory();
55 reasoner = QueryReasoner.getInstance(ontology);
56 reasoner.setToClassify(false);
57 reasoner.loadOntology(ontology);
58 sat = reasoner.preprocess();
59 thing = new OWLClassNodeSet(factory.getOWLThing());
60 }
61
62 @Override
63 public String getReasonerName() {
64 return "PAGOdA";
65 }
66
67 @Override
68 public Version getReasonerVersion() {
69 return null;
70 }
71
72 @Override
73 public BufferingMode getBufferingMode() {
74 // TODO Auto-generated method stub
75 return null;
76 }
77
78 @Override
79 public void flush() {
80 // TODO Auto-generated method stub
81
82 }
83
84 @Override
85 public List<OWLOntologyChange> getPendingChanges() {
86 // TODO Auto-generated method stub
87 return null;
88 }
89
90 @Override
91 public Set<OWLAxiom> getPendingAxiomAdditions() {
92 // TODO Auto-generated method stub
93 return null;
94 }
95
96 @Override
97 public Set<OWLAxiom> getPendingAxiomRemovals() {
98 // TODO Auto-generated method stub
99 return null;
100 }
101
102 @Override
103 public OWLOntology getRootOntology() {
104 return ontology;
105 }
106
107 @Override
108 public void interrupt() {
109 // TODO Auto-generated method stub
110
111 }
112
113 @Override
114 public void precomputeInferences(InferenceType... inferenceTypes) throws ReasonerInterruptedException, TimeOutException, InconsistentOntologyException {
115 if (!sat) {
116 throw new InconsistentOntologyException();
117 }
118 if (inferenceTypes.length == 1 && inferenceTypes[0].equals(InferenceType.CLASS_ASSERTIONS) && types.isEmpty()) {
119 Set<OWLClass> queriedClasses = new HashSet<OWLClass>();
120 for (OWLOntology onto: ontology.getImportsClosure())
121 for (OWLClass cls: onto.getClassesInSignature(true)) {
122// if (cls.toStringID().equals("http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Meritage"));
123// else continue;
124 if (!cls.equals(factory.getOWLThing()) && !queriedClasses.contains(cls)) {
125 queriedClasses.add(cls);
126 AnswerTuples tuples = null;
127 try {
128 tuples = reasoner.evaluate(String.format("select distinct ?x where { ?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <%s> .}", cls.toStringID()));
129 int cnt = 0;
130 for (GroundTerm t; tuples.isValid(); tuples.moveNext()) {
131 t = tuples.getTuple().getGroundTerm(0);
132 if (t instanceof Individual) {
133 addType(((Individual) t).getIRI(), cls);
134 ++cnt;
135 }
136 }
137 Utility.logInfo("The number of answers: " + cnt);
138 } finally {
139 if (tuples != null) tuples.dispose();
140 }
141 }
142 }
143 }
144 }
145
146 private void addType(String iri, OWLClass cls) {
147 OWLNamedIndividual ind = factory.getOWLNamedIndividual(IRI.create(iri));
148 OWLClassNodeSet set;
149 if (types.containsKey(ind)) {
150 set = types.get(ind);
151 }
152 else {
153 set = new OWLClassNodeSet(factory.getOWLThing());
154 types.put(ind, set);
155 }
156 set.addEntity(cls);
157 }
158
159 @Override
160 public boolean isPrecomputed(InferenceType inferenceType) {
161 // TODO Auto-generated method stub
162 return false;
163 }
164
165 @Override
166 public Set<InferenceType> getPrecomputableInferenceTypes() {
167 return java.util.Collections.singleton(InferenceType.CLASS_ASSERTIONS);
168 }
169
170 @Override
171 public boolean isConsistent() throws ReasonerInterruptedException, TimeOutException {
172 return sat;
173 }
174
175 @Override
176 public boolean isSatisfiable(OWLClassExpression classExpression) throws ReasonerInterruptedException, TimeOutException, ClassExpressionNotInProfileException, FreshEntitiesException, InconsistentOntologyException {
177 // TODO Auto-generated method stub
178 return false;
179 }
180
181 @Override
182 public Node<OWLClass> getUnsatisfiableClasses() throws ReasonerInterruptedException, TimeOutException, InconsistentOntologyException {
183 // TODO Auto-generated method stub
184 return null;
185 }
186
187 @Override
188 public boolean isEntailed(OWLAxiom axiom)
189 throws ReasonerInterruptedException,
190 UnsupportedEntailmentTypeException, TimeOutException,
191 AxiomNotInProfileException, FreshEntitiesException,
192 InconsistentOntologyException {
193 // TODO Auto-generated method stub
194 return false;
195 }
196
197 @Override
198 public boolean isEntailed(Set<? extends OWLAxiom> axioms)
199 throws ReasonerInterruptedException,
200 UnsupportedEntailmentTypeException, TimeOutException,
201 AxiomNotInProfileException, FreshEntitiesException,
202 InconsistentOntologyException {
203 // TODO Auto-generated method stub
204 return false;
205 }
206
207 @Override
208 public boolean isEntailmentCheckingSupported(AxiomType<?> axiomType) {
209 // TODO Auto-generated method stub
210 return false;
211 }
212
213 @Override
214 public Node<OWLClass> getTopClassNode() {
215 // TODO Auto-generated method stub
216 return null;
217 }
218
219 @Override
220 public Node<OWLClass> getBottomClassNode() {
221 // TODO Auto-generated method stub
222 return null;
223 }
224
225 @Override
226 public NodeSet<OWLClass> getSubClasses(OWLClassExpression ce, boolean direct)
227 throws ReasonerInterruptedException, TimeOutException,
228 FreshEntitiesException, InconsistentOntologyException,
229 ClassExpressionNotInProfileException {
230 // TODO Auto-generated method stub
231 return null;
232 }
233
234 @Override
235 public NodeSet<OWLClass> getSuperClasses(OWLClassExpression ce,
236 boolean direct) throws InconsistentOntologyException,
237 ClassExpressionNotInProfileException, FreshEntitiesException,
238 ReasonerInterruptedException, TimeOutException {
239 // TODO Auto-generated method stub
240 return null;
241 }
242
243 @Override
244 public Node<OWLClass> getEquivalentClasses(OWLClassExpression ce)
245 throws InconsistentOntologyException,
246 ClassExpressionNotInProfileException, FreshEntitiesException,
247 ReasonerInterruptedException, TimeOutException {
248 // TODO Auto-generated method stub
249 return null;
250 }
251
252 @Override
253 public NodeSet<OWLClass> getDisjointClasses(OWLClassExpression ce)
254 throws ReasonerInterruptedException, TimeOutException,
255 FreshEntitiesException, InconsistentOntologyException {
256 // TODO Auto-generated method stub
257 return null;
258 }
259
260 @Override
261 public Node<OWLObjectPropertyExpression> getTopObjectPropertyNode() {
262 // TODO Auto-generated method stub
263 return null;
264 }
265
266 @Override
267 public Node<OWLObjectPropertyExpression> getBottomObjectPropertyNode() {
268 // TODO Auto-generated method stub
269 return null;
270 }
271
272 @Override
273 public NodeSet<OWLObjectPropertyExpression> getSubObjectProperties(
274 OWLObjectPropertyExpression pe, boolean direct)
275 throws InconsistentOntologyException, FreshEntitiesException,
276 ReasonerInterruptedException, TimeOutException {
277 // TODO Auto-generated method stub
278 return null;
279 }
280
281 @Override
282 public NodeSet<OWLObjectPropertyExpression> getSuperObjectProperties(
283 OWLObjectPropertyExpression pe, boolean direct)
284 throws InconsistentOntologyException, FreshEntitiesException,
285 ReasonerInterruptedException, TimeOutException {
286 // TODO Auto-generated method stub
287 return null;
288 }
289
290 @Override
291 public Node<OWLObjectPropertyExpression> getEquivalentObjectProperties(
292 OWLObjectPropertyExpression pe)
293 throws InconsistentOntologyException, FreshEntitiesException,
294 ReasonerInterruptedException, TimeOutException {
295 // TODO Auto-generated method stub
296 return null;
297 }
298
299 @Override
300 public NodeSet<OWLObjectPropertyExpression> getDisjointObjectProperties(
301 OWLObjectPropertyExpression pe)
302 throws InconsistentOntologyException, FreshEntitiesException,
303 ReasonerInterruptedException, TimeOutException {
304 // TODO Auto-generated method stub
305 return null;
306 }
307
308 @Override
309 public Node<OWLObjectPropertyExpression> getInverseObjectProperties(
310 OWLObjectPropertyExpression pe)
311 throws InconsistentOntologyException, FreshEntitiesException,
312 ReasonerInterruptedException, TimeOutException {
313 // TODO Auto-generated method stub
314 return null;
315 }
316
317 @Override
318 public NodeSet<OWLClass> getObjectPropertyDomains(
319 OWLObjectPropertyExpression pe, boolean direct)
320 throws InconsistentOntologyException, FreshEntitiesException,
321 ReasonerInterruptedException, TimeOutException {
322 // TODO Auto-generated method stub
323 return null;
324 }
325
326 @Override
327 public NodeSet<OWLClass> getObjectPropertyRanges(
328 OWLObjectPropertyExpression pe, boolean direct)
329 throws InconsistentOntologyException, FreshEntitiesException,
330 ReasonerInterruptedException, TimeOutException {
331 // TODO Auto-generated method stub
332 return null;
333 }
334
335 @Override
336 public Node<OWLDataProperty> getTopDataPropertyNode() {
337 // TODO Auto-generated method stub
338 return null;
339 }
340
341 @Override
342 public Node<OWLDataProperty> getBottomDataPropertyNode() {
343 // TODO Auto-generated method stub
344 return null;
345 }
346
347 @Override
348 public NodeSet<OWLDataProperty> getSubDataProperties(OWLDataProperty pe,
349 boolean direct) throws InconsistentOntologyException,
350 FreshEntitiesException, ReasonerInterruptedException,
351 TimeOutException {
352 // TODO Auto-generated method stub
353 return null;
354 }
355
356 @Override
357 public NodeSet<OWLDataProperty> getSuperDataProperties(OWLDataProperty pe,
358 boolean direct) throws InconsistentOntologyException,
359 FreshEntitiesException, ReasonerInterruptedException,
360 TimeOutException {
361 // TODO Auto-generated method stub
362 return null;
363 }
364
365 @Override
366 public Node<OWLDataProperty> getEquivalentDataProperties(OWLDataProperty pe)
367 throws InconsistentOntologyException, FreshEntitiesException,
368 ReasonerInterruptedException, TimeOutException {
369 // TODO Auto-generated method stub
370 return null;
371 }
372
373 @Override
374 public NodeSet<OWLDataProperty> getDisjointDataProperties(
375 OWLDataPropertyExpression pe) throws InconsistentOntologyException,
376 FreshEntitiesException, ReasonerInterruptedException,
377 TimeOutException {
378 // TODO Auto-generated method stub
379 return null;
380 }
381
382 @Override
383 public NodeSet<OWLClass> getDataPropertyDomains(OWLDataProperty pe,
384 boolean direct) throws InconsistentOntologyException,
385 FreshEntitiesException, ReasonerInterruptedException,
386 TimeOutException {
387 // TODO Auto-generated method stub
388 return null;
389 }
390
391 private Map<OWLNamedIndividual, OWLClassNodeSet> types = new HashMap<OWLNamedIndividual, OWLClassNodeSet>();
392 private OWLClassNodeSet thing;
393
394 @Override
395 public NodeSet<OWLClass> getTypes(OWLNamedIndividual ind, boolean direct) throws InconsistentOntologyException, FreshEntitiesException, ReasonerInterruptedException, TimeOutException {
396 if (!sat) {
397 throw new InconsistentOntologyException();
398 }
399 if (types.containsKey(ind)) return types.get(ind);
400 return thing;
401 }
402
403 @Override
404 public NodeSet<OWLNamedIndividual> getInstances(OWLClassExpression ce,
405 boolean direct) throws InconsistentOntologyException,
406 ClassExpressionNotInProfileException, FreshEntitiesException,
407 ReasonerInterruptedException, TimeOutException {
408 // TODO Auto-generated method stub
409 return null;
410 }
411
412 @Override
413 public NodeSet<OWLNamedIndividual> getObjectPropertyValues(
414 OWLNamedIndividual ind, OWLObjectPropertyExpression pe)
415 throws InconsistentOntologyException, FreshEntitiesException,
416 ReasonerInterruptedException, TimeOutException {
417 // TODO Auto-generated method stub
418 return null;
419 }
420
421 @Override
422 public Set<OWLLiteral> getDataPropertyValues(OWLNamedIndividual ind,
423 OWLDataProperty pe) throws InconsistentOntologyException,
424 FreshEntitiesException, ReasonerInterruptedException,
425 TimeOutException {
426 // TODO Auto-generated method stub
427 return null;
428 }
429
430 @Override
431 public Node<OWLNamedIndividual> getSameIndividuals(OWLNamedIndividual ind)
432 throws InconsistentOntologyException, FreshEntitiesException,
433 ReasonerInterruptedException, TimeOutException {
434 // TODO Auto-generated method stub
435 return null;
436 }
437
438 @Override
439 public NodeSet<OWLNamedIndividual> getDifferentIndividuals(
440 OWLNamedIndividual ind) throws InconsistentOntologyException,
441 FreshEntitiesException, ReasonerInterruptedException,
442 TimeOutException {
443 // TODO Auto-generated method stub
444 return null;
445 }
446
447 @Override
448 public long getTimeOut() {
449 // TODO Auto-generated method stub
450 return 0;
451 }
452
453 @Override
454 public FreshEntityPolicy getFreshEntityPolicy() {
455 // TODO Auto-generated method stub
456 return null;
457 }
458
459 @Override
460 public IndividualNodeSetPolicy getIndividualNodeSetPolicy() {
461 // TODO Auto-generated method stub
462 return null;
463 }
464
465 @Override
466 public void dispose() {
467 reasoner.dispose();
468 }
469
470}