diff options
| author | RncLsn <rnc.lsn@gmail.com> | 2015-05-15 17:32:22 +0100 |
|---|---|---|
| committer | RncLsn <rnc.lsn@gmail.com> | 2015-05-15 17:32:22 +0100 |
| commit | 1b6a128137e5d7a6ff75566869232fc054afabef (patch) | |
| tree | 3def49c3c9c1e2ebebc49b82d9eb562b6d097cad /src/uk/ac/ox/cs/pagoda/approx/RLPlusOntology.java | |
| parent | bd995407098d1b0c79c17a28b0b23a2c24a493c6 (diff) | |
| download | ACQuA-1b6a128137e5d7a6ff75566869232fc054afabef.tar.gz ACQuA-1b6a128137e5d7a6ff75566869232fc054afabef.zip | |
Testing and fixing. Executed successfully on UOBM{1,2,3,4,5,6,7,8}.
Diffstat (limited to 'src/uk/ac/ox/cs/pagoda/approx/RLPlusOntology.java')
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/approx/RLPlusOntology.java | 61 |
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 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.approx; | 1 | package uk.ac.ox.cs.pagoda.approx; |
| 2 | 2 | ||
| 3 | import java.io.BufferedOutputStream; | ||
| 4 | import java.io.FileOutputStream; | ||
| 5 | import java.io.IOException; | ||
| 6 | import java.io.ObjectOutput; | ||
| 7 | import java.io.ObjectOutputStream; | ||
| 8 | import java.util.Collections; | ||
| 9 | import java.util.HashMap; | ||
| 10 | import java.util.HashSet; | ||
| 11 | import java.util.Iterator; | ||
| 12 | import java.util.LinkedList; | ||
| 13 | import java.util.Map; | ||
| 14 | import java.util.Random; | ||
| 15 | import java.util.Set; | ||
| 16 | |||
| 17 | import org.semanticweb.HermiT.Configuration; | 3 | import org.semanticweb.HermiT.Configuration; |
| 18 | import org.semanticweb.HermiT.model.DLClause; | 4 | import org.semanticweb.HermiT.model.DLClause; |
| 19 | import org.semanticweb.HermiT.model.DLOntology; | 5 | import org.semanticweb.HermiT.model.DLOntology; |
| 20 | import org.semanticweb.HermiT.structural.OWLClausification; | 6 | import org.semanticweb.HermiT.structural.OWLClausification; |
| 21 | import org.semanticweb.owlapi.model.IRI; | 7 | import org.semanticweb.owlapi.model.*; |
| 22 | import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; | ||
| 23 | import org.semanticweb.owlapi.model.OWLAxiom; | ||
| 24 | import org.semanticweb.owlapi.model.OWLClass; | ||
| 25 | import org.semanticweb.owlapi.model.OWLClassAssertionAxiom; | ||
| 26 | import org.semanticweb.owlapi.model.OWLClassExpression; | ||
| 27 | import org.semanticweb.owlapi.model.OWLDataFactory; | ||
| 28 | import org.semanticweb.owlapi.model.OWLDataHasValue; | ||
| 29 | import org.semanticweb.owlapi.model.OWLDataMaxCardinality; | ||
| 30 | import org.semanticweb.owlapi.model.OWLDataMinCardinality; | ||
| 31 | import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom; | ||
| 32 | import org.semanticweb.owlapi.model.OWLDataSomeValuesFrom; | ||
| 33 | import org.semanticweb.owlapi.model.OWLDatatype; | ||
| 34 | import org.semanticweb.owlapi.model.OWLDifferentIndividualsAxiom; | ||
| 35 | import org.semanticweb.owlapi.model.OWLIndividual; | ||
| 36 | import org.semanticweb.owlapi.model.OWLNamedIndividual; | ||
| 37 | import org.semanticweb.owlapi.model.OWLObjectAllValuesFrom; | ||
| 38 | import org.semanticweb.owlapi.model.OWLObjectComplementOf; | ||
| 39 | import org.semanticweb.owlapi.model.OWLObjectHasValue; | ||
| 40 | import org.semanticweb.owlapi.model.OWLObjectMaxCardinality; | ||
| 41 | import org.semanticweb.owlapi.model.OWLObjectMinCardinality; | ||
| 42 | import org.semanticweb.owlapi.model.OWLObjectOneOf; | ||
| 43 | import org.semanticweb.owlapi.model.OWLObjectProperty; | ||
| 44 | import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom; | ||
| 45 | import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; | ||
| 46 | import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; | ||
| 47 | import org.semanticweb.owlapi.model.OWLOntology; | ||
| 48 | import org.semanticweb.owlapi.model.OWLOntologyCreationException; | ||
| 49 | import org.semanticweb.owlapi.model.OWLOntologyManager; | ||
| 50 | import org.semanticweb.owlapi.model.OWLOntologyStorageException; | ||
| 51 | import org.semanticweb.owlapi.model.OWLSameIndividualAxiom; | ||
| 52 | import org.semanticweb.owlapi.profiles.OWL2RLProfile; | 8 | import org.semanticweb.owlapi.profiles.OWL2RLProfile; |
| 53 | import org.semanticweb.owlapi.profiles.OWLProfileReport; | 9 | import org.semanticweb.owlapi.profiles.OWLProfileReport; |
| 54 | import org.semanticweb.owlapi.profiles.OWLProfileViolation; | 10 | import org.semanticweb.owlapi.profiles.OWLProfileViolation; |
| 55 | |||
| 56 | import uk.ac.ox.cs.pagoda.constraints.NullaryBottom; | 11 | import uk.ac.ox.cs.pagoda.constraints.NullaryBottom; |
| 57 | import uk.ac.ox.cs.pagoda.constraints.UnaryBottom; | 12 | import uk.ac.ox.cs.pagoda.constraints.UnaryBottom; |
| 58 | import uk.ac.ox.cs.pagoda.owl.OWLHelper; | 13 | import uk.ac.ox.cs.pagoda.owl.OWLHelper; |
| 59 | import uk.ac.ox.cs.pagoda.util.Namespace; | 14 | import uk.ac.ox.cs.pagoda.util.Namespace; |
| 60 | import uk.ac.ox.cs.pagoda.util.Utility; | 15 | import uk.ac.ox.cs.pagoda.util.Utility; |
| 61 | 16 | ||
| 17 | import java.io.*; | ||
| 18 | import java.nio.file.Paths; | ||
| 19 | import java.util.*; | ||
| 20 | |||
| 62 | public class RLPlusOntology implements KnowledgeBase { | 21 | public 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 | ||
