From 2e069a4966e6305194c4168d6fc5c406123d7f64 Mon Sep 17 00:00:00 2001 From: RncLsn Date: Thu, 28 May 2015 10:29:11 +0100 Subject: NOT-WORKING: trying to add query-dependent Skolemisation. --- src/uk/ac/ox/cs/pagoda/approx/RLPlusOntology.java | 178 ++++++++++----------- src/uk/ac/ox/cs/pagoda/query/QueryRecord.java | 13 +- .../ox/cs/pagoda/reasoner/ConsistencyManager.java | 114 +++++++------ .../ox/cs/pagoda/reasoner/ELHOUQueryReasoner.java | 2 +- .../ox/cs/pagoda/reasoner/IterativeRefinement.java | 26 ++- .../ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java | 145 ++++++++--------- src/uk/ac/ox/cs/pagoda/reasoner/QueryReasoner.java | 12 +- .../ac/ox/cs/pagoda/reasoner/RLUQueryReasoner.java | 4 +- .../cs/pagoda/reasoner/light/RDFoxQueryEngine.java | 94 ++++++----- .../ox/cs/pagoda/summary/HermitSummaryFilter.java | 2 +- src/uk/ac/ox/cs/pagoda/tracking/QueryTracker.java | 38 ++--- 11 files changed, 310 insertions(+), 318 deletions(-) (limited to 'src/uk') diff --git a/src/uk/ac/ox/cs/pagoda/approx/RLPlusOntology.java b/src/uk/ac/ox/cs/pagoda/approx/RLPlusOntology.java index 1e17dac..767d379 100644 --- a/src/uk/ac/ox/cs/pagoda/approx/RLPlusOntology.java +++ b/src/uk/ac/ox/cs/pagoda/approx/RLPlusOntology.java @@ -38,46 +38,51 @@ public class RLPlusOntology implements KnowledgeBase { LinkedList clauses; Map correspondence; - BottomStrategy botStrategy; - + BottomStrategy botStrategy; + Random random = new Random(19900114); + private Map subCounter = null; + private Map atomic2negation = new HashMap(); + + // FIXME multiple anonymous ontologies @Override public void load(OWLOntology o, uk.ac.ox.cs.pagoda.constraints.BottomStrategy bottomStrategy) { if (bottomStrategy instanceof UnaryBottom) - botStrategy = BottomStrategy.UNARY; + botStrategy = BottomStrategy.UNARY; else if (bottomStrategy instanceof NullaryBottom) - botStrategy = BottomStrategy.NULLARY; - else - botStrategy = BottomStrategy.TOREMOVE; - - if (corrFileName == null) + botStrategy = BottomStrategy.NULLARY; + else + botStrategy = BottomStrategy.TOREMOVE; + + if(corrFileName == null) corrFileName = "rlplus.crr"; manager = o.getOWLOntologyManager(); // manager = OWLManager.createOWLOntologyManager(); - factory = manager.getOWLDataFactory(); - inputOntology = o; - + factory = manager.getOWLDataFactory(); + inputOntology = o; + try { String path = OWLHelper.getOntologyPath(inputOntology); - String name = path.substring(path.lastIndexOf(Utility.JAVA_FILE_SEPARATOR)); + String name = path.substring(path.lastIndexOf(Utility.JAVA_FILE_SEPARATOR)); String originalExtension = name.lastIndexOf(".") >= 0 ? name.substring(name.lastIndexOf(".")) : ""; - + if (inputOntology.getOntologyID().getOntologyIRI() == null) - ontologyIRI = "http://www.example.org/anonymous-ontology" + originalExtension; - else + ontologyIRI = "http://www.example.org/anonymous-ontology" + originalExtension; + else ontologyIRI = inputOntology.getOntologyID().getOntologyIRI().toString(); - - String tOntoIRI = ontologyIRI; + + String tOntoIRI = ontologyIRI; if (!tOntoIRI.endsWith(originalExtension)) tOntoIRI += originalExtension; - + String rlOntologyIRI = originalExtension.isEmpty() ? tOntoIRI + "-RL.owl" : tOntoIRI.replaceFirst(originalExtension, "-RL.owl"); String rlDocumentIRI = (outputPath = Paths.get(Utility.getGlobalTempDirAbsolutePath(), "RL.owl").toString()); outputOntology = manager.createOntology(IRI.create(rlOntologyIRI)); manager.setOntologyDocumentIRI(outputOntology, IRI.create(Utility.toFileIRI(rlDocumentIRI))); - - String tBoxOntologyIRI, aBoxOntologyIRI; - tBoxOntologyIRI = originalExtension.isEmpty() ? tOntoIRI + "-TBox.owl" : tOntoIRI.replaceFirst(originalExtension, "-TBox.owl"); + + String tBoxOntologyIRI, aBoxOntologyIRI; + tBoxOntologyIRI = + originalExtension.isEmpty() ? tOntoIRI + "-TBox.owl" : tOntoIRI.replaceFirst(originalExtension, "-TBox.owl"); aBoxOntologyIRI = originalExtension.isEmpty() ? tOntoIRI + "-ABox.owl" : tOntoIRI.replaceFirst(originalExtension, "-ABox.owl"); - + String tBoxDocumentIRI = Paths.get(Utility.getGlobalTempDirAbsolutePath(), "TBox.owl").toString(); String aBoxDocumentIRI = (aBoxPath = Paths.get(Utility.getGlobalTempDirAbsolutePath(), "ABox.owl").toString()); tBox = manager.createOntology(IRI.create(tBoxOntologyIRI)); @@ -85,10 +90,10 @@ public class RLPlusOntology implements KnowledgeBase { manager.setOntologyDocumentIRI(tBox, IRI.create(Utility.toFileIRI(tBoxDocumentIRI))); manager.setOntologyDocumentIRI(aBox, IRI.create(Utility.toFileIRI(aBoxDocumentIRI))); - FileOutputStream aBoxOut = new FileOutputStream(aBoxPath); + FileOutputStream aBoxOut = new FileOutputStream(aBoxPath); manager.saveOntology(aBox, aBoxOut); aBoxOut.close(); - + restOntology = manager.createOntology(); } catch (OWLOntologyCreationException e) { @@ -103,11 +108,11 @@ public class RLPlusOntology implements KnowledgeBase { } public OWLOntology getTBox() { - return tBox; + return tBox; } public String getABoxPath() { - return aBoxPath; + return aBoxPath; } private void add2SubCounter(OWLClassExpression exp) { @@ -118,24 +123,23 @@ public class RLPlusOntology implements KnowledgeBase { } public void simplify() { - if (simplifyABox()) { + if(simplifyABox()) { save(aBox); // save(tBox); - } - else - tBox = inputOntology; + } else + tBox = inputOntology; } - + @Override public void transform() { simplify(); filter(); clausify(); - + subCounter = new HashMap(); clauses = new LinkedList(); - Clausifier clausifier = Clausifier.getInstance(restOntology); - + Clausifier clausifier = Clausifier.getInstance(restOntology); + for (DLClause c: dlOntology.getDLClauses()) { Clause clause = new Clause(clausifier, c); clauses.add(clause); @@ -144,7 +148,7 @@ public class RLPlusOntology implements KnowledgeBase { * count the expressions in the left */ for (OWLClassExpression exp: clause.getSubClasses()) { - if (exp instanceof OWLClass) + if(exp instanceof OWLClass) add2SubCounter(exp); else if (exp instanceof OWLObjectSomeValuesFrom) { OWLObjectSomeValuesFrom someValue = (OWLObjectSomeValuesFrom)exp; @@ -155,8 +159,7 @@ public class RLPlusOntology implements KnowledgeBase { OWLObjectMinCardinality minCard = (OWLObjectMinCardinality)exp; add2SubCounter(factory.getOWLObjectSomeValuesFrom(minCard.getProperty(), factory.getOWLThing())); add2SubCounter(minCard.getFiller()); - } - else + } else Utility.logError("strange class expression: " + exp); } @@ -170,12 +173,12 @@ public class RLPlusOntology implements KnowledgeBase { addedAxioms.clear(); for (OWLClassExpression exp: getDisjunctionApprox0(clause.getSuperClasses())) { addedAxioms.add(factory.getOWLSubClassOfAxiom(subExp, transform(exp, addedAxioms))); - for (OWLAxiom a: addedAxioms) - addAxiom2output(a, factory.getOWLSubClassOfAxiom(subExp, + for(OWLAxiom a : addedAxioms) + addAxiom2output(a, factory.getOWLSubClassOfAxiom(subExp, OWLHelper.getSimplifiedDisjunction(factory, clause.getSuperClasses()))); } } - + subCounter.clear(); } @@ -185,7 +188,7 @@ public class RLPlusOntology implements KnowledgeBase { save(correspondence, corrFileName); save(outputOntology); } - + private void save(Map map, String corrFileName) { if (corrFileName == null) return ; ObjectOutput output; @@ -205,63 +208,61 @@ public class RLPlusOntology implements KnowledgeBase { e.printStackTrace(); } } - + /* * treat disjunction as conjunction */ private Set getDisjunctionApprox0(Set superClasses) { return superClasses; } - + /* * choose one simple class disjunct */ @SuppressWarnings("unused") private Set getDisjunctionApprox1(Set superClasses) { - if (superClasses.isEmpty() || superClasses.size() == 1) + if(superClasses.isEmpty() || superClasses.size() == 1) return superClasses; - + OWLClassExpression rep = null; int min = Integer.MAX_VALUE, o; - for (OWLClassExpression exp: superClasses) - if (exp instanceof OWLClass && (o = getOccurrence(exp)) < min) { + for(OWLClassExpression exp : superClasses) + if(exp instanceof OWLClass && (o = getOccurrence(exp)) < min) { min = o; rep = exp; } - - if (rep == null) rep = superClasses.iterator().next(); - + + if(rep == null) rep = superClasses.iterator().next(); + return Collections.singleton(rep); } - - Random random = new Random(19900114); + /* * randomly choose a class expression to represent this disjunction */ @SuppressWarnings("unused") private Set getDisjunctionApprox2(Set superClasses) { - if (superClasses.isEmpty() || superClasses.size() == 1) + if(superClasses.isEmpty() || superClasses.size() == 1) return superClasses; - + int index = random.nextInt() % superClasses.size(); if (index < 0) index += superClasses.size(); - + int i = 0; - for (OWLClassExpression exp: superClasses) + for(OWLClassExpression exp : superClasses) if (i++ == index) return Collections.singleton(exp); return null; } - private Map subCounter = null; /* * choose the one that appears least in the l.h.s. */ @SuppressWarnings("unused") private Set getDisjunctionApprox3(Set superClasses) { - if (superClasses.isEmpty() || superClasses.size() == 1) + if(superClasses.isEmpty() || superClasses.size() == 1) return superClasses; - + OWLClassExpression rep = null, exp1; int occurrence = Integer.MAX_VALUE, o; for (OWLClassExpression exp: superClasses) { @@ -272,16 +273,16 @@ public class RLPlusOntology implements KnowledgeBase { if (minCard.getCardinality() == 1) exp1 = factory.getOWLObjectSomeValuesFrom(minCard.getProperty(), minCard.getFiller()); } - + if (!subCounter.containsKey(exp1) || (o = subCounter.get(exp1)) < occurrence) { rep = exp; occurrence = o; } } - + return Collections.singleton(rep); } - + private int getOccurrence(OWLClassExpression exp) { if (!subCounter.containsKey(exp)) return 0; @@ -290,9 +291,9 @@ public class RLPlusOntology implements KnowledgeBase { @SuppressWarnings("unused") private Set getDisjunctionApprox4(Set superClasses) { - if (superClasses.isEmpty() || superClasses.size() == 1) + if(superClasses.isEmpty() || superClasses.size() == 1) return superClasses; - + OWLClassExpression rep = null; int occurrence = Integer.MAX_VALUE, o; for (OWLClassExpression exp: superClasses) { @@ -304,10 +305,9 @@ public class RLPlusOntology implements KnowledgeBase { o += getOccurrence(minCard.getFiller()); // if (o < o1) o = o1; } - } - else + } else o = getOccurrence(exp); - + if (o < occurrence || o == occurrence && !(rep instanceof OWLClass)) { rep = exp; occurrence = o; @@ -320,11 +320,11 @@ public class RLPlusOntology implements KnowledgeBase { private boolean simplifyABox() { boolean flag = false; Map complex2atomic= new HashMap(); - - OWLDatatype anyURI = factory.getOWLDatatype(IRI.create(Namespace.XSD_NS + "anyURI")); + + OWLDatatype anyURI = factory.getOWLDatatype(IRI.create(Namespace.XSD_NS + "anyURI")); OWLObjectProperty sameAs = factory.getOWLObjectProperty(IRI.create(Namespace.EQUALITY)); OWLObjectProperty differentFrom = factory.getOWLObjectProperty(IRI.create(Namespace.INEQUALITY)); - + for (OWLOntology imported: inputOntology.getImportsClosure()) for (OWLAxiom axiom: imported.getAxioms()) { if (axiom instanceof OWLClassAssertionAxiom) { @@ -334,7 +334,7 @@ public class RLPlusOntology implements KnowledgeBase { OWLClass cls; if (clsExp instanceof OWLClass) { if (((OWLClass) clsExp).toStringID().startsWith("owl:")) - manager.addAxiom(tBox, axiom); + manager.addAxiom(tBox, axiom); else manager.addAxiom(aBox, axiom); } else { @@ -343,40 +343,38 @@ public class RLPlusOntology implements KnowledgeBase { manager.addAxiom(tBox, factory.getOWLSubClassOfAxiom(cls, clsExp)); } manager.addAxiom(aBox, factory.getOWLClassAssertionAxiom(cls, assertion.getIndividual())); - } + } } else if (axiom instanceof OWLObjectPropertyAssertionAxiom || axiom instanceof OWLDataPropertyAssertionAxiom || axiom instanceof OWLAnnotationAssertionAxiom) { - if (axiom.getDataPropertiesInSignature().contains(anyURI)) continue; + if(axiom.getDataPropertiesInSignature().contains(anyURI)) continue; flag = true; manager.addAxiom(aBox, axiom); } else if (axiom instanceof OWLSameIndividualAxiom) { - OWLIndividual firstIndividual = null, previousIndividual = null, lastIndividual = null; + OWLIndividual firstIndividual = null, previousIndividual = null, lastIndividual = null; for (OWLIndividual next: ((OWLSameIndividualAxiom) axiom).getIndividuals()) { - if (firstIndividual == null) firstIndividual = previousIndividual = next; - else + if(firstIndividual == null) firstIndividual = previousIndividual = next; + else manager.addAxiom(aBox, factory.getOWLObjectPropertyAssertionAxiom(sameAs, previousIndividual, next)); previousIndividual = lastIndividual = next; } manager.addAxiom(aBox, factory.getOWLObjectPropertyAssertionAxiom(sameAs, lastIndividual, firstIndividual)); } else if (axiom instanceof OWLDifferentIndividualsAxiom) { - int index1 = 0, index2; + int index1 = 0, index2; for (OWLIndividual individual1: ((OWLDifferentIndividualsAxiom) axiom).getIndividuals()) { ++index1; - index2 = 0; + index2 = 0; for (OWLIndividual individual2: ((OWLDifferentIndividualsAxiom) axiom).getIndividuals()) { if (index2++ < index1) { - manager.addAxiom(aBox, factory.getOWLObjectPropertyAssertionAxiom(differentFrom, individual1, individual2)); - } - else break; + manager.addAxiom(aBox, factory.getOWLObjectPropertyAssertionAxiom(differentFrom, individual1, individual2)); + } else break; } } - } - else + } else manager.addAxiom(tBox, axiom); } - + return flag; } @@ -384,15 +382,15 @@ public class RLPlusOntology implements KnowledgeBase { OWL2RLProfile profile = new OWL2RLProfile(); OWLProfileReport report = profile.checkOntology(tBox); Set rlAxioms = tBox.getAxioms(); - OWLAxiom axiom; - + OWLAxiom axiom; + for (OWLProfileViolation violation: report.getViolations()) { manager.addAxiom(restOntology, axiom = violation.getAxiom()); - rlAxioms.remove(axiom); + rlAxioms.remove(axiom); } - + for (Iterator iter = rlAxioms.iterator(); iter.hasNext(); ) - addAxiom2output(iter.next(), null); + addAxiom2output(iter.next(), null); } private void clausify() { @@ -407,8 +405,6 @@ public class RLPlusOntology implements KnowledgeBase { if (correspondingAxiom != null) correspondence.put(axiom, correspondingAxiom); } - - private Map atomic2negation = new HashMap(); private OWLClassExpression transform(OWLClassExpression exp, Set addedAxioms) { if (exp instanceof OWLClass) diff --git a/src/uk/ac/ox/cs/pagoda/query/QueryRecord.java b/src/uk/ac/ox/cs/pagoda/query/QueryRecord.java index 8b73abb..fd20af1 100644 --- a/src/uk/ac/ox/cs/pagoda/query/QueryRecord.java +++ b/src/uk/ac/ox/cs/pagoda/query/QueryRecord.java @@ -77,7 +77,7 @@ public class QueryRecord { } public AnswerTuples getAnswers() { - if(processed()) + if(isProcessed()) return getLowerBoundAnswers(); return getUpperBoundAnswers(); @@ -155,7 +155,8 @@ public class QueryRecord { HashSet difference = new HashSet<>(soundAnswerTuples); difference.removeAll(namedAnswerTuples); if(!difference.isEmpty()) - throw new IllegalArgumentException("The upper bound does not contain the lower bound!"); + throw new IllegalArgumentException("The upper bound does not contain the lower bound! Missing answers: " + difference + .size()); } /*** END: debugging ***/ @@ -192,7 +193,7 @@ public class QueryRecord { processed = true; } - public boolean processed() { + public boolean isProcessed() { if(gapAnswerTuples != null && gapAnswerTuples.isEmpty()) processed = true; return processed; } @@ -228,7 +229,7 @@ public class QueryRecord { public void outputAnswers(BufferedWriter writer) throws IOException { int answerCounter = soundAnswerTuples.size(); - if(!processed()) answerCounter += gapAnswerTuples.size(); + if(!isProcessed()) answerCounter += gapAnswerTuples.size(); Utility.logInfo("The number of answer tuples: " + answerCounter); @@ -254,7 +255,7 @@ public class QueryRecord { writer.write(tuple.toString()); writer.newLine(); } - if (!processed()) + if(!isProcessed()) for (AnswerTuple tuple: gapAnswerTuples) { writer.write("*"); writer.write(tuple.toString()); @@ -269,7 +270,7 @@ public class QueryRecord { public void outputAnswerStatistics() { int answerCounter = soundAnswerTuples.size(); - if (!processed()) answerCounter += gapAnswerTuples.size(); + if(!isProcessed()) answerCounter += gapAnswerTuples.size(); Utility.logInfo("The number of answer tuples: " + answerCounter); // if (jsonAnswers != null) { diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/ConsistencyManager.java b/src/uk/ac/ox/cs/pagoda/reasoner/ConsistencyManager.java index 409a2c9..ef9338a 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/ConsistencyManager.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/ConsistencyManager.java @@ -30,43 +30,42 @@ public class ConsistencyManager { protected MyQueryReasoner m_reasoner; protected QueryManager m_queryManager; - Timer t = new Timer(); + Timer t = new Timer(); + QueryRecord fullQueryRecord; + QueryRecord[] botQueryRecords; + LinkedList toAddClauses; + boolean fragmentExtracted = false; public ConsistencyManager(MyQueryReasoner reasoner) { - m_reasoner = reasoner; - m_queryManager = reasoner.getQueryManager(); + m_reasoner = reasoner; + m_queryManager = reasoner.getQueryManager(); } - QueryRecord fullQueryRecord; - QueryRecord[] botQueryRecords; - - LinkedList toAddClauses; - boolean checkRLLowerBound() { fullQueryRecord = m_queryManager.create(QueryRecord.botQueryText, 0); - AnswerTuples iter = null; - + AnswerTuples iter = null; + try { iter = m_reasoner.rlLowerStore.evaluate(fullQueryRecord.getQueryText(), fullQueryRecord.getAnswerVariables()); fullQueryRecord.updateLowerBoundAnswers(iter); } finally { iter.dispose(); } - + if (fullQueryRecord.getNoOfSoundAnswers() > 0) { - Utility.logInfo("Answers to bottom in the lower bound: ", fullQueryRecord.outputSoundAnswerTuple()); + Utility.logInfo("Answers to bottom in the lower bound: ", fullQueryRecord.outputSoundAnswerTuple()); return false; } - return true; + return true; } - + boolean checkELLowerBound() { fullQueryRecord.updateLowerBoundAnswers(m_reasoner.elLowerStore.evaluate(fullQueryRecord.getQueryText(), fullQueryRecord.getAnswerVariables())); if (fullQueryRecord.getNoOfSoundAnswers() > 0) { - Utility.logInfo("Answers to bottom in the lower bound: ", fullQueryRecord.outputSoundAnswerTuple()); + Utility.logInfo("Answers to bottom in the lower bound: ", fullQueryRecord.outputSoundAnswerTuple()); return true; } - return true; + return true; } boolean checkUpper(BasicQueryEngine upperStore) { @@ -91,65 +90,64 @@ public class ConsistencyManager { fullQueryRecord.dispose(); } +// protected boolean unsatisfiability(double duration) { +// fullQueryRecord.dispose(); +// Utility.logDebug("The ontology and dataset is unsatisfiable."); +// return false; +// } + +// protected boolean satisfiability(double duration) { +// fullQueryRecord.dispose(); +// Utility.logDebug("The ontology and dataset is satisfiable."); +// return true; +// } + boolean check() { -// if (!checkRLLowerBound()) return false; -// if (!checkELLowerBound()) return false; -// if (checkLazyUpper()) return true; - AnswerTuples iter = null; - +// if (!checkRLLowerBound()) return false; +// if (!checkELLowerBound()) return false; +// if (checkLazyUpper()) return true; + AnswerTuples iter = null; + try { - iter = m_reasoner.trackingStore.evaluate(fullQueryRecord.getQueryText(), fullQueryRecord.getAnswerVariables()); + iter = + m_reasoner.trackingStore.evaluate(fullQueryRecord.getQueryText(), fullQueryRecord.getAnswerVariables()); fullQueryRecord.updateUpperBoundAnswers(iter); } finally { - if (iter != null) iter.dispose(); + if(iter != null) iter.dispose(); } - - if (fullQueryRecord.getNoOfCompleteAnswers() == 0) + + if(fullQueryRecord.getNoOfCompleteAnswers() == 0) return true; - + extractBottomFragment(); - + try { extractAxioms4Full(); - } catch (OWLOntologyCreationException e) { + } catch(OWLOntologyCreationException e) { e.printStackTrace(); } // fullQueryRecord.saveRelevantClause(); - - boolean satisfiability; - - Checker checker; - for (QueryRecord r: getQueryRecords()) { - // TODO to be removed ... + + boolean satisfiability; + + Checker checker; + for(QueryRecord r : getQueryRecords()) { + // TODO to be removed ... // r.saveRelevantOntology("bottom" + r.getQueryID() + ".owl"); checker = new HermitSummaryFilter(r, true); // m_reasoner.factory.getSummarisedReasoner(r); - satisfiability = checker.isConsistent(); + satisfiability = checker.isConsistent(); checker.dispose(); - if (!satisfiability) return false; + if(!satisfiability) return false; } - -// Checker checker = m_reasoner.factory.getSummarisedReasoner(fullQueryRecord); -// boolean satisfiable = checker.isConsistent(); + +// Checker checker = m_reasoner.factory.getSummarisedReasoner(fullQueryRecord); +// boolean satisfiable = checker.isConsistent(); // checker.dispose(); -// if (!satisfiable) return unsatisfiability(t.duration()); - +// if (!satisfiable) return unsatisfiability(t.duration()); + return true; } -// protected boolean unsatisfiability(double duration) { -// fullQueryRecord.dispose(); -// Utility.logDebug("The ontology and dataset is unsatisfiable."); -// return false; -// } - -// protected boolean satisfiability(double duration) { -// fullQueryRecord.dispose(); -// Utility.logDebug("The ontology and dataset is satisfiable."); -// return true; -// } - - boolean fragmentExtracted = false; - public void extractBottomFragment() { if (fragmentExtracted) return ; fragmentExtracted = true; @@ -179,7 +177,7 @@ public class ConsistencyManager { int[] group = new int[number - 1]; for (int i = 0; i < number - 1; ++i) group[i] = i; for (int i = 0; i < number - 1; ++i) - if (tempQueryRecords[i].processed()) tempQueryRecords[i].dispose(); + if(tempQueryRecords[i].isProcessed()) tempQueryRecords[i].dispose(); else if (group[i] == i) { ++bottomNumber; record = tempQueryRecords[i]; @@ -193,8 +191,8 @@ public class ConsistencyManager { int bottomCounter = 0; botQueryRecords = new QueryRecord[bottomNumber]; Variable X = Variable.create("X"); - for (int i = 0; i < number - 1; ++i) - if (!tempQueryRecords[i].processed()) + for (int i = 0; i < number - 1; ++i) + if(!tempQueryRecords[i].isProcessed()) if (group[i] == i) { botQueryRecords[bottomCounter] = record = tempQueryRecords[i]; record.resetInfo(QueryRecord.botQueryText.replace("Nothing", "Nothing_final" + (++bottomCounter)), 0, group[i] = bottomCounter); diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/ELHOUQueryReasoner.java b/src/uk/ac/ox/cs/pagoda/reasoner/ELHOUQueryReasoner.java index 34742c8..c74ea58 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/ELHOUQueryReasoner.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/ELHOUQueryReasoner.java @@ -68,7 +68,7 @@ class ELHOUQueryReasoner extends QueryReasoner { } queryRecord.addProcessingTime(Step.UPPER_BOUND, t.duration()); - if (queryRecord.processed()) { + if(queryRecord.isProcessed()) { queryRecord.setDifficulty(Step.UPPER_BOUND); return; } diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/IterativeRefinement.java b/src/uk/ac/ox/cs/pagoda/reasoner/IterativeRefinement.java index 447a92d..7847e7c 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/IterativeRefinement.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/IterativeRefinement.java @@ -1,9 +1,6 @@ package uk.ac.ox.cs.pagoda.reasoner; -import java.io.File; - import org.semanticweb.owlapi.model.OWLOntology; - import uk.ac.ox.cs.pagoda.constraints.BottomStrategy; import uk.ac.ox.cs.pagoda.constraints.UpperUnaryBottom; import uk.ac.ox.cs.pagoda.multistage.MultiStageQueryEngine; @@ -14,6 +11,8 @@ import uk.ac.ox.cs.pagoda.rules.GeneralProgram; import uk.ac.ox.cs.pagoda.tracking.QueryTracker; import uk.ac.ox.cs.pagoda.util.Utility; +import java.io.File; + public class IterativeRefinement { private static final int depthLimit = 1; @@ -23,16 +22,15 @@ public class IterativeRefinement { BasicQueryEngine m_trackingStore; QueryRecord[] botQueryRecords; - int m_depth = 0; - + int m_depth = 0; + String tempDataFile = "temp.ttl"; + public IterativeRefinement(QueryRecord queryRecord, QueryTracker tracker, BasicQueryEngine trackingStore, QueryRecord[] botQueryRecords) { - m_record = queryRecord; - m_tracker = tracker; + m_record = queryRecord; + m_tracker = tracker; m_trackingStore = trackingStore; - this.botQueryRecords = botQueryRecords; + this.botQueryRecords = botQueryRecords; } - - String tempDataFile = "temp.ttl"; public OWLOntology extractWithFullABox(String dataset, BottomStrategy upperBottom) { GeneralProgram program; @@ -58,8 +56,8 @@ public class IterativeRefinement { } finally { tEngine.dispose(); } - - if (m_record.processed()) + + if(m_record.isProcessed()) return null; if (!update) break; @@ -95,8 +93,8 @@ public class IterativeRefinement { } finally { tEngine.dispose(); } - - if (m_record.processed()) + + if(m_record.isProcessed()) return null; if (!update) break; diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java b/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java index cc0e647..b5b9534 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java @@ -23,7 +23,6 @@ import uk.ac.ox.cs.pagoda.util.Utility; import uk.ac.ox.cs.pagoda.util.tuples.Tuple; import java.util.Collection; -import java.util.HashMap; class MyQueryReasoner extends QueryReasoner { @@ -33,7 +32,7 @@ class MyQueryReasoner extends QueryReasoner { // String additonalDataFile; BasicQueryEngine rlLowerStore = null; BasicQueryEngine lazyUpperStore = null; - BasicQueryEngine limitedSkolemUpperStore; + // BasicQueryEngine limitedSkolemUpperStore; OWLOntology elho_ontology; // boolean[] namedIndividuals_lazyUpper; KarmaQueryEngine elLowerStore = null; @@ -99,7 +98,7 @@ class MyQueryReasoner extends QueryReasoner { useUpperStores = multiStageTag && !program.getGeneral().isHorn(); if(useUpperStores) { lazyUpperStore = getUpperStore("lazy-upper-bound", true); - limitedSkolemUpperStore = getUpperStore("limited-skolem-upper-bound", true); +// limitedSkolemUpperStore = getUpperStore("limited-skolem-upper-bound", true); } importData(program.getAdditionalDataFile()); @@ -147,20 +146,20 @@ class MyQueryReasoner extends QueryReasoner { Utility.logInfo("time for satisfiability checking: " + t.duration()); } - if(limitedSkolemUpperStore != null) { - limitedSkolemUpperStore.importRDFData(name, datafile); - limitedSkolemUpperStore.materialise("saturate named individuals", originalMarkProgram); - int tag = limitedSkolemUpperStore.materialiseSkolemly(program, null); - if(tag != 1) { - limitedSkolemUpperStore.dispose(); - limitedSkolemUpperStore = null; - } - if(tag == -1) return false; - } - if(satisfiable == SatisfiabilityStatus.UNCHECKED && consistency.checkUpper(limitedSkolemUpperStore)) { - satisfiable = SatisfiabilityStatus.SATISFIABLE; - Utility.logInfo("time for satisfiability checking: " + t.duration()); - } +// if(limitedSkolemUpperStore != null) { +// limitedSkolemUpperStore.importRDFData(name, datafile); +// limitedSkolemUpperStore.materialise("saturate named individuals", originalMarkProgram); +// int tag = limitedSkolemUpperStore.materialiseSkolemly(program, null); +// if(tag != 1) { +// limitedSkolemUpperStore.dispose(); +// limitedSkolemUpperStore = null; +// } +// if(tag == -1) return false; +// } +// if(satisfiable == SatisfiabilityStatus.UNCHECKED && consistency.checkUpper(limitedSkolemUpperStore)) { +// satisfiable = SatisfiabilityStatus.SATISFIABLE; +// Utility.logInfo("time for satisfiability checking: " + t.duration()); +// } trackingStore.importRDFData(name, datafile); trackingStore.materialise("saturate named individuals", originalMarkProgram); @@ -214,7 +213,7 @@ class MyQueryReasoner extends QueryReasoner { queryUpperBound(upperStore, queryRecord, queryRecord.getQueryText(), queryRecord.getAnswerVariables()); queryRecord.addProcessingTime(step, t.duration()); - if(queryRecord.processed()) { + if(queryRecord.isProcessed()) { queryRecord.setDifficulty(step); return true; } @@ -224,7 +223,7 @@ class MyQueryReasoner extends QueryReasoner { /** * Returns the part of the ontology relevant for Hermit, while computing the bound answers. * */ - private OWLOntology relevantPart(QueryRecord queryRecord) { + private boolean queryBounds(QueryRecord queryRecord) { AnswerTuples rlAnswer = null, elAnswer = null; t.reset(); @@ -243,15 +242,15 @@ class MyQueryReasoner extends QueryReasoner { Utility.logDebug("Tracking store"); if(queryUpperStore(trackingStore, queryRecord, extendedQueryTexts, Step.SIMPLE_UPPER_BOUND)) - return null; + return true; if(!queryRecord.isBottom()) { Utility.logDebug("Lazy store"); if(lazyUpperStore != null && queryUpperStore(lazyUpperStore, queryRecord, extendedQueryTexts, Step.LAZY_UPPER_BOUND)) - return null; - Utility.logDebug("Skolem store"); - if(limitedSkolemUpperStore != null && queryUpperStore(limitedSkolemUpperStore, queryRecord, extendedQueryTexts, Step.L_SKOLEM_UPPER_BOUND)) - return null; + return true; +// Utility.logDebug("Skolem store"); +// if(limitedSkolemUpperStore != null && queryUpperStore(limitedSkolemUpperStore, queryRecord, extendedQueryTexts, Step.L_SKOLEM_UPPER_BOUND)) +// return null; } t.reset(); @@ -266,52 +265,23 @@ class MyQueryReasoner extends QueryReasoner { } queryRecord.addProcessingTime(Step.EL_LOWER_BOUND, t.duration()); - if (queryRecord.processed()) { + if(queryRecord.isProcessed()) { queryRecord.setDifficulty(Step.EL_LOWER_BOUND); - return null; + return true; } + return false; + } + + private OWLOntology extractRelevantOntologySubset(QueryRecord queryRecord) { t.reset(); QueryTracker tracker = new QueryTracker(encoder, rlLowerStore, queryRecord); + OWLOntology relevantOntologySubset = tracker.extract(trackingStore, consistency.getQueryRecords(), true); - OWLOntology knowledgeBase; - t.reset(); -// if (program.getGeneral().isHorn()) { -// knowledgebase = tracker.extract(lazyUpperStore, consistency.getQueryRecords(), true); -// queryRecord.addProcessingTime(Step.Fragment, t.duration()); -// return knowledgebase; -// } -// else { - knowledgeBase = tracker.extract(trackingStore, consistency.getQueryRecords(), true); queryRecord.addProcessingTime(Step.FRAGMENT, t.duration()); -// } - - if(knowledgeBase.isEmpty() || queryRecord.isBottom()) - return knowledgeBase; - - if(program.getGeneral().isHorn()) return knowledgeBase; -// t.reset(); -// if (queryRecord.isHorn() && lazyUpperStore != null) { -//// knowledgebase = tracker.extract(lazyUpperStore, consistency.getQueryRecords(), true); -// } else if (queryRecord.getArity() < 3) { -// IterativeRefinement iterativeRefinement = new IterativeRefinement(queryRecord, tracker, trackingStore, consistency.getQueryRecords()); -// knowledgebase = iterativeRefinement.extractWithFullABox(importedData.toString(), program.getUpperBottomStrategy()); -// } -// -// queryRecord.addProcessingTime(Step.FRAGMENT_REFINEMENT, t.duration()); -// -// if (knowledgebase == null) -// queryRecord.setDifficulty(Step.FRAGMENT_REFINEMENT); - - return knowledgeBase; - } - - private String toJsonKeyValuePair(String key, Object value) { - HashMap map = new HashMap<>(); - map.put(key, value); - return QueryRecord.GsonCreator.getInstance().toJson(map); + return relevantOntologySubset; } private void queryUpperBound(BasicQueryEngine upperStore, QueryRecord queryRecord, String queryText, String[] answerVariables) { @@ -323,35 +293,59 @@ class MyQueryReasoner extends QueryReasoner { queryRecord.updateUpperBoundAnswers(rlAnswer); } finally { if(rlAnswer != null) rlAnswer.dispose(); - rlAnswer = null; } } -// int counter = 0; - @Override public void evaluate(QueryRecord queryRecord) { - OWLOntology knowledgeBase = relevantPart(queryRecord); - - if(knowledgeBase == null) { - Utility.logDebug("Difficulty of this query: " + queryRecord.getDifficulty()); + if(queryBounds(queryRecord)) return; - } - int aBoxCount = knowledgeBase.getABoxAxioms(true).size(); - Utility.logDebug("ABox axioms: " + aBoxCount + " TBox axioms: " + (knowledgeBase.getAxiomCount() - aBoxCount)); + OWLOntology relevantOntologySubset = extractRelevantOntologySubset(queryRecord); + + int aBoxCount = relevantOntologySubset.getABoxAxioms(true).size(); + Utility.logInfo("Relevant ontology subset: ABox_axioms=" + aBoxCount + " TBox_axioms=" + (relevantOntologySubset + .getAxiomCount() - aBoxCount)); // queryRecord.saveRelevantOntology("fragment_query" + queryRecord.getQueryID() + ".owl"); + if(querySkolemisedRelevantSubset(relevantOntologySubset, queryRecord)) + return; + Timer t = new Timer(); Checker summarisedChecker = new HermitSummaryFilter(queryRecord, properties.getToCallHermiT()); -// int validNumber = summarisedChecker.check(queryRecord.getGapAnswers()); summarisedChecker.dispose(); Utility.logDebug("Total time for full reasoner: " + t.duration()); -// if (validNumber == 0) { queryRecord.markAsProcessed(); Utility.logDebug("Difficulty of this query: " + queryRecord.getDifficulty()); -// } + } + + private boolean querySkolemisedRelevantSubset(OWLOntology relevantSubset, QueryRecord queryRecord) { + MultiStageQueryEngine relevantStore = + new MultiStageQueryEngine("Relevant-store", true); // checkValidity is true + DatalogProgram relevantProgram = new DatalogProgram(relevantSubset, false); // toClassify is false + +// relevantStore.importRDFData("data", importedData.toString()); // 2 answers more + relevantStore.importDataFromABoxOf(relevantSubset); + + int materialisationResult = relevantStore.materialiseSkolemly(relevantProgram, null); + if(materialisationResult != 1) + throw new RuntimeException("Skolemised materialisation error"); // TODO check consistency +// relevantStore.materialiseRestrictedly(relevantProgram, null); // it has been tried + + return queryUpperStore(relevantStore, queryRecord, queryRecord.getExtendedQueryText(), Step.L_SKOLEM_UPPER_BOUND); + + // the following has been tried +// Tuple extendedQueryText = queryRecord.getExtendedQueryText(); +// if(queryRecord.hasNonAnsDistinguishedVariables()) { +// queryUpperBound(relevantStore, queryRecord, extendedQueryText.get(0), queryRecord.getAnswerVariables()); +// queryUpperBound(relevantStore, queryRecord, extendedQueryText.get(1), queryRecord.getDistinguishedVariables()); +// } +// else +// queryUpperBound(relevantStore, queryRecord, queryRecord.getQueryText(), queryRecord.getAnswerVariables()); +// +// return queryRecord.isProcessed(); + } @Override @@ -375,7 +369,8 @@ class MyQueryReasoner extends QueryReasoner { if (lazyUpperStore != null) lazyUpperStore.dispose(); if (elLowerStore != null) elLowerStore.dispose(); if (trackingStore != null) trackingStore.dispose(); - if(limitedSkolemUpperStore != null) limitedSkolemUpperStore.dispose(); + +// if(limitedSkolemUpperStore != null) limitedSkolemUpperStore.dispose(); super.dispose(); } diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/QueryReasoner.java b/src/uk/ac/ox/cs/pagoda/reasoner/QueryReasoner.java index 64945e8..118c1b2 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/QueryReasoner.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/QueryReasoner.java @@ -147,7 +147,7 @@ PagodaProperties properties; if (forFacetGeneration) { QueryRecord record = m_queryManager.create(queryText); Utility.logInfo("---------- start evaluating upper bound for Query " + record.getQueryID() + " ----------", queryText); - if(!record.processed()) + if(!record.isProcessed()) evaluateUpper(record); // AnswerTuples tuples = record.getUpperBoundAnswers(); // for (AnswerTuple tuple; tuples.isValid(); tuples.moveNext()) { @@ -167,7 +167,7 @@ PagodaProperties properties; public AnswerTuples evaluate(String queryText) { QueryRecord record = m_queryManager.create(queryText); Utility.logInfo("---------- start evaluating Query " + record.getQueryID() + " ----------", queryText); - if(!record.processed()) + if(!record.isProcessed()) evaluate(record); AnswerTuples answer = record.getAnswers(); record.dispose(); @@ -178,7 +178,7 @@ PagodaProperties properties; public void evaluate_shell(String queryText) { QueryRecord record = m_queryManager.create(queryText); Utility.logInfo("---------- start evaluating Query " + record.getQueryID() + " ----------", queryText); - if(!record.processed()) + if(!record.isProcessed()) evaluate(record); Utility.logInfo("Answers to this query: ", record.outputSoundAnswerTuple()); record.dispose(); @@ -206,12 +206,12 @@ PagodaProperties properties; // if (Integer.parseInt(record.getQueryID()) != 218) continue; Utility.logInfo("---------- start evaluating Query " + record.getQueryID() + " ----------", record.getQueryText()); - if (!record.processed()) { + if(!record.isProcessed()) { t.reset(); - if (!record.processed()) + if(!record.isProcessed()) evaluate(record); Utility.logInfo("Total time to answer this query: " + t.duration()); - if (!fullReasoner && !record.processed()) { + if(!fullReasoner && !record.isProcessed()) { Utility.logInfo("The query has not been fully answered in " + t.duration() + " seconds."); continue; } diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/RLUQueryReasoner.java b/src/uk/ac/ox/cs/pagoda/reasoner/RLUQueryReasoner.java index bdef436..547140a 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/RLUQueryReasoner.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/RLUQueryReasoner.java @@ -53,8 +53,8 @@ class RLUQueryReasoner extends QueryReasoner { if (ans != null) ans.dispose(); } queryRecord.addProcessingTime(Step.UPPER_BOUND, t.duration()); - - if (queryRecord.processed()) + + if(queryRecord.isProcessed()) queryRecord.setDifficulty(Step.UPPER_BOUND); } diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/light/RDFoxQueryEngine.java b/src/uk/ac/ox/cs/pagoda/reasoner/light/RDFoxQueryEngine.java index 63773d9..61500f5 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/light/RDFoxQueryEngine.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/light/RDFoxQueryEngine.java @@ -1,5 +1,7 @@ package uk.ac.ox.cs.pagoda.reasoner.light; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; import uk.ac.ox.cs.JRDFox.JRDFStoreException; import uk.ac.ox.cs.JRDFox.Prefixes; import uk.ac.ox.cs.JRDFox.store.DataStore; @@ -18,32 +20,44 @@ import java.util.Collection; public abstract class RDFoxQueryEngine implements QueryEngine { public static final int matNoOfThreads = Runtime.getRuntime().availableProcessors() * 2; - - public String getName() { - return name; - } - protected String name; protected Prefixes prefixes = MyPrefixes.PAGOdAPrefixes.getRDFoxPrefixes(); public RDFoxQueryEngine(String name) { - this.name = name; - } - - public abstract DataStore getDataStore(); + this.name = name; + } + + public static DataStore createDataStore() { + DataStore instance = null; + try { +// instance = new DataStore("par-head-n"); + instance = new DataStore(StoreType.NarrowParallelHead); + instance.setNumberOfThreads(matNoOfThreads); + instance.initialize(); + } catch(JRDFStoreException e) { + e.printStackTrace(); + } + return instance; + } - public abstract void dispose(); + public String getName() { + return name; + } + public abstract DataStore getDataStore(); + + public abstract void dispose(); + public void importRDFData(String fileName, String importedFile) { - if (importedFile == null || importedFile.isEmpty()) return ; - Timer t = new Timer(); - DataStore store = getDataStore(); + if(importedFile == null || importedFile.isEmpty()) return; + Timer t = new Timer(); + DataStore store = getDataStore(); try { long oldTripleCount = store.getTriplesCount(), tripleCount; for (String file: importedFile.split(QueryReasoner.ImportDataFileSeparator)) { store.importTurtleFile(new File(file), prefixes); } - tripleCount = store.getTriplesCount(); + tripleCount = store.getTriplesCount(); Utility.logDebug(name + " store after importing " + fileName + ": " + tripleCount + " (" + (tripleCount - oldTripleCount) + " new)"); store.clearRulesAndMakeFactsExplicit(); } catch (JRDFStoreException e) { @@ -51,17 +65,32 @@ public abstract class RDFoxQueryEngine implements QueryEngine { } Utility.logDebug(name + " store finished importing " + fileName + " in " + t.duration() + " seconds."); } - + + public void importDataFromABoxOf(OWLOntology ontology) { + DataStore store = getDataStore(); + try { + long prevTriplesCount = store.getTriplesCount(); + store.importOntology(ontology.getOWLOntologyManager().createOntology(ontology.getABoxAxioms(true))); + long loadedTriples = store.getTriplesCount() - prevTriplesCount; + Utility.logInfo(name + ": loaded " + loadedTriples + " triples from " + ontology.getABoxAxioms(true) + .size() + " ABox axioms"); + } catch(JRDFStoreException | OWLOntologyCreationException e) { + e.printStackTrace(); + System.exit(1); + } + + } + public void materialise(String programName, String programText) { - if (programText == null) return ; + if(programText == null) return; Timer t = new Timer(); - DataStore store = getDataStore(); + DataStore store = getDataStore(); try { long oldTripleCount = store.getTriplesCount(), tripleCount; // store.addRules(new String[] {programText}); store.importRules(programText); store.applyReasoning(); - tripleCount = store.getTriplesCount(); + tripleCount = store.getTriplesCount(); Utility.logDebug(name + " store after materialising " + programName + ": " + tripleCount + " (" + (tripleCount - oldTripleCount) + " new)"); store.clearRulesAndMakeFactsExplicit(); } catch (JRDFStoreException e) { @@ -74,17 +103,17 @@ public abstract class RDFoxQueryEngine implements QueryEngine { public void evaluate(Collection queryTexts, String answerFile) { if (queryTexts == null) return ; - - int queryID = 0; - AnswerTuplesWriter answerWriter = new AnswerTuplesWriter(answerFile); + + int queryID = 0; + AnswerTuplesWriter answerWriter = new AnswerTuplesWriter(answerFile); AnswerTuples answerTuples; - Timer t = new Timer(); + Timer t = new Timer(); try { for (String query: queryTexts) { t.reset(); - answerTuples = null; + answerTuples = null; try { - answerTuples = evaluate(query); + answerTuples = evaluate(query); Utility.logDebug("time to answer Query " + ++queryID + ": " + t.duration()); answerWriter.write(answerTuples.getAnswerVariables(), answerTuples); } finally { @@ -94,22 +123,9 @@ public abstract class RDFoxQueryEngine implements QueryEngine { } finally { answerWriter.close(); } - + Utility.logDebug("done computing query answers by RDFox."); - - } - - public static DataStore createDataStore() { - DataStore instance = null; - try { -// instance = new DataStore("par-head-n"); - instance = new DataStore(StoreType.NarrowParallelHead); - instance.setNumberOfThreads(matNoOfThreads); - instance.initialize(); - } catch (JRDFStoreException e) { - e.printStackTrace(); - } - return instance; + } } diff --git a/src/uk/ac/ox/cs/pagoda/summary/HermitSummaryFilter.java b/src/uk/ac/ox/cs/pagoda/summary/HermitSummaryFilter.java index 663c716..90a2ed4 100644 --- a/src/uk/ac/ox/cs/pagoda/summary/HermitSummaryFilter.java +++ b/src/uk/ac/ox/cs/pagoda/summary/HermitSummaryFilter.java @@ -154,7 +154,7 @@ public class HermitSummaryFilter implements Checker { m_record.removeUpperBoundAnswers(falsified); - if (m_record.processed()) { + if(m_record.isProcessed()) { m_record.setDifficulty(Step.SUMMARISATION); m_record.addProcessingTime(Step.SUMMARISATION, t.duration()); return 0; diff --git a/src/uk/ac/ox/cs/pagoda/tracking/QueryTracker.java b/src/uk/ac/ox/cs/pagoda/tracking/QueryTracker.java index f836212..ee55be7 100644 --- a/src/uk/ac/ox/cs/pagoda/tracking/QueryTracker.java +++ b/src/uk/ac/ox/cs/pagoda/tracking/QueryTracker.java @@ -1,24 +1,13 @@ package uk.ac.ox.cs.pagoda.tracking; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.Set; - import org.semanticweb.HermiT.model.DLClause; -import org.semanticweb.owlapi.model.IRI; -import org.semanticweb.owlapi.model.OWLAxiom; -import org.semanticweb.owlapi.model.OWLClass; -import org.semanticweb.owlapi.model.OWLDataFactory; -import org.semanticweb.owlapi.model.OWLDataProperty; -import org.semanticweb.owlapi.model.OWLLiteral; -import org.semanticweb.owlapi.model.OWLIndividual; -import org.semanticweb.owlapi.model.OWLObject; -import org.semanticweb.owlapi.model.OWLObjectProperty; -import org.semanticweb.owlapi.model.OWLOntology; -import org.semanticweb.owlapi.model.OWLOntologyCreationException; -import org.semanticweb.owlapi.model.OWLOntologyManager; - +import org.semanticweb.owlapi.model.*; +import uk.ac.ox.cs.JRDFox.JRDFStoreException; +import uk.ac.ox.cs.JRDFox.model.Datatype; +import uk.ac.ox.cs.JRDFox.store.DataStore; +import uk.ac.ox.cs.JRDFox.store.DataStore.UpdateType; +import uk.ac.ox.cs.JRDFox.store.Resource; +import uk.ac.ox.cs.JRDFox.store.TupleIterator; import uk.ac.ox.cs.pagoda.MyPrefixes; import uk.ac.ox.cs.pagoda.hermit.DLClauseHelper; import uk.ac.ox.cs.pagoda.owl.OWLHelper; @@ -30,12 +19,11 @@ import uk.ac.ox.cs.pagoda.util.Namespace; import uk.ac.ox.cs.pagoda.util.Timer; import uk.ac.ox.cs.pagoda.util.UFS; import uk.ac.ox.cs.pagoda.util.Utility; -import uk.ac.ox.cs.JRDFox.JRDFStoreException; -import uk.ac.ox.cs.JRDFox.model.Datatype; -import uk.ac.ox.cs.JRDFox.store.DataStore; -import uk.ac.ox.cs.JRDFox.store.Resource; -import uk.ac.ox.cs.JRDFox.store.TupleIterator; -import uk.ac.ox.cs.JRDFox.store.DataStore.UpdateType; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.Set; public class QueryTracker { @@ -85,7 +73,7 @@ public class QueryTracker { store.applyReasoning(incrementally); tripleCount = store.getTriplesCount(); - Utility.logDebug("tracking store after materialising tracking program: " + Utility.logInfo("tracking store after materialising tracking program: " + tripleCount + " (" + (tripleCount - oldTripleCount) -- cgit v1.2.3