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 | |
| parent | 271b05caedafb3b7433d2163d59b2ab5f8106dfe (diff) | |
| download | ACQuA-1013812b487bc438df49ec93ad9433438d5d6cf6.tar.gz ACQuA-1013812b487bc438df49ec93ad9433438d5d6cf6.zip | |
Summarisation before Skolemisation. Added Reactome testcase.
| -rw-r--r-- | src/resources/pagoda.properties | 2 | ||||
| -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 | ||||
| -rw-r--r-- | test/resources/LightTests.xml | 6 | ||||
| -rw-r--r-- | test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaFLY.java | 2 | ||||
| -rw-r--r-- | test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaReactome.java | 26 | ||||
| -rw-r--r-- | test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaUOBM.java | 3 | ||||
| -rw-r--r-- | test/uk/ac/ox/cs/pagoda/query/CheckAnswers.java | 3 |
8 files changed, 71 insertions, 26 deletions
diff --git a/src/resources/pagoda.properties b/src/resources/pagoda.properties index 0401d64..64de225 100644 --- a/src/resources/pagoda.properties +++ b/src/resources/pagoda.properties | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | debug=true | 1 | debug=true |
| 2 | useAlwaysSimpleUpperBound=false | 2 | useAlwaysSimpleUpperBound=false |
| 3 | useSkolemUpperBound=false | 3 | useSkolemUpperBound=true |
| 4 | 4 | ||
| 5 | statisticsDir=/home/alessandro/Dropbox/Oxford/PAGOdA/statistics \ No newline at end of file | 5 | statisticsDir=/home/alessandro/Dropbox/Oxford/PAGOdA/statistics \ No newline at end of file |
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 |
diff --git a/test/resources/LightTests.xml b/test/resources/LightTests.xml index 69cb572..544833b 100644 --- a/test/resources/LightTests.xml +++ b/test/resources/LightTests.xml | |||
| @@ -7,13 +7,15 @@ | |||
| 7 | <run> | 7 | <run> |
| 8 | <include name="light"/> | 8 | <include name="light"/> |
| 9 | <!--<include name="justExecute"/>--> | 9 | <!--<include name="justExecute"/>--> |
| 10 | <exclude name="nonOriginal"/> | ||
| 10 | </run> | 11 | </run> |
| 11 | </groups> | 12 | </groups> |
| 12 | <classes> | 13 | <classes> |
| 13 | <class name="uk.ac.ox.cs.pagoda.global_tests.TestPagodaUOBM"/> | 14 | <!--<class name="uk.ac.ox.cs.pagoda.global_tests.TestPagodaReactome"/>--> |
| 15 | <!--<class name="uk.ac.ox.cs.pagoda.global_tests.TestPagodaUOBM"/>--> | ||
| 14 | <!--<class name="uk.ac.ox.cs.pagoda.global_tests.TestPagodaLUBM"/>--> | 16 | <!--<class name="uk.ac.ox.cs.pagoda.global_tests.TestPagodaLUBM"/>--> |
| 15 | <!--Fly does not terminate: query-5 looks really hard--> | 17 | <!--Fly does not terminate: query-5 looks really hard--> |
| 16 | <!--<class name="uk.ac.ox.cs.pagoda.global_tests.TestPagodaFLY"/>--> | 18 | <class name="uk.ac.ox.cs.pagoda.global_tests.TestPagodaFLY"/> |
| 17 | </classes> | 19 | </classes> |
| 18 | </test> | 20 | </test> |
| 19 | </suite> \ No newline at end of file | 21 | </suite> \ No newline at end of file |
diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaFLY.java b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaFLY.java index caaad35..31d2eac 100644 --- a/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaFLY.java +++ b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaFLY.java | |||
| @@ -52,7 +52,7 @@ public class TestPagodaFLY { | |||
| 52 | CheckAnswers.assertSameAnswers(answers, givenAnswers); | 52 | CheckAnswers.assertSameAnswers(answers, givenAnswers); |
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | @Test(groups = {"light", "justExecute"}) | 55 | @Test(groups = {"light", "justExecute", "nonOriginal"}) |
| 56 | public void justExecute_newQueries() throws IOException { | 56 | public void justExecute_newQueries() throws IOException { |
| 57 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | 57 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); |
| 58 | 58 | ||
diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaReactome.java b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaReactome.java new file mode 100644 index 0000000..5c05b94 --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaReactome.java | |||
| @@ -0,0 +1,26 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.global_tests; | ||
| 2 | |||
| 3 | import org.testng.annotations.Test; | ||
| 4 | import uk.ac.ox.cs.pagoda.Pagoda; | ||
| 5 | import uk.ac.ox.cs.pagoda.util.TestUtil; | ||
| 6 | |||
| 7 | import java.io.IOException; | ||
| 8 | import java.nio.file.Paths; | ||
| 9 | |||
| 10 | public class TestPagodaReactome { | ||
| 11 | |||
| 12 | @Test(groups = {"light"}) | ||
| 13 | public void justExecute() throws IOException { | ||
| 14 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | ||
| 15 | |||
| 16 | Pagoda.builder() | ||
| 17 | .ontology(Paths.get(ontoDir, "reactome/biopax-level3-processed.owl")) | ||
| 18 | .data(Paths.get(ontoDir, "reactome/data/sample_10.ttl")) | ||
| 19 | .query(Paths.get(ontoDir, "reactome/test.sparql")) | ||
| 20 | .classify(true) | ||
| 21 | .hermit(true) | ||
| 22 | .build() | ||
| 23 | .run(); | ||
| 24 | } | ||
| 25 | |||
| 26 | } | ||
diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaUOBM.java b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaUOBM.java index d0f0b9a..9fb6cbe 100644 --- a/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaUOBM.java +++ b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaUOBM.java | |||
| @@ -87,7 +87,8 @@ public class TestPagodaUOBM { | |||
| 87 | .query(Paths.get(ontoDir, "uobm/queries/uobm_sygenia_all-blanks.sparql")) | 87 | .query(Paths.get(ontoDir, "uobm/queries/uobm_sygenia_all-blanks.sparql")) |
| 88 | .classify(true) | 88 | .classify(true) |
| 89 | .hermit(true) | 89 | .hermit(true) |
| 90 | .build().run(); | 90 | .build() |
| 91 | .run(); | ||
| 91 | } | 92 | } |
| 92 | 93 | ||
| 93 | @Test(groups = {"justExecute"}) | 94 | @Test(groups = {"justExecute"}) |
diff --git a/test/uk/ac/ox/cs/pagoda/query/CheckAnswers.java b/test/uk/ac/ox/cs/pagoda/query/CheckAnswers.java index 97e3a57..71730c3 100644 --- a/test/uk/ac/ox/cs/pagoda/query/CheckAnswers.java +++ b/test/uk/ac/ox/cs/pagoda/query/CheckAnswers.java | |||
| @@ -25,8 +25,7 @@ public class CheckAnswers { | |||
| 25 | 25 | ||
| 26 | Gson gson = QueryRecord.GsonCreator.getInstance(); | 26 | Gson gson = QueryRecord.GsonCreator.getInstance(); |
| 27 | 27 | ||
| 28 | Type cqType = new TypeToken<Set<QueryRecord>>() { | 28 | Type cqType = new TypeToken<Set<QueryRecord>>() {}.getType(); |
| 29 | }.getType(); | ||
| 30 | Set<QueryRecord> computedAnswersRecords = gson.fromJson(computedReader, cqType); | 29 | Set<QueryRecord> computedAnswersRecords = gson.fromJson(computedReader, cqType); |
| 31 | Set<QueryRecord> givenAnswersRecords = gson.fromJson(givenReader, cqType); | 30 | Set<QueryRecord> givenAnswersRecords = gson.fromJson(givenReader, cqType); |
| 32 | 31 | ||
