-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #533 from balhoff/issue-518
Some refactoring of ReasonOperation.
- Loading branch information
Showing
7 changed files
with
288 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...main/java/org/obolibrary/robot/reason/InferredClassAssertionAxiomGeneratorDirectOnly.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.obolibrary.robot.reason; | ||
|
||
import java.util.Set; | ||
import javax.annotation.Nonnull; | ||
import org.semanticweb.owlapi.model.OWLClass; | ||
import org.semanticweb.owlapi.model.OWLClassAssertionAxiom; | ||
import org.semanticweb.owlapi.model.OWLDataFactory; | ||
import org.semanticweb.owlapi.model.OWLNamedIndividual; | ||
import org.semanticweb.owlapi.reasoner.OWLReasoner; | ||
import org.semanticweb.owlapi.util.InferredIndividualAxiomGenerator; | ||
|
||
/** An InferredAxiomGenerator which returns only direct class assettion axioms. */ | ||
public class InferredClassAssertionAxiomGeneratorDirectOnly | ||
extends InferredIndividualAxiomGenerator<OWLClassAssertionAxiom> { | ||
|
||
@Override | ||
protected void addAxioms( | ||
@Nonnull OWLNamedIndividual entity, | ||
@Nonnull OWLReasoner reasoner, | ||
@Nonnull OWLDataFactory dataFactory, | ||
@Nonnull Set<OWLClassAssertionAxiom> result) { | ||
for (OWLClass type : reasoner.getTypes(entity, true).getFlattened()) { | ||
result.add(dataFactory.getOWLClassAssertionAxiom(type, entity)); | ||
} | ||
} | ||
|
||
@Override | ||
public String getLabel() { | ||
return "Class assertions (individual direct types)"; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...ain/java/org/obolibrary/robot/reason/InferredSubClassAxiomGeneratorIncludingIndirect.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.obolibrary.robot.reason; | ||
|
||
import java.util.Set; | ||
import javax.annotation.Nonnull; | ||
import org.semanticweb.owlapi.model.OWLClass; | ||
import org.semanticweb.owlapi.model.OWLDataFactory; | ||
import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; | ||
import org.semanticweb.owlapi.reasoner.OWLReasoner; | ||
import org.semanticweb.owlapi.util.InferredClassAxiomGenerator; | ||
|
||
/** An InferredAxiomGenerator which returns both direct and indirect inferred subclass axioms. */ | ||
public class InferredSubClassAxiomGeneratorIncludingIndirect | ||
extends InferredClassAxiomGenerator<OWLSubClassOfAxiom> { | ||
|
||
@Override | ||
protected void addAxioms( | ||
@Nonnull OWLClass entity, | ||
@Nonnull OWLReasoner reasoner, | ||
@Nonnull OWLDataFactory dataFactory, | ||
@Nonnull Set<OWLSubClassOfAxiom> result) { | ||
if (reasoner.isSatisfiable(entity)) { | ||
for (OWLClass superclass : reasoner.getSuperClasses(entity, false).getFlattened()) { | ||
result.add(dataFactory.getOWLSubClassOfAxiom(entity, superclass)); | ||
} | ||
} else { | ||
result.add(dataFactory.getOWLSubClassOfAxiom(entity, dataFactory.getOWLNothing())); | ||
} | ||
} | ||
|
||
@Override | ||
public String getLabel() { | ||
return "Subclasses including indirect"; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...org/obolibrary/robot/reason/InferredSubObjectPropertyAxiomGeneratorIncludingIndirect.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.obolibrary.robot.reason; | ||
|
||
import java.util.Set; | ||
import javax.annotation.Nonnull; | ||
import org.semanticweb.owlapi.model.OWLDataFactory; | ||
import org.semanticweb.owlapi.model.OWLObjectProperty; | ||
import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; | ||
import org.semanticweb.owlapi.model.OWLSubObjectPropertyOfAxiom; | ||
import org.semanticweb.owlapi.reasoner.OWLReasoner; | ||
import org.semanticweb.owlapi.util.InferredObjectPropertyAxiomGenerator; | ||
|
||
/** | ||
* An InferredAxiomGenerator which returns both direct and indirect inferred subobjectproperty | ||
* axioms. | ||
*/ | ||
public class InferredSubObjectPropertyAxiomGeneratorIncludingIndirect | ||
extends InferredObjectPropertyAxiomGenerator<OWLSubObjectPropertyOfAxiom> { | ||
|
||
@Override | ||
protected void addAxioms( | ||
@Nonnull OWLObjectProperty entity, | ||
@Nonnull OWLReasoner reasoner, | ||
@Nonnull OWLDataFactory dataFactory, | ||
@Nonnull Set<OWLSubObjectPropertyOfAxiom> result, | ||
@Nonnull Set<OWLObjectPropertyExpression> nonSimpleProperties) { | ||
for (OWLObjectPropertyExpression prop : | ||
reasoner.getSuperObjectProperties(entity, false).getFlattened()) { | ||
result.add(dataFactory.getOWLSubObjectPropertyOfAxiom(entity, prop)); | ||
} | ||
} | ||
|
||
@Override | ||
public String getLabel() { | ||
return "Sub object properties including indirect"; | ||
} | ||
} |
Oops, something went wrong.