diff options
Diffstat (limited to 'src/uk/ac/ox/cs/pagoda/rules/ExistentialToDisjunctive.java')
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/rules/ExistentialToDisjunctive.java | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/src/uk/ac/ox/cs/pagoda/rules/ExistentialToDisjunctive.java b/src/uk/ac/ox/cs/pagoda/rules/ExistentialToDisjunctive.java deleted file mode 100644 index 2098f73..0000000 --- a/src/uk/ac/ox/cs/pagoda/rules/ExistentialToDisjunctive.java +++ /dev/null | |||
| @@ -1,75 +0,0 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.rules; | ||
| 2 | |||
| 3 | import org.semanticweb.HermiT.model.*; | ||
| 4 | import org.semanticweb.owlapi.model.OWLObjectProperty; | ||
| 5 | import org.semanticweb.owlapi.model.OWLOntology; | ||
| 6 | import uk.ac.ox.cs.pagoda.constraints.BottomStrategy; | ||
| 7 | import uk.ac.ox.cs.pagoda.rules.approximators.Approximator; | ||
| 8 | import uk.ac.ox.cs.pagoda.rules.approximators.OverApproxExist; | ||
| 9 | |||
| 10 | import java.util.Collection; | ||
| 11 | import java.util.HashSet; | ||
| 12 | import java.util.LinkedList; | ||
| 13 | import java.util.Set; | ||
| 14 | |||
| 15 | public class ExistentialToDisjunctive extends UpperProgram { | ||
| 16 | |||
| 17 | Set<String> inverseFuncProperties = new HashSet<String>(); | ||
| 18 | |||
| 19 | @Override | ||
| 20 | public void load(OWLOntology o, BottomStrategy bottomStrategy) { | ||
| 21 | super.load(o, bottomStrategy); | ||
| 22 | for (OWLObjectProperty prop: ontology.getObjectPropertiesInSignature(true)) | ||
| 23 | if (!(ontology.getInverseFunctionalObjectPropertyAxioms(prop).isEmpty())) | ||
| 24 | inverseFuncProperties.add(prop.getIRI().toString()); | ||
| 25 | ((RefinedOverApproxExist) m_approx).setInverseFuncProps(inverseFuncProperties); | ||
| 26 | } | ||
| 27 | |||
| 28 | @Override | ||
| 29 | protected void initApproximator() { | ||
| 30 | m_approx = new RefinedOverApproxExist(); | ||
| 31 | } | ||
| 32 | |||
| 33 | } | ||
| 34 | |||
| 35 | class RefinedOverApproxExist implements Approximator { | ||
| 36 | |||
| 37 | Approximator approxExist = new OverApproxExist(); | ||
| 38 | Set<String> inverseFuncProperties; | ||
| 39 | |||
| 40 | public void setInverseFuncProps(Set<String> set) { | ||
| 41 | inverseFuncProperties = set; | ||
| 42 | } | ||
| 43 | |||
| 44 | @Override | ||
| 45 | public Collection<DLClause> convert(DLClause clause, DLClause originalClause) { | ||
| 46 | DLPredicate p; | ||
| 47 | Collection<Atom> newHeadAtoms = new LinkedList<Atom>(); | ||
| 48 | for (Atom headAtom: clause.getHeadAtoms()) | ||
| 49 | newHeadAtoms.add(headAtom); | ||
| 50 | |||
| 51 | for (Atom headAtom: clause.getHeadAtoms()) { | ||
| 52 | p = headAtom.getDLPredicate(); | ||
| 53 | if (isAtLeastOneOnInverseFuncProperties(p)) | ||
| 54 | newHeadAtoms.add(headAtom); | ||
| 55 | } | ||
| 56 | |||
| 57 | if (newHeadAtoms.size() > clause.getHeadLength()) | ||
| 58 | clause = DLClause.create(newHeadAtoms.toArray(new Atom[0]), clause.getBodyAtoms()); | ||
| 59 | |||
| 60 | return approxExist.convert(clause, clause); | ||
| 61 | } | ||
| 62 | |||
| 63 | private boolean isAtLeastOneOnInverseFuncProperties(DLPredicate predicate) { | ||
| 64 | if (!(predicate instanceof AtLeastConcept)) | ||
| 65 | return false; | ||
| 66 | AtLeastConcept atLeast = (AtLeastConcept) predicate; | ||
| 67 | if (!(atLeast.getOnRole() instanceof AtomicRole)) | ||
| 68 | return false; | ||
| 69 | |||
| 70 | return atLeast.getNumber() == 1 && inverseFuncProperties.contains(((AtomicRole) atLeast.getOnRole()).getIRI()); | ||
| 71 | } | ||
| 72 | |||
| 73 | |||
| 74 | } | ||
| 75 | |||
