diff options
| author | Federico Igne <federico.igne@cs.ox.ac.uk> | 2022-05-10 18:17:06 +0100 |
|---|---|---|
| committer | Federico Igne <federico.igne@cs.ox.ac.uk> | 2022-05-11 12:34:47 +0100 |
| commit | 17bd9beaf7f358a44e5bf36a5855fe6727d506dc (patch) | |
| tree | 47e9310a0cff869d9ec017dcb2c81876407782c8 /src/uk/ac/ox/cs/pagoda/rules/ApproxProgram.java | |
| parent | 8651164cd632a5db310b457ce32d4fbc97bdc41c (diff) | |
| download | ACQuA-17bd9beaf7f358a44e5bf36a5855fe6727d506dc.tar.gz ACQuA-17bd9beaf7f358a44e5bf36a5855fe6727d506dc.zip | |
[pagoda] Move project to Scala
This commit includes a few changes:
- The repository still uses Maven to manage dependency but it is now a
Scala project.
- The code has been ported from OWLAPI 3.4.10 to 5.1.20
- A proof of concept program using both RSAComb and PAGOdA has been
added.
Diffstat (limited to 'src/uk/ac/ox/cs/pagoda/rules/ApproxProgram.java')
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/rules/ApproxProgram.java | 106 |
1 files changed, 0 insertions, 106 deletions
diff --git a/src/uk/ac/ox/cs/pagoda/rules/ApproxProgram.java b/src/uk/ac/ox/cs/pagoda/rules/ApproxProgram.java deleted file mode 100644 index acbf354..0000000 --- a/src/uk/ac/ox/cs/pagoda/rules/ApproxProgram.java +++ /dev/null | |||
| @@ -1,106 +0,0 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.rules; | ||
| 2 | |||
| 3 | import org.semanticweb.HermiT.model.DLClause; | ||
| 4 | import org.semanticweb.owlapi.model.OWLAxiom; | ||
| 5 | import org.semanticweb.owlapi.model.OWLSubPropertyChainOfAxiom; | ||
| 6 | import org.semanticweb.owlapi.model.OWLTransitiveObjectPropertyAxiom; | ||
| 7 | import uk.ac.ox.cs.pagoda.owl.OWLHelper; | ||
| 8 | import uk.ac.ox.cs.pagoda.rules.approximators.Approximator; | ||
| 9 | |||
| 10 | import java.util.*; | ||
| 11 | |||
| 12 | public abstract class ApproxProgram extends Program { | ||
| 13 | |||
| 14 | protected Approximator m_approx = null; | ||
| 15 | /** | ||
| 16 | * mapping from over-approximated DLClauses to DLClauses from the original ontology | ||
| 17 | */ | ||
| 18 | Map<DLClause, Object> correspondence = new HashMap<DLClause, Object>(); | ||
| 19 | |||
| 20 | protected ApproxProgram() { initApproximator(); } | ||
| 21 | |||
| 22 | protected abstract void initApproximator(); | ||
| 23 | |||
| 24 | @Override | ||
| 25 | public void transform() { | ||
| 26 | super.transform(); | ||
| 27 | Iterator<DLClause> iterClause = transitiveClauses.iterator(); | ||
| 28 | for (Iterator<OWLTransitiveObjectPropertyAxiom> iterAxiom = transitiveAxioms.iterator(); iterAxiom.hasNext(); ) | ||
| 29 | addCorrespondence(iterClause.next(), iterAxiom.next()); | ||
| 30 | |||
| 31 | iterClause = subPropChainClauses.iterator(); | ||
| 32 | for (Iterator<OWLSubPropertyChainOfAxiom> iterAxiom = subPropChainAxioms.iterator(); iterAxiom.hasNext(); ) | ||
| 33 | addCorrespondence(iterClause.next(), iterAxiom.next()); | ||
| 34 | } | ||
| 35 | |||
| 36 | @Override | ||
| 37 | public Collection<DLClause> convert2Clauses(DLClause clause) { | ||
| 38 | Collection<DLClause> ret = botStrategy.process(m_approx.convert(clause, clause)); | ||
| 39 | // OWLAxiom correspondingAxiom = OWLHelper.getOWLAxiom(ontology, clause); | ||
| 40 | for (DLClause newClause: ret) { | ||
| 41 | addCorrespondence(newClause, clause); | ||
| 42 | // addCorrespondence(newClause, correspondingAxiom); | ||
| 43 | } | ||
| 44 | return ret; | ||
| 45 | } | ||
| 46 | |||
| 47 | private void addCorrespondence(DLClause newClause, Object corresponding) { | ||
| 48 | Object object; | ||
| 49 | if ((object = correspondence.get(newClause)) != null) { | ||
| 50 | if (object.equals(corresponding)) | ||
| 51 | return ; | ||
| 52 | |||
| 53 | if (object instanceof DLClause) { | ||
| 54 | DLClause c1 = (DLClause) object; | ||
| 55 | if (c1.getHeadLength() == 1) return ; | ||
| 56 | DLClause c2 = (DLClause) corresponding; | ||
| 57 | if (c2.getHeadLength() == 1) { | ||
| 58 | correspondence.put(newClause, c2); | ||
| 59 | return ; | ||
| 60 | } | ||
| 61 | ClauseSet list = new ClauseSet(c1, c2); | ||
| 62 | correspondence.put(newClause, list); | ||
| 63 | } | ||
| 64 | else if (object instanceof ClauseSet){ | ||
| 65 | ClauseSet list = (ClauseSet) object; | ||
| 66 | list.add((DLClause) corresponding); | ||
| 67 | } | ||
| 68 | } | ||
| 69 | correspondence.put(newClause, corresponding); | ||
| 70 | } | ||
| 71 | |||
| 72 | public OWLAxiom getEquivalentAxiom(DLClause clause) { | ||
| 73 | Object obj = correspondence.get(clause); | ||
| 74 | while (obj != null && obj instanceof DLClause && !obj.equals(clause) && correspondence.containsKey(obj)) | ||
| 75 | obj = correspondence.get(clause); | ||
| 76 | if (obj instanceof OWLAxiom) | ||
| 77 | return (OWLAxiom) obj; | ||
| 78 | else if (obj != null) | ||
| 79 | return OWLHelper.getOWLAxiom(ontology, (DLClause) obj); | ||
| 80 | else { | ||
| 81 | return OWLHelper.getOWLAxiom(ontology, clause); | ||
| 82 | } | ||
| 83 | } | ||
| 84 | |||
| 85 | public DLClause getCorrespondingClause(DLClause clause) { | ||
| 86 | Object obj = correspondence.get(clause); | ||
| 87 | if (obj instanceof DLClause) | ||
| 88 | return (DLClause) obj; | ||
| 89 | else | ||
| 90 | return clause; | ||
| 91 | } | ||
| 92 | } | ||
| 93 | |||
| 94 | class ClauseSet extends HashSet<DLClause> { | ||
| 95 | |||
| 96 | /** | ||
| 97 | * | ||
| 98 | */ | ||
| 99 | private static final long serialVersionUID = 1L; | ||
| 100 | |||
| 101 | public ClauseSet(DLClause first, DLClause second) { | ||
| 102 | add(first); | ||
| 103 | add(second); | ||
| 104 | } | ||
| 105 | |||
| 106 | } \ No newline at end of file | ||
