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/tracking/BottomFragmentManager.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/tracking/BottomFragmentManager.java')
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/tracking/BottomFragmentManager.java | 100 |
1 files changed, 0 insertions, 100 deletions
diff --git a/src/uk/ac/ox/cs/pagoda/tracking/BottomFragmentManager.java b/src/uk/ac/ox/cs/pagoda/tracking/BottomFragmentManager.java deleted file mode 100644 index 09915e2..0000000 --- a/src/uk/ac/ox/cs/pagoda/tracking/BottomFragmentManager.java +++ /dev/null | |||
| @@ -1,100 +0,0 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.tracking; | ||
| 2 | |||
| 3 | import java.util.HashSet; | ||
| 4 | import java.util.Set; | ||
| 5 | |||
| 6 | import org.semanticweb.HermiT.model.AtomicConcept; | ||
| 7 | import org.semanticweb.HermiT.model.AtomicRole; | ||
| 8 | import org.semanticweb.HermiT.model.DLClause; | ||
| 9 | import org.semanticweb.HermiT.model.DLPredicate; | ||
| 10 | import org.semanticweb.owlapi.model.OWLAxiom; | ||
| 11 | import org.semanticweb.owlapi.model.OWLClass; | ||
| 12 | import org.semanticweb.owlapi.model.OWLClassAssertionAxiom; | ||
| 13 | import org.semanticweb.owlapi.model.OWLDataProperty; | ||
| 14 | import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom; | ||
| 15 | import org.semanticweb.owlapi.model.OWLObjectProperty; | ||
| 16 | import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom; | ||
| 17 | |||
| 18 | import uk.ac.ox.cs.pagoda.constraints.PredicateDependency; | ||
| 19 | import uk.ac.ox.cs.pagoda.query.QueryRecord; | ||
| 20 | import uk.ac.ox.cs.pagoda.rules.ApproxProgram; | ||
| 21 | import uk.ac.ox.cs.pagoda.rules.GeneralProgram; | ||
| 22 | import uk.ac.ox.cs.pagoda.util.Utility; | ||
| 23 | |||
| 24 | public class BottomFragmentManager { | ||
| 25 | |||
| 26 | QueryRecord m_record; | ||
| 27 | GeneralProgram m_program; | ||
| 28 | PredicateDependency m_graph; | ||
| 29 | |||
| 30 | public BottomFragmentManager(QueryRecord record) { | ||
| 31 | m_record = record; | ||
| 32 | m_program = new GeneralProgram(record.getRelevantClauses(), record.getRelevantOntology()); | ||
| 33 | m_graph = m_program.buildDependencyGraph(); | ||
| 34 | } | ||
| 35 | |||
| 36 | public Set<DLClause> relevantClauses(Set<DLClause> disjuntiveRules) { | ||
| 37 | Set<DLClause> relevant = new HashSet<DLClause>(); | ||
| 38 | Set<DLClause> now = new HashSet<DLClause>(); | ||
| 39 | Set<DLClause> last = new HashSet<DLClause>(); | ||
| 40 | |||
| 41 | for (DLClause rule: disjuntiveRules) | ||
| 42 | for (DLPredicate p: m_graph.collectPredicate(rule.getHeadAtoms())) | ||
| 43 | now.addAll(m_graph.pathToBottom(p)); | ||
| 44 | |||
| 45 | while (!relevant.containsAll(now)) { | ||
| 46 | relevant.addAll(now); | ||
| 47 | last.clear(); | ||
| 48 | last = now; | ||
| 49 | now = new HashSet<DLClause>(); | ||
| 50 | |||
| 51 | for (DLClause rule: last) { | ||
| 52 | for (DLPredicate p: m_graph.collectPredicate(rule.getHeadAtoms())) | ||
| 53 | now.addAll(m_graph.pathToBottom(p)); | ||
| 54 | for (DLPredicate p: m_graph.collectPredicate(rule.getBodyAtoms())) | ||
| 55 | now.addAll(m_graph.pathTo(p)); | ||
| 56 | } | ||
| 57 | } | ||
| 58 | |||
| 59 | Utility.logDebug("There are " + relevant.size() + " clauses in the bottom fragment related to this query."); | ||
| 60 | return relevant; | ||
| 61 | } | ||
| 62 | |||
| 63 | public Set<OWLAxiom> relevantOntology(Set<DLClause> clauses, ApproxProgram upperProgram) { | ||
| 64 | Set<OWLAxiom> axioms = new HashSet<OWLAxiom>(); | ||
| 65 | Set<DLPredicate> predicates = new HashSet<DLPredicate>(); | ||
| 66 | for (DLClause clause: clauses) { | ||
| 67 | OWLAxiom axiom = upperProgram.getEquivalentAxiom(clause); | ||
| 68 | axioms.add(axiom); | ||
| 69 | predicates.addAll(m_graph.collectPredicate(clause.getHeadAtoms())); | ||
| 70 | predicates.addAll(m_graph.collectPredicate(clause.getBodyAtoms())); | ||
| 71 | } | ||
| 72 | |||
| 73 | int tboxCounter = axioms.size(); | ||
| 74 | Utility.logDebug("There are " + tboxCounter + " TBox axioms in the bottom fragment related to this query."); | ||
| 75 | String name; | ||
| 76 | for (OWLAxiom axiom: m_record.getRelevantOntology().getABoxAxioms(true)) { | ||
| 77 | if (axiom instanceof OWLClassAssertionAxiom) { | ||
| 78 | OWLClass cls = (OWLClass) ((OWLClassAssertionAxiom) axiom).getClassExpression(); | ||
| 79 | name = cls.getIRI().toString(); | ||
| 80 | if (predicates.contains(AtomicConcept.create(name))) | ||
| 81 | axioms.add(axiom); | ||
| 82 | } | ||
| 83 | else if (axiom instanceof OWLObjectPropertyAssertionAxiom) { | ||
| 84 | OWLObjectProperty prop = (OWLObjectProperty) ((OWLObjectPropertyAssertionAxiom) axiom).getProperty(); | ||
| 85 | name = prop.getIRI().toString(); | ||
| 86 | if (predicates.contains(AtomicRole.create(name))) | ||
| 87 | axioms.add(axiom); | ||
| 88 | } | ||
| 89 | else if (axiom instanceof OWLDataPropertyAssertionAxiom) { | ||
| 90 | OWLDataProperty prop = (OWLDataProperty) ((OWLDataPropertyAssertionAxiom) axiom).getProperty(); | ||
| 91 | name = prop.getIRI().toString(); | ||
| 92 | if (predicates.contains(AtomicRole.create(name))) | ||
| 93 | axioms.add(axiom); | ||
| 94 | } | ||
| 95 | } | ||
| 96 | |||
| 97 | Utility.logDebug("There are " + (axioms.size() - tboxCounter) + " ABox axioms in the bottom fragment related to this query."); | ||
| 98 | return axioms; | ||
| 99 | } | ||
| 100 | } | ||
