diff options
| author | Federico Igne <federico.igne@cs.ox.ac.uk> | 2022-05-18 15:09:37 +0100 |
|---|---|---|
| committer | Federico Igne <federico.igne@cs.ox.ac.uk> | 2022-05-18 15:38:25 +0100 |
| commit | 537277d9ce3ba2aff1d66d1b19dbb77e17be0d48 (patch) | |
| tree | d82884a5a72c7a8741084f7f324770d6b2e3489e | |
| parent | 52bba67e640fb1e30817fd1114a54e1d38ad5a74 (diff) | |
| download | ACQuA-537277d9ce3ba2aff1d66d1b19dbb77e17be0d48.tar.gz ACQuA-537277d9ce3ba2aff1d66d1b19dbb77e17be0d48.zip | |
build(hermit): bump HermiT v1.3.8.1 -> v1.4.5.519
This commit contains a "hacky" fix for KARMA2 to access some (now
private) field in the OWLAxioms class. The code is now using Java
Reflections to turn a private field public and gain access to internal
resources.
9 files changed, 53 insertions, 19 deletions
| @@ -54,9 +54,12 @@ | |||
| 54 | <version>1.3</version> | 54 | <version>1.3</version> |
| 55 | </dependency> | 55 | </dependency> |
| 56 | <dependency> | 56 | <dependency> |
| 57 | <groupId>com.hermit-reasoner</groupId> | 57 | <groupId>net.sourceforge.owlapi</groupId> |
| 58 | <artifactId>org.semanticweb.hermit</artifactId> | 58 | <artifactId>org.semanticweb.hermit</artifactId> |
| 59 | <version>1.3.8.1</version> | 59 | <version>1.4.5.519</version> |
| 60 | <!-- <groupId>com.hermit-reasoner</groupId> --> | ||
| 61 | <!-- <artifactId>org.semanticweb.hermit</artifactId> --> | ||
| 62 | <!-- <version>1.3.8.1</version> --> | ||
| 60 | </dependency> | 63 | </dependency> |
| 61 | <dependency> | 64 | <dependency> |
| 62 | <groupId>net.sourceforge.owlapi</groupId> | 65 | <groupId>net.sourceforge.owlapi</groupId> |
diff --git a/src/main/java/org/semanticweb/karma2/clausifier/OntologyProcesser.java b/src/main/java/org/semanticweb/karma2/clausifier/OntologyProcesser.java index 5ff339e..8e97a2f 100644 --- a/src/main/java/org/semanticweb/karma2/clausifier/OntologyProcesser.java +++ b/src/main/java/org/semanticweb/karma2/clausifier/OntologyProcesser.java | |||
| @@ -12,6 +12,7 @@ import java.util.HashSet; | |||
| 12 | import java.util.LinkedHashSet; | 12 | import java.util.LinkedHashSet; |
| 13 | import java.util.List; | 13 | import java.util.List; |
| 14 | import java.util.Set; | 14 | import java.util.Set; |
| 15 | import java.lang.reflect.*; | ||
| 15 | 16 | ||
| 16 | import org.semanticweb.HermiT.model.Atom; | 17 | import org.semanticweb.HermiT.model.Atom; |
| 17 | import org.semanticweb.HermiT.model.AtomicConcept; | 18 | import org.semanticweb.HermiT.model.AtomicConcept; |
| @@ -196,21 +197,46 @@ public class OntologyProcesser { | |||
| 196 | public void clausify(OWLDataFactory factory,String ontologyIRI,OWLAxioms axioms,OWLAxiomsExpressivity axiomsExpressivity, File dataFile, File ruleFile) { | 197 | public void clausify(OWLDataFactory factory,String ontologyIRI,OWLAxioms axioms,OWLAxiomsExpressivity axiomsExpressivity, File dataFile, File ruleFile) { |
| 197 | Set<DLClause> dlClauses=new LinkedHashSet<DLClause>(); | 198 | Set<DLClause> dlClauses=new LinkedHashSet<DLClause>(); |
| 198 | Set<Atom> positiveFacts=new HashSet<Atom>(); | 199 | Set<Atom> positiveFacts=new HashSet<Atom>(); |
| 199 | for (OWLObjectPropertyExpression[] inclusion : axioms.m_simpleObjectPropertyInclusions) { | 200 | /* Quick fix (using Java reflexions) to access some fields that became private in later versions. |
| 200 | Atom subRoleAtom=getRoleAtom(inclusion[0],X,Y); | 201 | * TODO: find how to properly do this... don't be that guy! |
| 201 | Atom superRoleAtom=getRoleAtom(inclusion[1],X,Y); | 202 | */ |
| 203 | Field f_simpleObjectPropertyInclusions; | ||
| 204 | Field f_conceptInclusions; | ||
| 205 | Field f_facts; | ||
| 206 | Collection<List<OWLObjectPropertyExpression>> m_simpleObjectPropertyInclusions; | ||
| 207 | Collection<List<OWLClassExpression>> m_conceptInclusions; | ||
| 208 | Collection<OWLIndividualAxiom> m_facts; | ||
| 209 | try { | ||
| 210 | f_simpleObjectPropertyInclusions = axioms.getClass().getDeclaredField("m_simpleObjectPropertyInclusions"); | ||
| 211 | f_simpleObjectPropertyInclusions.setAccessible(true); | ||
| 212 | f_conceptInclusions = axioms.getClass().getDeclaredField("m_conceptInclusions"); | ||
| 213 | f_conceptInclusions.setAccessible(true); | ||
| 214 | f_facts = axioms.getClass().getDeclaredField("m_facts"); | ||
| 215 | f_facts.setAccessible(true); | ||
| 216 | m_simpleObjectPropertyInclusions = (Collection<List<OWLObjectPropertyExpression>>) f_simpleObjectPropertyInclusions.get(axioms); | ||
| 217 | m_conceptInclusions = (Collection<List<OWLClassExpression>>) f_conceptInclusions.get(axioms); | ||
| 218 | m_facts = (Collection<OWLIndividualAxiom>) f_facts.get(axioms); | ||
| 219 | } catch (java.lang.NoSuchFieldException e) { | ||
| 220 | return; | ||
| 221 | } catch (java.lang.IllegalAccessException e) { | ||
| 222 | return; | ||
| 223 | } | ||
| 224 | |||
| 225 | for (List<OWLObjectPropertyExpression> inclusion : m_simpleObjectPropertyInclusions) { | ||
| 226 | Atom subRoleAtom=getRoleAtom(inclusion.get(0),X,Y); | ||
| 227 | Atom superRoleAtom=getRoleAtom(inclusion.get(1),X,Y); | ||
| 202 | DLClause dlClause=DLClause.create(new Atom[] { superRoleAtom },new Atom[] { subRoleAtom }); | 228 | DLClause dlClause=DLClause.create(new Atom[] { superRoleAtom },new Atom[] { subRoleAtom }); |
| 203 | dlClauses.add(dlClause); | 229 | dlClauses.add(dlClause); |
| 204 | } | 230 | } |
| 205 | NormalizedDatalogAxiomClausifier clausifier=new NormalizedDatalogAxiomClausifier(positiveFacts,factory); | 231 | NormalizedDatalogAxiomClausifier clausifier=new NormalizedDatalogAxiomClausifier(positiveFacts,factory); |
| 206 | for (OWLClassExpression[] inclusion : axioms.m_conceptInclusions) { | 232 | for (List<OWLClassExpression> inclusion : m_conceptInclusions) { |
| 207 | for (OWLClassExpression description : inclusion) | 233 | for (OWLClassExpression description : inclusion) |
| 208 | description.accept(clausifier); | 234 | description.accept(clausifier); |
| 209 | for(DLClause dlClause :clausifier.getDLClause()) | 235 | for(DLClause dlClause :clausifier.getDLClause()) |
| 210 | dlClauses.add(dlClause.getSafeVersion(AtomicConcept.THING)); | 236 | dlClauses.add(dlClause.getSafeVersion(AtomicConcept.THING)); |
| 211 | } | 237 | } |
| 212 | DatalogFactClausifier factClausifier=new DatalogFactClausifier(positiveFacts); | 238 | DatalogFactClausifier factClausifier=new DatalogFactClausifier(positiveFacts); |
| 213 | for (OWLIndividualAxiom fact : axioms.m_facts) | 239 | for (OWLIndividualAxiom fact : m_facts) |
| 214 | fact.accept(factClausifier); | 240 | fact.accept(factClausifier); |
| 215 | writeDataFile(positiveFacts, dataFile); | 241 | writeDataFile(positiveFacts, dataFile); |
| 216 | writeRules(dlClauses, ruleFile); | 242 | writeRules(dlClauses, ruleFile); |
diff --git a/src/main/java/uk/ac/ox/cs/pagoda/reasoner/HermiTReasoner.java b/src/main/java/uk/ac/ox/cs/pagoda/reasoner/HermiTReasoner.java index ac62488..ebf1960 100644 --- a/src/main/java/uk/ac/ox/cs/pagoda/reasoner/HermiTReasoner.java +++ b/src/main/java/uk/ac/ox/cs/pagoda/reasoner/HermiTReasoner.java | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.reasoner; | 1 | package uk.ac.ox.cs.pagoda.reasoner; |
| 2 | 2 | ||
| 3 | import org.semanticweb.HermiT.Configuration; | ||
| 3 | import org.semanticweb.HermiT.Reasoner; | 4 | import org.semanticweb.HermiT.Reasoner; |
| 4 | import org.semanticweb.owlapi.model.*; | 5 | import org.semanticweb.owlapi.model.*; |
| 5 | import uk.ac.ox.cs.JRDFox.model.Individual; | 6 | import uk.ac.ox.cs.JRDFox.model.Individual; |
| @@ -63,7 +64,7 @@ class HermiTReasoner extends QueryReasoner { | |||
| 63 | factory = onto.getOWLOntologyManager().getOWLDataFactory(); | 64 | factory = onto.getOWLOntologyManager().getOWLDataFactory(); |
| 64 | roller = new QueryRoller(factory); | 65 | roller = new QueryRoller(factory); |
| 65 | 66 | ||
| 66 | hermit = new Reasoner(onto); | 67 | hermit = new Reasoner(new Configuration(), onto); |
| 67 | return isConsistent(); | 68 | return isConsistent(); |
| 68 | } | 69 | } |
| 69 | 70 | ||
diff --git a/src/main/java/uk/ac/ox/cs/pagoda/reasoner/full/HermitChecker.java b/src/main/java/uk/ac/ox/cs/pagoda/reasoner/full/HermitChecker.java index 3f3c22d..fb7e062 100644 --- a/src/main/java/uk/ac/ox/cs/pagoda/reasoner/full/HermitChecker.java +++ b/src/main/java/uk/ac/ox/cs/pagoda/reasoner/full/HermitChecker.java | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.reasoner.full; | 1 | package uk.ac.ox.cs.pagoda.reasoner.full; |
| 2 | 2 | ||
| 3 | import org.semanticweb.HermiT.Configuration; | ||
| 3 | import org.semanticweb.HermiT.Reasoner; | 4 | import org.semanticweb.HermiT.Reasoner; |
| 4 | import org.semanticweb.HermiT.model.DLClause; | 5 | import org.semanticweb.HermiT.model.DLClause; |
| 5 | import org.semanticweb.HermiT.model.Term; | 6 | import org.semanticweb.HermiT.model.Term; |
| @@ -57,7 +58,7 @@ public class HermitChecker extends Checker { | |||
| 57 | // record = other.record; | 58 | // record = other.record; |
| 58 | } | 59 | } |
| 59 | 60 | ||
| 60 | hermit = new Reasoner(ontology); | 61 | hermit = new Reasoner(new Configuration(), ontology); |
| 61 | } | 62 | } |
| 62 | 63 | ||
| 63 | public HermitChecker(OWLOntology ontology, QueryRecord record, boolean toCheck) { | 64 | public HermitChecker(OWLOntology ontology, QueryRecord record, boolean toCheck) { |
| @@ -174,12 +175,12 @@ public class HermitChecker extends Checker { | |||
| 174 | addTopAndBotTuple(topAxioms, botAxioms); | 175 | addTopAndBotTuple(topAxioms, botAxioms); |
| 175 | manager.addAxioms(ontology, topAxioms); | 176 | manager.addAxioms(ontology, topAxioms); |
| 176 | manager.addAxioms(ontology, botAxioms); | 177 | manager.addAxioms(ontology, botAxioms); |
| 177 | hermit = new Reasoner(ontology); | 178 | hermit = new Reasoner(new Configuration(), ontology); |
| 178 | boolean topValid = true; | 179 | boolean topValid = true; |
| 179 | if(!hermit.isConsistent() || topAnswerTuple != null && (topValid = check(topAnswerTuple))) { | 180 | if(!hermit.isConsistent() || topAnswerTuple != null && (topValid = check(topAnswerTuple))) { |
| 180 | hermit.dispose(); | 181 | hermit.dispose(); |
| 181 | manager.removeAxioms(ontology, topAxioms); | 182 | manager.removeAxioms(ontology, topAxioms); |
| 182 | hermit = new Reasoner(ontology); | 183 | hermit = new Reasoner(new Configuration(), ontology); |
| 183 | } | 184 | } |
| 184 | else { | 185 | else { |
| 185 | if(!topValid) tag = -1; | 186 | if(!topValid) tag = -1; |
| @@ -187,7 +188,7 @@ public class HermitChecker extends Checker { | |||
| 187 | } | 188 | } |
| 188 | } | 189 | } |
| 189 | else | 190 | else |
| 190 | hermit = new Reasoner(ontology); | 191 | hermit = new Reasoner(new Configuration(), ontology); |
| 191 | } | 192 | } |
| 192 | 193 | ||
| 193 | private void addTopAndBotTuple(Set<OWLAxiom> topAxioms, Set<OWLAxiom> botAxioms) { | 194 | private void addTopAndBotTuple(Set<OWLAxiom> topAxioms, Set<OWLAxiom> botAxioms) { |
diff --git a/src/main/java/uk/ac/ox/cs/pagoda/rules/LowerDatalogProgram.java b/src/main/java/uk/ac/ox/cs/pagoda/rules/LowerDatalogProgram.java index a2676e8..2610652 100644 --- a/src/main/java/uk/ac/ox/cs/pagoda/rules/LowerDatalogProgram.java +++ b/src/main/java/uk/ac/ox/cs/pagoda/rules/LowerDatalogProgram.java | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.rules; | 1 | package uk.ac.ox.cs.pagoda.rules; |
| 2 | 2 | ||
| 3 | import org.apache.commons.io.FilenameUtils; | 3 | import org.apache.commons.io.FilenameUtils; |
| 4 | import org.semanticweb.HermiT.Configuration; | ||
| 4 | import org.semanticweb.HermiT.Reasoner; | 5 | import org.semanticweb.HermiT.Reasoner; |
| 5 | import org.semanticweb.HermiT.model.*; | 6 | import org.semanticweb.HermiT.model.*; |
| 6 | import org.semanticweb.owlapi.model.*; | 7 | import org.semanticweb.owlapi.model.*; |
| @@ -149,7 +150,7 @@ class ClassifyThread extends Thread { | |||
| 149 | public void run() { | 150 | public void run() { |
| 150 | ontology = m_program.getOntology(); | 151 | ontology = m_program.getOntology(); |
| 151 | try { | 152 | try { |
| 152 | hermitReasoner = new Reasoner(ontology); | 153 | hermitReasoner = new Reasoner(new Configuration(), ontology); |
| 153 | Timer t = new Timer(); | 154 | Timer t = new Timer(); |
| 154 | hermitReasoner.classifyClasses(); | 155 | hermitReasoner.classifyClasses(); |
| 155 | Utility.logInfo("HermiT classification done: " + t.duration()); | 156 | Utility.logInfo("HermiT classification done: " + t.duration()); |
| @@ -235,4 +236,4 @@ class ClassifyThread extends Thread { | |||
| 235 | private Atom getAtom(OWLClass c) { | 236 | private Atom getAtom(OWLClass c) { |
| 236 | return Atom.create(AtomicConcept.create(c.toStringID()), X); | 237 | return Atom.create(AtomicConcept.create(c.toStringID()), X); |
| 237 | } | 238 | } |
| 238 | } \ No newline at end of file | 239 | } |
diff --git a/src/main/java/uk/ac/ox/cs/pagoda/rules/Program.java b/src/main/java/uk/ac/ox/cs/pagoda/rules/Program.java index de06f52..22eb9ec 100644 --- a/src/main/java/uk/ac/ox/cs/pagoda/rules/Program.java +++ b/src/main/java/uk/ac/ox/cs/pagoda/rules/Program.java | |||
| @@ -273,7 +273,7 @@ protected PredicateDependency dependencyGraph; | |||
| 273 | Utility.logInfo("The number of data property range axioms that are ignored: " + noOfDataPropertyRangeAxioms + "(" + noOfAxioms + ")"); | 273 | Utility.logInfo("The number of data property range axioms that are ignored: " + noOfDataPropertyRangeAxioms + "(" + noOfAxioms + ")"); |
| 274 | 274 | ||
| 275 | DLOntology dlOntology = (DLOntology) clausifier.preprocessAndClausify(filteredOntology, null)[1]; | 275 | DLOntology dlOntology = (DLOntology) clausifier.preprocessAndClausify(filteredOntology, null)[1]; |
| 276 | dlClauses = dlOntology.getDLClauses(); | 276 | dlClauses = new HashSet<DLClause>(dlOntology.getDLClauses()); |
| 277 | positiveFacts = dlOntology.getPositiveFacts(); | 277 | positiveFacts = dlOntology.getPositiveFacts(); |
| 278 | } | 278 | } |
| 279 | 279 | ||
diff --git a/src/test/java/uk/ac/ox/cs/hermit/HermitQueryReasoner.java b/src/test/java/uk/ac/ox/cs/hermit/HermitQueryReasoner.java index 957790f..a98acba 100644 --- a/src/test/java/uk/ac/ox/cs/hermit/HermitQueryReasoner.java +++ b/src/test/java/uk/ac/ox/cs/hermit/HermitQueryReasoner.java | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | package uk.ac.ox.cs.hermit; | 1 | package uk.ac.ox.cs.hermit; |
| 2 | 2 | ||
| 3 | import org.semanticweb.HermiT.Configuration; | ||
| 3 | import org.semanticweb.HermiT.Reasoner; | 4 | import org.semanticweb.HermiT.Reasoner; |
| 4 | import org.semanticweb.HermiT.model.Atom; | 5 | import org.semanticweb.HermiT.model.Atom; |
| 5 | import org.semanticweb.HermiT.model.AtomicRole; | 6 | import org.semanticweb.HermiT.model.AtomicRole; |
| @@ -75,7 +76,7 @@ public class HermitQueryReasoner { | |||
| 75 | // for (OWLAxiom axiom: o.getAxioms()) | 76 | // for (OWLAxiom axiom: o.getAxioms()) |
| 76 | // System.out.println(axiom); | 77 | // System.out.println(axiom); |
| 77 | 78 | ||
| 78 | Reasoner hermit = new Reasoner(onto); | 79 | Reasoner hermit = new Reasoner(new Configuration(), onto); |
| 79 | if (!hermit.isConsistent()) { | 80 | if (!hermit.isConsistent()) { |
| 80 | System.out.println("The ontology is inconsistent."); | 81 | System.out.println("The ontology is inconsistent."); |
| 81 | return ; | 82 | return ; |
diff --git a/src/test/java/uk/ac/ox/cs/hermit/HermitTester.java b/src/test/java/uk/ac/ox/cs/hermit/HermitTester.java index dc70284..b46360d 100644 --- a/src/test/java/uk/ac/ox/cs/hermit/HermitTester.java +++ b/src/test/java/uk/ac/ox/cs/hermit/HermitTester.java | |||
| @@ -20,7 +20,7 @@ public class HermitTester { | |||
| 20 | 20 | ||
| 21 | public static void main(String[] args) { | 21 | public static void main(String[] args) { |
| 22 | OWLOntology onto = OWLHelper.loadOntology("imported.owl"); | 22 | OWLOntology onto = OWLHelper.loadOntology("imported.owl"); |
| 23 | Reasoner hermit = new Reasoner(onto); | 23 | Reasoner hermit = new Reasoner(new Configuration(), onto); |
| 24 | OWLDataFactory f = onto.getOWLOntologyManager().getOWLDataFactory(); | 24 | OWLDataFactory f = onto.getOWLOntologyManager().getOWLDataFactory(); |
| 25 | OWLClass concept = f.getOWLClass(IRI.create("http://semantics.crl.ibm.com/univ-bench-dl.owl#Query12")); | 25 | OWLClass concept = f.getOWLClass(IRI.create("http://semantics.crl.ibm.com/univ-bench-dl.owl#Query12")); |
| 26 | 26 | ||
diff --git a/src/test/java/uk/ac/ox/cs/pagoda/summary/SummaryTester.java b/src/test/java/uk/ac/ox/cs/pagoda/summary/SummaryTester.java index 60c8ed4..f91251d 100644 --- a/src/test/java/uk/ac/ox/cs/pagoda/summary/SummaryTester.java +++ b/src/test/java/uk/ac/ox/cs/pagoda/summary/SummaryTester.java | |||
| @@ -6,6 +6,7 @@ import java.io.FileOutputStream; | |||
| 6 | import java.io.IOException; | 6 | import java.io.IOException; |
| 7 | import java.util.Scanner; | 7 | import java.util.Scanner; |
| 8 | 8 | ||
| 9 | import org.semanticweb.HermiT.Configuration; | ||
| 9 | import org.semanticweb.HermiT.Reasoner; | 10 | import org.semanticweb.HermiT.Reasoner; |
| 10 | import org.semanticweb.owlapi.model.AxiomType; | 11 | import org.semanticweb.owlapi.model.AxiomType; |
| 11 | import org.semanticweb.owlapi.model.IRI; | 12 | import org.semanticweb.owlapi.model.IRI; |
| @@ -65,7 +66,7 @@ public class SummaryTester { | |||
| 65 | OWLDataFactory factory = summary.getOWLOntologyManager().getOWLDataFactory(); | 66 | OWLDataFactory factory = summary.getOWLOntologyManager().getOWLDataFactory(); |
| 66 | QueryRoller r = new QueryRoller(factory); | 67 | QueryRoller r = new QueryRoller(factory); |
| 67 | OWLClassExpression summarisedQueryExp; | 68 | OWLClassExpression summarisedQueryExp; |
| 68 | Reasoner reasoner = new Reasoner(summary); | 69 | Reasoner reasoner = new Reasoner(new Configuration(), summary); |
| 69 | QueryManager queryManager = new QueryManager(); | 70 | QueryManager queryManager = new QueryManager(); |
| 70 | int upperBoundCounter, queryID = 0; | 71 | int upperBoundCounter, queryID = 0; |
| 71 | StringBuilder queryText = new StringBuilder(); | 72 | StringBuilder queryText = new StringBuilder(); |
