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 /src/main/java/org/semanticweb/karma2/clausifier/OntologyProcesser.java | |
| 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.
Diffstat (limited to 'src/main/java/org/semanticweb/karma2/clausifier/OntologyProcesser.java')
| -rw-r--r-- | src/main/java/org/semanticweb/karma2/clausifier/OntologyProcesser.java | 36 |
1 files changed, 31 insertions, 5 deletions
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); |
