diff options
| author | RncLsn <rnc.lsn@gmail.com> | 2015-06-26 17:41:35 +0100 |
|---|---|---|
| committer | RncLsn <rnc.lsn@gmail.com> | 2015-06-26 17:41:35 +0100 |
| commit | 1013812b487bc438df49ec93ad9433438d5d6cf6 (patch) | |
| tree | d656446445ce3f25f2d2e4cfd65014ba5fd6b267 /src/uk | |
| parent | 271b05caedafb3b7433d2163d59b2ab5f8106dfe (diff) | |
| download | ACQuA-1013812b487bc438df49ec93ad9433438d5d6cf6.tar.gz ACQuA-1013812b487bc438df49ec93ad9433438d5d6cf6.zip | |
Summarisation before Skolemisation. Added Reactome testcase.
Diffstat (limited to 'src/uk')
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java | 22 | ||||
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/summary/HermitSummaryFilter.java | 33 |
2 files changed, 36 insertions, 19 deletions
diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java b/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java index 51cb44d..04b2c65 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java | |||
| @@ -43,6 +43,7 @@ class MyQueryReasoner extends QueryReasoner { | |||
| 43 | private Collection<String> predicatesWithGap = null; | 43 | private Collection<String> predicatesWithGap = null; |
| 44 | private ConsistencyStatus isConsistent; | 44 | private ConsistencyStatus isConsistent; |
| 45 | private ConsistencyManager consistency = new ConsistencyManager(this); | 45 | private ConsistencyManager consistency = new ConsistencyManager(this); |
| 46 | private int relevantOntologiesCounter = 0; | ||
| 46 | 47 | ||
| 47 | public MyQueryReasoner() { | 48 | public MyQueryReasoner() { |
| 48 | setup(true); | 49 | setup(true); |
| @@ -188,17 +189,22 @@ class MyQueryReasoner extends QueryReasoner { | |||
| 188 | return; | 189 | return; |
| 189 | 190 | ||
| 190 | OWLOntology relevantOntologySubset = extractRelevantOntologySubset(queryRecord); | 191 | OWLOntology relevantOntologySubset = extractRelevantOntologySubset(queryRecord); |
| 191 | // queryRecord.saveRelevantOntology("/home/alessandro/Desktop/test-relevant-ontology.owl"); | 192 | |
| 193 | queryRecord.saveRelevantOntology("/home/alessandro/Desktop/test-relevant-ontology-"+relevantOntologiesCounter+".owl"); | ||
| 194 | relevantOntologiesCounter++; | ||
| 195 | |||
| 196 | Utility.logInfo("Summarisation..."); | ||
| 197 | HermitSummaryFilter summarisedChecker = new HermitSummaryFilter(queryRecord, properties.getToCallHermiT()); | ||
| 198 | if(summarisedChecker.check(queryRecord.getGapAnswers()) == 0) | ||
| 199 | return; | ||
| 192 | 200 | ||
| 193 | if(properties.getUseSkolemUpperBound() && | 201 | if(properties.getUseSkolemUpperBound() && |
| 194 | querySkolemisedRelevantSubset(relevantOntologySubset, queryRecord)) { | 202 | querySkolemisedRelevantSubset(relevantOntologySubset, queryRecord)) |
| 195 | return; | 203 | return; |
| 196 | } | ||
| 197 | 204 | ||
| 205 | Utility.logInfo("Full reasoning..."); | ||
| 198 | Timer t = new Timer(); | 206 | Timer t = new Timer(); |
| 199 | HermitSummaryFilter summarisedChecker = new HermitSummaryFilter(queryRecord, properties.getToCallHermiT()); | 207 | summarisedChecker.checkByFullReasoner(queryRecord.getGapAnswers()); |
| 200 | summarisedChecker.check(queryRecord.getGapAnswers()); | ||
| 201 | // summarisedChecker.checkByFullReasoner(queryRecord.getGapAnswers()); | ||
| 202 | Utility.logDebug("Total time for full reasoner: " + t.duration()); | 208 | Utility.logDebug("Total time for full reasoner: " + t.duration()); |
| 203 | 209 | ||
| 204 | queryRecord.markAsProcessed(); | 210 | queryRecord.markAsProcessed(); |
| @@ -360,7 +366,7 @@ class MyQueryReasoner extends QueryReasoner { | |||
| 360 | } | 366 | } |
| 361 | 367 | ||
| 362 | private boolean querySkolemisedRelevantSubset(OWLOntology relevantSubset, QueryRecord queryRecord) { | 368 | private boolean querySkolemisedRelevantSubset(OWLOntology relevantSubset, QueryRecord queryRecord) { |
| 363 | Utility.logInfo("Evaluating semi-Skolemised relevant upper store..."); | 369 | Utility.logInfo("Evaluating semi-Skolemised relevant upper store"); |
| 364 | t.reset(); | 370 | t.reset(); |
| 365 | 371 | ||
| 366 | DatalogProgram relevantProgram = new DatalogProgram(relevantSubset, false); // toClassify is false | 372 | DatalogProgram relevantProgram = new DatalogProgram(relevantSubset, false); // toClassify is false |
| @@ -371,7 +377,7 @@ class MyQueryReasoner extends QueryReasoner { | |||
| 371 | relevantStore.importDataFromABoxOf(relevantSubset); | 377 | relevantStore.importDataFromABoxOf(relevantSubset); |
| 372 | String relevantOriginalMarkProgram = OWLHelper.getOriginalMarkProgram(relevantSubset); | 378 | String relevantOriginalMarkProgram = OWLHelper.getOriginalMarkProgram(relevantSubset); |
| 373 | 379 | ||
| 374 | int queryDependentMaxTermDepth = 10; // TODO make it dynamic | 380 | int queryDependentMaxTermDepth = 5; // TODO make it dynamic |
| 375 | relevantStore.materialise("Mark original individuals", relevantOriginalMarkProgram); | 381 | relevantStore.materialise("Mark original individuals", relevantOriginalMarkProgram); |
| 376 | int materialisationTag = relevantStore.materialiseSkolemly(relevantProgram, null, | 382 | int materialisationTag = relevantStore.materialiseSkolemly(relevantProgram, null, |
| 377 | queryDependentMaxTermDepth); | 383 | queryDependentMaxTermDepth); |
diff --git a/src/uk/ac/ox/cs/pagoda/summary/HermitSummaryFilter.java b/src/uk/ac/ox/cs/pagoda/summary/HermitSummaryFilter.java index 95f2cbb..2d2198f 100644 --- a/src/uk/ac/ox/cs/pagoda/summary/HermitSummaryFilter.java +++ b/src/uk/ac/ox/cs/pagoda/summary/HermitSummaryFilter.java | |||
| @@ -27,7 +27,9 @@ public class HermitSummaryFilter extends Checker { | |||
| 27 | HermitChecker summarisedHermiT = null; | 27 | HermitChecker summarisedHermiT = null; |
| 28 | boolean summarisedConsistency; | 28 | boolean summarisedConsistency; |
| 29 | Endomorph endomorphismChecker = null; | 29 | Endomorph endomorphismChecker = null; |
| 30 | 30 | private HashSet<AnswerTuple> passed; | |
| 31 | private int counter; | ||
| 32 | |||
| 31 | public HermitSummaryFilter(QueryRecord record, boolean toCallHermiT) { | 33 | public HermitSummaryFilter(QueryRecord record, boolean toCallHermiT) { |
| 32 | m_record = record; | 34 | m_record = record; |
| 33 | HermitChecker hermitChecker = new HermitChecker(record.getRelevantOntology(), record, toCallHermiT); | 35 | HermitChecker hermitChecker = new HermitChecker(record.getRelevantOntology(), record, toCallHermiT); |
| @@ -115,6 +117,20 @@ public class HermitSummaryFilter extends Checker { | |||
| 115 | return summarisedHermiT.getNoOfCalls() + endomorphismChecker.getNoOfCalls(); | 117 | return summarisedHermiT.getNoOfCalls() + endomorphismChecker.getNoOfCalls(); |
| 116 | } | 118 | } |
| 117 | 119 | ||
| 120 | public int checkByFullReasoner(AnswerTuples answers) { | ||
| 121 | if(isDisposed()) throw new DisposedException(); | ||
| 122 | if(m_record.isProcessed()) | ||
| 123 | return 0; | ||
| 124 | |||
| 125 | Utility.logDebug("The number of answers to be checked with HermiT: " + passed.size() + "/" + counter); | ||
| 126 | m_record.setDifficulty(Step.FULL_REASONING); | ||
| 127 | |||
| 128 | if(summarisedConsistency) | ||
| 129 | return endomorphismChecker.check(new AnswerTuplesImp(m_record.getAnswerVariables(), passed)); | ||
| 130 | else | ||
| 131 | return endomorphismChecker.check(answers); | ||
| 132 | } | ||
| 133 | |||
| 118 | @Override | 134 | @Override |
| 119 | public int check(AnswerTuples answers) { | 135 | public int check(AnswerTuples answers) { |
| 120 | if(isDisposed()) throw new DisposedException(); | 136 | if(isDisposed()) throw new DisposedException(); |
| @@ -125,10 +141,11 @@ public class HermitSummaryFilter extends Checker { | |||
| 125 | initialiseSummarisedReasoner(); | 141 | initialiseSummarisedReasoner(); |
| 126 | 142 | ||
| 127 | if(summarisedConsistency) { | 143 | if(summarisedConsistency) { |
| 128 | Set<AnswerTuple> passed = new HashSet<AnswerTuple>(), succ = new HashSet<AnswerTuple>(); | 144 | passed = new HashSet<AnswerTuple>(); |
| 145 | Set<AnswerTuple> succ = new HashSet<AnswerTuple>(); | ||
| 129 | Set<AnswerTuple> falsified = new HashSet<AnswerTuple>(), fail = new HashSet<AnswerTuple>(); | 146 | Set<AnswerTuple> falsified = new HashSet<AnswerTuple>(), fail = new HashSet<AnswerTuple>(); |
| 130 | 147 | ||
| 131 | int counter = 0; | 148 | counter = 0; |
| 132 | AnswerTuple representative; | 149 | AnswerTuple representative; |
| 133 | for(AnswerTuple answer; answers.isValid(); answers.moveNext()) { | 150 | for(AnswerTuple answer; answers.isValid(); answers.moveNext()) { |
| 134 | ++counter; | 151 | ++counter; |
| @@ -158,20 +175,14 @@ public class HermitSummaryFilter extends Checker { | |||
| 158 | m_record.addProcessingTime(Step.SUMMARISATION, t.duration()); | 175 | m_record.addProcessingTime(Step.SUMMARISATION, t.duration()); |
| 159 | return 0; | 176 | return 0; |
| 160 | } | 177 | } |
| 161 | |||
| 162 | Utility.logDebug("The number of answers to be checked with HermiT: " + passed.size() + "/" + counter); | ||
| 163 | |||
| 164 | m_record.setDifficulty(Step.FULL_REASONING); | ||
| 165 | m_record.addProcessingTime(Step.SUMMARISATION, t.duration()); | 178 | m_record.addProcessingTime(Step.SUMMARISATION, t.duration()); |
| 166 | |||
| 167 | return endomorphismChecker.check(new AnswerTuplesImp(m_record.getAnswerVariables(), passed)); | ||
| 168 | } | 179 | } |
| 169 | else { | 180 | else { |
| 170 | m_record.addProcessingTime(Step.SUMMARISATION, t.duration()); | 181 | m_record.addProcessingTime(Step.SUMMARISATION, t.duration()); |
| 171 | // m_record.saveRelevantOntology("fragment.owl"); | 182 | // m_record.saveRelevantOntology("fragment.owl"); |
| 172 | m_record.setDifficulty(Step.FULL_REASONING); | ||
| 173 | return endomorphismChecker.check(answers); | ||
| 174 | } | 183 | } |
| 184 | |||
| 185 | return 1; | ||
| 175 | } | 186 | } |
| 176 | 187 | ||
| 177 | @Override | 188 | @Override |
