diff options
| author | RncLsn <rnc.lsn@gmail.com> | 2015-06-03 19:24:50 +0100 |
|---|---|---|
| committer | RncLsn <rnc.lsn@gmail.com> | 2015-06-03 19:24:50 +0100 |
| commit | a840a197549ced185f212b2aa74abed8774c8b5c (patch) | |
| tree | 91168e111df7245b0cc1bf52c2738597a1a4a2e4 /src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java | |
| parent | b3b822d187a6402a39d30e471fe90a5dfad64312 (diff) | |
| download | ACQuA-a840a197549ced185f212b2aa74abed8774c8b5c.tar.gz ACQuA-a840a197549ced185f212b2aa74abed8774c8b5c.zip | |
Reintroduced extended queries. Successfully tested on LightTests and GapAnswers.
Diffstat (limited to 'src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java')
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java | 54 |
1 files changed, 16 insertions, 38 deletions
diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java b/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java index b4e2f5a..3027a73 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java | |||
| @@ -19,6 +19,7 @@ import uk.ac.ox.cs.pagoda.tracking.QueryTracker; | |||
| 19 | import uk.ac.ox.cs.pagoda.tracking.TrackingRuleEncoder; | 19 | import uk.ac.ox.cs.pagoda.tracking.TrackingRuleEncoder; |
| 20 | import uk.ac.ox.cs.pagoda.tracking.TrackingRuleEncoderDisjVar1; | 20 | import uk.ac.ox.cs.pagoda.tracking.TrackingRuleEncoderDisjVar1; |
| 21 | import uk.ac.ox.cs.pagoda.tracking.TrackingRuleEncoderWithGap; | 21 | import uk.ac.ox.cs.pagoda.tracking.TrackingRuleEncoderWithGap; |
| 22 | import uk.ac.ox.cs.pagoda.util.PagodaProperties; | ||
| 22 | import uk.ac.ox.cs.pagoda.util.Timer; | 23 | import uk.ac.ox.cs.pagoda.util.Timer; |
| 23 | import uk.ac.ox.cs.pagoda.util.Utility; | 24 | import uk.ac.ox.cs.pagoda.util.Utility; |
| 24 | import uk.ac.ox.cs.pagoda.util.disposable.DisposedException; | 25 | import uk.ac.ox.cs.pagoda.util.disposable.DisposedException; |
| @@ -44,7 +45,6 @@ class MyQueryReasoner extends QueryReasoner { | |||
| 44 | private Collection<String> predicatesWithGap = null; | 45 | private Collection<String> predicatesWithGap = null; |
| 45 | private ConsistencyStatus isConsistent; | 46 | private ConsistencyStatus isConsistent; |
| 46 | private ConsistencyManager consistency = new ConsistencyManager(this); | 47 | private ConsistencyManager consistency = new ConsistencyManager(this); |
| 47 | private boolean useSkolemisation = false; // now only debugging | ||
| 48 | 48 | ||
| 49 | public MyQueryReasoner() { | 49 | public MyQueryReasoner() { |
| 50 | setup(true); | 50 | setup(true); |
| @@ -192,7 +192,8 @@ class MyQueryReasoner extends QueryReasoner { | |||
| 192 | OWLOntology relevantOntologySubset = extractRelevantOntologySubset(queryRecord); | 192 | OWLOntology relevantOntologySubset = extractRelevantOntologySubset(queryRecord); |
| 193 | queryRecord.saveRelevantOntology("/home/alessandro/Desktop/fragment_query" + queryRecord.getQueryID() + ".owl"); | 193 | queryRecord.saveRelevantOntology("/home/alessandro/Desktop/fragment_query" + queryRecord.getQueryID() + ".owl"); |
| 194 | 194 | ||
| 195 | if(useSkolemisation && querySkolemisedRelevantSubset(relevantOntologySubset, queryRecord)) | 195 | if(PagodaProperties.getDefaultUseSkolemUpperBound() && |
| 196 | querySkolemisedRelevantSubset(relevantOntologySubset, queryRecord)) | ||
| 196 | return; | 197 | return; |
| 197 | 198 | ||
| 198 | Timer t = new Timer(); | 199 | Timer t = new Timer(); |
| @@ -263,10 +264,12 @@ class MyQueryReasoner extends QueryReasoner { | |||
| 263 | private boolean queryUpperStore(BasicQueryEngine upperStore, QueryRecord queryRecord, | 264 | private boolean queryUpperStore(BasicQueryEngine upperStore, QueryRecord queryRecord, |
| 264 | Tuple<String> extendedQuery, Step step) { | 265 | Tuple<String> extendedQuery, Step step) { |
| 265 | t.reset(); | 266 | t.reset(); |
| 266 | if(queryRecord.hasNonAnsDistinguishedVariables()) | 267 | |
| 268 | queryUpperBound(upperStore, queryRecord, queryRecord.getQueryText(), queryRecord.getAnswerVariables()); | ||
| 269 | if(!queryRecord.isProcessed() && !queryRecord.getQueryText().equals(extendedQuery.get(0))) | ||
| 267 | queryUpperBound(upperStore, queryRecord, extendedQuery.get(0), queryRecord.getAnswerVariables()); | 270 | queryUpperBound(upperStore, queryRecord, extendedQuery.get(0), queryRecord.getAnswerVariables()); |
| 268 | else | 271 | if(!queryRecord.isProcessed() && queryRecord.hasNonAnsDistinguishedVariables()) |
| 269 | queryUpperBound(upperStore, queryRecord, queryRecord.getQueryText(), queryRecord.getAnswerVariables()); | 272 | queryUpperBound(upperStore, queryRecord, extendedQuery.get(1), queryRecord.getDistinguishedVariables()); |
| 270 | 273 | ||
| 271 | queryRecord.addProcessingTime(step, t.duration()); | 274 | queryRecord.addProcessingTime(step, t.duration()); |
| 272 | if(queryRecord.isProcessed()) { | 275 | if(queryRecord.isProcessed()) { |
| @@ -276,34 +279,6 @@ class MyQueryReasoner extends QueryReasoner { | |||
| 276 | return false; | 279 | return false; |
| 277 | } | 280 | } |
| 278 | 281 | ||
| 279 | private boolean checkGapAnswers(BasicQueryEngine relevantStore, QueryRecord queryRecord) { | ||
| 280 | t.reset(); | ||
| 281 | Tuple<String> extendedQueries = queryRecord.getExtendedQueryText(); | ||
| 282 | if(queryRecord.hasNonAnsDistinguishedVariables()) | ||
| 283 | checkGapAnswers(relevantStore, queryRecord, extendedQueries.get(0), queryRecord.getAnswerVariables()); | ||
| 284 | else | ||
| 285 | checkGapAnswers(relevantStore, queryRecord, queryRecord.getQueryText(), queryRecord.getAnswerVariables()); | ||
| 286 | |||
| 287 | queryRecord.addProcessingTime(Step.L_SKOLEM_UPPER_BOUND, t.duration()); | ||
| 288 | if(queryRecord.isProcessed()) { | ||
| 289 | queryRecord.setDifficulty(Step.L_SKOLEM_UPPER_BOUND); | ||
| 290 | return true; | ||
| 291 | } | ||
| 292 | return false; | ||
| 293 | } | ||
| 294 | |||
| 295 | private void checkGapAnswers(BasicQueryEngine relevantStore, QueryRecord queryRecord, String queryText, String[] answerVariables) { | ||
| 296 | AnswerTuples rlAnswer = null; | ||
| 297 | try { | ||
| 298 | Utility.logDebug(queryText); | ||
| 299 | rlAnswer = relevantStore.evaluate(queryText, answerVariables); | ||
| 300 | Utility.logDebug(t.duration()); | ||
| 301 | queryRecord.checkUpperBoundAnswers(rlAnswer); | ||
| 302 | } finally { | ||
| 303 | if(rlAnswer != null) rlAnswer.dispose(); | ||
| 304 | } | ||
| 305 | } | ||
| 306 | |||
| 307 | /** | 282 | /** |
| 308 | * Returns the part of the ontology relevant for Hermit, while computing the bound answers. | 283 | * Returns the part of the ontology relevant for Hermit, while computing the bound answers. |
| 309 | */ | 284 | */ |
| @@ -322,9 +297,11 @@ class MyQueryReasoner extends QueryReasoner { | |||
| 322 | 297 | ||
| 323 | Tuple<String> extendedQueryTexts = queryRecord.getExtendedQueryText(); | 298 | Tuple<String> extendedQueryTexts = queryRecord.getExtendedQueryText(); |
| 324 | 299 | ||
| 325 | Utility.logDebug("Tracking store"); | 300 | if(PagodaProperties.getDefaultUseAlwaysSimpleUpperBound() || lazyUpperStore == null) { |
| 326 | if(queryUpperStore(trackingStore, queryRecord, extendedQueryTexts, Step.SIMPLE_UPPER_BOUND)) | 301 | Utility.logDebug("Tracking store"); |
| 327 | return true; | 302 | if(queryUpperStore(trackingStore, queryRecord, extendedQueryTexts, Step.SIMPLE_UPPER_BOUND)) |
| 303 | return true; | ||
| 304 | } | ||
| 328 | 305 | ||
| 329 | if(!queryRecord.isBottom()) { | 306 | if(!queryRecord.isBottom()) { |
| 330 | Utility.logDebug("Lazy store"); | 307 | Utility.logDebug("Lazy store"); |
| @@ -362,7 +339,6 @@ class MyQueryReasoner extends QueryReasoner { | |||
| 362 | 339 | ||
| 363 | queryRecord.addProcessingTime(Step.FRAGMENT, t.duration()); | 340 | queryRecord.addProcessingTime(Step.FRAGMENT, t.duration()); |
| 364 | 341 | ||
| 365 | // just statistics | ||
| 366 | int numOfABoxAxioms = relevantOntologySubset.getABoxAxioms(true).size(); | 342 | int numOfABoxAxioms = relevantOntologySubset.getABoxAxioms(true).size(); |
| 367 | int numOfTBoxAxioms = relevantOntologySubset.getAxiomCount() - numOfABoxAxioms; | 343 | int numOfTBoxAxioms = relevantOntologySubset.getAxiomCount() - numOfABoxAxioms; |
| 368 | Utility.logInfo("Relevant ontology-subset has been extracted: |ABox|=" | 344 | Utility.logInfo("Relevant ontology-subset has been extracted: |ABox|=" |
| @@ -407,7 +383,9 @@ class MyQueryReasoner extends QueryReasoner { | |||
| 407 | return false; | 383 | return false; |
| 408 | } | 384 | } |
| 409 | 385 | ||
| 410 | boolean isFullyProcessed = checkGapAnswers(relevantStore, queryRecord); | 386 | boolean isFullyProcessed = queryUpperStore(relevantStore, queryRecord, |
| 387 | queryRecord.getExtendedQueryText(), | ||
| 388 | Step.L_SKOLEM_UPPER_BOUND); | ||
| 411 | Utility.logInfo("Semi-Skolemised relevant upper store has been evaluated"); | 389 | Utility.logInfo("Semi-Skolemised relevant upper store has been evaluated"); |
| 412 | return isFullyProcessed; | 390 | return isFullyProcessed; |
| 413 | } | 391 | } |
