diff options
Diffstat (limited to 'src/uk')
17 files changed, 217 insertions, 182 deletions
diff --git a/src/uk/ac/ox/cs/pagoda/multistage/MultiStageQueryEngine.java b/src/uk/ac/ox/cs/pagoda/multistage/MultiStageQueryEngine.java index b74fe7d..b77c264 100644 --- a/src/uk/ac/ox/cs/pagoda/multistage/MultiStageQueryEngine.java +++ b/src/uk/ac/ox/cs/pagoda/multistage/MultiStageQueryEngine.java | |||
| @@ -18,6 +18,9 @@ public class MultiStageQueryEngine extends StageQueryEngine { | |||
| 18 | super(name, checkValidity); | 18 | super(name, checkValidity); |
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | /** | ||
| 22 | * c-chase | ||
| 23 | */ | ||
| 21 | @Override | 24 | @Override |
| 22 | public void materialiseFoldedly(DatalogProgram dProgram, GapByStore4ID gap) { | 25 | public void materialiseFoldedly(DatalogProgram dProgram, GapByStore4ID gap) { |
| 23 | materialise("lower program", dProgram.getLower().toString()); | 26 | materialise("lower program", dProgram.getLower().toString()); |
| @@ -27,6 +30,9 @@ public class MultiStageQueryEngine extends StageQueryEngine { | |||
| 27 | materialise(program, treatment, gap); | 30 | materialise(program, treatment, gap); |
| 28 | } | 31 | } |
| 29 | 32 | ||
| 33 | /** | ||
| 34 | * c-chase^f | ||
| 35 | */ | ||
| 30 | @Override | 36 | @Override |
| 31 | public int materialiseRestrictedly(DatalogProgram dProgram, GapByStore4ID gap) { | 37 | public int materialiseRestrictedly(DatalogProgram dProgram, GapByStore4ID gap) { |
| 32 | if (gap != null) | 38 | if (gap != null) |
diff --git a/src/uk/ac/ox/cs/pagoda/multistage/MultiStageUpperProgram.java b/src/uk/ac/ox/cs/pagoda/multistage/MultiStageUpperProgram.java index caa26fa..4239ccc 100644 --- a/src/uk/ac/ox/cs/pagoda/multistage/MultiStageUpperProgram.java +++ b/src/uk/ac/ox/cs/pagoda/multistage/MultiStageUpperProgram.java | |||
| @@ -245,6 +245,7 @@ public abstract class MultiStageUpperProgram { | |||
| 245 | if (tuples != null) tuples.dispose(); | 245 | if (tuples != null) tuples.dispose(); |
| 246 | } | 246 | } |
| 247 | 247 | ||
| 248 | tuples = null; | ||
| 248 | try { | 249 | try { |
| 249 | tuples = engine.internal_evaluateNotExpanded(SparqlHelper.getSPARQLQuery(atoms, x, y)); | 250 | tuples = engine.internal_evaluateNotExpanded(SparqlHelper.getSPARQLQuery(atoms, x, y)); |
| 250 | for (long multi = tuples.open(); multi != 0; multi = tuples.getNext()) | 251 | for (long multi = tuples.open(); multi != 0; multi = tuples.getNext()) |
| @@ -279,7 +280,7 @@ public abstract class MultiStageUpperProgram { | |||
| 279 | TupleIterator tuples = null; | 280 | TupleIterator tuples = null; |
| 280 | try { | 281 | try { |
| 281 | tuples = engine.internal_evaluateNotExpanded(headQuery); | 282 | tuples = engine.internal_evaluateNotExpanded(headQuery); |
| 282 | for (; tuples.isValid(); tuples.getNext()) | 283 | for (long multi = tuples.open(); multi != 0; multi = tuples.getNext()) |
| 283 | headAnswers.add(new AnswerTupleID(tuples)); | 284 | headAnswers.add(new AnswerTupleID(tuples)); |
| 284 | } catch (JRDFStoreException e) { | 285 | } catch (JRDFStoreException e) { |
| 285 | e.printStackTrace(); | 286 | e.printStackTrace(); |
diff --git a/src/uk/ac/ox/cs/pagoda/multistage/TwoStageApplication.java b/src/uk/ac/ox/cs/pagoda/multistage/TwoStageApplication.java index e52213b..f08bfbd 100644 --- a/src/uk/ac/ox/cs/pagoda/multistage/TwoStageApplication.java +++ b/src/uk/ac/ox/cs/pagoda/multistage/TwoStageApplication.java | |||
| @@ -149,8 +149,8 @@ abstract class TwoStageApplication { | |||
| 149 | // TODO Auto-generated catch block | 149 | // TODO Auto-generated catch block |
| 150 | e.printStackTrace(); | 150 | e.printStackTrace(); |
| 151 | } finally { | 151 | } finally { |
| 152 | if (tuples != null) | 152 | if (tuples != null) tuples.dispose(); |
| 153 | tuples.dispose(); | 153 | tuples = null; |
| 154 | } | 154 | } |
| 155 | } | 155 | } |
| 156 | } | 156 | } |
| @@ -209,8 +209,7 @@ abstract class TwoStageApplication { | |||
| 209 | // TODO Auto-generated catch block | 209 | // TODO Auto-generated catch block |
| 210 | e.printStackTrace(); | 210 | e.printStackTrace(); |
| 211 | } finally { | 211 | } finally { |
| 212 | if (tuples != null) | 212 | if (tuples != null) tuples.dispose(); |
| 213 | tuples.dispose(); | ||
| 214 | } | 213 | } |
| 215 | return ret; | 214 | return ret; |
| 216 | } | 215 | } |
diff --git a/src/uk/ac/ox/cs/pagoda/query/GapByTriple.java b/src/uk/ac/ox/cs/pagoda/query/GapByTriple.java index 1a94f07..a1c1b0e 100644 --- a/src/uk/ac/ox/cs/pagoda/query/GapByTriple.java +++ b/src/uk/ac/ox/cs/pagoda/query/GapByTriple.java | |||
| @@ -53,7 +53,7 @@ public class GapByTriple extends GapTupleIterator<String> { | |||
| 53 | 53 | ||
| 54 | @Override | 54 | @Override |
| 55 | public boolean hasNext() { | 55 | public boolean hasNext() { |
| 56 | TupleIterator iter; | 56 | TupleIterator iter = null; |
| 57 | boolean inGap; | 57 | boolean inGap; |
| 58 | StringBuffer queryBuffer = new StringBuffer(); | 58 | StringBuffer queryBuffer = new StringBuffer(); |
| 59 | try { | 59 | try { |
| @@ -75,9 +75,13 @@ public class GapByTriple extends GapTupleIterator<String> { | |||
| 75 | queryBuffer.setLength(0); | 75 | queryBuffer.setLength(0); |
| 76 | queryBuffer.append("SELECT WHERE { ").append(sub).append(" ").append(predicate).append(" ").append(obj).append(" }"); | 76 | queryBuffer.append("SELECT WHERE { ").append(sub).append(" ").append(predicate).append(" ").append(obj).append(" }"); |
| 77 | 77 | ||
| 78 | iter = lowerStore.compileQuery(queryBuffer.toString(), prefixes, parameters); | 78 | try { |
| 79 | inGap = iter.open() != 0; | 79 | iter = lowerStore.compileQuery(queryBuffer.toString(), prefixes, parameters); |
| 80 | iter.dispose(); | 80 | inGap = iter.open() != 0; |
| 81 | } finally { | ||
| 82 | if (iter != null) iter.dispose(); | ||
| 83 | iter = null; | ||
| 84 | } | ||
| 81 | if (inGap) | 85 | if (inGap) |
| 82 | return true; | 86 | return true; |
| 83 | } | 87 | } |
diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/ConsistencyManager.java b/src/uk/ac/ox/cs/pagoda/reasoner/ConsistencyManager.java index a222645..7d3e40c 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/ConsistencyManager.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/ConsistencyManager.java | |||
| @@ -43,7 +43,15 @@ public class ConsistencyManager { | |||
| 43 | 43 | ||
| 44 | boolean checkRLLowerBound() { | 44 | boolean checkRLLowerBound() { |
| 45 | fullQueryRecord = m_queryManager.create(QueryRecord.botQueryText, 0); | 45 | fullQueryRecord = m_queryManager.create(QueryRecord.botQueryText, 0); |
| 46 | fullQueryRecord.updateLowerBoundAnswers(m_reasoner.rlLowerStore.evaluate(fullQueryRecord.getQueryText(), fullQueryRecord.getAnswerVariables())); | 46 | AnswerTuples iter = null; |
| 47 | |||
| 48 | try { | ||
| 49 | iter = m_reasoner.rlLowerStore.evaluate(fullQueryRecord.getQueryText(), fullQueryRecord.getAnswerVariables()); | ||
| 50 | fullQueryRecord.updateLowerBoundAnswers(iter); | ||
| 51 | } finally { | ||
| 52 | iter.dispose(); | ||
| 53 | } | ||
| 54 | |||
| 47 | if (fullQueryRecord.getNoOfSoundAnswers() > 0) { | 55 | if (fullQueryRecord.getNoOfSoundAnswers() > 0) { |
| 48 | Utility.logInfo("Answers to bottom in the lower bound: ", fullQueryRecord.outputSoundAnswerTuple()); | 56 | Utility.logInfo("Answers to bottom in the lower bound: ", fullQueryRecord.outputSoundAnswerTuple()); |
| 49 | return unsatisfiability(t.duration()); | 57 | return unsatisfiability(t.duration()); |
| @@ -81,8 +89,15 @@ public class ConsistencyManager { | |||
| 81 | // if (!checkRLLowerBound()) return false; | 89 | // if (!checkRLLowerBound()) return false; |
| 82 | // if (!checkELLowerBound()) return false; | 90 | // if (!checkELLowerBound()) return false; |
| 83 | // if (checkLazyUpper()) return true; | 91 | // if (checkLazyUpper()) return true; |
| 92 | AnswerTuples iter = null; | ||
| 93 | |||
| 94 | try { | ||
| 95 | iter = m_reasoner.trackingStore.evaluate(fullQueryRecord.getQueryText(), fullQueryRecord.getAnswerVariables()); | ||
| 96 | fullQueryRecord.updateUpperBoundAnswers(iter); | ||
| 97 | } finally { | ||
| 98 | if (iter != null) iter.dispose(); | ||
| 99 | } | ||
| 84 | 100 | ||
| 85 | fullQueryRecord.updateUpperBoundAnswers(m_reasoner.trackingStore.evaluate(fullQueryRecord.getQueryText(), fullQueryRecord.getAnswerVariables())); | ||
| 86 | if (fullQueryRecord.getNoOfCompleteAnswers() == 0) | 101 | if (fullQueryRecord.getNoOfCompleteAnswers() == 0) |
| 87 | return satisfiability(t.duration()); | 102 | return satisfiability(t.duration()); |
| 88 | 103 | ||
| @@ -101,7 +116,7 @@ public class ConsistencyManager { | |||
| 101 | for (QueryRecord r: getQueryRecords()) { | 116 | for (QueryRecord r: getQueryRecords()) { |
| 102 | // TODO to be removed ... | 117 | // TODO to be removed ... |
| 103 | // r.saveRelevantOntology("bottom" + r.getQueryID() + ".owl"); | 118 | // r.saveRelevantOntology("bottom" + r.getQueryID() + ".owl"); |
| 104 | checker = new HermitSummaryFilter(r); // m_reasoner.factory.getSummarisedReasoner(r); | 119 | checker = new HermitSummaryFilter(r, true); // m_reasoner.factory.getSummarisedReasoner(r); |
| 105 | satisfiability = checker.isConsistent(); | 120 | satisfiability = checker.isConsistent(); |
| 106 | checker.dispose(); | 121 | checker.dispose(); |
| 107 | if (!satisfiability) return unsatisfiability(t.duration()); | 122 | if (!satisfiability) return unsatisfiability(t.duration()); |
| @@ -143,8 +158,15 @@ public class ConsistencyManager { | |||
| 143 | QueryRecord[] tempQueryRecords = new QueryRecord[number - 1]; | 158 | QueryRecord[] tempQueryRecords = new QueryRecord[number - 1]; |
| 144 | QueryRecord record; | 159 | QueryRecord record; |
| 145 | for (int i = 0; i < number - 1; ++i) { | 160 | for (int i = 0; i < number - 1; ++i) { |
| 146 | tempQueryRecords[i] = record = m_queryManager.create(QueryRecord.botQueryText.replace("Nothing", "Nothing" + (i + 1)), 0, i + 1); | 161 | tempQueryRecords[i] = record = m_queryManager.create(QueryRecord.botQueryText.replace("Nothing", "Nothing" + (i + 1)), 0, i + 1); |
| 147 | record.updateUpperBoundAnswers(m_reasoner.trackingStore.evaluate(record.getQueryText(), record.getAnswerVariables())); | 162 | AnswerTuples iter = null; |
| 163 | try { | ||
| 164 | iter = m_reasoner.trackingStore.evaluate(record.getQueryText(), record.getAnswerVariables()); | ||
| 165 | record.updateUpperBoundAnswers(iter); | ||
| 166 | } finally { | ||
| 167 | if (iter != null) iter.dispose(); | ||
| 168 | iter = null; | ||
| 169 | } | ||
| 148 | } | 170 | } |
| 149 | 171 | ||
| 150 | int bottomNumber = 0; | 172 | int bottomNumber = 0; |
diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/ConsistencyManager2.java b/src/uk/ac/ox/cs/pagoda/reasoner/ConsistencyManager2.java index 67dc4fc..9c335f3 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/ConsistencyManager2.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/ConsistencyManager2.java | |||
| @@ -3,6 +3,7 @@ package uk.ac.ox.cs.pagoda.reasoner; | |||
| 3 | import org.semanticweb.owlapi.model.OWLOntologyCreationException; | 3 | import org.semanticweb.owlapi.model.OWLOntologyCreationException; |
| 4 | import org.semanticweb.owlapi.model.OWLOntologyManager; | 4 | import org.semanticweb.owlapi.model.OWLOntologyManager; |
| 5 | 5 | ||
| 6 | import uk.ac.ox.cs.pagoda.query.AnswerTuples; | ||
| 6 | import uk.ac.ox.cs.pagoda.query.QueryRecord; | 7 | import uk.ac.ox.cs.pagoda.query.QueryRecord; |
| 7 | import uk.ac.ox.cs.pagoda.reasoner.full.Checker; | 8 | import uk.ac.ox.cs.pagoda.reasoner.full.Checker; |
| 8 | import uk.ac.ox.cs.pagoda.summary.HermitSummaryFilter; | 9 | import uk.ac.ox.cs.pagoda.summary.HermitSummaryFilter; |
| @@ -32,8 +33,15 @@ public class ConsistencyManager2 extends ConsistencyManager { | |||
| 32 | // if (!checkRLLowerBound()) return false; | 33 | // if (!checkRLLowerBound()) return false; |
| 33 | // if (!checkELLowerBound()) return false; | 34 | // if (!checkELLowerBound()) return false; |
| 34 | if (checkLazyUpper()) return true; | 35 | if (checkLazyUpper()) return true; |
| 36 | AnswerTuples iter = null; | ||
| 37 | |||
| 38 | try { | ||
| 39 | iter = m_reasoner.trackingStore.evaluate(fullQueryRecord.getQueryText(), fullQueryRecord.getAnswerVariables()); | ||
| 40 | fullQueryRecord.updateUpperBoundAnswers(iter); | ||
| 41 | } finally { | ||
| 42 | if (iter != null) iter.dispose(); | ||
| 43 | } | ||
| 35 | 44 | ||
| 36 | fullQueryRecord.updateUpperBoundAnswers(m_reasoner.trackingStore.evaluate(fullQueryRecord.getQueryText(), fullQueryRecord.getAnswerVariables())); | ||
| 37 | if (fullQueryRecord.getNoOfCompleteAnswers() == 0) | 45 | if (fullQueryRecord.getNoOfCompleteAnswers() == 0) |
| 38 | return satisfiability(t.duration()); | 46 | return satisfiability(t.duration()); |
| 39 | 47 | ||
| @@ -43,7 +51,7 @@ public class ConsistencyManager2 extends ConsistencyManager { | |||
| 43 | e.printStackTrace(); | 51 | e.printStackTrace(); |
| 44 | } | 52 | } |
| 45 | 53 | ||
| 46 | Checker checker = new HermitSummaryFilter(fullQueryRecord); // m_reasoner.factory.getSummarisedReasoner(fullQueryRecord); | 54 | Checker checker = new HermitSummaryFilter(fullQueryRecord, true); // m_reasoner.factory.getSummarisedReasoner(fullQueryRecord); |
| 47 | // fullQueryRecord.saveRelevantOntology("fragment_bottom.owl"); | 55 | // fullQueryRecord.saveRelevantOntology("fragment_bottom.owl"); |
| 48 | boolean satisfiable = checker.isConsistent(); | 56 | boolean satisfiable = checker.isConsistent(); |
| 49 | checker.dispose(); | 57 | checker.dispose(); |
diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/ELHOQueryReasoner.java b/src/uk/ac/ox/cs/pagoda/reasoner/ELHOQueryReasoner.java index 4ebe5f2..ab57ccf 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/ELHOQueryReasoner.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/ELHOQueryReasoner.java | |||
| @@ -54,7 +54,7 @@ public class ELHOQueryReasoner extends QueryReasoner { | |||
| 54 | 54 | ||
| 55 | @Override | 55 | @Override |
| 56 | public void loadOntology(OWLOntology ontology) { | 56 | public void loadOntology(OWLOntology ontology) { |
| 57 | program = new LowerDatalogProgram(!forSemFacet); | 57 | program = new LowerDatalogProgram(properties.getToClassify()); |
| 58 | program.load(ontology, new UnaryBottom()); | 58 | program.load(ontology, new UnaryBottom()); |
| 59 | program.transform(); | 59 | program.transform(); |
| 60 | 60 | ||
diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/ELHOUQueryReasoner.java b/src/uk/ac/ox/cs/pagoda/reasoner/ELHOUQueryReasoner.java index 62d238b..0d24a02 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/ELHOUQueryReasoner.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/ELHOUQueryReasoner.java | |||
| @@ -113,7 +113,7 @@ public class ELHOUQueryReasoner extends QueryReasoner { | |||
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | OWLOntology ontology = o; | 115 | OWLOntology ontology = o; |
| 116 | program = new DatalogProgram(ontology, !forSemFacet); | 116 | program = new DatalogProgram(ontology, properties.getToClassify()); |
| 117 | 117 | ||
| 118 | importData(program.getAdditionalDataFile()); | 118 | importData(program.getAdditionalDataFile()); |
| 119 | 119 | ||
diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/IterativeRefinement.java b/src/uk/ac/ox/cs/pagoda/reasoner/IterativeRefinement.java index ba6a4d4..447a92d 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/IterativeRefinement.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/IterativeRefinement.java | |||
| @@ -7,6 +7,7 @@ import org.semanticweb.owlapi.model.OWLOntology; | |||
| 7 | import uk.ac.ox.cs.pagoda.constraints.BottomStrategy; | 7 | import uk.ac.ox.cs.pagoda.constraints.BottomStrategy; |
| 8 | import uk.ac.ox.cs.pagoda.constraints.UpperUnaryBottom; | 8 | import uk.ac.ox.cs.pagoda.constraints.UpperUnaryBottom; |
| 9 | import uk.ac.ox.cs.pagoda.multistage.MultiStageQueryEngine; | 9 | import uk.ac.ox.cs.pagoda.multistage.MultiStageQueryEngine; |
| 10 | import uk.ac.ox.cs.pagoda.query.AnswerTuples; | ||
| 10 | import uk.ac.ox.cs.pagoda.query.QueryRecord; | 11 | import uk.ac.ox.cs.pagoda.query.QueryRecord; |
| 11 | import uk.ac.ox.cs.pagoda.reasoner.light.BasicQueryEngine; | 12 | import uk.ac.ox.cs.pagoda.reasoner.light.BasicQueryEngine; |
| 12 | import uk.ac.ox.cs.pagoda.rules.GeneralProgram; | 13 | import uk.ac.ox.cs.pagoda.rules.GeneralProgram; |
| @@ -47,7 +48,13 @@ public class IterativeRefinement { | |||
| 47 | return m_record.getRelevantOntology(); | 48 | return m_record.getRelevantOntology(); |
| 48 | } | 49 | } |
| 49 | 50 | ||
| 50 | update = m_record.updateUpperBoundAnswers(tEngine.evaluate(m_record.getQueryText())); | 51 | AnswerTuples ans = null; |
| 52 | try { | ||
| 53 | ans = tEngine.evaluate(m_record.getQueryText()); | ||
| 54 | update = m_record.updateUpperBoundAnswers(ans); | ||
| 55 | } finally { | ||
| 56 | if (ans != null) ans.dispose(); | ||
| 57 | } | ||
| 51 | } finally { | 58 | } finally { |
| 52 | tEngine.dispose(); | 59 | tEngine.dispose(); |
| 53 | } | 60 | } |
| @@ -78,7 +85,13 @@ public class IterativeRefinement { | |||
| 78 | return m_record.getRelevantOntology(); | 85 | return m_record.getRelevantOntology(); |
| 79 | } | 86 | } |
| 80 | 87 | ||
| 81 | update = m_record.updateUpperBoundAnswers(tEngine.evaluate(m_record.getQueryText())); | 88 | AnswerTuples ans = null; |
| 89 | try { | ||
| 90 | ans = tEngine.evaluate(m_record.getQueryText()); | ||
| 91 | update = m_record.updateUpperBoundAnswers(ans); | ||
| 92 | } finally { | ||
| 93 | if (ans != null) ans.dispose(); | ||
| 94 | } | ||
| 82 | } finally { | 95 | } finally { |
| 83 | tEngine.dispose(); | 96 | tEngine.dispose(); |
| 84 | } | 97 | } |
diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java b/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java index 2c2feae..875dcdd 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java | |||
| @@ -85,7 +85,7 @@ public class MyQueryReasoner extends QueryReasoner { | |||
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | ontology = o; | 87 | ontology = o; |
| 88 | program = new DatalogProgram(ontology, !forSemFacet); | 88 | program = new DatalogProgram(ontology, properties.getToClassify()); |
| 89 | // program.getLower().save(); | 89 | // program.getLower().save(); |
| 90 | // program.getUpper().save(); | 90 | // program.getUpper().save(); |
| 91 | // program.getGeneral().save(); | 91 | // program.getGeneral().save(); |
| @@ -275,11 +275,10 @@ public class MyQueryReasoner extends QueryReasoner { | |||
| 275 | rlAnswer = upperStore.evaluate(queryText, answerVariables); | 275 | rlAnswer = upperStore.evaluate(queryText, answerVariables); |
| 276 | Utility.logDebug(t.duration()); | 276 | Utility.logDebug(t.duration()); |
| 277 | queryRecord.updateUpperBoundAnswers(rlAnswer); | 277 | queryRecord.updateUpperBoundAnswers(rlAnswer); |
| 278 | rlAnswer.dispose(); | ||
| 279 | } finally { | 278 | } finally { |
| 280 | if (rlAnswer != null) rlAnswer.dispose(); | 279 | if (rlAnswer != null) rlAnswer.dispose(); |
| 280 | rlAnswer = null; | ||
| 281 | } | 281 | } |
| 282 | rlAnswer = null; | ||
| 283 | } | 282 | } |
| 284 | 283 | ||
| 285 | @Override | 284 | @Override |
| @@ -296,11 +295,11 @@ public class MyQueryReasoner extends QueryReasoner { | |||
| 296 | // queryRecord.saveRelevantOntology("fragment_query" + queryRecord.getQueryID() + ".owl"); | 295 | // queryRecord.saveRelevantOntology("fragment_query" + queryRecord.getQueryID() + ".owl"); |
| 297 | 296 | ||
| 298 | Timer t = new Timer(); | 297 | Timer t = new Timer(); |
| 299 | Checker summarisedChecker = new HermitSummaryFilter(queryRecord); | 298 | Checker summarisedChecker = new HermitSummaryFilter(queryRecord, properties.getToCallHermiT()); |
| 300 | int validNumber = summarisedChecker.check(queryRecord.getGapAnswers()); | 299 | int validNumber = summarisedChecker.check(queryRecord.getGapAnswers()); |
| 301 | summarisedChecker.dispose(); | 300 | summarisedChecker.dispose(); |
| 302 | Utility.logDebug("Total time for full reasoner: " + t.duration()); | 301 | Utility.logDebug("Total time for full reasoner: " + t.duration()); |
| 303 | if (!forSemFacet || validNumber == 0) { | 302 | if (validNumber == 0) { |
| 304 | queryRecord.markAsProcessed(); | 303 | queryRecord.markAsProcessed(); |
| 305 | Utility.logDebug("Difficulty of this query: " + queryRecord.getDifficulty()); | 304 | Utility.logDebug("Difficulty of this query: " + queryRecord.getDifficulty()); |
| 306 | } | 305 | } |
diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/QueryReasoner.java b/src/uk/ac/ox/cs/pagoda/reasoner/QueryReasoner.java index 0c009a2..a484444 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/QueryReasoner.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/QueryReasoner.java | |||
| @@ -14,23 +14,41 @@ import uk.ac.ox.cs.pagoda.owl.OWLHelper; | |||
| 14 | import uk.ac.ox.cs.pagoda.query.AnswerTuples; | 14 | import uk.ac.ox.cs.pagoda.query.AnswerTuples; |
| 15 | import uk.ac.ox.cs.pagoda.query.QueryManager; | 15 | import uk.ac.ox.cs.pagoda.query.QueryManager; |
| 16 | import uk.ac.ox.cs.pagoda.query.QueryRecord; | 16 | import uk.ac.ox.cs.pagoda.query.QueryRecord; |
| 17 | import uk.ac.ox.cs.pagoda.util.Properties; | ||
| 17 | import uk.ac.ox.cs.pagoda.util.Timer; | 18 | import uk.ac.ox.cs.pagoda.util.Timer; |
| 18 | import uk.ac.ox.cs.pagoda.util.Utility; | 19 | import uk.ac.ox.cs.pagoda.util.Utility; |
| 19 | 20 | ||
| 20 | public abstract class QueryReasoner { | 21 | public abstract class QueryReasoner { |
| 21 | 22 | ||
| 22 | protected boolean forSemFacet = false; | 23 | // protected boolean forSemFacet = false; |
| 23 | 24 | Properties properties; | |
| 25 | |||
| 24 | public static enum Type { Full, RLU, ELHOU }; | 26 | public static enum Type { Full, RLU, ELHOU }; |
| 25 | 27 | ||
| 26 | public static QueryReasoner getInstanceForSemFacet(OWLOntology o) { | 28 | public static QueryReasoner getInstance(Properties p) { |
| 27 | QueryReasoner reasoner = getInstance(Type.Full, o, true, true); | 29 | OWLOntology ontology = OWLHelper.loadOntology(p.getOntologyPath()); |
| 28 | reasoner.forSemFacet = true; | 30 | QueryReasoner pagoda = getInstance(ontology, p); |
| 29 | return reasoner; | 31 | pagoda.properties = p; |
| 32 | pagoda.loadOntology(ontology); | ||
| 33 | pagoda.importData(p.getDataPath()); | ||
| 34 | if (pagoda.preprocess()) { | ||
| 35 | System.out.println("The ontology is consistent!"); | ||
| 36 | return pagoda; | ||
| 37 | } | ||
| 38 | else { | ||
| 39 | System.out.println("The ontology is inconsistent!"); | ||
| 40 | pagoda.dispose(); | ||
| 41 | return null; | ||
| 42 | } | ||
| 30 | } | 43 | } |
| 31 | 44 | ||
| 32 | |||
| 33 | public static QueryReasoner getInstance(OWLOntology o) { | 45 | public static QueryReasoner getInstance(OWLOntology o) { |
| 46 | QueryReasoner pagoda = getInstance(Type.Full, o, true, true); | ||
| 47 | pagoda.properties = new Properties(); | ||
| 48 | return pagoda; | ||
| 49 | } | ||
| 50 | |||
| 51 | private static QueryReasoner getInstance(OWLOntology o, Properties p) { | ||
| 34 | return getInstance(Type.Full, o, true, true); | 52 | return getInstance(Type.Full, o, true, true); |
| 35 | } | 53 | } |
| 36 | 54 | ||
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 6f5d363..97925fc 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/full/HermitChecker.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/full/HermitChecker.java | |||
| @@ -43,6 +43,7 @@ public class HermitChecker implements Checker { | |||
| 43 | protected OWLOntology ontology; | 43 | protected OWLOntology ontology; |
| 44 | protected QueryRecord record; | 44 | protected QueryRecord record; |
| 45 | protected QueryGraph qGraph = null; | 45 | protected QueryGraph qGraph = null; |
| 46 | boolean toCheck = true; | ||
| 46 | 47 | ||
| 47 | public HermitChecker(Checker checker) { | 48 | public HermitChecker(Checker checker) { |
| 48 | if (checker instanceof HermitChecker) { | 49 | if (checker instanceof HermitChecker) { |
| @@ -58,12 +59,13 @@ public class HermitChecker implements Checker { | |||
| 58 | hermit = new Reasoner(ontology); | 59 | hermit = new Reasoner(ontology); |
| 59 | } | 60 | } |
| 60 | 61 | ||
| 61 | public HermitChecker(OWLOntology ontology, QueryRecord record) { | 62 | public HermitChecker(OWLOntology ontology, QueryRecord record, boolean toCheck) { |
| 62 | this.ontology = ontology; | 63 | this.ontology = ontology; |
| 63 | queryText = record.getQueryText(); | 64 | queryText = record.getQueryText(); |
| 64 | answerVariable = record.getVariables(); | 65 | answerVariable = record.getVariables(); |
| 65 | queryClause = record.getClause(); | 66 | queryClause = record.getClause(); |
| 66 | // this.record = record; | 67 | // this.record = record; |
| 68 | this.toCheck = toCheck; | ||
| 67 | } | 69 | } |
| 68 | 70 | ||
| 69 | public HermitChecker(OWLOntology ontology, String queryText) { | 71 | public HermitChecker(OWLOntology ontology, String queryText) { |
| @@ -198,6 +200,8 @@ public class HermitChecker implements Checker { | |||
| 198 | 200 | ||
| 199 | @Override | 201 | @Override |
| 200 | public boolean check(AnswerTuple answerTuple) { | 202 | public boolean check(AnswerTuple answerTuple) { |
| 203 | if (!toCheck) return false; | ||
| 204 | |||
| 201 | if (hermit == null) initialiseReasoner(); | 205 | if (hermit == null) initialiseReasoner(); |
| 202 | if (tag != 0) return tag == 1; | 206 | if (tag != 0) return tag == 1; |
| 203 | ++counter; | 207 | ++counter; |
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 3207ff1..11588ce 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/light/BasicQueryEngine.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/light/BasicQueryEngine.java | |||
| @@ -47,8 +47,8 @@ public class BasicQueryEngine extends RDFoxQueryEngine { | |||
| 47 | getDataStore().clearRulesAndMakeFactsExplicit(); | 47 | getDataStore().clearRulesAndMakeFactsExplicit(); |
| 48 | } catch (JRDFStoreException e) { | 48 | } catch (JRDFStoreException e) { |
| 49 | e.printStackTrace(); | 49 | e.printStackTrace(); |
| 50 | gap.clear(); | ||
| 51 | } finally { | 50 | } finally { |
| 51 | gap.clear(); | ||
| 52 | } | 52 | } |
| 53 | } | 53 | } |
| 54 | else | 54 | else |
| @@ -149,9 +149,14 @@ public class BasicQueryEngine extends RDFoxQueryEngine { | |||
| 149 | if (instanceTuples != null) instanceTuples.dispose(); | 149 | if (instanceTuples != null) instanceTuples.dispose(); |
| 150 | } | 150 | } |
| 151 | } | 151 | } |
| 152 | } catch (JRDFStoreException e) { | ||
| 153 | e.printStackTrace(); | ||
| 154 | } finally { | ||
| 155 | if (predicateTuples != null) predicateTuples.dispose(); | ||
| 156 | predicateTuples = null; | ||
| 157 | } | ||
| 152 | 158 | ||
| 153 | predicateTuples.dispose(); | 159 | try { |
| 154 | |||
| 155 | predicateTuples = getDataStore().compileQuery("SELECT DISTINCT ?Y WHERE { ?X ?Y ?Z }", prefixes, parameters); | 160 | predicateTuples = getDataStore().compileQuery("SELECT DISTINCT ?Y WHERE { ?X ?Y ?Z }", prefixes, parameters); |
| 156 | for (long multi = predicateTuples.open(); multi != 0; multi = predicateTuples.getNext()) { | 161 | for (long multi = predicateTuples.open(); multi != 0; multi = predicateTuples.getNext()) { |
| 157 | predicate = RDFoxTripleManager.getQuotedTerm(predicateTuples.getResource(0)); | 162 | predicate = RDFoxTripleManager.getQuotedTerm(predicateTuples.getResource(0)); |
| @@ -172,6 +177,7 @@ public class BasicQueryEngine extends RDFoxQueryEngine { | |||
| 172 | e.printStackTrace(); | 177 | e.printStackTrace(); |
| 173 | } finally { | 178 | } finally { |
| 174 | if (predicateTuples != null) predicateTuples.dispose(); | 179 | if (predicateTuples != null) predicateTuples.dispose(); |
| 180 | predicateTuples = null; | ||
| 175 | } | 181 | } |
| 176 | 182 | ||
| 177 | Utility.redirectCurrentOut(filename); | 183 | Utility.redirectCurrentOut(filename); |
| @@ -184,13 +190,13 @@ public class BasicQueryEngine extends RDFoxQueryEngine { | |||
| 184 | 190 | ||
| 185 | public TupleIterator internal_evaluateAgainstIDBs(String queryText) throws JRDFStoreException { | 191 | public TupleIterator internal_evaluateAgainstIDBs(String queryText) throws JRDFStoreException { |
| 186 | TupleIterator iter = store.compileQuery(queryText, prefixes, parameters, TripleStatus.TUPLE_STATUS_IDB.union(TripleStatus.TUPLE_STATUS_EDB), TripleStatus.TUPLE_STATUS_IDB); | 192 | TupleIterator iter = store.compileQuery(queryText, prefixes, parameters, TripleStatus.TUPLE_STATUS_IDB.union(TripleStatus.TUPLE_STATUS_EDB), TripleStatus.TUPLE_STATUS_IDB); |
| 187 | iter.open(); | 193 | // iter.open(); |
| 188 | return iter; | 194 | return iter; |
| 189 | } | 195 | } |
| 190 | 196 | ||
| 191 | public TupleIterator internal_evaluate(String queryText) throws JRDFStoreException { | 197 | public TupleIterator internal_evaluate(String queryText) throws JRDFStoreException { |
| 192 | TupleIterator iter = store.compileQuery(queryText, prefixes, parameters); | 198 | TupleIterator iter = store.compileQuery(queryText, prefixes, parameters); |
| 193 | iter.open(); | 199 | // iter.open(); |
| 194 | return iter; | 200 | return iter; |
| 195 | } | 201 | } |
| 196 | 202 | ||
| @@ -201,7 +207,7 @@ public class BasicQueryEngine extends RDFoxQueryEngine { | |||
| 201 | public TupleIterator internal_evaluateNotExpanded(String queryText) throws JRDFStoreException { | 207 | public TupleIterator internal_evaluateNotExpanded(String queryText) throws JRDFStoreException { |
| 202 | parameters.m_expandEquality = false; | 208 | parameters.m_expandEquality = false; |
| 203 | TupleIterator iter = store.compileQuery(queryText, prefixes, parameters); | 209 | TupleIterator iter = store.compileQuery(queryText, prefixes, parameters); |
| 204 | iter.open(); | 210 | // iter.open(); |
| 205 | parameters.m_expandEquality = true; | 211 | parameters.m_expandEquality = true; |
| 206 | return iter; | 212 | return iter; |
| 207 | } | 213 | } |
| @@ -346,19 +352,22 @@ public class BasicQueryEngine extends RDFoxQueryEngine { | |||
| 346 | for (int[] t: collection) | 352 | for (int[] t: collection) |
| 347 | store.addTriplesByResourceIDs(t, ut); | 353 | store.addTriplesByResourceIDs(t, ut); |
| 348 | 354 | ||
| 349 | iter = internal_evaluateAgainstIDBs("select ?x ?y ?z where { ?x ?y ?z . }"); | 355 | try { |
| 350 | for (long multi = iter.open(); multi != 0; multi = iter.getNext()) { | 356 | iter = internal_evaluateAgainstIDBs("select ?x ?y ?z where { ?x ?y ?z . }"); |
| 351 | int[] triple = new int[3]; | 357 | for (long multi = iter.open(); multi != 0; multi = iter.getNext()) { |
| 352 | for (int i = 0; i < 3; ++i) | 358 | int[] triple = new int[3]; |
| 353 | triple[i] = iter.getResourceID(i); | 359 | for (int i = 0; i < 3; ++i) |
| 354 | store.addTriplesByResourceIDs(triple, ut); | 360 | triple[i] = iter.getResourceID(i); |
| 361 | store.addTriplesByResourceIDs(triple, ut); | ||
| 362 | } | ||
| 363 | } finally { | ||
| 364 | if (iter != null) iter.dispose(); | ||
| 365 | iter = null; | ||
| 355 | } | 366 | } |
| 356 | store.applyReasoning(true); | 367 | store.applyReasoning(true); |
| 357 | } catch (JRDFStoreException e) { | 368 | } catch (JRDFStoreException e) { |
| 358 | e.printStackTrace(); | 369 | e.printStackTrace(); |
| 359 | } finally { | 370 | } |
| 360 | if (iter != null) iter.dispose(); | ||
| 361 | } | ||
| 362 | Utility.logInfo("Time for deletion: " + timer.duration()); | 371 | Utility.logInfo("Time for deletion: " + timer.duration()); |
| 363 | } | 372 | } |
| 364 | 373 | ||
diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/light/RDFoxTripleManager.java b/src/uk/ac/ox/cs/pagoda/reasoner/light/RDFoxTripleManager.java index 2280b12..c2065dc 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/light/RDFoxTripleManager.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/light/RDFoxTripleManager.java | |||
| @@ -2,12 +2,9 @@ package uk.ac.ox.cs.pagoda.reasoner.light; | |||
| 2 | 2 | ||
| 3 | import java.util.Collection; | 3 | import java.util.Collection; |
| 4 | import java.util.HashMap; | 4 | import java.util.HashMap; |
| 5 | import java.util.HashSet; | ||
| 6 | import java.util.LinkedList; | 5 | import java.util.LinkedList; |
| 7 | import java.util.Map; | 6 | import java.util.Map; |
| 8 | import java.util.Queue; | 7 | import java.util.Queue; |
| 9 | import java.util.Set; | ||
| 10 | |||
| 11 | import org.semanticweb.HermiT.model.AnnotatedEquality; | 8 | import org.semanticweb.HermiT.model.AnnotatedEquality; |
| 12 | import org.semanticweb.HermiT.model.Atom; | 9 | import org.semanticweb.HermiT.model.Atom; |
| 13 | import org.semanticweb.HermiT.model.AtomicConcept; | 10 | import org.semanticweb.HermiT.model.AtomicConcept; |
| @@ -37,7 +34,7 @@ public class RDFoxTripleManager { | |||
| 37 | 34 | ||
| 38 | DataStore m_store; | 35 | DataStore m_store; |
| 39 | Dictionary m_dict; | 36 | Dictionary m_dict; |
| 40 | Set<Atom> triplesByTerm = new HashSet<Atom>(); | 37 | // Set<Atom> triplesByTerm = new HashSet<Atom>(); |
| 41 | 38 | ||
| 42 | public RDFoxTripleManager(DataStore store, boolean incrementally) { | 39 | public RDFoxTripleManager(DataStore store, boolean incrementally) { |
| 43 | m_store = store; | 40 | m_store = store; |
| @@ -63,7 +60,16 @@ public class RDFoxTripleManager { | |||
| 63 | } | 60 | } |
| 64 | 61 | ||
| 65 | public void addTripleByID(int[] tuple) { | 62 | public void addTripleByID(int[] tuple) { |
| 63 | // System.out.println(getRawTerm(tuple[0]) + " " + getRawTerm(tuple[1]) + " " + getRawTerm(tuple[2]) + " ."); | ||
| 66 | try { | 64 | try { |
| 65 | // Resource[] rsc = new Resource[3]; | ||
| 66 | // m_dict.getResources(tuple, 0, 3, rsc); | ||
| 67 | // | ||
| 68 | // GroundTerm[] terms = new GroundTerm[3]; | ||
| 69 | // for (int i = 0; i < 3; ++i) | ||
| 70 | // terms[i] = uk.ac.ox.cs.JRDFox.model.Individual.create(rsc[i].m_lexicalForm); | ||
| 71 | // m_store.addTriples(terms, m_incrementally); | ||
| 72 | |||
| 67 | m_store.addTriplesByResourceIDs(tuple, m_incrementally); | 73 | m_store.addTriplesByResourceIDs(tuple, m_incrementally); |
| 68 | } catch (JRDFStoreException e) { | 74 | } catch (JRDFStoreException e) { |
| 69 | e.printStackTrace(); | 75 | e.printStackTrace(); |
diff --git a/src/uk/ac/ox/cs/pagoda/summary/HermitSummaryFilter.java b/src/uk/ac/ox/cs/pagoda/summary/HermitSummaryFilter.java index a57d188..a0ecce8 100644 --- a/src/uk/ac/ox/cs/pagoda/summary/HermitSummaryFilter.java +++ b/src/uk/ac/ox/cs/pagoda/summary/HermitSummaryFilter.java | |||
| @@ -34,9 +34,9 @@ public class HermitSummaryFilter implements Checker { | |||
| 34 | 34 | ||
| 35 | Endomorph endomorphismChecker = null; | 35 | Endomorph endomorphismChecker = null; |
| 36 | 36 | ||
| 37 | public HermitSummaryFilter(QueryRecord record) { | 37 | public HermitSummaryFilter(QueryRecord record, boolean toCallHermiT) { |
| 38 | m_record = record; | 38 | m_record = record; |
| 39 | HermitChecker hermitChecker = new HermitChecker(record.getRelevantOntology(), record); | 39 | HermitChecker hermitChecker = new HermitChecker(record.getRelevantOntology(), record, toCallHermiT); |
| 40 | endomorphismChecker = new Endomorph(record, hermitChecker); | 40 | endomorphismChecker = new Endomorph(record, hermitChecker); |
| 41 | hermitChecker.setDependencyGraph(endomorphismChecker.getDependencyGraph()); | 41 | hermitChecker.setDependencyGraph(endomorphismChecker.getDependencyGraph()); |
| 42 | } | 42 | } |
diff --git a/src/uk/ac/ox/cs/pagoda/tracking/QueryTracker.java b/src/uk/ac/ox/cs/pagoda/tracking/QueryTracker.java index 0e19e30..f836212 100644 --- a/src/uk/ac/ox/cs/pagoda/tracking/QueryTracker.java +++ b/src/uk/ac/ox/cs/pagoda/tracking/QueryTracker.java | |||
| @@ -35,6 +35,7 @@ import uk.ac.ox.cs.JRDFox.model.Datatype; | |||
| 35 | import uk.ac.ox.cs.JRDFox.store.DataStore; | 35 | import uk.ac.ox.cs.JRDFox.store.DataStore; |
| 36 | import uk.ac.ox.cs.JRDFox.store.Resource; | 36 | import uk.ac.ox.cs.JRDFox.store.Resource; |
| 37 | import uk.ac.ox.cs.JRDFox.store.TupleIterator; | 37 | import uk.ac.ox.cs.JRDFox.store.TupleIterator; |
| 38 | import uk.ac.ox.cs.JRDFox.store.DataStore.UpdateType; | ||
| 38 | 39 | ||
| 39 | public class QueryTracker { | 40 | public class QueryTracker { |
| 40 | 41 | ||
| @@ -80,7 +81,7 @@ public class QueryTracker { | |||
| 80 | Timer t1 = new Timer(); | 81 | Timer t1 = new Timer(); |
| 81 | oldTripleCount = store.getTriplesCount(); | 82 | oldTripleCount = store.getTriplesCount(); |
| 82 | // store.addRules(new String[] {m_encoder.getTrackingProgram()}); | 83 | // store.addRules(new String[] {m_encoder.getTrackingProgram()}); |
| 83 | store.importRules(m_encoder.getTrackingProgram()); | 84 | store.importRules(m_encoder.getTrackingProgram(), UpdateType.ScheduleForAddition); |
| 84 | store.applyReasoning(incrementally); | 85 | store.applyReasoning(incrementally); |
| 85 | tripleCount = store.getTriplesCount(); | 86 | tripleCount = store.getTriplesCount(); |
| 86 | 87 | ||
| @@ -93,8 +94,7 @@ public class QueryTracker { | |||
| 93 | + t1.duration() + " seconds."); | 94 | + t1.duration() + " seconds."); |
| 94 | } catch (JRDFStoreException e) { | 95 | } catch (JRDFStoreException e) { |
| 95 | e.printStackTrace(); | 96 | e.printStackTrace(); |
| 96 | } | 97 | } |
| 97 | |||
| 98 | extractAxioms(trackingStore); | 98 | extractAxioms(trackingStore); |
| 99 | 99 | ||
| 100 | trackingStore.clearRulesAndIDBFacts(m_encoder.getAddedData()); | 100 | trackingStore.clearRulesAndIDBFacts(m_encoder.getAddedData()); |
| @@ -145,8 +145,7 @@ public class QueryTracker { | |||
| 145 | } catch (JRDFStoreException e) { | 145 | } catch (JRDFStoreException e) { |
| 146 | e.printStackTrace(); | 146 | e.printStackTrace(); |
| 147 | } finally { | 147 | } finally { |
| 148 | if (answers != null) | 148 | if (answers != null) answers.dispose(); |
| 149 | answers.dispose(); | ||
| 150 | } | 149 | } |
| 151 | 150 | ||
| 152 | Utility.logTrace("Extracted TBox axioms: "); | 151 | Utility.logTrace("Extracted TBox axioms: "); |
| @@ -190,7 +189,6 @@ public class QueryTracker { | |||
| 190 | } | 189 | } |
| 191 | } | 190 | } |
| 192 | } catch (JRDFStoreException e) { | 191 | } catch (JRDFStoreException e) { |
| 193 | // TODO Auto-generated catch block | ||
| 194 | e.printStackTrace(); | 192 | e.printStackTrace(); |
| 195 | } finally { | 193 | } finally { |
| 196 | if (trackingAnswers != null) trackingAnswers.dispose(); | 194 | if (trackingAnswers != null) trackingAnswers.dispose(); |
| @@ -329,9 +327,7 @@ public class QueryTracker { | |||
| 329 | continue; | 327 | continue; |
| 330 | TupleIterator answers = null, lowerAnswers = null; | 328 | TupleIterator answers = null, lowerAnswers = null; |
| 331 | Set<String> lower = new HashSet<String>(); | 329 | Set<String> lower = new HashSet<String>(); |
| 332 | OWLClass cls = factory | 330 | OWLClass cls = factory.getOWLClass(IRI.create(clsIRI.startsWith("<") ? OWLHelper.removeAngles(clsIRI) : clsIRI)); |
| 333 | .getOWLClass(IRI.create(clsIRI.startsWith("<") ? OWLHelper | ||
| 334 | .removeAngles(clsIRI) : clsIRI)); | ||
| 335 | try { | 331 | try { |
| 336 | answers = trackingStore.internal_evaluateAgainstIDBs(getSPARQLQuery4Unary(trackingIRI)); | 332 | answers = trackingStore.internal_evaluateAgainstIDBs(getSPARQLQuery4Unary(trackingIRI)); |
| 337 | answers.open(); | 333 | answers.open(); |
| @@ -359,10 +355,8 @@ public class QueryTracker { | |||
| 359 | } catch (JRDFStoreException e) { | 355 | } catch (JRDFStoreException e) { |
| 360 | e.printStackTrace(); | 356 | e.printStackTrace(); |
| 361 | } finally { | 357 | } finally { |
| 362 | if (answers != null) | 358 | if (answers != null) answers.dispose(); |
| 363 | answers.dispose(); | 359 | if (lowerAnswers != null) lowerAnswers.dispose(); |
| 364 | if (lowerAnswers != null) | ||
| 365 | lowerAnswers.dispose(); | ||
| 366 | lower.clear(); | 360 | lower.clear(); |
| 367 | } | 361 | } |
| 368 | Utility.logDebug("class: " + clsIRI + " " + count); | 362 | Utility.logDebug("class: " + clsIRI + " " + count); |
| @@ -370,53 +364,37 @@ public class QueryTracker { | |||
| 370 | return aboxAxiomCounter; | 364 | return aboxAxiomCounter; |
| 371 | } | 365 | } |
| 372 | 366 | ||
| 373 | private void getDerivedPredicates(BasicQueryEngine trackingStore, | 367 | private void getDerivedPredicates(BasicQueryEngine trackingStore, Set<String> unaryPredicates, Set<String> binaryPredicates) { |
| 374 | Set<String> unaryPredicates, Set<String> binaryPredicates) { | ||
| 375 | |||
| 376 | TupleIterator derivedTuples = null; | 368 | TupleIterator derivedTuples = null; |
| 377 | String selectedPredicate = OWLHelper.addAngles(m_encoder.getSelectedPredicate()); | 369 | String selectedPredicate = OWLHelper.addAngles(m_encoder.getSelectedPredicate()); |
| 378 | try { | 370 | try { |
| 379 | derivedTuples = trackingStore | 371 | derivedTuples = trackingStore.internal_evaluateAgainstIDBs("select distinct ?z where { ?x <" + Namespace.RDF_TYPE + "> ?z . }"); |
| 380 | .internal_evaluateAgainstIDBs("select distinct ?z where { ?x <" | ||
| 381 | + Namespace.RDF_TYPE + "> ?z . }"); | ||
| 382 | for (long multi = derivedTuples.open(); multi != 0; multi = derivedTuples.getNext()) { | 372 | for (long multi = derivedTuples.open(); multi != 0; multi = derivedTuples.getNext()) { |
| 383 | String p = RDFoxTripleManager.getQuotedTerm(derivedTuples.getResource(0)); | 373 | String p = RDFoxTripleManager.getQuotedTerm(derivedTuples.getResource(0)); |
| 384 | if (p.equals(selectedPredicate)) | 374 | if (p.equals(selectedPredicate)) ; |
| 385 | ; | 375 | else if (m_encoder.isAuxPredicate(p)) ; |
| 386 | else if (m_encoder.isAuxPredicate(p)) | 376 | else unaryPredicates.add(p); |
| 387 | ; | ||
| 388 | else | ||
| 389 | unaryPredicates.add(p); | ||
| 390 | } | 377 | } |
| 391 | } catch (JRDFStoreException e) { | 378 | } catch (JRDFStoreException e) { |
| 392 | e.printStackTrace(); | 379 | e.printStackTrace(); |
| 393 | } finally { | 380 | } finally { |
| 394 | if (derivedTuples != null) | 381 | if (derivedTuples != null) derivedTuples.dispose(); |
| 395 | derivedTuples.dispose(); | ||
| 396 | } | 382 | } |
| 397 | 383 | ||
| 398 | derivedTuples = null; | 384 | derivedTuples = null; |
| 399 | try { | 385 | try { |
| 400 | derivedTuples = trackingStore | 386 | derivedTuples = trackingStore.internal_evaluateAgainstIDBs("select distinct ?y where { ?x ?y ?z . }"); |
| 401 | .internal_evaluateAgainstIDBs("select distinct ?y where { ?x ?y ?z . }"); | ||
| 402 | for (long multi = derivedTuples.open(); multi != 0; multi = derivedTuples.getNext()) { | 387 | for (long multi = derivedTuples.open(); multi != 0; multi = derivedTuples.getNext()) { |
| 403 | String p = RDFoxTripleManager.getQuotedTerm(derivedTuples.getResource(0)); | 388 | String p = RDFoxTripleManager.getQuotedTerm(derivedTuples.getResource(0)); |
| 404 | if (p.equals(Namespace.RDF_TYPE_ABBR) | 389 | if (p.equals(Namespace.RDF_TYPE_ABBR) || p.equals(Namespace.RDF_TYPE_QUOTED)) ; |
| 405 | || p.equals(Namespace.RDF_TYPE_QUOTED)) | 390 | else if (p.equals(Namespace.EQUALITY_ABBR) || p.equals(Namespace.EQUALITY_QUOTED)) ; |
| 406 | ; | 391 | else if (m_encoder.isAuxPredicate(p)) ; |
| 407 | else if (p.equals(Namespace.EQUALITY_ABBR) | 392 | else binaryPredicates.add(p); |
| 408 | || p.equals(Namespace.EQUALITY_QUOTED)) | ||
| 409 | ; | ||
| 410 | else if (m_encoder.isAuxPredicate(p)) | ||
| 411 | ; | ||
| 412 | else | ||
| 413 | binaryPredicates.add(p); | ||
| 414 | } | 393 | } |
| 415 | } catch (JRDFStoreException e) { | 394 | } catch (JRDFStoreException e) { |
| 416 | e.printStackTrace(); | 395 | e.printStackTrace(); |
| 417 | } finally { | 396 | } finally { |
| 418 | if (derivedTuples != null) | 397 | if (derivedTuples != null) derivedTuples.dispose(); |
| 419 | derivedTuples.dispose(); | ||
| 420 | } | 398 | } |
| 421 | } | 399 | } |
| 422 | 400 | ||
| @@ -428,8 +406,7 @@ public class QueryTracker { | |||
| 428 | toAddedRecords.add(botQueryRecord); | 406 | toAddedRecords.add(botQueryRecord); |
| 429 | 407 | ||
| 430 | for (QueryRecord botQueryRecord : toAddedRecords) { | 408 | for (QueryRecord botQueryRecord : toAddedRecords) { |
| 431 | m_manager.addAxioms(m_record.getRelevantOntology(), botQueryRecord | 409 | m_manager.addAxioms(m_record.getRelevantOntology(), botQueryRecord.getRelevantOntology().getAxioms()); |
| 432 | .getRelevantOntology().getAxioms()); | ||
| 433 | for (DLClause clause : botQueryRecord.getRelevantClauses()) | 410 | for (DLClause clause : botQueryRecord.getRelevantClauses()) |
| 434 | m_record.addRelevantClauses(clause); | 411 | m_record.addRelevantClauses(clause); |
| 435 | } | 412 | } |
| @@ -456,16 +433,14 @@ public class QueryTracker { | |||
| 456 | 433 | ||
| 457 | private String getSPARQLQuery4Unary(String p) { | 434 | private String getSPARQLQuery4Unary(String p) { |
| 458 | StringBuilder builder = new StringBuilder(); | 435 | StringBuilder builder = new StringBuilder(); |
| 459 | builder.append("select ?x where { ?x <") | 436 | builder.append("select ?x where { ?x <").append(Namespace.RDF_TYPE).append("> "); |
| 460 | .append(Namespace.RDF_TYPE).append("> "); | ||
| 461 | builder.append(p).append(" . }"); | 437 | builder.append(p).append(" . }"); |
| 462 | return builder.toString(); | 438 | return builder.toString(); |
| 463 | } | 439 | } |
| 464 | 440 | ||
| 465 | private String getSPARQLQuery4Binary(String p) { | 441 | private String getSPARQLQuery4Binary(String p) { |
| 466 | StringBuilder builder = new StringBuilder(); | 442 | StringBuilder builder = new StringBuilder(); |
| 467 | builder.append("select ?x ?y where { ?x ").append(p) | 443 | builder.append("select ?x ?y where { ?x ").append(p).append(" ?y . }"); |
| 468 | .append(" ?y . }"); | ||
| 469 | return builder.toString(); | 444 | return builder.toString(); |
| 470 | } | 445 | } |
| 471 | 446 | ||
diff --git a/src/uk/ac/ox/cs/pagoda/util/Properties.java b/src/uk/ac/ox/cs/pagoda/util/Properties.java index 551f94f..b687b53 100644 --- a/src/uk/ac/ox/cs/pagoda/util/Properties.java +++ b/src/uk/ac/ox/cs/pagoda/util/Properties.java | |||
| @@ -1,95 +1,66 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.util; | 1 | package uk.ac.ox.cs.pagoda.util; |
| 2 | 2 | ||
| 3 | import java.io.BufferedReader; | ||
| 4 | import java.io.FileInputStream; | 3 | import java.io.FileInputStream; |
| 5 | import java.io.IOException; | 4 | import java.io.IOException; |
| 6 | import java.io.InputStreamReader; | 5 | import java.io.InputStream; |
| 7 | import java.util.HashMap; | ||
| 8 | 6 | ||
| 9 | public class Properties { | 7 | public class Properties { |
| 10 | |||
| 11 | public static final String FILE_SEPARATOR = ";"; | ||
| 12 | 8 | ||
| 13 | // switches | 9 | String dataPath = null; |
| 14 | // public static final String reuseGapFile = "REUSE_GAP"; | 10 | public String getDataPath() { return dataPath; } |
| 15 | public static final String toTrackProofs = "TO_TRACK"; | 11 | public void setDataPath(String path) { dataPath = path; } |
| 16 | public static final String checkAnswers = "TO_CHECK_ANSWERS"; | ||
| 17 | public static final String redirectSysOut = "TO_REDIRECT_SYS_OUT"; | ||
| 18 | public static final String considerEqualities = "TO_CONSIDER_EQUALITIES"; | ||
| 19 | |||
| 20 | // parameters | ||
| 21 | public static final String testcase = "TEST_CASE"; | ||
| 22 | public static final String typeOfLowerBounds = "TYPE_LOWER_BOUNDS"; | ||
| 23 | public static final String FULL_REASONER = "OWLREASONER"; | ||
| 24 | |||
| 25 | // file locations | ||
| 26 | public static final String ontologyFile = "LOWER_T_FILE"; | ||
| 27 | public static final String importedData = "IMPORT"; | ||
| 28 | public static final String queryFile = "QUERY_FILE"; | ||
| 29 | |||
| 30 | // auxiliary files | ||
| 31 | // public static final String auxiliaryDirectory = "AUXILIARY_DIRECTORY"; | ||
| 32 | // public static final String queryAnswerGapFile = "GAP_FILE"; | ||
| 33 | // public static final String lowerAnswerFile = "LOWER_ANSWER_FILE"; | ||
| 34 | // public static final String upperAnswerFile = "UPPER_ANSWER_FILE"; | ||
| 35 | // public static final String boundsGapFile = "BOUNDS_GAP_FILE"; | ||
| 36 | // public static final String fragmentFile = "FRAGMENT_FILE"; | ||
| 37 | 12 | ||
| 38 | public static final String correspondence = "CORRESPONDENCE"; | 13 | String ontologyPath; |
| 39 | 14 | public String getOntologyPath() { return ontologyPath; } | |
| 40 | private HashMap<String, String> param = new HashMap<String, String>(); | 15 | public void setOntologyPath(String path) { ontologyPath = path; } |
| 41 | |||
| 42 | public static final String on = String.valueOf(true); | ||
| 43 | public static final String off = String.valueOf(false); | ||
| 44 | |||
| 45 | public void reset() { | ||
| 46 | param.clear(); | ||
| 47 | // param.put(reuseGapFile, on); | ||
| 48 | param.put(toTrackProofs, on); | ||
| 49 | param.put(checkAnswers, on); | ||
| 50 | param.put(redirectSysOut, off); | ||
| 51 | param.put(considerEqualities, off); | ||
| 52 | } | ||
| 53 | |||
| 54 | public Properties() { | ||
| 55 | reset(); | ||
| 56 | } | ||
| 57 | |||
| 58 | public void addImportedFile(String additionalDataFile) { | ||
| 59 | if (additionalDataFile == null) return ; | ||
| 60 | String files = param.get(importedData); | ||
| 61 | StringBuilder sb = new StringBuilder(); | ||
| 62 | if (files != null) | ||
| 63 | sb.append(files).append(FILE_SEPARATOR); | ||
| 64 | sb.append(additionalDataFile); | ||
| 65 | param.put(importedData, sb.toString()); | ||
| 66 | } | ||
| 67 | 16 | ||
| 68 | public void load(String file) throws IOException { | 17 | String queryPath = null; |
| 69 | BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file))); | 18 | public String getQueryPath() { return queryPath; } |
| 70 | String line; | 19 | public void setQueryPath(String path) { queryPath = path; } |
| 71 | String tokens[]; | 20 | |
| 72 | while ((line = Utility.readLine(reader)) != null) { | 21 | String answerPath = null; |
| 73 | if (line.isEmpty() || line.startsWith("#")) | 22 | public String getAnswerPath() { return answerPath; } |
| 74 | continue; | 23 | public void setAnswerPath(String path) { answerPath = path; } |
| 24 | |||
| 25 | boolean toClassify = true; | ||
| 26 | public boolean getToClassify() { return toClassify; } | ||
| 27 | public void setToClassify(boolean flag) { toClassify = flag; } | ||
| 28 | |||
| 29 | boolean toCallHermiT = true; | ||
| 30 | public boolean getToCallHermiT() { return toCallHermiT; } | ||
| 31 | public void setToCallHermiT(boolean flag) { toCallHermiT = flag; } | ||
| 32 | |||
| 33 | public static boolean ShellModeDefault = false; | ||
| 34 | |||
| 35 | boolean shellMode = ShellModeDefault; | ||
| 36 | public boolean getShellMode() { return shellMode; } | ||
| 37 | public void setShellMode(boolean flag) { shellMode = flag; } | ||
| 38 | |||
| 39 | public Properties(String path) { | ||
| 40 | java.util.Properties m_properties = new java.util.Properties(); | ||
| 41 | InputStream inputStream = null; | ||
| 42 | try { | ||
| 43 | inputStream = new FileInputStream(path); | ||
| 44 | m_properties.load(inputStream); | ||
| 75 | 45 | ||
| 76 | tokens = line.split("="); | 46 | setOntologyPath(m_properties.getProperty("ONTOLOGY")); |
| 77 | if (tokens[1].equals("on")) | 47 | setDataPath(m_properties.getProperty("DATA")); |
| 78 | set(tokens[0], String.valueOf(true)); | 48 | setQueryPath(m_properties.getProperty("QUERY")); |
| 79 | else if (tokens[1].equals("off")) | 49 | setAnswerPath(m_properties.getProperty("ANSWER")); |
| 80 | set(tokens[0], String.valueOf(false)); | 50 | setToClassify(Boolean.parseBoolean(m_properties.getProperty("TO_CLASSIFY"))); |
| 81 | else | 51 | setToCallHermiT(Boolean.parseBoolean(m_properties.getProperty("CALL_HERMIT"))); |
| 82 | set(tokens[0], tokens[1]); | 52 | |
| 53 | } catch (IOException e) { | ||
| 54 | e.printStackTrace(); | ||
| 55 | } finally { | ||
| 56 | if (inputStream != null) | ||
| 57 | try { | ||
| 58 | inputStream.close(); | ||
| 59 | } catch (IOException e) { | ||
| 60 | e.printStackTrace(); | ||
| 61 | } | ||
| 83 | } | 62 | } |
| 84 | reader.close(); | ||
| 85 | } | ||
| 86 | |||
| 87 | public String get(String key) { | ||
| 88 | return param.get(key); | ||
| 89 | } | ||
| 90 | |||
| 91 | public void set(String key, String value) { | ||
| 92 | param.put(key, value); | ||
| 93 | } | 63 | } |
| 64 | public Properties() { } | ||
| 94 | 65 | ||
| 95 | } | 66 | } |
