diff options
23 files changed, 508 insertions, 396 deletions
| @@ -5,4 +5,5 @@ | |||
| 5 | /testcase/ | 5 | /testcase/ |
| 6 | /*.log* | 6 | /*.log* |
| 7 | 7 | ||
| 8 | test_reports \ No newline at end of file | 8 | test_reports |
| 9 | .idea \ No newline at end of file | ||
diff --git a/src/uk/ac/ox/cs/pagoda/endomorph/Endomorph.java b/src/uk/ac/ox/cs/pagoda/endomorph/Endomorph.java index e6b50f9..cde0895 100644 --- a/src/uk/ac/ox/cs/pagoda/endomorph/Endomorph.java +++ b/src/uk/ac/ox/cs/pagoda/endomorph/Endomorph.java | |||
| @@ -1,11 +1,8 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.endomorph; | 1 | package uk.ac.ox.cs.pagoda.endomorph; |
| 2 | 2 | ||
| 3 | import java.util.Collection; | ||
| 4 | import java.util.LinkedList; | ||
| 5 | |||
| 6 | import org.semanticweb.owlapi.model.OWLOntology; | 3 | import org.semanticweb.owlapi.model.OWLOntology; |
| 7 | 4 | import uk.ac.ox.cs.pagoda.endomorph.plan.CheckPlan; | |
| 8 | import uk.ac.ox.cs.pagoda.endomorph.plan.*; | 5 | import uk.ac.ox.cs.pagoda.endomorph.plan.OpenEndPlan; |
| 9 | import uk.ac.ox.cs.pagoda.query.AnswerTuple; | 6 | import uk.ac.ox.cs.pagoda.query.AnswerTuple; |
| 10 | import uk.ac.ox.cs.pagoda.query.AnswerTuples; | 7 | import uk.ac.ox.cs.pagoda.query.AnswerTuples; |
| 11 | import uk.ac.ox.cs.pagoda.query.QueryRecord; | 8 | import uk.ac.ox.cs.pagoda.query.QueryRecord; |
| @@ -14,8 +11,12 @@ import uk.ac.ox.cs.pagoda.summary.Graph; | |||
| 14 | import uk.ac.ox.cs.pagoda.summary.NodeTuple; | 11 | import uk.ac.ox.cs.pagoda.summary.NodeTuple; |
| 15 | import uk.ac.ox.cs.pagoda.util.Timer; | 12 | import uk.ac.ox.cs.pagoda.util.Timer; |
| 16 | import uk.ac.ox.cs.pagoda.util.Utility; | 13 | import uk.ac.ox.cs.pagoda.util.Utility; |
| 14 | import uk.ac.ox.cs.pagoda.util.disposable.DisposedException; | ||
| 17 | 15 | ||
| 18 | public class Endomorph implements Checker { | 16 | import java.util.Collection; |
| 17 | import java.util.LinkedList; | ||
| 18 | |||
| 19 | public class Endomorph extends Checker { | ||
| 19 | 20 | ||
| 20 | Checker fullReasoner; | 21 | Checker fullReasoner; |
| 21 | DependencyGraph dGraph; | 22 | DependencyGraph dGraph; |
| @@ -36,6 +37,8 @@ public class Endomorph implements Checker { | |||
| 36 | 37 | ||
| 37 | @Override | 38 | @Override |
| 38 | public int check(AnswerTuples answerTuples) { | 39 | public int check(AnswerTuples answerTuples) { |
| 40 | if(isDisposed()) throw new DisposedException(); | ||
| 41 | |||
| 39 | Collection<NodeTuple> nodes = new LinkedList<NodeTuple>(); | 42 | Collection<NodeTuple> nodes = new LinkedList<NodeTuple>(); |
| 40 | int counter = 0; | 43 | int counter = 0; |
| 41 | 44 | ||
| @@ -62,33 +65,47 @@ public class Endomorph implements Checker { | |||
| 62 | } | 65 | } |
| 63 | 66 | ||
| 64 | public OWLOntology getOntology() { | 67 | public OWLOntology getOntology() { |
| 68 | if(isDisposed()) throw new DisposedException(); | ||
| 69 | |||
| 65 | return m_record.getRelevantOntology(); | 70 | return m_record.getRelevantOntology(); |
| 66 | } | 71 | } |
| 67 | 72 | ||
| 68 | @Override | 73 | @Override |
| 69 | public boolean check(AnswerTuple answerTuple) { | 74 | public boolean check(AnswerTuple answerTuple) { |
| 75 | if(isDisposed()) throw new DisposedException(); | ||
| 76 | |||
| 70 | return fullReasoner.check(answerTuple); | 77 | return fullReasoner.check(answerTuple); |
| 71 | } | 78 | } |
| 72 | 79 | ||
| 73 | @Override | 80 | @Override |
| 74 | public boolean isConsistent() { | 81 | public boolean isConsistent() { |
| 82 | if(isDisposed()) throw new DisposedException(); | ||
| 83 | |||
| 75 | return fullReasoner.isConsistent(); | 84 | return fullReasoner.isConsistent(); |
| 76 | } | 85 | } |
| 77 | 86 | ||
| 78 | @Override | 87 | @Override |
| 79 | public void dispose() { | 88 | public void dispose() { |
| 89 | super.dispose(); | ||
| 90 | |||
| 80 | fullReasoner.dispose(); | 91 | fullReasoner.dispose(); |
| 81 | } | 92 | } |
| 82 | 93 | ||
| 83 | public Graph getGraph() { | 94 | public Graph getGraph() { |
| 95 | if(isDisposed()) throw new DisposedException(); | ||
| 96 | |||
| 84 | return graph; | 97 | return graph; |
| 85 | } | 98 | } |
| 86 | 99 | ||
| 87 | public Checker getChecker() { | 100 | public Checker getChecker() { |
| 101 | if(isDisposed()) throw new DisposedException(); | ||
| 102 | |||
| 88 | return fullReasoner; | 103 | return fullReasoner; |
| 89 | } | 104 | } |
| 90 | 105 | ||
| 91 | public DependencyGraph getDependencyGraph() { | 106 | public DependencyGraph getDependencyGraph() { |
| 107 | if(isDisposed()) throw new DisposedException(); | ||
| 108 | |||
| 92 | return dGraph; | 109 | return dGraph; |
| 93 | } | 110 | } |
| 94 | 111 | ||
diff --git a/src/uk/ac/ox/cs/pagoda/multistage/LimitedSkolemisationApplication.java b/src/uk/ac/ox/cs/pagoda/multistage/LimitedSkolemisationApplication.java index b548d39..efcf9ba 100644 --- a/src/uk/ac/ox/cs/pagoda/multistage/LimitedSkolemisationApplication.java +++ b/src/uk/ac/ox/cs/pagoda/multistage/LimitedSkolemisationApplication.java | |||
| @@ -9,8 +9,12 @@ public class LimitedSkolemisationApplication extends RestrictedApplication { | |||
| 9 | 9 | ||
| 10 | public static final int MAX_DEPTH = 1; | 10 | public static final int MAX_DEPTH = 1; |
| 11 | 11 | ||
| 12 | public LimitedSkolemisationApplication(Program program, BottomStrategy upperBottom) { | 12 | public LimitedSkolemisationApplication(Program program, BottomStrategy upperBottom, int maxDepth) { |
| 13 | super(program, upperBottom); | 13 | super(program, upperBottom); |
| 14 | m_approxExist = new LimitedSkolemisationApproximator(MAX_DEPTH); | 14 | m_approxExist = new LimitedSkolemisationApproximator(maxDepth); |
| 15 | } | ||
| 16 | |||
| 17 | public LimitedSkolemisationApplication(Program program, BottomStrategy upperBottom) { | ||
| 18 | this(program, upperBottom, MAX_DEPTH); | ||
| 15 | } | 19 | } |
| 16 | } | 20 | } |
diff --git a/src/uk/ac/ox/cs/pagoda/multistage/MultiStageQueryEngine.java b/src/uk/ac/ox/cs/pagoda/multistage/MultiStageQueryEngine.java index e1be6d2..0987279 100644 --- a/src/uk/ac/ox/cs/pagoda/multistage/MultiStageQueryEngine.java +++ b/src/uk/ac/ox/cs/pagoda/multistage/MultiStageQueryEngine.java | |||
| @@ -49,22 +49,28 @@ public class MultiStageQueryEngine extends StageQueryEngine { | |||
| 49 | RestrictedApplication program = new RestrictedApplication(generalProgram, dProgram.getUpperBottomStrategy()); | 49 | RestrictedApplication program = new RestrictedApplication(generalProgram, dProgram.getUpperBottomStrategy()); |
| 50 | Treatment treatment = new Pick4NegativeConceptNaive(this, program); | 50 | Treatment treatment = new Pick4NegativeConceptNaive(this, program); |
| 51 | int ret = materialise(program, treatment, gap); | 51 | int ret = materialise(program, treatment, gap); |
| 52 | treatment.dispose(); // does nothing | 52 | treatment.dispose(); // FIXME does nothing |
| 53 | return ret; | 53 | return ret; |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | public int materialise4SpecificQuery(Program generalProgram, QueryRecord record, BottomStrategy upperBottom) { | 56 | /** |
| 57 | * delta-chase | ||
| 58 | */ | ||
| 59 | public int materialiseSkolemly(DatalogProgram dProgram, GapByStore4ID gap, int maxTermDepth) { | ||
| 57 | if(isDisposed()) throw new DisposedException(); | 60 | if(isDisposed()) throw new DisposedException(); |
| 58 | 61 | ||
| 59 | RestrictedApplication program = new RestrictedApplication(generalProgram, upperBottom); | 62 | materialise("lower program", dProgram.getLower().toString()); |
| 60 | Treatment treatment = new Pick4NegativeConceptQuerySpecific(this, program, record); | 63 | Program generalProgram = dProgram.getGeneral(); |
| 61 | int ret = materialise(program, treatment, null); | 64 | LimitedSkolemisationApplication program = |
| 62 | treatment.dispose(); | 65 | new LimitedSkolemisationApplication(generalProgram, |
| 63 | return ret; | 66 | dProgram.getUpperBottomStrategy(), |
| 67 | maxTermDepth); | ||
| 68 | Treatment treatment = new Pick4NegativeConceptNaive(this, program); | ||
| 69 | return materialise(program, treatment, gap); | ||
| 64 | } | 70 | } |
| 65 | 71 | ||
| 66 | /** | 72 | /** |
| 67 | * delta-chase | 73 | * delta-chase with fixed mad term depth |
| 68 | */ | 74 | */ |
| 69 | @Override | 75 | @Override |
| 70 | public int materialiseSkolemly(DatalogProgram dProgram, GapByStore4ID gap) { | 76 | public int materialiseSkolemly(DatalogProgram dProgram, GapByStore4ID gap) { |
| @@ -78,6 +84,16 @@ public class MultiStageQueryEngine extends StageQueryEngine { | |||
| 78 | return materialise(program, treatment, gap); | 84 | return materialise(program, treatment, gap); |
| 79 | } | 85 | } |
| 80 | 86 | ||
| 87 | public int materialise4SpecificQuery(Program generalProgram, QueryRecord record, BottomStrategy upperBottom) { | ||
| 88 | if(isDisposed()) throw new DisposedException(); | ||
| 89 | |||
| 90 | RestrictedApplication program = new RestrictedApplication(generalProgram, upperBottom); | ||
| 91 | Treatment treatment = new Pick4NegativeConceptQuerySpecific(this, program, record); | ||
| 92 | int ret = materialise(program, treatment, null); | ||
| 93 | treatment.dispose(); // FIXME does nothing | ||
| 94 | return ret; | ||
| 95 | } | ||
| 96 | |||
| 81 | private int materialise(MultiStageUpperProgram program, Treatment treatment, GapByStore4ID gap) { | 97 | private int materialise(MultiStageUpperProgram program, Treatment treatment, GapByStore4ID gap) { |
| 82 | if(gap != null) | 98 | if(gap != null) |
| 83 | treatment.addAdditionalGapTuples(); | 99 | treatment.addAdditionalGapTuples(); |
| @@ -128,7 +144,7 @@ public class MultiStageQueryEngine extends StageQueryEngine { | |||
| 128 | 144 | ||
| 129 | if(!isValid()) { | 145 | if(!isValid()) { |
| 130 | if(iteration == 1) { | 146 | if(iteration == 1) { |
| 131 | Utility.logInfo("The ontology is inconsistent."); | 147 | Utility.logDebug("The ontology is inconsistent."); |
| 132 | return -1; | 148 | return -1; |
| 133 | } | 149 | } |
| 134 | Utility.logInfo(name + " store FAILED for multi-stage materialisation in " + t.duration() + " seconds."); | 150 | Utility.logInfo(name + " store FAILED for multi-stage materialisation in " + t.duration() + " seconds."); |
diff --git a/src/uk/ac/ox/cs/pagoda/query/QueryRecord.java b/src/uk/ac/ox/cs/pagoda/query/QueryRecord.java index 516a461..3edb2c3 100644 --- a/src/uk/ac/ox/cs/pagoda/query/QueryRecord.java +++ b/src/uk/ac/ox/cs/pagoda/query/QueryRecord.java | |||
| @@ -613,7 +613,7 @@ public class QueryRecord extends Disposable { | |||
| 613 | } | 613 | } |
| 614 | // } | 614 | // } |
| 615 | 615 | ||
| 616 | TupleBuilder result = new TupleBuilder(); | 616 | TupleBuilder<String> result = new TupleBuilder<>(); |
| 617 | result.append(extendedSelect + " " + fullyExtendedWhere); | 617 | result.append(extendedSelect + " " + fullyExtendedWhere); |
| 618 | 618 | ||
| 619 | extra.setLength(0); | 619 | extra.setLength(0); |
diff --git a/src/uk/ac/ox/cs/pagoda/query/rollup/QueryGraph.java b/src/uk/ac/ox/cs/pagoda/query/rollup/QueryGraph.java index 58d7add..a567699 100644 --- a/src/uk/ac/ox/cs/pagoda/query/rollup/QueryGraph.java +++ b/src/uk/ac/ox/cs/pagoda/query/rollup/QueryGraph.java | |||
| @@ -1,49 +1,11 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.query.rollup; | 1 | package uk.ac.ox.cs.pagoda.query.rollup; |
| 2 | 2 | ||
| 3 | import java.util.HashMap; | 3 | import org.semanticweb.HermiT.model.*; |
| 4 | import java.util.HashSet; | 4 | import org.semanticweb.owlapi.model.*; |
| 5 | import java.util.Iterator; | ||
| 6 | import java.util.Map; | ||
| 7 | import java.util.Set; | ||
| 8 | |||
| 9 | import org.semanticweb.HermiT.model.Atom; | ||
| 10 | import org.semanticweb.HermiT.model.AtomicConcept; | ||
| 11 | import org.semanticweb.HermiT.model.AtomicRole; | ||
| 12 | import org.semanticweb.HermiT.model.Constant; | ||
| 13 | import org.semanticweb.HermiT.model.Individual; | ||
| 14 | import org.semanticweb.HermiT.model.Term; | ||
| 15 | import org.semanticweb.HermiT.model.Variable; | ||
| 16 | import org.semanticweb.owlapi.model.IRI; | ||
| 17 | import org.semanticweb.owlapi.model.OWLAxiom; | ||
| 18 | import org.semanticweb.owlapi.model.OWLClass; | ||
| 19 | import org.semanticweb.owlapi.model.OWLClassExpression; | ||
| 20 | import org.semanticweb.owlapi.model.OWLClassExpressionVisitorEx; | ||
| 21 | import org.semanticweb.owlapi.model.OWLDataAllValuesFrom; | ||
| 22 | import org.semanticweb.owlapi.model.OWLDataExactCardinality; | ||
| 23 | import org.semanticweb.owlapi.model.OWLDataFactory; | ||
| 24 | import org.semanticweb.owlapi.model.OWLDataHasValue; | ||
| 25 | import org.semanticweb.owlapi.model.OWLDataMaxCardinality; | ||
| 26 | import org.semanticweb.owlapi.model.OWLDataMinCardinality; | ||
| 27 | import org.semanticweb.owlapi.model.OWLDataSomeValuesFrom; | ||
| 28 | import org.semanticweb.owlapi.model.OWLIndividual; | ||
| 29 | import org.semanticweb.owlapi.model.OWLLiteral; | ||
| 30 | import org.semanticweb.owlapi.model.OWLNamedIndividual; | ||
| 31 | import org.semanticweb.owlapi.model.OWLObjectAllValuesFrom; | ||
| 32 | import org.semanticweb.owlapi.model.OWLObjectComplementOf; | ||
| 33 | import org.semanticweb.owlapi.model.OWLObjectExactCardinality; | ||
| 34 | import org.semanticweb.owlapi.model.OWLObjectHasSelf; | ||
| 35 | import org.semanticweb.owlapi.model.OWLObjectHasValue; | ||
| 36 | import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; | ||
| 37 | import org.semanticweb.owlapi.model.OWLObjectMaxCardinality; | ||
| 38 | import org.semanticweb.owlapi.model.OWLObjectMinCardinality; | ||
| 39 | import org.semanticweb.owlapi.model.OWLObjectOneOf; | ||
| 40 | import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; | ||
| 41 | import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; | ||
| 42 | import org.semanticweb.owlapi.model.OWLObjectUnionOf; | ||
| 43 | import org.semanticweb.owlapi.model.OWLOntology; | ||
| 44 | |||
| 45 | import uk.ac.ox.cs.pagoda.util.Namespace; | 5 | import uk.ac.ox.cs.pagoda.util.Namespace; |
| 46 | 6 | ||
| 7 | import java.util.*; | ||
| 8 | |||
| 47 | public class QueryGraph { | 9 | public class QueryGraph { |
| 48 | 10 | ||
| 49 | Set<Variable> freeVars = new HashSet<Variable>(); | 11 | Set<Variable> freeVars = new HashSet<Variable>(); |
| @@ -82,168 +44,170 @@ public class QueryGraph { | |||
| 82 | 44 | ||
| 83 | rollup(); | 45 | rollup(); |
| 84 | } | 46 | } |
| 85 | |||
| 86 | private void updateExistentiallyVariables(Variable argumentVariable) { | ||
| 87 | if (freeVars.contains(argumentVariable)) return ; | ||
| 88 | existVars.add(argumentVariable); | ||
| 89 | } | ||
| 90 | 47 | ||
| 91 | public void createEdges(Term u, AtomicRole r, Term v) { | 48 | public void createEdges(Term u, AtomicRole r, Term v) { |
| 92 | if (ontology.containsDataPropertyInSignature(IRI.create(r.getIRI()))) { | 49 | if(ontology.containsDataPropertyInSignature(IRI.create(r.getIRI()))) { |
| 93 | // edges.add(u, new DataEdge(r, v)); | 50 | // edges.add(u, new DataEdge(r, v)); |
| 94 | Constant c = (Constant) v; | 51 | Constant c = (Constant) v; |
| 95 | OWLLiteral l = factory.getOWLLiteral(c.getLexicalForm(), c.getDatatypeURI()); | 52 | OWLLiteral l = factory.getOWLLiteral(c.getLexicalForm(), c.getDatatypeURI()); |
| 96 | concepts.add(u, factory.getOWLDataHasValue(factory.getOWLDataProperty(IRI.create(r.getIRI())), l)); | 53 | concepts.add(u, factory.getOWLDataHasValue(factory.getOWLDataProperty(IRI.create(r.getIRI())), l)); |
| 97 | } | 54 | } |
| 98 | else { | 55 | else { |
| 99 | boolean rollable = existVars.contains(u) || existVars.contains(v); | 56 | boolean rollable = existVars.contains(u) || existVars.contains(v); |
| 100 | 57 | ||
| 101 | ObjectEdge edge = new ObjectEdge(r, v, false); | 58 | ObjectEdge edge = new ObjectEdge(r, v, false); |
| 102 | if (rollable) { | 59 | if(rollable) { |
| 103 | rollable_edges.add(u, edge); | 60 | rollable_edges.add(u, edge); |
| 104 | edge = new ObjectEdge(r, u, true); | 61 | edge = new ObjectEdge(r, u, true); |
| 105 | rollable_edges.add(v, edge); | 62 | rollable_edges.add(v, edge); |
| 106 | } | 63 | } |
| 107 | else edges.add(u, edge); | 64 | else edges.add(u, edge); |
| 108 | 65 | ||
| 109 | } | 66 | } |
| 110 | } | 67 | } |
| 68 | |||
| 69 | public Set<OWLAxiom> getPropertyAssertions(Map<Variable, Term> assignment) { | ||
| 70 | OWLIndividual sub, obj; | ||
| 71 | Set<OWLAxiom> axioms = new HashSet<OWLAxiom>(); | ||
| 72 | for(Map.Entry<Term, Set<ObjectEdge>> entry : edges.map.entrySet()) { | ||
| 73 | sub = factory.getOWLNamedIndividual(IRI.create(getIndividual(entry.getKey(), assignment).getIRI())); | ||
| 74 | for(ObjectEdge edge : entry.getValue()) { | ||
| 75 | Individual individual = getIndividual(edge.v, assignment); | ||
| 76 | String iri = individual.getIRI(); | ||
| 77 | obj = factory.getOWLNamedIndividual(IRI.create(iri)); | ||
| 78 | axioms.add(factory.getOWLObjectPropertyAssertionAxiom(edge.p, sub, obj)); | ||
| 79 | } | ||
| 80 | } | ||
| 81 | return axioms; | ||
| 82 | } | ||
| 83 | |||
| 84 | public Set<OWLAxiom> getAssertions(Map<Variable, Term> assignment) { | ||
| 85 | if(!rollable_edges.isEmpty()) return null; | ||
| 86 | |||
| 87 | OWLIndividual sub; | ||
| 88 | Visitor visitor = new Visitor(factory, assignment); | ||
| 89 | Set<OWLAxiom> axioms = getPropertyAssertions(assignment); | ||
| 90 | for(Map.Entry<Term, Set<OWLClassExpression>> entry : concepts.map.entrySet()) { | ||
| 91 | if(existVars.contains(entry.getKey())) continue; | ||
| 92 | sub = factory.getOWLNamedIndividual(IRI.create(getIndividual(entry.getKey(), assignment).getIRI())); | ||
| 93 | for(OWLClassExpression clsExp : entry.getValue()) { | ||
| 94 | axioms.add(factory.getOWLClassAssertionAxiom(clsExp.accept(visitor), sub)); | ||
| 95 | } | ||
| 96 | } | ||
| 97 | return axioms; | ||
| 98 | } | ||
| 99 | |||
| 100 | private void updateExistentiallyVariables(Variable argumentVariable) { | ||
| 101 | if(freeVars.contains(argumentVariable)) return; | ||
| 102 | existVars.add(argumentVariable); | ||
| 103 | } | ||
| 111 | 104 | ||
| 112 | private void rollup() { | 105 | private void rollup() { |
| 113 | for (boolean updated = true; updated; ) { | 106 | for (boolean updated = true; updated; ) { |
| 114 | updated = false; | 107 | updated = false; |
| 115 | 108 | ||
| 116 | Set<ObjectEdge> set; | 109 | Set<ObjectEdge> set; |
| 117 | for (Variable var: existVars) { | 110 | for (Variable var: existVars) { |
| 118 | if ((set = rollable_edges.map.get(var)) != null && set.size() == 1) { | 111 | if ((set = rollable_edges.map.get(var)) != null && set.size() == 1) { |
| 119 | updated = true; | 112 | updated = true; |
| 120 | ObjectEdge edge = set.iterator().next(); | 113 | ObjectEdge edge = set.iterator().next(); |
| 121 | rollupEdge(edge.v, edge.p.getInverseProperty().getSimplified(), var, true); | 114 | rollupEdge(edge.v, edge.p.getInverseProperty().getSimplified(), var, true); |
| 122 | set.clear(); | 115 | set.clear(); |
| 123 | } | 116 | } |
| 124 | } | 117 | } |
| 125 | if (updated) continue; | 118 | if(updated) continue; |
| 126 | 119 | ||
| 127 | for (Variable var: existVars) { | 120 | for (Variable var: existVars) { |
| 128 | set = rollable_edges.map.get(var); | 121 | set = rollable_edges.map.get(var); |
| 129 | if (set == null) continue; | 122 | if(set == null) continue; |
| 130 | for (Iterator<ObjectEdge> iter = set.iterator(); iter.hasNext(); ) { | 123 | for (Iterator<ObjectEdge> iter = set.iterator(); iter.hasNext(); ) { |
| 131 | ObjectEdge edge = iter.next(); | 124 | ObjectEdge edge = iter.next(); |
| 132 | if (constants.contains(edge.v) || freeVars.contains(edge.v)) { | 125 | if (constants.contains(edge.v) || freeVars.contains(edge.v)) { |
| 133 | updated = true; | 126 | updated = true; |
| 134 | rollupEdge(var, edge.p, edge.v, false); | 127 | rollupEdge(var, edge.p, edge.v, false); |
| 135 | iter.remove(); | 128 | iter.remove(); |
| 136 | } | 129 | } |
| 137 | } | 130 | } |
| 138 | } | 131 | } |
| 139 | } | 132 | } |
| 140 | 133 | ||
| 141 | } | 134 | } |
| 142 | 135 | ||
| 143 | private void rollupEdge(Term u, OWLObjectPropertyExpression op, Term v, boolean inverse) { | 136 | private void rollupEdge(Term u, OWLObjectPropertyExpression op, Term v, boolean inverse) { |
| 144 | if (existVars.contains(v)) { | 137 | if (existVars.contains(v)) { |
| 145 | concepts.add(u, factory.getOWLObjectSomeValuesFrom(op, factory.getOWLObjectIntersectionOf(concepts.get(v)))); | 138 | concepts.add(u, factory.getOWLObjectSomeValuesFrom(op, factory.getOWLObjectIntersectionOf(concepts.get(v)))); |
| 146 | } | 139 | } |
| 147 | else { | 140 | else { |
| 148 | OWLIndividual obj = getOWLIndividual(v); | 141 | OWLIndividual obj = getOWLIndividual(v); |
| 149 | concepts.add(u, factory.getOWLObjectHasValue(op, obj)); | 142 | concepts.add(u, factory.getOWLObjectHasValue(op, obj)); |
| 150 | } | 143 | } |
| 151 | 144 | ||
| 152 | if (inverse) | 145 | if(inverse) |
| 153 | removeRollableEdge(u, op, v); | 146 | removeRollableEdge(u, op, v); |
| 154 | else | 147 | else |
| 155 | removeRollableEdge(v, op.getInverseProperty().getSimplified(), u); | 148 | removeRollableEdge(v, op.getInverseProperty().getSimplified(), u); |
| 156 | } | 149 | } |
| 157 | 150 | ||
| 158 | private void removeRollableEdge(Term u, OWLObjectPropertyExpression op, Term v) { | 151 | private void removeRollableEdge(Term u, OWLObjectPropertyExpression op, Term v) { |
| 159 | Set<ObjectEdge> set = rollable_edges.get(u); | 152 | Set<ObjectEdge> set = rollable_edges.get(u); |
| 160 | ObjectEdge edge; | 153 | ObjectEdge edge; |
| 161 | if (set != null) | 154 | if (set != null) |
| 162 | for (Iterator<ObjectEdge> iter = set.iterator(); iter.hasNext(); ) { | 155 | for (Iterator<ObjectEdge> iter = set.iterator(); iter.hasNext(); ) { |
| 163 | edge = iter.next(); | 156 | edge = iter.next(); |
| 164 | if (edge.p.equals(op) && edge.v.equals(v)) iter.remove(); | 157 | if(edge.p.equals(op) && edge.v.equals(v)) iter.remove(); |
| 165 | } | 158 | } |
| 166 | } | 159 | } |
| 167 | 160 | ||
| 168 | OWLNamedIndividual getOWLIndividual(Term t) { | 161 | OWLNamedIndividual getOWLIndividual(Term t) { |
| 169 | if (freeVars.contains(t)) | 162 | if (freeVars.contains(t)) |
| 170 | return new VariableIndividual((Variable) t); | 163 | return new VariableIndividual((Variable) t); |
| 171 | else if (t instanceof Variable) | 164 | else if (t instanceof Variable) |
| 172 | return null; | 165 | return null; |
| 173 | else | 166 | else |
| 174 | return factory.getOWLNamedIndividual(IRI.create(((Individual) t).getIRI())); | 167 | return factory.getOWLNamedIndividual(IRI.create(((Individual) t).getIRI())); |
| 168 | } | ||
| 169 | |||
| 170 | private Individual getIndividual(Term key, Map<Variable, Term> assignment) { | ||
| 171 | if(key instanceof Individual) | ||
| 172 | return (Individual) key; | ||
| 173 | else | ||
| 174 | return (Individual) assignment.get(key); | ||
| 175 | } | 175 | } |
| 176 | 176 | ||
| 177 | class ObjectEdge { | 177 | class ObjectEdge { |
| 178 | OWLObjectPropertyExpression p; | 178 | OWLObjectPropertyExpression p; |
| 179 | Term v; | 179 | Term v; |
| 180 | 180 | ||
| 181 | public ObjectEdge(AtomicRole r, Term t, boolean inverse) { | 181 | public ObjectEdge(AtomicRole r, Term t, boolean inverse) { |
| 182 | p = factory.getOWLObjectProperty(IRI.create(r.getIRI())); | 182 | p = factory.getOWLObjectProperty(IRI.create(r.getIRI())); |
| 183 | if (inverse) p = p.getInverseProperty(); | 183 | if(inverse) p = p.getInverseProperty(); |
| 184 | v = t; | 184 | v = t; |
| 185 | 185 | ||
| 186 | } | 186 | } |
| 187 | } | 187 | } |
| 188 | 188 | ||
| 189 | class MultiMap<K, V> { | 189 | class MultiMap<K, V> { |
| 190 | 190 | ||
| 191 | HashMap<K, Set<V>> map = new HashMap<K, Set<V>>(); | 191 | HashMap<K, Set<V>> map = new HashMap<K, Set<V>>(); |
| 192 | |||
| 193 | void add(K key, V value) { | ||
| 194 | Set<V> list = map.get(key); | ||
| 195 | if (list == null) | ||
| 196 | map.put(key, list = new HashSet<V>()); | ||
| 197 | list.add(value); | ||
| 198 | } | ||
| 199 | 192 | ||
| 200 | public Set<V> get(K v) { | 193 | public Set<V> get(K v) { |
| 201 | return map.get(v); | 194 | return map.get(v); |
| 202 | } | 195 | } |
| 203 | 196 | ||
| 204 | public boolean isEmpty() { | 197 | public boolean isEmpty() { |
| 205 | for (Map.Entry<K, Set<V>> entry: map.entrySet()) | 198 | for(Map.Entry<K, Set<V>> entry : map.entrySet()) |
| 206 | if (!entry.getValue().isEmpty()) | 199 | if(!entry.getValue().isEmpty()) |
| 207 | return false; | 200 | return false; |
| 208 | return true; | 201 | return true; |
| 209 | } | 202 | } |
| 210 | |||
| 211 | } | ||
| 212 | 203 | ||
| 213 | public Set<OWLAxiom> getPropertyAssertions(Map<Variable, Term> assignment) { | 204 | void add(K key, V value) { |
| 214 | OWLIndividual sub, obj; | 205 | Set<V> list = map.get(key); |
| 215 | Set<OWLAxiom> axioms = new HashSet<OWLAxiom>(); | 206 | if(list == null) |
| 216 | for (Map.Entry<Term, Set<ObjectEdge>> entry: edges.map.entrySet()) { | 207 | map.put(key, list = new HashSet<V>()); |
| 217 | sub = factory.getOWLNamedIndividual(IRI.create(getIndividual(entry.getKey(), assignment).getIRI())); | 208 | list.add(value); |
| 218 | for (ObjectEdge edge: entry.getValue()) { | ||
| 219 | obj = factory.getOWLNamedIndividual(IRI.create(getIndividual(edge.v, assignment).getIRI())); | ||
| 220 | axioms.add(factory.getOWLObjectPropertyAssertionAxiom(edge.p, sub, obj)); | ||
| 221 | } | ||
| 222 | } | ||
| 223 | return axioms; | ||
| 224 | } | ||
| 225 | |||
| 226 | public Set<OWLAxiom> getAssertions(Map<Variable, Term> assignment) { | ||
| 227 | if (!rollable_edges.isEmpty()) return null; | ||
| 228 | |||
| 229 | OWLIndividual sub; | ||
| 230 | Visitor visitor = new Visitor(factory, assignment); | ||
| 231 | Set<OWLAxiom> axioms = getPropertyAssertions(assignment); | ||
| 232 | for (Map.Entry<Term, Set<OWLClassExpression>> entry: concepts.map.entrySet()) { | ||
| 233 | if (existVars.contains(entry.getKey())) continue; | ||
| 234 | sub = factory.getOWLNamedIndividual(IRI.create(getIndividual(entry.getKey(), assignment).getIRI())); | ||
| 235 | for (OWLClassExpression clsExp: entry.getValue()) { | ||
| 236 | axioms.add(factory.getOWLClassAssertionAxiom(clsExp.accept(visitor), sub)); | ||
| 237 | } | ||
| 238 | } | 209 | } |
| 239 | return axioms; | ||
| 240 | } | ||
| 241 | 210 | ||
| 242 | private Individual getIndividual(Term key, Map<Variable, Term> assignment) { | ||
| 243 | if (key instanceof Individual) | ||
| 244 | return (Individual) key; | ||
| 245 | else | ||
| 246 | return (Individual) assignment.get(key); | ||
| 247 | } | 211 | } |
| 248 | } | 212 | } |
| 249 | 213 | ||
diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/ConsistencyManager.java b/src/uk/ac/ox/cs/pagoda/reasoner/ConsistencyManager.java index 453b5ca..3fd2fbd 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/ConsistencyManager.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/ConsistencyManager.java | |||
| @@ -23,6 +23,7 @@ import uk.ac.ox.cs.pagoda.tracking.TrackingRuleEncoder; | |||
| 23 | import uk.ac.ox.cs.pagoda.util.Timer; | 23 | import uk.ac.ox.cs.pagoda.util.Timer; |
| 24 | import uk.ac.ox.cs.pagoda.util.Utility; | 24 | import uk.ac.ox.cs.pagoda.util.Utility; |
| 25 | import uk.ac.ox.cs.pagoda.util.disposable.Disposable; | 25 | import uk.ac.ox.cs.pagoda.util.disposable.Disposable; |
| 26 | import uk.ac.ox.cs.pagoda.util.disposable.DisposedException; | ||
| 26 | 27 | ||
| 27 | import java.util.LinkedList; | 28 | import java.util.LinkedList; |
| 28 | 29 | ||
| @@ -49,6 +50,8 @@ public class ConsistencyManager extends Disposable { | |||
| 49 | } | 50 | } |
| 50 | 51 | ||
| 51 | public void extractBottomFragment() { | 52 | public void extractBottomFragment() { |
| 53 | if(isDisposed()) throw new DisposedException(); | ||
| 54 | |||
| 52 | if(fragmentExtracted) return; | 55 | if(fragmentExtracted) return; |
| 53 | fragmentExtracted = true; | 56 | fragmentExtracted = true; |
| 54 | 57 | ||
| @@ -141,10 +144,14 @@ public class ConsistencyManager extends Disposable { | |||
| 141 | } | 144 | } |
| 142 | 145 | ||
| 143 | public QueryRecord[] getQueryRecords() { | 146 | public QueryRecord[] getQueryRecords() { |
| 147 | if(isDisposed()) throw new DisposedException(); | ||
| 148 | |||
| 144 | return botQueryRecords; | 149 | return botQueryRecords; |
| 145 | } | 150 | } |
| 146 | 151 | ||
| 147 | boolean checkRLLowerBound() { | 152 | boolean checkRLLowerBound() { |
| 153 | if(isDisposed()) throw new DisposedException(); | ||
| 154 | |||
| 148 | fullQueryRecord = m_queryManager.create(QueryRecord.botQueryText, 0); | 155 | fullQueryRecord = m_queryManager.create(QueryRecord.botQueryText, 0); |
| 149 | AnswerTuples iter = null; | 156 | AnswerTuples iter = null; |
| 150 | 157 | ||
| @@ -175,6 +182,8 @@ public class ConsistencyManager extends Disposable { | |||
| 175 | // } | 182 | // } |
| 176 | 183 | ||
| 177 | boolean checkELLowerBound() { | 184 | boolean checkELLowerBound() { |
| 185 | if(isDisposed()) throw new DisposedException(); | ||
| 186 | |||
| 178 | fullQueryRecord.updateLowerBoundAnswers(m_reasoner.elLowerStore.evaluate(fullQueryRecord.getQueryText(), fullQueryRecord | 187 | fullQueryRecord.updateLowerBoundAnswers(m_reasoner.elLowerStore.evaluate(fullQueryRecord.getQueryText(), fullQueryRecord |
| 179 | .getAnswerVariables())); | 188 | .getAnswerVariables())); |
| 180 | if(fullQueryRecord.getNoOfSoundAnswers() > 0) { | 189 | if(fullQueryRecord.getNoOfSoundAnswers() > 0) { |
| @@ -185,6 +194,8 @@ public class ConsistencyManager extends Disposable { | |||
| 185 | } | 194 | } |
| 186 | 195 | ||
| 187 | boolean checkUpper(BasicQueryEngine upperStore) { | 196 | boolean checkUpper(BasicQueryEngine upperStore) { |
| 197 | if(isDisposed()) throw new DisposedException(); | ||
| 198 | |||
| 188 | if(upperStore != null) { | 199 | if(upperStore != null) { |
| 189 | AnswerTuples tuples = null; | 200 | AnswerTuples tuples = null; |
| 190 | try { | 201 | try { |
| @@ -202,6 +213,8 @@ public class ConsistencyManager extends Disposable { | |||
| 202 | } | 213 | } |
| 203 | 214 | ||
| 204 | boolean check() { | 215 | boolean check() { |
| 216 | if(isDisposed()) throw new DisposedException(); | ||
| 217 | |||
| 205 | // if (!checkRLLowerBound()) return false; | 218 | // if (!checkRLLowerBound()) return false; |
| 206 | // if (!checkELLowerBound()) return false; | 219 | // if (!checkELLowerBound()) return false; |
| 207 | // if (checkLazyUpper()) return true; | 220 | // if (checkLazyUpper()) return true; |
diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/ELHOQueryReasoner.java b/src/uk/ac/ox/cs/pagoda/reasoner/ELHOQueryReasoner.java index 0a151bc..cc2c4c0 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/ELHOQueryReasoner.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/ELHOQueryReasoner.java | |||
| @@ -70,7 +70,7 @@ class ELHOQueryReasoner extends QueryReasoner { | |||
| 70 | @Override | 70 | @Override |
| 71 | public boolean preprocess() { | 71 | public boolean preprocess() { |
| 72 | if(isDisposed()) throw new DisposedException(); | 72 | if(isDisposed()) throw new DisposedException(); |
| 73 | elLowerStore.importRDFData("data", importedData.toString()); | 73 | elLowerStore.importRDFData("data", getImportedData()); |
| 74 | String rlLowerProgramText = program.toString(); | 74 | String rlLowerProgramText = program.toString(); |
| 75 | // program.save(); | 75 | // program.save(); |
| 76 | elLowerStore.materialise("lower program", rlLowerProgramText); | 76 | elLowerStore.materialise("lower program", rlLowerProgramText); |
diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/ELHOUQueryReasoner.java b/src/uk/ac/ox/cs/pagoda/reasoner/ELHOUQueryReasoner.java index 771190e..a56a793 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/ELHOUQueryReasoner.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/ELHOUQueryReasoner.java | |||
| @@ -129,7 +129,7 @@ class ELHOUQueryReasoner extends QueryReasoner { | |||
| 129 | @Override | 129 | @Override |
| 130 | public boolean preprocess() { | 130 | public boolean preprocess() { |
| 131 | if(isDisposed()) throw new DisposedException(); | 131 | if(isDisposed()) throw new DisposedException(); |
| 132 | String name = "data", datafile = importedData.toString(); | 132 | String name = "data", datafile = getImportedData(); |
| 133 | 133 | ||
| 134 | String lowername = "lower program"; | 134 | String lowername = "lower program"; |
| 135 | String rlLowerProgramText = program.getLower().toString(); | 135 | String rlLowerProgramText = program.getLower().toString(); |
diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/HermiTReasoner.java b/src/uk/ac/ox/cs/pagoda/reasoner/HermiTReasoner.java index 78b9a0b..15eb9e8 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/HermiTReasoner.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/HermiTReasoner.java | |||
| @@ -46,7 +46,7 @@ class HermiTReasoner extends QueryReasoner { | |||
| 46 | if(isDisposed()) throw new DisposedException(); | 46 | if(isDisposed()) throw new DisposedException(); |
| 47 | OWLOntology tbox = onto; | 47 | OWLOntology tbox = onto; |
| 48 | try { | 48 | try { |
| 49 | onto = OWLHelper.getImportedOntology(tbox, importedData.toString().split(ImportDataFileSeparator)); | 49 | onto = OWLHelper.getImportedOntology(tbox, getImportedData().split(ImportDataFileSeparator)); |
| 50 | importedOntologyPath = OWLHelper.getOntologyPath(onto); | 50 | importedOntologyPath = OWLHelper.getOntologyPath(onto); |
| 51 | } catch(OWLOntologyCreationException | OWLOntologyStorageException | IOException e) { | 51 | } catch(OWLOntologyCreationException | OWLOntologyStorageException | IOException e) { |
| 52 | e.printStackTrace(); | 52 | e.printStackTrace(); |
| @@ -55,7 +55,7 @@ class HermiTReasoner extends QueryReasoner { | |||
| 55 | DatalogProgram datalogProgram = new DatalogProgram(tbox, false); | 55 | DatalogProgram datalogProgram = new DatalogProgram(tbox, false); |
| 56 | importData(datalogProgram.getAdditionalDataFile()); | 56 | importData(datalogProgram.getAdditionalDataFile()); |
| 57 | upperStore = new MultiStageQueryEngine("rl-upper", false); | 57 | upperStore = new MultiStageQueryEngine("rl-upper", false); |
| 58 | upperStore.importRDFData("data", importedData.toString()); | 58 | upperStore.importRDFData("data", getImportedData()); |
| 59 | GapByStore4ID gap = new GapByStore4ID(upperStore); | 59 | GapByStore4ID gap = new GapByStore4ID(upperStore); |
| 60 | upperStore.materialiseFoldedly(datalogProgram, gap); | 60 | upperStore.materialiseFoldedly(datalogProgram, gap); |
| 61 | gap.clear(); | 61 | gap.clear(); |
diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java b/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java index acdb8a3..b4e2f5a 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java | |||
| @@ -29,20 +29,22 @@ import java.util.Collection; | |||
| 29 | class MyQueryReasoner extends QueryReasoner { | 29 | class MyQueryReasoner extends QueryReasoner { |
| 30 | 30 | ||
| 31 | OWLOntology ontology; | 31 | OWLOntology ontology; |
| 32 | OWLOntology elho_ontology; | ||
| 32 | DatalogProgram program; | 33 | DatalogProgram program; |
| 33 | 34 | ||
| 34 | BasicQueryEngine rlLowerStore = null; | 35 | BasicQueryEngine rlLowerStore = null; |
| 35 | BasicQueryEngine lazyUpperStore = null; | ||
| 36 | // MultiStageQueryEngine limitedSkolemUpperStore; | ||
| 37 | OWLOntology elho_ontology; | ||
| 38 | KarmaQueryEngine elLowerStore = null; | 36 | KarmaQueryEngine elLowerStore = null; |
| 39 | BasicQueryEngine trackingStore = null; | 37 | MultiStageQueryEngine lazyUpperStore = null; |
| 38 | MultiStageQueryEngine trackingStore = null; | ||
| 40 | TrackingRuleEncoder encoder; | 39 | TrackingRuleEncoder encoder; |
| 40 | |||
| 41 | private boolean equalityTag; | 41 | private boolean equalityTag; |
| 42 | private Timer t = new Timer(); | 42 | private Timer t = new Timer(); |
| 43 | |||
| 43 | private Collection<String> predicatesWithGap = null; | 44 | private Collection<String> predicatesWithGap = null; |
| 44 | private SatisfiabilityStatus satisfiable; | 45 | private ConsistencyStatus isConsistent; |
| 45 | private ConsistencyManager consistency = new ConsistencyManager(this); | 46 | private ConsistencyManager consistency = new ConsistencyManager(this); |
| 47 | private boolean useSkolemisation = false; // now only debugging | ||
| 46 | 48 | ||
| 47 | public MyQueryReasoner() { | 49 | public MyQueryReasoner() { |
| 48 | setup(true); | 50 | setup(true); |
| @@ -92,11 +94,15 @@ class MyQueryReasoner extends QueryReasoner { | |||
| 92 | t.reset(); | 94 | t.reset(); |
| 93 | Utility.logInfo("Preprocessing (and checking satisfiability)..."); | 95 | Utility.logInfo("Preprocessing (and checking satisfiability)..."); |
| 94 | 96 | ||
| 95 | String name = "data", datafile = importedData.toString(); | 97 | String name = "data", datafile = getImportedData(); |
| 96 | rlLowerStore.importRDFData(name, datafile); | 98 | rlLowerStore.importRDFData(name, datafile); |
| 97 | rlLowerStore.materialise("lower program", program.getLower().toString()); | 99 | rlLowerStore.materialise("lower program", program.getLower().toString()); |
| 98 | // program.getLower().save(); | 100 | // program.getLower().save(); |
| 99 | if(!consistency.checkRLLowerBound()) return false; | 101 | if(!consistency.checkRLLowerBound()) { |
| 102 | Utility.logDebug("time for satisfiability checking: " + t.duration()); | ||
| 103 | isConsistent = ConsistencyStatus.INCONSISTENT; | ||
| 104 | return false; | ||
| 105 | } | ||
| 100 | Utility.logDebug("The number of sameAs assertions in RL lower store: " + rlLowerStore.getSameAsNumber()); | 106 | Utility.logDebug("The number of sameAs assertions in RL lower store: " + rlLowerStore.getSameAsNumber()); |
| 101 | 107 | ||
| 102 | String originalMarkProgram = OWLHelper.getOriginalMarkProgram(ontology); | 108 | String originalMarkProgram = OWLHelper.getOriginalMarkProgram(ontology); |
| @@ -105,20 +111,28 @@ class MyQueryReasoner extends QueryReasoner { | |||
| 105 | elLowerStore.materialise("saturate named individuals", originalMarkProgram); | 111 | elLowerStore.materialise("saturate named individuals", originalMarkProgram); |
| 106 | elLowerStore.materialise("lower program", program.getLower().toString()); | 112 | elLowerStore.materialise("lower program", program.getLower().toString()); |
| 107 | elLowerStore.initialiseKarma(); | 113 | elLowerStore.initialiseKarma(); |
| 108 | if(!consistency.checkELLowerBound()) return false; | 114 | if(!consistency.checkELLowerBound()) { |
| 115 | Utility.logDebug("time for satisfiability checking: " + t.duration()); | ||
| 116 | isConsistent = ConsistencyStatus.INCONSISTENT; | ||
| 117 | return false; | ||
| 118 | } | ||
| 109 | 119 | ||
| 110 | if(lazyUpperStore != null) { | 120 | if(lazyUpperStore != null) { |
| 111 | lazyUpperStore.importRDFData(name, datafile); | 121 | lazyUpperStore.importRDFData(name, datafile); |
| 112 | lazyUpperStore.materialise("saturate named individuals", originalMarkProgram); | 122 | lazyUpperStore.materialise("saturate named individuals", originalMarkProgram); |
| 113 | int tag = lazyUpperStore.materialiseRestrictedly(program, null); | 123 | int tag = lazyUpperStore.materialiseRestrictedly(program, null); |
| 114 | if(tag != 1) { | 124 | if(tag == -1) { |
| 125 | Utility.logDebug("time for satisfiability checking: " + t.duration()); | ||
| 126 | isConsistent = ConsistencyStatus.INCONSISTENT; | ||
| 127 | return false; | ||
| 128 | } | ||
| 129 | else if(tag != 1) { | ||
| 115 | lazyUpperStore.dispose(); | 130 | lazyUpperStore.dispose(); |
| 116 | lazyUpperStore = null; | 131 | lazyUpperStore = null; |
| 117 | } | 132 | } |
| 118 | if(tag == -1) return false; | ||
| 119 | } | 133 | } |
| 120 | if(consistency.checkUpper(lazyUpperStore)) { | 134 | if(consistency.checkUpper(lazyUpperStore)) { |
| 121 | satisfiable = SatisfiabilityStatus.SATISFIABLE; | 135 | isConsistent = ConsistencyStatus.CONSISTENT; |
| 122 | Utility.logDebug("time for satisfiability checking: " + t.duration()); | 136 | Utility.logDebug("time for satisfiability checking: " + t.duration()); |
| 123 | } | 137 | } |
| 124 | 138 | ||
| @@ -140,13 +154,12 @@ class MyQueryReasoner extends QueryReasoner { | |||
| 140 | // encoder = new TrackingRuleEncoderDisjVar2(program.getUpper(), trackingStore); | 154 | // encoder = new TrackingRuleEncoderDisjVar2(program.getUpper(), trackingStore); |
| 141 | // encoder = new TrackingRuleEncoderDisj2(program.getUpper(), trackingStore); | 155 | // encoder = new TrackingRuleEncoderDisj2(program.getUpper(), trackingStore); |
| 142 | 156 | ||
| 157 | // TODO add consistency check by Skolem-upper-bound | ||
| 158 | |||
| 143 | if(!isConsistent()) | 159 | if(!isConsistent()) |
| 144 | return false; | 160 | return false; |
| 145 | 161 | ||
| 146 | consistency.extractBottomFragment(); | 162 | consistency.extractBottomFragment(); |
| 147 | consistency.dispose(); | ||
| 148 | |||
| 149 | program.dispose(); | ||
| 150 | 163 | ||
| 151 | return true; | 164 | return true; |
| 152 | } | 165 | } |
| @@ -154,11 +167,19 @@ class MyQueryReasoner extends QueryReasoner { | |||
| 154 | @Override | 167 | @Override |
| 155 | public boolean isConsistent() { | 168 | public boolean isConsistent() { |
| 156 | if(isDisposed()) throw new DisposedException(); | 169 | if(isDisposed()) throw new DisposedException(); |
| 157 | if(satisfiable == SatisfiabilityStatus.UNCHECKED) { | 170 | |
| 158 | satisfiable = consistency.check() ? SatisfiabilityStatus.SATISFIABLE : SatisfiabilityStatus.UNSATISFIABLE; | 171 | if(isConsistent == ConsistencyStatus.UNCHECKED) { |
| 159 | Utility.logInfo("time for satisfiability checking: " + t.duration()); | 172 | isConsistent = consistency.check() ? ConsistencyStatus.CONSISTENT : ConsistencyStatus.INCONSISTENT; |
| 173 | Utility.logDebug("time for satisfiability checking: " + t.duration()); | ||
| 174 | } | ||
| 175 | if(isConsistent == ConsistencyStatus.CONSISTENT) { | ||
| 176 | Utility.logInfo("The ontology is consistent!"); | ||
| 177 | return true; | ||
| 178 | } | ||
| 179 | else { | ||
| 180 | Utility.logInfo("The ontology is inconsistent!"); | ||
| 181 | return false; | ||
| 160 | } | 182 | } |
| 161 | return satisfiable == SatisfiabilityStatus.SATISFIABLE; | ||
| 162 | } | 183 | } |
| 163 | 184 | ||
| 164 | @Override | 185 | @Override |
| @@ -169,9 +190,9 @@ class MyQueryReasoner extends QueryReasoner { | |||
| 169 | return; | 190 | return; |
| 170 | 191 | ||
| 171 | OWLOntology relevantOntologySubset = extractRelevantOntologySubset(queryRecord); | 192 | OWLOntology relevantOntologySubset = extractRelevantOntologySubset(queryRecord); |
| 172 | // queryRecord.saveRelevantOntology("fragment_query" + queryRecord.getQueryID() + ".owl"); | 193 | queryRecord.saveRelevantOntology("/home/alessandro/Desktop/fragment_query" + queryRecord.getQueryID() + ".owl"); |
| 173 | 194 | ||
| 174 | if(querySkolemisedRelevantSubset(relevantOntologySubset, queryRecord)) | 195 | if(useSkolemisation && querySkolemisedRelevantSubset(relevantOntologySubset, queryRecord)) |
| 175 | return; | 196 | return; |
| 176 | 197 | ||
| 177 | Timer t = new Timer(); | 198 | Timer t = new Timer(); |
| @@ -207,12 +228,14 @@ class MyQueryReasoner extends QueryReasoner { | |||
| 207 | if(lazyUpperStore != null) lazyUpperStore.dispose(); | 228 | if(lazyUpperStore != null) lazyUpperStore.dispose(); |
| 208 | if(elLowerStore != null) elLowerStore.dispose(); | 229 | if(elLowerStore != null) elLowerStore.dispose(); |
| 209 | if(trackingStore != null) trackingStore.dispose(); | 230 | if(trackingStore != null) trackingStore.dispose(); |
| 210 | // if(limitedSkolemUpperStore != null) limitedSkolemUpperStore.dispose(); | 231 | if(consistency != null) consistency.dispose(); |
| 232 | if(program != null) program.dispose(); | ||
| 211 | } | 233 | } |
| 212 | 234 | ||
| 213 | private void setup(boolean considerEqualities) { | 235 | private void setup(boolean considerEqualities) { |
| 214 | if(isDisposed()) throw new DisposedException(); | 236 | if(isDisposed()) throw new DisposedException(); |
| 215 | satisfiable = SatisfiabilityStatus.UNCHECKED; | 237 | |
| 238 | isConsistent = ConsistencyStatus.UNCHECKED; | ||
| 216 | this.equalityTag = considerEqualities; | 239 | this.equalityTag = considerEqualities; |
| 217 | 240 | ||
| 218 | rlLowerStore = new BasicQueryEngine("rl-lower-bound"); | 241 | rlLowerStore = new BasicQueryEngine("rl-lower-bound"); |
| @@ -239,7 +262,7 @@ class MyQueryReasoner extends QueryReasoner { | |||
| 239 | */ | 262 | */ |
| 240 | private boolean queryUpperStore(BasicQueryEngine upperStore, QueryRecord queryRecord, | 263 | private boolean queryUpperStore(BasicQueryEngine upperStore, QueryRecord queryRecord, |
| 241 | Tuple<String> extendedQuery, Step step) { | 264 | Tuple<String> extendedQuery, Step step) { |
| 242 | 265 | t.reset(); | |
| 243 | if(queryRecord.hasNonAnsDistinguishedVariables()) | 266 | if(queryRecord.hasNonAnsDistinguishedVariables()) |
| 244 | queryUpperBound(upperStore, queryRecord, extendedQuery.get(0), queryRecord.getAnswerVariables()); | 267 | queryUpperBound(upperStore, queryRecord, extendedQuery.get(0), queryRecord.getAnswerVariables()); |
| 245 | else | 268 | else |
| @@ -254,6 +277,7 @@ class MyQueryReasoner extends QueryReasoner { | |||
| 254 | } | 277 | } |
| 255 | 278 | ||
| 256 | private boolean checkGapAnswers(BasicQueryEngine relevantStore, QueryRecord queryRecord) { | 279 | private boolean checkGapAnswers(BasicQueryEngine relevantStore, QueryRecord queryRecord) { |
| 280 | t.reset(); | ||
| 257 | Tuple<String> extendedQueries = queryRecord.getExtendedQueryText(); | 281 | Tuple<String> extendedQueries = queryRecord.getExtendedQueryText(); |
| 258 | if(queryRecord.hasNonAnsDistinguishedVariables()) | 282 | if(queryRecord.hasNonAnsDistinguishedVariables()) |
| 259 | checkGapAnswers(relevantStore, queryRecord, extendedQueries.get(0), queryRecord.getAnswerVariables()); | 283 | checkGapAnswers(relevantStore, queryRecord, extendedQueries.get(0), queryRecord.getAnswerVariables()); |
| @@ -296,8 +320,6 @@ class MyQueryReasoner extends QueryReasoner { | |||
| 296 | } | 320 | } |
| 297 | queryRecord.addProcessingTime(Step.LOWER_BOUND, t.duration()); | 321 | queryRecord.addProcessingTime(Step.LOWER_BOUND, t.duration()); |
| 298 | 322 | ||
| 299 | t.reset(); | ||
| 300 | |||
| 301 | Tuple<String> extendedQueryTexts = queryRecord.getExtendedQueryText(); | 323 | Tuple<String> extendedQueryTexts = queryRecord.getExtendedQueryText(); |
| 302 | 324 | ||
| 303 | Utility.logDebug("Tracking store"); | 325 | Utility.logDebug("Tracking store"); |
| @@ -343,8 +365,6 @@ class MyQueryReasoner extends QueryReasoner { | |||
| 343 | // just statistics | 365 | // just statistics |
| 344 | int numOfABoxAxioms = relevantOntologySubset.getABoxAxioms(true).size(); | 366 | int numOfABoxAxioms = relevantOntologySubset.getABoxAxioms(true).size(); |
| 345 | int numOfTBoxAxioms = relevantOntologySubset.getAxiomCount() - numOfABoxAxioms; | 367 | int numOfTBoxAxioms = relevantOntologySubset.getAxiomCount() - numOfABoxAxioms; |
| 346 | int originalNumOfABoxAxioms = ontology.getABoxAxioms(true).size(); | ||
| 347 | int originalNumOfTBoxAxioms = ontology.getAxiomCount() - originalNumOfABoxAxioms; | ||
| 348 | Utility.logInfo("Relevant ontology-subset has been extracted: |ABox|=" | 368 | Utility.logInfo("Relevant ontology-subset has been extracted: |ABox|=" |
| 349 | + numOfABoxAxioms + ", |TBox|=" + numOfTBoxAxioms); | 369 | + numOfABoxAxioms + ", |TBox|=" + numOfTBoxAxioms); |
| 350 | 370 | ||
| @@ -365,6 +385,7 @@ class MyQueryReasoner extends QueryReasoner { | |||
| 365 | 385 | ||
| 366 | private boolean querySkolemisedRelevantSubset(OWLOntology relevantSubset, QueryRecord queryRecord) { | 386 | private boolean querySkolemisedRelevantSubset(OWLOntology relevantSubset, QueryRecord queryRecord) { |
| 367 | Utility.logInfo("Evaluating semi-Skolemised relevant upper store..."); | 387 | Utility.logInfo("Evaluating semi-Skolemised relevant upper store..."); |
| 388 | t.reset(); | ||
| 368 | 389 | ||
| 369 | DatalogProgram relevantProgram = new DatalogProgram(relevantSubset, false); // toClassify is false | 390 | DatalogProgram relevantProgram = new DatalogProgram(relevantSubset, false); // toClassify is false |
| 370 | 391 | ||
| @@ -373,16 +394,24 @@ class MyQueryReasoner extends QueryReasoner { | |||
| 373 | 394 | ||
| 374 | relevantStore.importDataFromABoxOf(relevantSubset); | 395 | relevantStore.importDataFromABoxOf(relevantSubset); |
| 375 | 396 | ||
| 376 | int materialisationResult = relevantStore.materialiseSkolemly(relevantProgram, null); | 397 | int queryDependentMaxTermDepth = 1; // TODO make it dynamic |
| 377 | if(materialisationResult != 1) | 398 | int materialisationTag = relevantStore.materialiseSkolemly(relevantProgram, null, |
| 378 | throw new RuntimeException("Skolemised materialisation error"); // TODO check consistency | 399 | queryDependentMaxTermDepth); |
| 400 | queryRecord.addProcessingTime(Step.L_SKOLEM_UPPER_BOUND, t.duration()); | ||
| 401 | if(materialisationTag == -1) { | ||
| 402 | throw new Error("A consistent ontology has turned out to be " + | ||
| 403 | "inconsistent in the Skolemises-relevant-upper-store"); | ||
| 404 | } | ||
| 405 | else if(materialisationTag != 1) { | ||
| 406 | Utility.logInfo("Semi-Skolemised relevant upper store cannot be employed"); | ||
| 407 | return false; | ||
| 408 | } | ||
| 379 | 409 | ||
| 380 | boolean isFullyProcessed = checkGapAnswers(relevantStore, queryRecord); | 410 | boolean isFullyProcessed = checkGapAnswers(relevantStore, queryRecord); |
| 381 | |||
| 382 | Utility.logInfo("Semi-Skolemised relevant upper store has been evaluated"); | 411 | Utility.logInfo("Semi-Skolemised relevant upper store has been evaluated"); |
| 383 | return isFullyProcessed; | 412 | return isFullyProcessed; |
| 384 | } | 413 | } |
| 385 | 414 | ||
| 386 | enum SatisfiabilityStatus {SATISFIABLE, UNSATISFIABLE, UNCHECKED} | 415 | private enum ConsistencyStatus {CONSISTENT, INCONSISTENT, UNCHECKED} |
| 387 | 416 | ||
| 388 | } | 417 | } |
diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/QueryReasoner.java b/src/uk/ac/ox/cs/pagoda/reasoner/QueryReasoner.java index 962a78f..eab6a1b 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/QueryReasoner.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/QueryReasoner.java | |||
| @@ -26,10 +26,10 @@ public abstract class QueryReasoner extends Disposable { | |||
| 26 | private static final boolean DEFAULT_MULTI_STAGES = true; | 26 | private static final boolean DEFAULT_MULTI_STAGES = true; |
| 27 | private static final boolean DEFAULT_EQUALITIES = true; | 27 | private static final boolean DEFAULT_EQUALITIES = true; |
| 28 | public boolean fullReasoner = this instanceof MyQueryReasoner; | 28 | public boolean fullReasoner = this instanceof MyQueryReasoner; |
| 29 | protected StringBuilder importedData = new StringBuilder(); | ||
| 30 | // protected boolean forSemFacet = false; | 29 | // protected boolean forSemFacet = false; |
| 31 | PagodaProperties properties; | 30 | PagodaProperties properties; |
| 32 | BufferedWriter answerWriter = null; | 31 | BufferedWriter answerWriter = null; |
| 32 | private StringBuilder importedData = new StringBuilder(); | ||
| 33 | private QueryManager m_queryManager = new QueryManager(); | 33 | private QueryManager m_queryManager = new QueryManager(); |
| 34 | 34 | ||
| 35 | public static QueryReasoner getInstance(PagodaProperties p) { | 35 | public static QueryReasoner getInstance(PagodaProperties p) { |
| @@ -208,10 +208,6 @@ public abstract class QueryReasoner extends Disposable { | |||
| 208 | queryRecords.stream().forEach(record -> record.dispose()); | 208 | queryRecords.stream().forEach(record -> record.dispose()); |
| 209 | } | 209 | } |
| 210 | 210 | ||
| 211 | // public void evaluate(Collection<QueryRecord> queryRecords) { | ||
| 212 | // evaluate(queryRecords); | ||
| 213 | // } | ||
| 214 | |||
| 215 | @Override | 211 | @Override |
| 216 | public void dispose() { | 212 | public void dispose() { |
| 217 | super.dispose(); | 213 | super.dispose(); |
| @@ -225,11 +221,19 @@ public abstract class QueryReasoner extends Disposable { | |||
| 225 | // Utility.cleanup(); | 221 | // Utility.cleanup(); |
| 226 | } | 222 | } |
| 227 | 223 | ||
| 224 | // public void evaluate(Collection<QueryRecord> queryRecords) { | ||
| 225 | // evaluate(queryRecords); | ||
| 226 | // } | ||
| 227 | |||
| 228 | public QueryManager getQueryManager() { | 228 | public QueryManager getQueryManager() { |
| 229 | if(isDisposed()) throw new DisposedException(); | 229 | if(isDisposed()) throw new DisposedException(); |
| 230 | return m_queryManager; | 230 | return m_queryManager; |
| 231 | } | 231 | } |
| 232 | 232 | ||
| 233 | protected String getImportedData() { | ||
| 234 | return importedData.toString(); | ||
| 235 | } | ||
| 236 | |||
| 233 | private void importDataDirectory(File file) { | 237 | private void importDataDirectory(File file) { |
| 234 | for(File child : file.listFiles()) | 238 | for(File child : file.listFiles()) |
| 235 | if(child.isFile()) importDataFile(child); | 239 | if(child.isFile()) importDataFile(child); |
diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/RLQueryReasoner.java b/src/uk/ac/ox/cs/pagoda/reasoner/RLQueryReasoner.java index 16e2627..3934498 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/RLQueryReasoner.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/RLQueryReasoner.java | |||
| @@ -57,7 +57,7 @@ class RLQueryReasoner extends QueryReasoner { | |||
| 57 | @Override | 57 | @Override |
| 58 | public boolean preprocess() { | 58 | public boolean preprocess() { |
| 59 | if(isDisposed()) throw new DisposedException(); | 59 | if(isDisposed()) throw new DisposedException(); |
| 60 | rlLowerStore.importRDFData("data", importedData.toString()); | 60 | rlLowerStore.importRDFData("data", getImportedData()); |
| 61 | rlLowerStore.materialise("lower program", program.toString()); | 61 | rlLowerStore.materialise("lower program", program.toString()); |
| 62 | 62 | ||
| 63 | return isConsistent(); | 63 | return isConsistent(); |
diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/RLUQueryReasoner.java b/src/uk/ac/ox/cs/pagoda/reasoner/RLUQueryReasoner.java index d0712e1..368fbb2 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/RLUQueryReasoner.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/RLUQueryReasoner.java | |||
| @@ -97,7 +97,7 @@ class RLUQueryReasoner extends QueryReasoner { | |||
| 97 | @Override | 97 | @Override |
| 98 | public boolean preprocess() { | 98 | public boolean preprocess() { |
| 99 | if(isDisposed()) throw new DisposedException(); | 99 | if(isDisposed()) throw new DisposedException(); |
| 100 | String datafile = importedData.toString(); | 100 | String datafile = getImportedData(); |
| 101 | rlLowerStore.importRDFData("data", datafile); | 101 | rlLowerStore.importRDFData("data", datafile); |
| 102 | rlLowerStore.materialise("lower program", program.getLower().toString()); | 102 | rlLowerStore.materialise("lower program", program.getLower().toString()); |
| 103 | 103 | ||
diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/full/Checker.java b/src/uk/ac/ox/cs/pagoda/reasoner/full/Checker.java index 849b971..fd620a5 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/full/Checker.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/full/Checker.java | |||
| @@ -2,14 +2,14 @@ package uk.ac.ox.cs.pagoda.reasoner.full; | |||
| 2 | 2 | ||
| 3 | import uk.ac.ox.cs.pagoda.query.AnswerTuple; | 3 | import uk.ac.ox.cs.pagoda.query.AnswerTuple; |
| 4 | import uk.ac.ox.cs.pagoda.query.AnswerTuples; | 4 | import uk.ac.ox.cs.pagoda.query.AnswerTuples; |
| 5 | import uk.ac.ox.cs.pagoda.util.disposable.Disposable; | ||
| 5 | 6 | ||
| 6 | public interface Checker { | 7 | public abstract class Checker extends Disposable { |
| 7 | 8 | ||
| 8 | public int check(AnswerTuples answers); | 9 | public abstract int check(AnswerTuples answers); |
| 9 | |||
| 10 | public boolean check(AnswerTuple answer); | ||
| 11 | 10 | ||
| 12 | public boolean isConsistent(); | 11 | public abstract boolean check(AnswerTuple answer); |
| 12 | |||
| 13 | public abstract boolean isConsistent(); | ||
| 13 | 14 | ||
| 14 | public void dispose(); | ||
| 15 | } | 15 | } |
diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/full/HermitChecker.java b/src/uk/ac/ox/cs/pagoda/reasoner/full/HermitChecker.java index 5dcf0f8..35db0f2 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/full/HermitChecker.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/full/HermitChecker.java | |||
| @@ -1,24 +1,10 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.reasoner.full; | 1 | package uk.ac.ox.cs.pagoda.reasoner.full; |
| 2 | 2 | ||
| 3 | import java.util.HashMap; | ||
| 4 | import java.util.HashSet; | ||
| 5 | import java.util.Map; | ||
| 6 | import java.util.Set; | ||
| 7 | |||
| 8 | import org.semanticweb.HermiT.Reasoner; | 3 | import org.semanticweb.HermiT.Reasoner; |
| 9 | import org.semanticweb.HermiT.model.DLClause; | 4 | import org.semanticweb.HermiT.model.DLClause; |
| 10 | import org.semanticweb.HermiT.model.Term; | 5 | import org.semanticweb.HermiT.model.Term; |
| 11 | import org.semanticweb.HermiT.model.Variable; | 6 | import org.semanticweb.HermiT.model.Variable; |
| 12 | import org.semanticweb.owlapi.model.IRI; | 7 | import org.semanticweb.owlapi.model.*; |
| 13 | import org.semanticweb.owlapi.model.OWLAxiom; | ||
| 14 | import org.semanticweb.owlapi.model.OWLClassAssertionAxiom; | ||
| 15 | import org.semanticweb.owlapi.model.OWLDataFactory; | ||
| 16 | import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom; | ||
| 17 | import org.semanticweb.owlapi.model.OWLIndividual; | ||
| 18 | import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom; | ||
| 19 | import org.semanticweb.owlapi.model.OWLOntology; | ||
| 20 | import org.semanticweb.owlapi.model.OWLOntologyManager; | ||
| 21 | |||
| 22 | import uk.ac.ox.cs.pagoda.endomorph.Clique; | 8 | import uk.ac.ox.cs.pagoda.endomorph.Clique; |
| 23 | import uk.ac.ox.cs.pagoda.endomorph.DependencyGraph; | 9 | import uk.ac.ox.cs.pagoda.endomorph.DependencyGraph; |
| 24 | import uk.ac.ox.cs.pagoda.hermit.DLClauseHelper; | 10 | import uk.ac.ox.cs.pagoda.hermit.DLClauseHelper; |
| @@ -30,216 +16,236 @@ import uk.ac.ox.cs.pagoda.util.ConjunctiveQueryHelper; | |||
| 30 | import uk.ac.ox.cs.pagoda.util.Namespace; | 16 | import uk.ac.ox.cs.pagoda.util.Namespace; |
| 31 | import uk.ac.ox.cs.pagoda.util.Timer; | 17 | import uk.ac.ox.cs.pagoda.util.Timer; |
| 32 | import uk.ac.ox.cs.pagoda.util.Utility; | 18 | import uk.ac.ox.cs.pagoda.util.Utility; |
| 19 | import uk.ac.ox.cs.pagoda.util.disposable.DisposedException; | ||
| 33 | 20 | ||
| 34 | public class HermitChecker implements Checker { | 21 | import java.util.HashMap; |
| 35 | 22 | import java.util.HashSet; | |
| 36 | protected OWLDataFactory factory; | 23 | import java.util.Map; |
| 24 | import java.util.Set; | ||
| 37 | 25 | ||
| 38 | private String queryText; | 26 | public class HermitChecker extends Checker { |
| 39 | private DLClause queryClause; | ||
| 40 | 27 | ||
| 41 | private Reasoner hermit; | 28 | protected OWLDataFactory factory; |
| 42 | protected String[][] answerVariable; | 29 | protected String[][] answerVariable; |
| 43 | protected OWLOntology ontology; | 30 | protected OWLOntology ontology; |
| 44 | protected QueryRecord record; | 31 | protected QueryRecord record; |
| 45 | protected QueryGraph qGraph = null; | 32 | protected QueryGraph qGraph = null; |
| 46 | boolean toCheck = true; | 33 | boolean toCheck = true; |
| 47 | 34 | AnswerTuple topAnswerTuple = null, botAnswerTuple = null; | |
| 35 | private String queryText; | ||
| 36 | private DLClause queryClause; | ||
| 37 | private Reasoner hermit; | ||
| 38 | private int tag = 0; | ||
| 39 | private int counter = 0; | ||
| 40 | private DependencyGraph dGraph = null; | ||
| 48 | public HermitChecker(Checker checker) { | 41 | public HermitChecker(Checker checker) { |
| 49 | if (checker instanceof HermitChecker) { | 42 | if (checker instanceof HermitChecker) { |
| 50 | HermitChecker other = (HermitChecker) checker; | 43 | HermitChecker other = (HermitChecker) checker; |
| 51 | factory = other.factory; | 44 | factory = other.factory; |
| 52 | queryText = other.queryText; | 45 | queryText = other.queryText; |
| 53 | queryClause = other.queryClause; | 46 | queryClause = other.queryClause; |
| 54 | answerVariable = other.answerVariable; | 47 | answerVariable = other.answerVariable; |
| 55 | ontology = other.ontology; | 48 | ontology = other.ontology; |
| 56 | // record = other.record; | 49 | // record = other.record; |
| 57 | } | 50 | } |
| 58 | 51 | ||
| 59 | hermit = new Reasoner(ontology); | 52 | hermit = new Reasoner(ontology); |
| 60 | } | 53 | } |
| 61 | 54 | ||
| 62 | public HermitChecker(OWLOntology ontology, QueryRecord record, boolean toCheck) { | 55 | public HermitChecker(OWLOntology ontology, QueryRecord record, boolean toCheck) { |
| 63 | this.ontology = ontology; | 56 | this.ontology = ontology; |
| 64 | queryText = record.getQueryText(); | 57 | queryText = record.getQueryText(); |
| 65 | answerVariable = record.getVariables(); | 58 | answerVariable = record.getVariables(); |
| 66 | queryClause = record.getClause(); | 59 | queryClause = record.getClause(); |
| 67 | // this.record = record; | 60 | // this.record = record; |
| 68 | this.toCheck = toCheck; | 61 | this.toCheck = toCheck; |
| 69 | } | 62 | } |
| 70 | 63 | ||
| 71 | public HermitChecker(OWLOntology ontology, String queryText) { | 64 | public HermitChecker(OWLOntology ontology, String queryText) { |
| 72 | this.ontology = ontology; | 65 | this.ontology = ontology; |
| 73 | this.queryText = queryText; | 66 | this.queryText = queryText; |
| 74 | answerVariable = queryText == null ? null : ConjunctiveQueryHelper.getAnswerVariables(queryText); | 67 | answerVariable = queryText == null ? null : ConjunctiveQueryHelper.getAnswerVariables(queryText); |
| 75 | queryClause = DLClauseHelper.getQuery(queryText, null); | 68 | queryClause = DLClauseHelper.getQuery(queryText, null); |
| 76 | // this.record = null; | 69 | // this.record = null; |
| 70 | } | ||
| 71 | |||
| 72 | @Override | ||
| 73 | public int check(AnswerTuples answers) { | ||
| 74 | if(isDisposed()) throw new DisposedException(); | ||
| 75 | |||
| 76 | if(hermit == null) initialiseReasoner(); | ||
| 77 | int answerCounter = 0, counter = 0; | ||
| 78 | for(; answers.isValid(); answers.moveNext()) { | ||
| 79 | ++counter; | ||
| 80 | if(check(answers.getTuple())) ++answerCounter; | ||
| 81 | } | ||
| 82 | answers.dispose(); | ||
| 83 | |||
| 84 | Utility.logDebug("The number of individuals to be checked by HermiT: " + counter, | ||
| 85 | "The number of correct answers: " + answerCounter); | ||
| 86 | return answerCounter; | ||
| 87 | } | ||
| 88 | |||
| 89 | @Override | ||
| 90 | public boolean check(AnswerTuple answerTuple) { | ||
| 91 | if(isDisposed()) throw new DisposedException(); | ||
| 92 | |||
| 93 | if(!toCheck) return false; | ||
| 94 | |||
| 95 | if(hermit == null) initialiseReasoner(); | ||
| 96 | if(tag != 0) return tag == 1; | ||
| 97 | ++counter; | ||
| 98 | Timer t = new Timer(); | ||
| 99 | Map<Variable, Term> sub = answerTuple.getAssignment(answerVariable[1]); | ||
| 100 | Set<OWLAxiom> toCheckAxioms = qGraph.getAssertions(sub); | ||
| 101 | |||
| 102 | // for (OWLAxiom axiom: toCheckAxioms) System.out.println(axiom.toString()); | ||
| 103 | |||
| 104 | if(hermit.isEntailed(toCheckAxioms)) { | ||
| 105 | Utility.logDebug("@TIME to check one tuple: " + t.duration()); | ||
| 106 | return true; | ||
| 107 | } | ||
| 108 | Utility.logDebug("@TIME to check one tuple: " + t.duration()); | ||
| 109 | return false; | ||
| 77 | } | 110 | } |
| 78 | 111 | ||
| 79 | private int tag = 0; | 112 | @Override |
| 80 | AnswerTuple topAnswerTuple = null, botAnswerTuple = null; | 113 | public boolean isConsistent() { |
| 81 | 114 | if(isDisposed()) throw new DisposedException(); | |
| 115 | |||
| 116 | if(hermit == null) initialiseReasoner(); | ||
| 117 | return hermit.isConsistent(); | ||
| 118 | } | ||
| 119 | |||
| 120 | public void dispose() { | ||
| 121 | super.dispose(); | ||
| 122 | |||
| 123 | Utility.logInfo("Hermit was called " + counter + " times."); | ||
| 124 | if(hermit != null) hermit.dispose(); | ||
| 125 | hermit = null; | ||
| 126 | } | ||
| 127 | |||
| 128 | public void setDependencyGraph(DependencyGraph dGraph) { | ||
| 129 | if(isDisposed()) throw new DisposedException(); | ||
| 130 | |||
| 131 | this.dGraph = dGraph; | ||
| 132 | } | ||
| 133 | |||
| 82 | private void initialiseReasoner() { | 134 | private void initialiseReasoner() { |
| 83 | qGraph = new QueryGraph(queryClause.getBodyAtoms(), answerVariable[1], ontology); | 135 | qGraph = new QueryGraph(queryClause.getBodyAtoms(), answerVariable[1], ontology); |
| 84 | OWLOntologyManager manager = ontology.getOWLOntologyManager(); | 136 | OWLOntologyManager manager = ontology.getOWLOntologyManager(); |
| 85 | factory = manager.getOWLDataFactory(); | 137 | factory = manager.getOWLDataFactory(); |
| 86 | 138 | ||
| 87 | if (hermit != null) hermit.dispose(); | 139 | if(hermit != null) hermit.dispose(); |
| 88 | 140 | ||
| 89 | if (dGraph != null && answerVariable[1].length == 1 && (dGraph.getExits().size() > 1 || dGraph.getEntrances().size() > 1)) { | 141 | if(dGraph != null && answerVariable[1].length == 1 && (dGraph.getExits().size() > 1 || dGraph.getEntrances() |
| 90 | Set<OWLAxiom> topAxioms = new HashSet<OWLAxiom>(); | 142 | .size() > 1)) { |
| 91 | Set<OWLAxiom> botAxioms = new HashSet<OWLAxiom>(); | 143 | Set<OWLAxiom> topAxioms = new HashSet<OWLAxiom>(); |
| 144 | Set<OWLAxiom> botAxioms = new HashSet<OWLAxiom>(); | ||
| 92 | addTopAndBotTuple(topAxioms, botAxioms); | 145 | addTopAndBotTuple(topAxioms, botAxioms); |
| 93 | manager.addAxioms(ontology, topAxioms); | 146 | manager.addAxioms(ontology, topAxioms); |
| 94 | manager.addAxioms(ontology, botAxioms); | 147 | manager.addAxioms(ontology, botAxioms); |
| 95 | hermit = new Reasoner(ontology); | 148 | hermit = new Reasoner(ontology); |
| 96 | boolean topValid = true; | 149 | boolean topValid = true; |
| 97 | if (!hermit.isConsistent() || topAnswerTuple != null && (topValid = check(topAnswerTuple))) { | 150 | if(!hermit.isConsistent() || topAnswerTuple != null && (topValid = check(topAnswerTuple))) { |
| 98 | hermit.dispose(); | 151 | hermit.dispose(); |
| 99 | manager.removeAxioms(ontology, topAxioms); | 152 | manager.removeAxioms(ontology, topAxioms); |
| 100 | hermit = new Reasoner(ontology); | 153 | hermit = new Reasoner(ontology); |
| 101 | } else { | 154 | } |
| 102 | if (!topValid) tag = -1; | 155 | else { |
| 103 | else | 156 | if(!topValid) tag = -1; |
| 104 | if (botAnswerTuple != null && check(botAnswerTuple)) tag = 1; | 157 | else if(botAnswerTuple != null && check(botAnswerTuple)) tag = 1; |
| 105 | } | 158 | } |
| 106 | } | 159 | } |
| 107 | else | 160 | else |
| 108 | hermit = new Reasoner(ontology); | 161 | hermit = new Reasoner(ontology); |
| 109 | } | 162 | } |
| 110 | 163 | ||
| 111 | private void addTopAndBotTuple(Set<OWLAxiom> topAxioms, Set<OWLAxiom> botAxioms) { | 164 | private void addTopAndBotTuple(Set<OWLAxiom> topAxioms, Set<OWLAxiom> botAxioms) { |
| 112 | String top_str = Namespace.PAGODA_ANONY + "top", bot_str = Namespace.PAGODA_ANONY + "bot"; | 165 | String top_str = Namespace.PAGODA_ANONY + "top", bot_str = Namespace.PAGODA_ANONY + "bot"; |
| 113 | topAnswerTuple = new AnswerTuple(new uk.ac.ox.cs.JRDFox.model.Individual[] { uk.ac.ox.cs.JRDFox.model.Individual.create(top_str) } ); | 166 | topAnswerTuple = |
| 114 | botAnswerTuple = new AnswerTuple(new uk.ac.ox.cs.JRDFox.model.Individual[] { uk.ac.ox.cs.JRDFox.model.Individual.create(bot_str) } ); | 167 | new AnswerTuple(new uk.ac.ox.cs.JRDFox.model.Individual[]{uk.ac.ox.cs.JRDFox.model.Individual.create(top_str)}); |
| 115 | OWLIndividual top_ind = factory.getOWLNamedIndividual(IRI.create(top_str)), bot_ind = factory.getOWLNamedIndividual(IRI.create(bot_str)); | 168 | botAnswerTuple = |
| 116 | Map<OWLAxiom, Integer> counter = new HashMap<OWLAxiom, Integer>(); | 169 | new AnswerTuple(new uk.ac.ox.cs.JRDFox.model.Individual[]{uk.ac.ox.cs.JRDFox.model.Individual.create(bot_str)}); |
| 117 | 170 | OWLIndividual top_ind = factory.getOWLNamedIndividual(IRI.create(top_str)), bot_ind = | |
| 171 | factory.getOWLNamedIndividual(IRI.create(bot_str)); | ||
| 172 | Map<OWLAxiom, Integer> counter = new HashMap<OWLAxiom, Integer>(); | ||
| 173 | |||
| 118 | Set<String> topAnswers = new HashSet<String>(), botAnswers = new HashSet<String>(); | 174 | Set<String> topAnswers = new HashSet<String>(), botAnswers = new HashSet<String>(); |
| 119 | OWLIndividual sub, obj; | 175 | OWLIndividual sub, obj; |
| 120 | if (dGraph.getExits().size() > 1) { | 176 | if(dGraph.getExits().size() > 1) { |
| 121 | for (Clique answerClique: dGraph.getExits()) | 177 | for(Clique answerClique : dGraph.getExits()) |
| 122 | topAnswers.add(((uk.ac.ox.cs.JRDFox.model.Individual) answerClique.getRepresentative().getAnswerTuple().getGroundTerm(0)).getIRI()); | 178 | topAnswers.add(((uk.ac.ox.cs.JRDFox.model.Individual) answerClique.getRepresentative() |
| 179 | .getAnswerTuple() | ||
| 180 | .getGroundTerm(0)).getIRI()); | ||
| 123 | } | 181 | } |
| 124 | else topAnswerTuple = null; | 182 | else topAnswerTuple = null; |
| 125 | 183 | ||
| 126 | if (dGraph.getEntrances().size() > 1) { | 184 | if(dGraph.getEntrances().size() > 1) { |
| 127 | for (Clique answerClique: dGraph.getEntrances()) | 185 | for(Clique answerClique : dGraph.getEntrances()) |
| 128 | botAnswers.add(((uk.ac.ox.cs.JRDFox.model.Individual) answerClique.getRepresentative().getAnswerTuple().getGroundTerm(0)).getIRI()); | 186 | botAnswers.add(((uk.ac.ox.cs.JRDFox.model.Individual) answerClique.getRepresentative() |
| 187 | .getAnswerTuple() | ||
| 188 | .getGroundTerm(0)).getIRI()); | ||
| 129 | } | 189 | } |
| 130 | else botAnswerTuple = null; | 190 | else botAnswerTuple = null; |
| 131 | 191 | ||
| 132 | for (OWLAxiom axiom: ontology.getABoxAxioms(true)) | 192 | for(OWLAxiom axiom : ontology.getABoxAxioms(true)) |
| 133 | if (axiom instanceof OWLClassAssertionAxiom) { | 193 | if(axiom instanceof OWLClassAssertionAxiom) { |
| 134 | OWLClassAssertionAxiom ca = (OWLClassAssertionAxiom) axiom; | 194 | OWLClassAssertionAxiom ca = (OWLClassAssertionAxiom) axiom; |
| 135 | sub = ca.getIndividual(); | 195 | sub = ca.getIndividual(); |
| 136 | if (topAnswers.contains(sub.toStringID())) | 196 | if(topAnswers.contains(sub.toStringID())) |
| 137 | topAxioms.add(factory.getOWLClassAssertionAxiom(ca.getClassExpression(), top_ind)); | 197 | topAxioms.add(factory.getOWLClassAssertionAxiom(ca.getClassExpression(), top_ind)); |
| 138 | if (botAnswers.contains(sub.toStringID())) | 198 | if(botAnswers.contains(sub.toStringID())) |
| 139 | inc(counter, factory.getOWLClassAssertionAxiom(ca.getClassExpression(), bot_ind)); | 199 | inc(counter, factory.getOWLClassAssertionAxiom(ca.getClassExpression(), bot_ind)); |
| 140 | } | 200 | } |
| 141 | else if (axiom instanceof OWLObjectPropertyAssertionAxiom) { | 201 | else if(axiom instanceof OWLObjectPropertyAssertionAxiom) { |
| 142 | OWLObjectPropertyAssertionAxiom oa = (OWLObjectPropertyAssertionAxiom) axiom; | 202 | OWLObjectPropertyAssertionAxiom oa = (OWLObjectPropertyAssertionAxiom) axiom; |
| 143 | sub = oa.getSubject(); obj = oa.getObject(); | 203 | sub = oa.getSubject(); |
| 144 | if (topAnswers.contains(sub.toStringID())) | 204 | obj = oa.getObject(); |
| 145 | if (topAnswers.contains(obj.toStringID())) | 205 | if(topAnswers.contains(sub.toStringID())) |
| 206 | if(topAnswers.contains(obj.toStringID())) | ||
| 146 | topAxioms.add(factory.getOWLObjectPropertyAssertionAxiom(oa.getProperty(), top_ind, top_ind)); | 207 | topAxioms.add(factory.getOWLObjectPropertyAssertionAxiom(oa.getProperty(), top_ind, top_ind)); |
| 147 | else | 208 | else |
| 148 | topAxioms.add(factory.getOWLObjectPropertyAssertionAxiom(oa.getProperty(), top_ind, obj)); | 209 | topAxioms.add(factory.getOWLObjectPropertyAssertionAxiom(oa.getProperty(), top_ind, obj)); |
| 149 | else { | 210 | else { |
| 150 | if (topAnswers.contains(obj.toStringID())) | 211 | if(topAnswers.contains(obj.toStringID())) |
| 151 | topAxioms.add(factory.getOWLObjectPropertyAssertionAxiom(oa.getProperty(), sub, top_ind)); | 212 | topAxioms.add(factory.getOWLObjectPropertyAssertionAxiom(oa.getProperty(), sub, top_ind)); |
| 152 | } | 213 | } |
| 153 | 214 | ||
| 154 | if (botAnswers.contains(sub.toStringID())) | 215 | if(botAnswers.contains(sub.toStringID())) |
| 155 | if (botAnswers.contains(obj.toStringID())) | 216 | if(botAnswers.contains(obj.toStringID())) |
| 156 | inc(counter, factory.getOWLObjectPropertyAssertionAxiom(oa.getProperty(), bot_ind, bot_ind)); | 217 | inc(counter, factory.getOWLObjectPropertyAssertionAxiom(oa.getProperty(), bot_ind, bot_ind)); |
| 157 | else | 218 | else |
| 158 | inc(counter, factory.getOWLObjectPropertyAssertionAxiom(oa.getProperty(), bot_ind, obj)); | 219 | inc(counter, factory.getOWLObjectPropertyAssertionAxiom(oa.getProperty(), bot_ind, obj)); |
| 159 | else { | 220 | else { |
| 160 | if (botAnswers.contains(obj.toStringID())) | 221 | if(botAnswers.contains(obj.toStringID())) |
| 161 | inc(counter, factory.getOWLObjectPropertyAssertionAxiom(oa.getProperty(), sub, bot_ind)); | 222 | inc(counter, factory.getOWLObjectPropertyAssertionAxiom(oa.getProperty(), sub, bot_ind)); |
| 162 | } | 223 | } |
| 163 | 224 | ||
| 164 | } | 225 | } |
| 165 | else if (axiom instanceof OWLDataPropertyAssertionAxiom) { | 226 | else if(axiom instanceof OWLDataPropertyAssertionAxiom) { |
| 166 | OWLDataPropertyAssertionAxiom da = (OWLDataPropertyAssertionAxiom) axiom; | 227 | OWLDataPropertyAssertionAxiom da = (OWLDataPropertyAssertionAxiom) axiom; |
| 167 | sub = da.getSubject(); | 228 | sub = da.getSubject(); |
| 168 | if (topAnswers.contains(sub.toStringID())) | 229 | if(topAnswers.contains(sub.toStringID())) |
| 169 | topAxioms.add(factory.getOWLDataPropertyAssertionAxiom(da.getProperty(), top_ind, da.getObject())); | 230 | topAxioms.add(factory.getOWLDataPropertyAssertionAxiom(da.getProperty(), top_ind, da.getObject())); |
| 170 | 231 | ||
| 171 | if (botAnswers.contains(sub.toStringID())) | 232 | if(botAnswers.contains(sub.toStringID())) |
| 172 | inc(counter, factory.getOWLDataPropertyAssertionAxiom(da.getProperty(), bot_ind, da.getObject())); | 233 | inc(counter, factory.getOWLDataPropertyAssertionAxiom(da.getProperty(), bot_ind, da.getObject())); |
| 173 | } | 234 | } |
| 174 | 235 | ||
| 175 | int number = botAnswers.size(); | 236 | int number = botAnswers.size(); |
| 176 | for (Map.Entry<OWLAxiom, Integer> entry: counter.entrySet()) { | 237 | for(Map.Entry<OWLAxiom, Integer> entry : counter.entrySet()) { |
| 177 | if (entry.getValue() == number) | 238 | if(entry.getValue() == number) |
| 178 | botAxioms.add(entry.getKey()); | 239 | botAxioms.add(entry.getKey()); |
| 179 | } | 240 | } |
| 180 | } | 241 | } |
| 181 | 242 | ||
| 182 | private void inc(Map<OWLAxiom, Integer> counter, OWLAxiom newAxiom) { | 243 | private void inc(Map<OWLAxiom, Integer> counter, OWLAxiom newAxiom) { |
| 183 | Integer number = counter.get(newAxiom); | 244 | if(isDisposed()) throw new DisposedException(); |
| 184 | if (number == null) counter.put(newAxiom, 1); | ||
| 185 | else counter.put(newAxiom, number + 1); | ||
| 186 | } | ||
| 187 | 245 | ||
| 188 | @Override | 246 | Integer number = counter.get(newAxiom); |
| 189 | public int check(AnswerTuples answers) { | 247 | if(number == null) counter.put(newAxiom, 1); |
| 190 | if (hermit == null) initialiseReasoner(); | 248 | else counter.put(newAxiom, number + 1); |
| 191 | int answerCounter = 0, counter = 0; | ||
| 192 | for (; answers.isValid(); answers.moveNext()) { | ||
| 193 | ++counter; | ||
| 194 | if (check(answers.getTuple())) ++answerCounter; | ||
| 195 | } | ||
| 196 | answers.dispose(); | ||
| 197 | |||
| 198 | Utility.logDebug("The number of individuals to be checked by HermiT: " + counter, | ||
| 199 | "The number of correct answers: " + answerCounter); | ||
| 200 | return answerCounter; | ||
| 201 | } | ||
| 202 | |||
| 203 | private int counter = 0; | ||
| 204 | |||
| 205 | @Override | ||
| 206 | public boolean check(AnswerTuple answerTuple) { | ||
| 207 | if (!toCheck) return false; | ||
| 208 | |||
| 209 | if (hermit == null) initialiseReasoner(); | ||
| 210 | if (tag != 0) return tag == 1; | ||
| 211 | ++counter; | ||
| 212 | Timer t = new Timer(); | ||
| 213 | Map<Variable, Term> sub = answerTuple.getAssignment(answerVariable[1]); | ||
| 214 | Set<OWLAxiom> toCheckAxioms = qGraph.getAssertions(sub); | ||
| 215 | |||
| 216 | // for (OWLAxiom axiom: toCheckAxioms) System.out.println(axiom.toString()); | ||
| 217 | |||
| 218 | if (hermit.isEntailed(toCheckAxioms)) { | ||
| 219 | Utility.logDebug("@TIME to check one tuple: " + t.duration()); | ||
| 220 | return true; | ||
| 221 | } | ||
| 222 | Utility.logDebug("@TIME to check one tuple: " + t.duration()); | ||
| 223 | return false; | ||
| 224 | } | ||
| 225 | |||
| 226 | @Override | ||
| 227 | public boolean isConsistent() { | ||
| 228 | if (hermit == null) initialiseReasoner(); | ||
| 229 | return hermit.isConsistent(); | ||
| 230 | } | ||
| 231 | |||
| 232 | |||
| 233 | public void dispose() { | ||
| 234 | Utility.logInfo("Hermit was called " + counter + " times."); | ||
| 235 | if (hermit != null) hermit.dispose(); | ||
| 236 | hermit = null; | ||
| 237 | } | ||
| 238 | |||
| 239 | private DependencyGraph dGraph = null; | ||
| 240 | |||
| 241 | public void setDependencyGraph(DependencyGraph dGraph) { | ||
| 242 | this.dGraph = dGraph; | ||
| 243 | } | 249 | } |
| 244 | 250 | ||
| 245 | } | 251 | } |
diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/light/BasicQueryEngine.java b/src/uk/ac/ox/cs/pagoda/reasoner/light/BasicQueryEngine.java index fe43e09..107d3ca 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/light/BasicQueryEngine.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/light/BasicQueryEngine.java | |||
| @@ -104,16 +104,22 @@ public class BasicQueryEngine extends RDFoxQueryEngine { | |||
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | public void outputInstance4BinaryPredicate(String iri, String filename) { | 106 | public void outputInstance4BinaryPredicate(String iri, String filename) { |
| 107 | if(isDisposed()) throw new DisposedException(); | ||
| 108 | |||
| 107 | Utility.redirectCurrentOut(filename); | 109 | Utility.redirectCurrentOut(filename); |
| 108 | outputInstance4BinaryPredicate(iri); | 110 | outputInstance4BinaryPredicate(iri); |
| 109 | Utility.closeCurrentOut(); | 111 | Utility.closeCurrentOut(); |
| 110 | } | 112 | } |
| 111 | 113 | ||
| 112 | public void outputInstance4BinaryPredicate(String iri) { | 114 | public void outputInstance4BinaryPredicate(String iri) { |
| 115 | if(isDisposed()) throw new DisposedException(); | ||
| 116 | |||
| 113 | outputAnswers("select ?x ?y where { ?x <" + iri + "> ?y . }"); | 117 | outputAnswers("select ?x ?y where { ?x <" + iri + "> ?y . }"); |
| 114 | } | 118 | } |
| 115 | 119 | ||
| 116 | public void outputInstanceNumbers(String filename) { | 120 | public void outputInstanceNumbers(String filename) { |
| 121 | if(isDisposed()) throw new DisposedException(); | ||
| 122 | |||
| 117 | TupleIterator predicateTuples = null; | 123 | TupleIterator predicateTuples = null; |
| 118 | TupleIterator instanceTuples; | 124 | TupleIterator instanceTuples; |
| 119 | Set<String> number = new HashSet<String>(); | 125 | Set<String> number = new HashSet<String>(); |
| @@ -177,6 +183,8 @@ public class BasicQueryEngine extends RDFoxQueryEngine { | |||
| 177 | } | 183 | } |
| 178 | 184 | ||
| 179 | public TupleIterator internal_evaluateAgainstIDBs(String queryText) throws JRDFStoreException { | 185 | public TupleIterator internal_evaluateAgainstIDBs(String queryText) throws JRDFStoreException { |
| 186 | if(isDisposed()) throw new DisposedException(); | ||
| 187 | |||
| 180 | TupleIterator iter = | 188 | TupleIterator iter = |
| 181 | store.compileQuery(queryText, prefixes, parameters, TripleStatus.TUPLE_STATUS_IDB.union(TripleStatus.TUPLE_STATUS_EDB), TripleStatus.TUPLE_STATUS_IDB); | 189 | store.compileQuery(queryText, prefixes, parameters, TripleStatus.TUPLE_STATUS_IDB.union(TripleStatus.TUPLE_STATUS_EDB), TripleStatus.TUPLE_STATUS_IDB); |
| 182 | // iter.open(); | 190 | // iter.open(); |
| @@ -184,16 +192,22 @@ public class BasicQueryEngine extends RDFoxQueryEngine { | |||
| 184 | } | 192 | } |
| 185 | 193 | ||
| 186 | public TupleIterator internal_evaluate(String queryText) throws JRDFStoreException { | 194 | public TupleIterator internal_evaluate(String queryText) throws JRDFStoreException { |
| 195 | if(isDisposed()) throw new DisposedException(); | ||
| 196 | |||
| 187 | TupleIterator iter = store.compileQuery(queryText, prefixes, parameters); | 197 | TupleIterator iter = store.compileQuery(queryText, prefixes, parameters); |
| 188 | // iter.open(); | 198 | // iter.open(); |
| 189 | return iter; | 199 | return iter; |
| 190 | } | 200 | } |
| 191 | 201 | ||
| 192 | public void setExpandEquality(boolean flag) { | 202 | public void setExpandEquality(boolean flag) { |
| 203 | if(isDisposed()) throw new DisposedException(); | ||
| 204 | |||
| 193 | parameters.m_expandEquality = flag; | 205 | parameters.m_expandEquality = flag; |
| 194 | } | 206 | } |
| 195 | 207 | ||
| 196 | public TupleIterator internal_evaluateNotExpanded(String queryText) throws JRDFStoreException { | 208 | public TupleIterator internal_evaluateNotExpanded(String queryText) throws JRDFStoreException { |
| 209 | if(isDisposed()) throw new DisposedException(); | ||
| 210 | |||
| 197 | parameters.m_expandEquality = false; | 211 | parameters.m_expandEquality = false; |
| 198 | TupleIterator iter = store.compileQuery(queryText, prefixes, parameters); | 212 | TupleIterator iter = store.compileQuery(queryText, prefixes, parameters); |
| 199 | // iter.open(); | 213 | // iter.open(); |
| @@ -202,10 +216,14 @@ public class BasicQueryEngine extends RDFoxQueryEngine { | |||
| 202 | } | 216 | } |
| 203 | 217 | ||
| 204 | public TupleIterator internal_evaluate(String queryText, boolean incrementally) throws JRDFStoreException { | 218 | public TupleIterator internal_evaluate(String queryText, boolean incrementally) throws JRDFStoreException { |
| 219 | if(isDisposed()) throw new DisposedException(); | ||
| 220 | |||
| 205 | return incrementally ? internal_evaluateAgainstIDBs(queryText) : internal_evaluate(queryText); | 221 | return incrementally ? internal_evaluateAgainstIDBs(queryText) : internal_evaluate(queryText); |
| 206 | } | 222 | } |
| 207 | 223 | ||
| 208 | public String getUnusedRules(Collection<DLClause> clauses, boolean toUpdate) { | 224 | public String getUnusedRules(Collection<DLClause> clauses, boolean toUpdate) { |
| 225 | if(isDisposed()) throw new DisposedException(); | ||
| 226 | |||
| 209 | DLClause clause; | 227 | DLClause clause; |
| 210 | for(Iterator<DLClause> iter = clauses.iterator(); iter.hasNext(); ) { | 228 | for(Iterator<DLClause> iter = clauses.iterator(); iter.hasNext(); ) { |
| 211 | if(materialisedRules.contains(clause = iter.next())) | 229 | if(materialisedRules.contains(clause = iter.next())) |
| @@ -219,10 +237,14 @@ public class BasicQueryEngine extends RDFoxQueryEngine { | |||
| 219 | } | 237 | } |
| 220 | 238 | ||
| 221 | public void outputMaterialisedRules() { | 239 | public void outputMaterialisedRules() { |
| 240 | if(isDisposed()) throw new DisposedException(); | ||
| 241 | |||
| 222 | System.out.println(DLClauseHelper.toString(materialisedRules)); | 242 | System.out.println(DLClauseHelper.toString(materialisedRules)); |
| 223 | } | 243 | } |
| 224 | 244 | ||
| 225 | public void outputAnswers(String query) { | 245 | public void outputAnswers(String query) { |
| 246 | if(isDisposed()) throw new DisposedException(); | ||
| 247 | |||
| 226 | TupleIterator iter = null; | 248 | TupleIterator iter = null; |
| 227 | try { | 249 | try { |
| 228 | iter = internal_evaluate(query); | 250 | iter = internal_evaluate(query); |
| @@ -241,6 +263,8 @@ public class BasicQueryEngine extends RDFoxQueryEngine { | |||
| 241 | } | 263 | } |
| 242 | 264 | ||
| 243 | public void outputInstance4UnaryPredicate(String iri) { | 265 | public void outputInstance4UnaryPredicate(String iri) { |
| 266 | if(isDisposed()) throw new DisposedException(); | ||
| 267 | |||
| 244 | outputAnswers("select ?x where { ?x " | 268 | outputAnswers("select ?x where { ?x " |
| 245 | + "<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <" | 269 | + "<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <" |
| 246 | + iri | 270 | + iri |
| @@ -248,14 +272,20 @@ public class BasicQueryEngine extends RDFoxQueryEngine { | |||
| 248 | } | 272 | } |
| 249 | 273 | ||
| 250 | public void outputSubjects(String p, String o) { | 274 | public void outputSubjects(String p, String o) { |
| 275 | if(isDisposed()) throw new DisposedException(); | ||
| 276 | |||
| 251 | outputAnswers("select x where { ?x <" + p + "> <" + o + "> . }"); | 277 | outputAnswers("select x where { ?x <" + p + "> <" + o + "> . }"); |
| 252 | } | 278 | } |
| 253 | 279 | ||
| 254 | public void outputObjects(String s, String p) { | 280 | public void outputObjects(String s, String p) { |
| 281 | if(isDisposed()) throw new DisposedException(); | ||
| 282 | |||
| 255 | outputAnswers("select ?x where { <" + s + "> <" + p + "> ?x . }"); | 283 | outputAnswers("select ?x where { <" + s + "> <" + p + "> ?x . }"); |
| 256 | } | 284 | } |
| 257 | 285 | ||
| 258 | public void outputIDBFacts() { | 286 | public void outputIDBFacts() { |
| 287 | if(isDisposed()) throw new DisposedException(); | ||
| 288 | |||
| 259 | TupleIterator iter = null; | 289 | TupleIterator iter = null; |
| 260 | try { | 290 | try { |
| 261 | iter = internal_evaluateAgainstIDBs("select distict ?x ?y ?z where { ?x ?y ?z }"); | 291 | iter = internal_evaluateAgainstIDBs("select distict ?x ?y ?z where { ?x ?y ?z }"); |
| @@ -274,10 +304,14 @@ public class BasicQueryEngine extends RDFoxQueryEngine { | |||
| 274 | } | 304 | } |
| 275 | 305 | ||
| 276 | public void outputType4Individual(String iri) { | 306 | public void outputType4Individual(String iri) { |
| 307 | if(isDisposed()) throw new DisposedException(); | ||
| 308 | |||
| 277 | outputAnswers("select ?z where { <" + iri + "> " + Namespace.RDF_TYPE_QUOTED + " ?z }"); | 309 | outputAnswers("select ?z where { <" + iri + "> " + Namespace.RDF_TYPE_QUOTED + " ?z }"); |
| 278 | } | 310 | } |
| 279 | 311 | ||
| 280 | public int getSameAsNumber() { | 312 | public int getSameAsNumber() { |
| 313 | if(isDisposed()) throw new DisposedException(); | ||
| 314 | |||
| 281 | TupleIterator iter = null; | 315 | TupleIterator iter = null; |
| 282 | int counter = 0; | 316 | int counter = 0; |
| 283 | try { | 317 | try { |
| @@ -294,6 +328,8 @@ public class BasicQueryEngine extends RDFoxQueryEngine { | |||
| 294 | } | 328 | } |
| 295 | 329 | ||
| 296 | public UFS<String> getEqualityGroups(boolean reuse) { | 330 | public UFS<String> getEqualityGroups(boolean reuse) { |
| 331 | if(isDisposed()) throw new DisposedException(); | ||
| 332 | |||
| 297 | if(reuse && equalityGroups != null) return equalityGroups; | 333 | if(reuse && equalityGroups != null) return equalityGroups; |
| 298 | 334 | ||
| 299 | equalityGroups = new UFS<String>(); | 335 | equalityGroups = new UFS<String>(); |
| @@ -317,6 +353,8 @@ public class BasicQueryEngine extends RDFoxQueryEngine { | |||
| 317 | } | 353 | } |
| 318 | 354 | ||
| 319 | public void clearRulesAndIDBFacts(Collection<int[]> collection) { | 355 | public void clearRulesAndIDBFacts(Collection<int[]> collection) { |
| 356 | if(isDisposed()) throw new DisposedException(); | ||
| 357 | |||
| 320 | // performDeletion(collection); | 358 | // performDeletion(collection); |
| 321 | collection.clear(); | 359 | collection.clear(); |
| 322 | try { | 360 | try { |
diff --git a/src/uk/ac/ox/cs/pagoda/rules/approximators/LimitedSkolemisationApproximator.java b/src/uk/ac/ox/cs/pagoda/rules/approximators/LimitedSkolemisationApproximator.java index 3f1ed7e..5f6e362 100644 --- a/src/uk/ac/ox/cs/pagoda/rules/approximators/LimitedSkolemisationApproximator.java +++ b/src/uk/ac/ox/cs/pagoda/rules/approximators/LimitedSkolemisationApproximator.java | |||
| @@ -3,6 +3,7 @@ package uk.ac.ox.cs.pagoda.rules.approximators; | |||
| 3 | import org.semanticweb.HermiT.model.*; | 3 | import org.semanticweb.HermiT.model.*; |
| 4 | import uk.ac.ox.cs.pagoda.multistage.MultiStageUpperProgram; | 4 | import uk.ac.ox.cs.pagoda.multistage.MultiStageUpperProgram; |
| 5 | import uk.ac.ox.cs.pagoda.rules.ExistConstantApproximator; | 5 | import uk.ac.ox.cs.pagoda.rules.ExistConstantApproximator; |
| 6 | import uk.ac.ox.cs.pagoda.util.Utility; | ||
| 6 | import uk.ac.ox.cs.pagoda.util.tuples.Tuple; | 7 | import uk.ac.ox.cs.pagoda.util.tuples.Tuple; |
| 7 | import uk.ac.ox.cs.pagoda.util.tuples.TupleBuilder; | 8 | import uk.ac.ox.cs.pagoda.util.tuples.TupleBuilder; |
| 8 | 9 | ||
| @@ -53,12 +54,22 @@ public class LimitedSkolemisationApproximator implements TupleDependentApproxima | |||
| 53 | 54 | ||
| 54 | } | 55 | } |
| 55 | 56 | ||
| 57 | public int getMaxDepth(Tuple<Individual> violationTuple) { | ||
| 58 | int maxDepth = 0; | ||
| 59 | for(Individual individual : violationTuple) | ||
| 60 | maxDepth = Integer.max(maxDepth, skolemTermsManager.getDepthOf(individual)); | ||
| 61 | |||
| 62 | return maxDepth; | ||
| 63 | } | ||
| 64 | |||
| 56 | private Collection<DLClause> overApprox(DLClause clause, DLClause originalClause, Collection<Tuple<Individual>> violationTuples) { | 65 | private Collection<DLClause> overApprox(DLClause clause, DLClause originalClause, Collection<Tuple<Individual>> violationTuples) { |
| 57 | ArrayList<DLClause> result = new ArrayList<>(); | 66 | ArrayList<DLClause> result = new ArrayList<>(); |
| 58 | 67 | ||
| 59 | for (Tuple<Individual> violationTuple : violationTuples) | 68 | for (Tuple<Individual> violationTuple : violationTuples) |
| 60 | if (getMaxDepth(violationTuple) > maxTermDepth) | 69 | if(getMaxDepth(violationTuple) > maxTermDepth) { |
| 61 | result.addAll(alternativeApproximator.convert(clause, originalClause, null)); | 70 | result.addAll(alternativeApproximator.convert(clause, originalClause, null)); |
| 71 | Utility.logDebug("Approximating maximal individual by a constant in rule:" + originalClause); | ||
| 72 | } | ||
| 62 | else | 73 | else |
| 63 | result.addAll(getGroundSkolemisation(clause, originalClause, violationTuple)); | 74 | result.addAll(getGroundSkolemisation(clause, originalClause, violationTuple)); |
| 64 | 75 | ||
| @@ -138,13 +149,4 @@ public class LimitedSkolemisationApproximator implements TupleDependentApproxima | |||
| 138 | 149 | ||
| 139 | // END: copy and paste | 150 | // END: copy and paste |
| 140 | } | 151 | } |
| 141 | |||
| 142 | |||
| 143 | public int getMaxDepth(Tuple<Individual> violationTuple) { | ||
| 144 | int maxDepth = 0; | ||
| 145 | for (Individual individual : violationTuple) | ||
| 146 | maxDepth = Integer.max(maxDepth, skolemTermsManager.getDepthOf(individual)); | ||
| 147 | |||
| 148 | return maxDepth; | ||
| 149 | } | ||
| 150 | } | 152 | } |
diff --git a/src/uk/ac/ox/cs/pagoda/summary/HermitSummaryFilter.java b/src/uk/ac/ox/cs/pagoda/summary/HermitSummaryFilter.java index 90a2ed4..f3f08e9 100644 --- a/src/uk/ac/ox/cs/pagoda/summary/HermitSummaryFilter.java +++ b/src/uk/ac/ox/cs/pagoda/summary/HermitSummaryFilter.java | |||
| @@ -14,11 +14,12 @@ import uk.ac.ox.cs.pagoda.reasoner.full.HermitChecker; | |||
| 14 | import uk.ac.ox.cs.pagoda.tracking.TrackingRuleEncoder; | 14 | import uk.ac.ox.cs.pagoda.tracking.TrackingRuleEncoder; |
| 15 | import uk.ac.ox.cs.pagoda.util.Timer; | 15 | import uk.ac.ox.cs.pagoda.util.Timer; |
| 16 | import uk.ac.ox.cs.pagoda.util.Utility; | 16 | import uk.ac.ox.cs.pagoda.util.Utility; |
| 17 | import uk.ac.ox.cs.pagoda.util.disposable.DisposedException; | ||
| 17 | 18 | ||
| 18 | import java.util.HashSet; | 19 | import java.util.HashSet; |
| 19 | import java.util.Set; | 20 | import java.util.Set; |
| 20 | 21 | ||
| 21 | public class HermitSummaryFilter implements Checker { | 22 | public class HermitSummaryFilter extends Checker { |
| 22 | 23 | ||
| 23 | public static final String QueryAnswerTermPrefix = TrackingRuleEncoder.QueryPredicate + "_term"; | 24 | public static final String QueryAnswerTermPrefix = TrackingRuleEncoder.QueryPredicate + "_term"; |
| 24 | QueryRecord m_record; | 25 | QueryRecord m_record; |
| @@ -97,6 +98,8 @@ public class HermitSummaryFilter implements Checker { | |||
| 97 | 98 | ||
| 98 | @Override | 99 | @Override |
| 99 | public boolean isConsistent() { | 100 | public boolean isConsistent() { |
| 101 | if(isDisposed()) throw new DisposedException(); | ||
| 102 | |||
| 100 | if (summary == null) | 103 | if (summary == null) |
| 101 | summary = new Summary(endomorphismChecker.getOntology(), endomorphismChecker.getGraph()); | 104 | summary = new Summary(endomorphismChecker.getOntology(), endomorphismChecker.getGraph()); |
| 102 | 105 | ||
| @@ -107,31 +110,22 @@ public class HermitSummaryFilter implements Checker { | |||
| 107 | return endomorphismChecker.isConsistent(); | 110 | return endomorphismChecker.isConsistent(); |
| 108 | } | 111 | } |
| 109 | 112 | ||
| 110 | private void initialiseSummarisedReasoner() { | ||
| 111 | Timer t = new Timer(); | ||
| 112 | summarisedHermiT = new HermitChecker(summary.getSummary(), summary.getSummary(m_record)); | ||
| 113 | // summary.save("summarised_query" + m_record.getQueryID() + ".owl"); | ||
| 114 | if(summarisedConsistency = summarisedHermiT.isConsistent()) | ||
| 115 | Utility.logDebug("The summary of ABox is consistent with the TBox."); | ||
| 116 | else | ||
| 117 | Utility.logDebug("The summary of ABox is NOT consistent with the TBox."); | ||
| 118 | m_record.addProcessingTime(Step.SUMMARISATION, t.duration()); | ||
| 119 | } | ||
| 120 | |||
| 121 | @Override | 113 | @Override |
| 122 | public int check(AnswerTuples answers) { | 114 | public int check(AnswerTuples answers) { |
| 115 | if(isDisposed()) throw new DisposedException(); | ||
| 116 | |||
| 123 | Timer t = new Timer(); | 117 | Timer t = new Timer(); |
| 124 | OWLOntology newOntology = addOntologyWithQueryPreciate(endomorphismChecker.getOntology(), m_record, answers); | 118 | OWLOntology newOntology = addOntologyWithQueryPreciate(endomorphismChecker.getOntology(), m_record, answers); |
| 125 | summary = new Summary(newOntology); | 119 | summary = new Summary(newOntology); |
| 126 | initialiseSummarisedReasoner(); | 120 | initialiseSummarisedReasoner(); |
| 127 | 121 | ||
| 128 | if (summarisedConsistency) { | 122 | if(summarisedConsistency) { |
| 129 | Set<AnswerTuple> passed = new HashSet<AnswerTuple>(), succ = new HashSet<AnswerTuple>(); | 123 | Set<AnswerTuple> passed = new HashSet<AnswerTuple>(), succ = new HashSet<AnswerTuple>(); |
| 130 | Set<AnswerTuple> falsified = new HashSet<AnswerTuple>(), fail = new HashSet<AnswerTuple>(); | 124 | Set<AnswerTuple> falsified = new HashSet<AnswerTuple>(), fail = new HashSet<AnswerTuple>(); |
| 131 | 125 | ||
| 132 | int counter = 0; | 126 | int counter = 0; |
| 133 | AnswerTuple representative; | 127 | AnswerTuple representative; |
| 134 | for (AnswerTuple answer; answers.isValid(); answers.moveNext()) { | 128 | for(AnswerTuple answer; answers.isValid(); answers.moveNext()) { |
| 135 | ++counter; | 129 | ++counter; |
| 136 | answer = answers.getTuple(); | 130 | answer = answers.getTuple(); |
| 137 | representative = summary.getSummary(answer); | 131 | representative = summary.getSummary(answer); |
| @@ -140,13 +134,13 @@ public class HermitSummaryFilter implements Checker { | |||
| 140 | else if(succ.contains(representative)) | 134 | else if(succ.contains(representative)) |
| 141 | passed.add(answer); | 135 | passed.add(answer); |
| 142 | else if(summarisedHermiT.check(representative)) { | 136 | else if(summarisedHermiT.check(representative)) { |
| 143 | succ.add(representative); | 137 | succ.add(representative); |
| 144 | passed.add(answer); | 138 | passed.add(answer); |
| 145 | } | 139 | } |
| 146 | else { | 140 | else { |
| 147 | fail.add(representative); | 141 | fail.add(representative); |
| 148 | falsified.add(answer); | 142 | falsified.add(answer); |
| 149 | } | 143 | } |
| 150 | } | 144 | } |
| 151 | answers.dispose(); | 145 | answers.dispose(); |
| 152 | 146 | ||
| @@ -177,16 +171,31 @@ public class HermitSummaryFilter implements Checker { | |||
| 177 | 171 | ||
| 178 | @Override | 172 | @Override |
| 179 | public boolean check(AnswerTuple answer) { | 173 | public boolean check(AnswerTuple answer) { |
| 180 | AnswerTuple representative = summary.getSummary(answer); | 174 | if(isDisposed()) throw new DisposedException(); |
| 181 | if (summarisedHermiT.isConsistent() && !summarisedHermiT.check(representative)) | 175 | |
| 176 | AnswerTuple representative = summary.getSummary(answer); | ||
| 177 | if(summarisedHermiT.isConsistent() && !summarisedHermiT.check(representative)) | ||
| 182 | return false; | 178 | return false; |
| 183 | return endomorphismChecker.check(answer); | 179 | return endomorphismChecker.check(answer); |
| 184 | } | 180 | } |
| 185 | 181 | ||
| 186 | @Override | 182 | @Override |
| 187 | public void dispose() { | 183 | public void dispose() { |
| 188 | if (summarisedHermiT != null) summarisedHermiT.dispose(); | 184 | super.dispose(); |
| 189 | endomorphismChecker.dispose(); | 185 | |
| 186 | if(summarisedHermiT != null) summarisedHermiT.dispose(); | ||
| 187 | endomorphismChecker.dispose(); | ||
| 188 | } | ||
| 189 | |||
| 190 | private void initialiseSummarisedReasoner() { | ||
| 191 | Timer t = new Timer(); | ||
| 192 | summarisedHermiT = new HermitChecker(summary.getSummary(), summary.getSummary(m_record)); | ||
| 193 | // summary.save("summarised_query" + m_record.getQueryID() + ".owl"); | ||
| 194 | if(summarisedConsistency = summarisedHermiT.isConsistent()) | ||
| 195 | Utility.logDebug("The summary of ABox is consistent with the TBox."); | ||
| 196 | else | ||
| 197 | Utility.logDebug("The summary of ABox is NOT consistent with the TBox."); | ||
| 198 | m_record.addProcessingTime(Step.SUMMARISATION, t.duration()); | ||
| 190 | } | 199 | } |
| 191 | 200 | ||
| 192 | } | 201 | } |
diff --git a/src/uk/ac/ox/cs/pagoda/util/PagodaProperties.java b/src/uk/ac/ox/cs/pagoda/util/PagodaProperties.java index be6627a..7b7d48d 100644 --- a/src/uk/ac/ox/cs/pagoda/util/PagodaProperties.java +++ b/src/uk/ac/ox/cs/pagoda/util/PagodaProperties.java | |||
| @@ -1,5 +1,7 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.util; | 1 | package uk.ac.ox.cs.pagoda.util; |
| 2 | 2 | ||
| 3 | import org.apache.log4j.Logger; | ||
| 4 | |||
| 3 | import java.io.FileInputStream; | 5 | import java.io.FileInputStream; |
| 4 | import java.io.IOException; | 6 | import java.io.IOException; |
| 5 | import java.io.InputStream; | 7 | import java.io.InputStream; |
| @@ -20,6 +22,8 @@ public class PagodaProperties { | |||
| 20 | in.close(); | 22 | in.close(); |
| 21 | if(config.containsKey("debug")) { | 23 | if(config.containsKey("debug")) { |
| 22 | debug = Boolean.parseBoolean(config.getProperty("debug")); | 24 | debug = Boolean.parseBoolean(config.getProperty("debug")); |
| 25 | Logger.getLogger("PagodaProperties") | ||
| 26 | .info("Debugging mode is enabled (you can disable it from file \"pagoda.properties\")"); | ||
| 23 | } | 27 | } |
| 24 | } catch(IOException e) { | 28 | } catch(IOException e) { |
| 25 | e.printStackTrace(); | 29 | e.printStackTrace(); |
diff --git a/src/uk/ac/ox/cs/pagoda/util/Utility.java b/src/uk/ac/ox/cs/pagoda/util/Utility.java index e98cc81..cef4abd 100644 --- a/src/uk/ac/ox/cs/pagoda/util/Utility.java +++ b/src/uk/ac/ox/cs/pagoda/util/Utility.java | |||
| @@ -29,7 +29,7 @@ public class Utility { | |||
| 29 | private static StringBuilder logMessage = new StringBuilder(); | 29 | private static StringBuilder logMessage = new StringBuilder(); |
| 30 | 30 | ||
| 31 | static { | 31 | static { |
| 32 | LOGS = Logger.getLogger("PAGOdA"); | 32 | LOGS = Logger.getLogger("Pagoda"); |
| 33 | LOGS.setLevel(Level.DEBUG); | 33 | LOGS.setLevel(Level.DEBUG); |
| 34 | } | 34 | } |
| 35 | 35 | ||
| @@ -37,6 +37,10 @@ public class Utility { | |||
| 37 | outs.push(System.out); | 37 | outs.push(System.out); |
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | static { | ||
| 41 | |||
| 42 | } | ||
| 43 | |||
| 40 | public static String getGlobalTempDirAbsolutePath() { | 44 | public static String getGlobalTempDirAbsolutePath() { |
| 41 | if(tempDir == null) { | 45 | if(tempDir == null) { |
| 42 | try { | 46 | try { |
diff --git a/test/resources/HeavyTests.xml b/test/resources/HeavyTests.xml index 4a96553..c0b0044 100644 --- a/test/resources/HeavyTests.xml +++ b/test/resources/HeavyTests.xml | |||
| @@ -11,7 +11,7 @@ | |||
| 11 | </groups> | 11 | </groups> |
| 12 | <classes> | 12 | <classes> |
| 13 | <class name="uk.ac.ox.cs.pagoda.global_tests.TestPagodaUOBM"/> | 13 | <class name="uk.ac.ox.cs.pagoda.global_tests.TestPagodaUOBM"/> |
| 14 | <class name="uk.ac.ox.cs.pagoda.global_tests.TestPagodaLUBM"/> | 14 | <!--<class name="uk.ac.ox.cs.pagoda.global_tests.TestPagodaLUBM"/>--> |
| 15 | </classes> | 15 | </classes> |
| 16 | </test> | 16 | </test> |
| 17 | </suite> \ No newline at end of file | 17 | </suite> \ No newline at end of file |
diff --git a/test/resources/LightTests.xml b/test/resources/LightTests.xml index d8691d7..92edb48 100644 --- a/test/resources/LightTests.xml +++ b/test/resources/LightTests.xml | |||
| @@ -12,6 +12,7 @@ | |||
| 12 | <classes> | 12 | <classes> |
| 13 | <class name="uk.ac.ox.cs.pagoda.global_tests.TestPagodaUOBM"/> | 13 | <class name="uk.ac.ox.cs.pagoda.global_tests.TestPagodaUOBM"/> |
| 14 | <class name="uk.ac.ox.cs.pagoda.global_tests.TestPagodaLUBM"/> | 14 | <class name="uk.ac.ox.cs.pagoda.global_tests.TestPagodaLUBM"/> |
| 15 | <!--Fly does not terminate: query-5 is really hard--> | ||
| 15 | <!--<class name="uk.ac.ox.cs.pagoda.global_tests.TestPagodaFLY"/>--> | 16 | <!--<class name="uk.ac.ox.cs.pagoda.global_tests.TestPagodaFLY"/>--> |
| 16 | </classes> | 17 | </classes> |
| 17 | </test> | 18 | </test> |
