diff options
Diffstat (limited to 'src/uk/ac/ox/cs/pagoda/reasoner')
10 files changed, 122 insertions, 43 deletions
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(); |
