aboutsummaryrefslogtreecommitdiff
path: root/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java
diff options
context:
space:
mode:
authorRncLsn <rnc.lsn@gmail.com>2015-05-15 17:32:22 +0100
committerRncLsn <rnc.lsn@gmail.com>2015-05-15 17:32:22 +0100
commit1b6a128137e5d7a6ff75566869232fc054afabef (patch)
tree3def49c3c9c1e2ebebc49b82d9eb562b6d097cad /src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java
parentbd995407098d1b0c79c17a28b0b23a2c24a493c6 (diff)
downloadACQuA-1b6a128137e5d7a6ff75566869232fc054afabef.tar.gz
ACQuA-1b6a128137e5d7a6ff75566869232fc054afabef.zip
Testing and fixing. Executed successfully on UOBM{1,2,3,4,5,6,7,8}.
Diffstat (limited to 'src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java')
-rw-r--r--src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java44
1 files changed, 21 insertions, 23 deletions
diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java b/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java
index 36ea7de..1f435b7 100644
--- a/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java
+++ b/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java
@@ -50,6 +50,7 @@ public class MyQueryReasoner extends QueryReasoner {
50 private Collection<String> predicatesWithGap = null; 50 private Collection<String> predicatesWithGap = null;
51 private Boolean satisfiable; 51 private Boolean satisfiable;
52 private ConsistencyManager consistency = new ConsistencyManager(this); 52 private ConsistencyManager consistency = new ConsistencyManager(this);
53 private boolean useUpperStores = false;
53 54
54 public MyQueryReasoner() { 55 public MyQueryReasoner() {
55 setup(true, true); 56 setup(true, true);
@@ -101,9 +102,9 @@ public class MyQueryReasoner extends QueryReasoner {
101// program.getUpper().save(); 102// program.getUpper().save();
102// program.getGeneral().save(); 103// program.getGeneral().save();
103 104
104 if (multiStageTag && !program.getGeneral().isHorn()) { 105 useUpperStores = multiStageTag && !program.getGeneral().isHorn();
106 if (useUpperStores) {
105 lazyUpperStore = getUpperStore("lazy-upper-bound", true); // new MultiStageQueryEngine("lazy-upper-bound", true); // 107 lazyUpperStore = getUpperStore("lazy-upper-bound", true); // new MultiStageQueryEngine("lazy-upper-bound", true); //
106 // TODO CHECK
107 limitedSkolemUpperStore = getUpperStore("limited-skolem-upper-bound", true); 108 limitedSkolemUpperStore = getUpperStore("limited-skolem-upper-bound", true);
108 } 109 }
109 110
@@ -120,7 +121,7 @@ public class MyQueryReasoner extends QueryReasoner {
120 @Override 121 @Override
121 public boolean preprocess() { 122 public boolean preprocess() {
122 t.reset(); 123 t.reset();
123 Utility.logInfo("Preprocessing ... checking satisfiability ... "); 124 Utility.logInfo("Preprocessing... checking satisfiability... ");
124 125
125 String name = "data", datafile = importedData.toString(); 126 String name = "data", datafile = importedData.toString();
126 rlLowerStore.importRDFData(name, datafile); 127 rlLowerStore.importRDFData(name, datafile);
@@ -147,12 +148,11 @@ public class MyQueryReasoner extends QueryReasoner {
147 } 148 }
148 if (tag == -1) return false; 149 if (tag == -1) return false;
149 } 150 }
150 if (consistency.checkLazyUpper()) { 151 if (consistency.checkUpper(lazyUpperStore)) {
151 satisfiable = true; 152 satisfiable = true;
152 Utility.logInfo("time for satisfiability checking: " + t.duration()); 153 Utility.logInfo("time for satisfiability checking: " + t.duration());
153 } 154 }
154 155
155 // TODO check
156 if (limitedSkolemUpperStore != null) { 156 if (limitedSkolemUpperStore != null) {
157 limitedSkolemUpperStore.importRDFData(name, datafile); 157 limitedSkolemUpperStore.importRDFData(name, datafile);
158 limitedSkolemUpperStore.materialise("saturate named individuals", originalMarkProgram); 158 limitedSkolemUpperStore.materialise("saturate named individuals", originalMarkProgram);
@@ -163,16 +163,14 @@ public class MyQueryReasoner extends QueryReasoner {
163 } 163 }
164 if (tag == -1) return false; 164 if (tag == -1) return false;
165 } 165 }
166 // FIXME nullPointerException 166 if (consistency.checkUpper(limitedSkolemUpperStore)) {
167// if (consistency.checkSkolemUpper()) { 167 satisfiable = true;
168// satisfiable = true; 168 Utility.logInfo("time for satisfiability checking: " + t.duration());
169// Utility.logInfo("time for satisfiability checking: " + t.duration()); 169 }
170// }
171 170
172 trackingStore.importRDFData(name, datafile); 171 trackingStore.importRDFData(name, datafile);
173 trackingStore.materialise("saturate named individuals", originalMarkProgram); 172 trackingStore.materialise("saturate named individuals", originalMarkProgram);
174 173
175// materialiseFullUpper();
176 GapByStore4ID gap = new GapByStore4ID(trackingStore); 174 GapByStore4ID gap = new GapByStore4ID(trackingStore);
177 trackingStore.materialiseFoldedly(program, gap); 175 trackingStore.materialiseFoldedly(program, gap);
178 predicatesWithGap = gap.getPredicatesWithGap(); 176 predicatesWithGap = gap.getPredicatesWithGap();
@@ -192,6 +190,7 @@ public class MyQueryReasoner extends QueryReasoner {
192 return false; 190 return false;
193 191
194 consistency.extractBottomFragment(); 192 consistency.extractBottomFragment();
193 consistency.dispose();
195 return true; 194 return true;
196 } 195 }
197 196
@@ -204,6 +203,9 @@ public class MyQueryReasoner extends QueryReasoner {
204 return satisfiable; 203 return satisfiable;
205 } 204 }
206 205
206 /**
207 * Returns the relevant part of the ontology, while computing the bound answers.
208 * */
207 private OWLOntology relevantPart(QueryRecord queryRecord) { 209 private OWLOntology relevantPart(QueryRecord queryRecord) {
208 AnswerTuples rlAnswer = null, elAnswer = null; 210 AnswerTuples rlAnswer = null, elAnswer = null;
209 211
@@ -216,13 +218,13 @@ public class MyQueryReasoner extends QueryReasoner {
216 if (rlAnswer != null) rlAnswer.dispose(); 218 if (rlAnswer != null) rlAnswer.dispose();
217 } 219 }
218 queryRecord.addProcessingTime(Step.LowerBound, t.duration()); 220 queryRecord.addProcessingTime(Step.LowerBound, t.duration());
219 rlAnswer = null;
220 221
221 t.reset(); 222 t.reset();
222 BasicQueryEngine upperStore = queryRecord.isBottom() || lazyUpperStore == null ? trackingStore : lazyUpperStore; 223 BasicQueryEngine upperStore = queryRecord.isBottom() || lazyUpperStore == null ? trackingStore : lazyUpperStore;
223 224
224 String[] extendedQuery = queryRecord.getExtendedQueryText(); 225 String[] extendedQuery = queryRecord.getExtendedQueryText();
225 226
227 // TODO why the following???
226 queryUpperBound(upperStore, queryRecord, queryRecord.getQueryText(), queryRecord.getAnswerVariables()); 228 queryUpperBound(upperStore, queryRecord, queryRecord.getQueryText(), queryRecord.getAnswerVariables());
227 229
228 if (!queryRecord.processed() && !queryRecord.getQueryText().equals(extendedQuery[0])) { 230 if (!queryRecord.processed() && !queryRecord.getQueryText().equals(extendedQuery[0])) {
@@ -232,25 +234,21 @@ public class MyQueryReasoner extends QueryReasoner {
232 queryUpperBound(upperStore, queryRecord, extendedQuery[1], queryRecord.getDistinguishedVariables()); 234 queryUpperBound(upperStore, queryRecord, extendedQuery[1], queryRecord.getDistinguishedVariables());
233 } 235 }
234 236
235 Utility.logDebug(toJsonKeyValuePair("upperBound1", queryRecord)); 237// Utility.logDebug(toJsonKeyValuePair("upperBound", queryRecord));
236 238
237 // TODO check whether it is harmful. In case is not, implement it properly 239 // TODO test intersection and new upper bound
238 // BEGIN: trying to intersect
239 if (!queryRecord.isBottom() && lazyUpperStore != null) { 240 if (!queryRecord.isBottom() && lazyUpperStore != null) {
240 queryUpperBound(trackingStore, queryRecord, queryRecord.getQueryText(), queryRecord.getAnswerVariables()); 241 queryUpperBound(trackingStore, queryRecord, queryRecord.getQueryText(), queryRecord.getAnswerVariables());
241 } 242 }
242 if (!queryRecord.isBottom() && limitedSkolemUpperStore != null) { 243 if (!queryRecord.isBottom() && limitedSkolemUpperStore != null) {
243 queryUpperBound(limitedSkolemUpperStore, queryRecord, queryRecord.getQueryText(), queryRecord.getAnswerVariables()); 244 queryUpperBound(limitedSkolemUpperStore, queryRecord, queryRecord.getQueryText(), queryRecord.getAnswerVariables());
244 } 245 }
245 // END: trying to intersect
246 246
247 queryRecord.addProcessingTime(Step.UpperBound, t.duration()); 247 queryRecord.addProcessingTime(Step.UpperBound, t.duration());
248 if (queryRecord.processed()) { 248 if (queryRecord.processed()) {
249 queryRecord.setDifficulty(Step.UpperBound); 249 queryRecord.setDifficulty(Step.UpperBound);
250 return null; 250 return null;
251 } 251 }
252
253 // TODO add evaluation on new upper store
254 252
255 t.reset(); 253 t.reset();
256 try { 254 try {
@@ -327,15 +325,15 @@ public class MyQueryReasoner extends QueryReasoner {
327 325
328 @Override 326 @Override
329 public void evaluate(QueryRecord queryRecord) { 327 public void evaluate(QueryRecord queryRecord) {
330 OWLOntology knowledgebase = relevantPart(queryRecord); 328 OWLOntology knowledgeBase = relevantPart(queryRecord);
331 329
332 if (knowledgebase == null) { 330 if (knowledgeBase == null) {
333 Utility.logDebug("Difficulty of this query: " + queryRecord.getDifficulty()); 331 Utility.logDebug("Difficulty of this query: " + queryRecord.getDifficulty());
334 return ; 332 return ;
335 } 333 }
336 334
337 int aboxcount = knowledgebase.getABoxAxioms(true).size(); 335 int aBoxCount = knowledgeBase.getABoxAxioms(true).size();
338 Utility.logDebug("ABox axioms: " + aboxcount + " TBox axioms: " + (knowledgebase.getAxiomCount() - aboxcount)); 336 Utility.logDebug("ABox axioms: " + aBoxCount + " TBox axioms: " + (knowledgeBase.getAxiomCount() - aBoxCount));
339// queryRecord.saveRelevantOntology("fragment_query" + queryRecord.getQueryID() + ".owl"); 337// queryRecord.saveRelevantOntology("fragment_query" + queryRecord.getQueryID() + ".owl");
340 338
341 Timer t = new Timer(); 339 Timer t = new Timer();