aboutsummaryrefslogtreecommitdiff
path: root/src/uk/ac/ox/cs/pagoda/approx/RLPlusOntology.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/uk/ac/ox/cs/pagoda/approx/RLPlusOntology.java')
-rw-r--r--src/uk/ac/ox/cs/pagoda/approx/RLPlusOntology.java61
1 files changed, 10 insertions, 51 deletions
diff --git a/src/uk/ac/ox/cs/pagoda/approx/RLPlusOntology.java b/src/uk/ac/ox/cs/pagoda/approx/RLPlusOntology.java
index a60b664..1e17dac 100644
--- a/src/uk/ac/ox/cs/pagoda/approx/RLPlusOntology.java
+++ b/src/uk/ac/ox/cs/pagoda/approx/RLPlusOntology.java
@@ -1,64 +1,23 @@
1package uk.ac.ox.cs.pagoda.approx; 1package uk.ac.ox.cs.pagoda.approx;
2 2
3import java.io.BufferedOutputStream;
4import java.io.FileOutputStream;
5import java.io.IOException;
6import java.io.ObjectOutput;
7import java.io.ObjectOutputStream;
8import java.util.Collections;
9import java.util.HashMap;
10import java.util.HashSet;
11import java.util.Iterator;
12import java.util.LinkedList;
13import java.util.Map;
14import java.util.Random;
15import java.util.Set;
16
17import org.semanticweb.HermiT.Configuration; 3import org.semanticweb.HermiT.Configuration;
18import org.semanticweb.HermiT.model.DLClause; 4import org.semanticweb.HermiT.model.DLClause;
19import org.semanticweb.HermiT.model.DLOntology; 5import org.semanticweb.HermiT.model.DLOntology;
20import org.semanticweb.HermiT.structural.OWLClausification; 6import org.semanticweb.HermiT.structural.OWLClausification;
21import org.semanticweb.owlapi.model.IRI; 7import org.semanticweb.owlapi.model.*;
22import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom;
23import org.semanticweb.owlapi.model.OWLAxiom;
24import org.semanticweb.owlapi.model.OWLClass;
25import org.semanticweb.owlapi.model.OWLClassAssertionAxiom;
26import org.semanticweb.owlapi.model.OWLClassExpression;
27import org.semanticweb.owlapi.model.OWLDataFactory;
28import org.semanticweb.owlapi.model.OWLDataHasValue;
29import org.semanticweb.owlapi.model.OWLDataMaxCardinality;
30import org.semanticweb.owlapi.model.OWLDataMinCardinality;
31import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom;
32import org.semanticweb.owlapi.model.OWLDataSomeValuesFrom;
33import org.semanticweb.owlapi.model.OWLDatatype;
34import org.semanticweb.owlapi.model.OWLDifferentIndividualsAxiom;
35import org.semanticweb.owlapi.model.OWLIndividual;
36import org.semanticweb.owlapi.model.OWLNamedIndividual;
37import org.semanticweb.owlapi.model.OWLObjectAllValuesFrom;
38import org.semanticweb.owlapi.model.OWLObjectComplementOf;
39import org.semanticweb.owlapi.model.OWLObjectHasValue;
40import org.semanticweb.owlapi.model.OWLObjectMaxCardinality;
41import org.semanticweb.owlapi.model.OWLObjectMinCardinality;
42import org.semanticweb.owlapi.model.OWLObjectOneOf;
43import org.semanticweb.owlapi.model.OWLObjectProperty;
44import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom;
45import org.semanticweb.owlapi.model.OWLObjectPropertyExpression;
46import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom;
47import org.semanticweb.owlapi.model.OWLOntology;
48import org.semanticweb.owlapi.model.OWLOntologyCreationException;
49import org.semanticweb.owlapi.model.OWLOntologyManager;
50import org.semanticweb.owlapi.model.OWLOntologyStorageException;
51import org.semanticweb.owlapi.model.OWLSameIndividualAxiom;
52import org.semanticweb.owlapi.profiles.OWL2RLProfile; 8import org.semanticweb.owlapi.profiles.OWL2RLProfile;
53import org.semanticweb.owlapi.profiles.OWLProfileReport; 9import org.semanticweb.owlapi.profiles.OWLProfileReport;
54import org.semanticweb.owlapi.profiles.OWLProfileViolation; 10import org.semanticweb.owlapi.profiles.OWLProfileViolation;
55
56import uk.ac.ox.cs.pagoda.constraints.NullaryBottom; 11import uk.ac.ox.cs.pagoda.constraints.NullaryBottom;
57import uk.ac.ox.cs.pagoda.constraints.UnaryBottom; 12import uk.ac.ox.cs.pagoda.constraints.UnaryBottom;
58import uk.ac.ox.cs.pagoda.owl.OWLHelper; 13import uk.ac.ox.cs.pagoda.owl.OWLHelper;
59import uk.ac.ox.cs.pagoda.util.Namespace; 14import uk.ac.ox.cs.pagoda.util.Namespace;
60import uk.ac.ox.cs.pagoda.util.Utility; 15import uk.ac.ox.cs.pagoda.util.Utility;
61 16
17import java.io.*;
18import java.nio.file.Paths;
19import java.util.*;
20
62public class RLPlusOntology implements KnowledgeBase { 21public class RLPlusOntology implements KnowledgeBase {
63 22
64 OWLOntologyManager manager; 23 OWLOntologyManager manager;
@@ -111,7 +70,7 @@ public class RLPlusOntology implements KnowledgeBase {
111 if (!tOntoIRI.endsWith(originalExtension)) tOntoIRI += originalExtension; 70 if (!tOntoIRI.endsWith(originalExtension)) tOntoIRI += originalExtension;
112 71
113 String rlOntologyIRI = originalExtension.isEmpty() ? tOntoIRI + "-RL.owl" : tOntoIRI.replaceFirst(originalExtension, "-RL.owl"); 72 String rlOntologyIRI = originalExtension.isEmpty() ? tOntoIRI + "-RL.owl" : tOntoIRI.replaceFirst(originalExtension, "-RL.owl");
114 String rlDocumentIRI = (outputPath = Utility.TempDirectory + "RL.owl"); 73 String rlDocumentIRI = (outputPath = Paths.get(Utility.getGlobalTempDirAbsolutePath(), "RL.owl").toString());
115 outputOntology = manager.createOntology(IRI.create(rlOntologyIRI)); 74 outputOntology = manager.createOntology(IRI.create(rlOntologyIRI));
116 manager.setOntologyDocumentIRI(outputOntology, IRI.create(Utility.toFileIRI(rlDocumentIRI))); 75 manager.setOntologyDocumentIRI(outputOntology, IRI.create(Utility.toFileIRI(rlDocumentIRI)));
117 76
@@ -119,8 +78,8 @@ public class RLPlusOntology implements KnowledgeBase {
119 tBoxOntologyIRI = originalExtension.isEmpty() ? tOntoIRI + "-TBox.owl" : tOntoIRI.replaceFirst(originalExtension, "-TBox.owl"); 78 tBoxOntologyIRI = originalExtension.isEmpty() ? tOntoIRI + "-TBox.owl" : tOntoIRI.replaceFirst(originalExtension, "-TBox.owl");
120 aBoxOntologyIRI = originalExtension.isEmpty() ? tOntoIRI + "-ABox.owl" : tOntoIRI.replaceFirst(originalExtension, "-ABox.owl"); 79 aBoxOntologyIRI = originalExtension.isEmpty() ? tOntoIRI + "-ABox.owl" : tOntoIRI.replaceFirst(originalExtension, "-ABox.owl");
121 80
122 String tBoxDocumentIRI = (Utility.TempDirectory + "TBox.owl"); 81 String tBoxDocumentIRI = Paths.get(Utility.getGlobalTempDirAbsolutePath(), "TBox.owl").toString();
123 String aBoxDocumentIRI = (aBoxPath = Utility.TempDirectory + "ABox.owl"); 82 String aBoxDocumentIRI = (aBoxPath = Paths.get(Utility.getGlobalTempDirAbsolutePath(), "ABox.owl").toString());
124 tBox = manager.createOntology(IRI.create(tBoxOntologyIRI)); 83 tBox = manager.createOntology(IRI.create(tBoxOntologyIRI));
125 aBox = manager.createOntology(IRI.create(aBoxOntologyIRI)); 84 aBox = manager.createOntology(IRI.create(aBoxOntologyIRI));
126 manager.setOntologyDocumentIRI(tBox, IRI.create(Utility.toFileIRI(tBoxDocumentIRI))); 85 manager.setOntologyDocumentIRI(tBox, IRI.create(Utility.toFileIRI(tBoxDocumentIRI)));
@@ -488,7 +447,7 @@ public class RLPlusOntology implements KnowledgeBase {
488 addedAxioms.add(factory.getOWLObjectPropertyRangeAxiom(r, tExp)); 447 addedAxioms.add(factory.getOWLObjectPropertyRangeAxiom(r, tExp));
489 } 448 }
490 else if (botStrategy != BottomStrategy.TOREMOVE) { 449 else if (botStrategy != BottomStrategy.TOREMOVE) {
491 OWLClass cls = (OWLClass) ((OWLObjectComplementOf) tExp).getComplementNNF(); 450 OWLClass cls = (OWLClass) tExp.getComplementNNF();
492 OWLClass neg; 451 OWLClass neg;
493 if ((neg = atomic2negation.get(cls)) == null) { 452 if ((neg = atomic2negation.get(cls)) == null) {
494 neg = getNewConcept(outputOntology, rlCounter); 453 neg = getNewConcept(outputOntology, rlCounter);
@@ -632,6 +591,6 @@ public class RLPlusOntology implements KnowledgeBase {
632 corrFileName = path; 591 corrFileName = path;
633 } 592 }
634 593
635 private static enum BottomStrategy { TOREMOVE, NULLARY, UNARY } 594 private enum BottomStrategy { TOREMOVE, NULLARY, UNARY }
636} 595}
637 596