From 1b6a128137e5d7a6ff75566869232fc054afabef Mon Sep 17 00:00:00 2001 From: RncLsn Date: Fri, 15 May 2015 17:32:22 +0100 Subject: Testing and fixing. Executed successfully on UOBM{1,2,3,4,5,6,7,8}. --- .../Maven__net_sf_ehcache_ehcache_2_10_0.xml | 13 ++ config/fly.conf | 19 -- config/fly.properties | 19 ++ config/log4j.properties | 24 ++- config/lubm.conf | 20 --- config/lubm.properties | 20 +++ config/uobm.conf | 20 --- config/uobm.properties | 20 +++ pom.xml | 5 + src/uk/ac/ox/cs/pagoda/approx/RLPlusOntology.java | 61 ++----- .../pagoda/multistage/MultiStageQueryEngine.java | 4 +- src/uk/ac/ox/cs/pagoda/query/QueryRecord.java | 18 +- .../ox/cs/pagoda/reasoner/ConsistencyManager.java | 68 +++----- .../ox/cs/pagoda/reasoner/ConsistencyManager2.java | 6 +- .../ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java | 44 +++-- src/uk/ac/ox/cs/pagoda/reasoner/QueryReasoner.java | 13 +- .../cs/pagoda/reasoner/light/KarmaQueryEngine.java | 26 +-- .../cs/pagoda/reasoner/light/RDFoxQueryEngine.java | 22 ++- .../pagoda/reasoner/light/RDFoxTripleManager.java | 54 ++++-- src/uk/ac/ox/cs/pagoda/rules/Program.java | 38 +--- src/uk/ac/ox/cs/pagoda/util/Utility.java | 49 ++++-- test/AllTests.xml | 4 +- test/FullEvaluation.xml | 4 +- .../ac/ox/cs/pagoda/global_tests/ClauseTester.java | 158 +++++++++++++++++ .../ox/cs/pagoda/global_tests/CostEvaluation.java | 115 ++++++++++++ .../ac/ox/cs/pagoda/global_tests/JAIR_PAGOdA.java | 193 +++++++++++++++++++++ .../cs/pagoda/global_tests/JAIR_Scalability.java | 91 ++++++++++ .../ox/cs/pagoda/global_tests/LightEvaluation.java | 67 +++++++ .../ox/cs/pagoda/global_tests/PagodaDBPedia.java | 30 ++++ .../uk/ac/ox/cs/pagoda/global_tests/PagodaELU.java | 20 +++ .../uk/ac/ox/cs/pagoda/global_tests/PagodaFLY.java | 25 +++ .../ac/ox/cs/pagoda/global_tests/PagodaLUBM.java | 24 +++ .../uk/ac/ox/cs/pagoda/global_tests/PagodaNPD.java | 46 +++++ .../ox/cs/pagoda/global_tests/PagodaNPD_bench.java | 30 ++++ .../uk/ac/ox/cs/pagoda/global_tests/PagodaRLU.java | 20 +++ .../ac/ox/cs/pagoda/global_tests/PagodaUOBM.java | 53 ++++++ .../pagoda/global_tests/TestGlobalCorrectness.java | 53 ++++++ .../ac/ox/cs/pagoda/test_units/ClauseTester.java | 164 ----------------- .../ac/ox/cs/pagoda/test_units/CostEvaluation.java | 115 ------------ .../uk/ac/ox/cs/pagoda/test_units/JAIR_PAGOdA.java | 193 --------------------- .../ox/cs/pagoda/test_units/JAIR_Scalability.java | 91 ---------- .../ox/cs/pagoda/test_units/LightEvaluation.java | 67 ------- .../ac/ox/cs/pagoda/test_units/PagodaDBPedia.java | 30 ---- test/uk/ac/ox/cs/pagoda/test_units/PagodaELU.java | 20 --- test/uk/ac/ox/cs/pagoda/test_units/PagodaFLY.java | 25 --- test/uk/ac/ox/cs/pagoda/test_units/PagodaLUBM.java | 24 --- test/uk/ac/ox/cs/pagoda/test_units/PagodaNPD.java | 46 ----- .../ox/cs/pagoda/test_units/PagodaNPD_bench.java | 30 ---- test/uk/ac/ox/cs/pagoda/test_units/PagodaRLU.java | 20 --- test/uk/ac/ox/cs/pagoda/test_units/PagodaUOBM.java | 24 --- .../pagoda/test_units/TestGlobalCorrectness.java | 52 ------ test/uk/ac/ox/cs/pagoda/tester/PagodaTester.java | 10 +- 52 files changed, 1209 insertions(+), 1198 deletions(-) create mode 100644 .idea/libraries/Maven__net_sf_ehcache_ehcache_2_10_0.xml delete mode 100644 config/fly.conf create mode 100644 config/fly.properties delete mode 100644 config/lubm.conf create mode 100644 config/lubm.properties delete mode 100644 config/uobm.conf create mode 100644 config/uobm.properties create mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/ClauseTester.java create mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/CostEvaluation.java create mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/JAIR_PAGOdA.java create mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/JAIR_Scalability.java create mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/LightEvaluation.java create mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/PagodaDBPedia.java create mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/PagodaELU.java create mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/PagodaFLY.java create mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/PagodaLUBM.java create mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/PagodaNPD.java create mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/PagodaNPD_bench.java create mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/PagodaRLU.java create mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/PagodaUOBM.java create mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/TestGlobalCorrectness.java delete mode 100644 test/uk/ac/ox/cs/pagoda/test_units/ClauseTester.java delete mode 100644 test/uk/ac/ox/cs/pagoda/test_units/CostEvaluation.java delete mode 100644 test/uk/ac/ox/cs/pagoda/test_units/JAIR_PAGOdA.java delete mode 100644 test/uk/ac/ox/cs/pagoda/test_units/JAIR_Scalability.java delete mode 100644 test/uk/ac/ox/cs/pagoda/test_units/LightEvaluation.java delete mode 100644 test/uk/ac/ox/cs/pagoda/test_units/PagodaDBPedia.java delete mode 100644 test/uk/ac/ox/cs/pagoda/test_units/PagodaELU.java delete mode 100644 test/uk/ac/ox/cs/pagoda/test_units/PagodaFLY.java delete mode 100644 test/uk/ac/ox/cs/pagoda/test_units/PagodaLUBM.java delete mode 100644 test/uk/ac/ox/cs/pagoda/test_units/PagodaNPD.java delete mode 100644 test/uk/ac/ox/cs/pagoda/test_units/PagodaNPD_bench.java delete mode 100644 test/uk/ac/ox/cs/pagoda/test_units/PagodaRLU.java delete mode 100644 test/uk/ac/ox/cs/pagoda/test_units/PagodaUOBM.java delete mode 100644 test/uk/ac/ox/cs/pagoda/test_units/TestGlobalCorrectness.java diff --git a/.idea/libraries/Maven__net_sf_ehcache_ehcache_2_10_0.xml b/.idea/libraries/Maven__net_sf_ehcache_ehcache_2_10_0.xml new file mode 100644 index 0000000..3f89356 --- /dev/null +++ b/.idea/libraries/Maven__net_sf_ehcache_ehcache_2_10_0.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/config/fly.conf b/config/fly.conf deleted file mode 100644 index 88c85c3..0000000 --- a/config/fly.conf +++ /dev/null @@ -1,19 +0,0 @@ -#ONTOLOGY variable points to the file that stores ontology of interest -ONTOLOGY=data/fly/fly_anatomy_XP_with_GJ_FC_individuals.owl -#ONTOLOGY=data/fly/fbbt_vfb_ind_pr_nr.owl - -#QUERY variable points to the file that stores all queries -QUERY=data/fly/fly.sparql -#QUERY=data/fly/test.sparql - -#ANSWER variable points to the file to output all answers -#ANSWER=data/fly/fly.ans - -#TO_CLASSIFY switch for the optimisation to specify if the ontology is first classified by HermiT -TO_CLASSIFY=false - -#CALL_HERMIT variable to specify if HermiT is called or not -CALL_HERMIT=true - -#SHELL_MODE to enable query execution from console input -SHELL_MODE=false \ No newline at end of file diff --git a/config/fly.properties b/config/fly.properties new file mode 100644 index 0000000..88c85c3 --- /dev/null +++ b/config/fly.properties @@ -0,0 +1,19 @@ +#ONTOLOGY variable points to the file that stores ontology of interest +ONTOLOGY=data/fly/fly_anatomy_XP_with_GJ_FC_individuals.owl +#ONTOLOGY=data/fly/fbbt_vfb_ind_pr_nr.owl + +#QUERY variable points to the file that stores all queries +QUERY=data/fly/fly.sparql +#QUERY=data/fly/test.sparql + +#ANSWER variable points to the file to output all answers +#ANSWER=data/fly/fly.ans + +#TO_CLASSIFY switch for the optimisation to specify if the ontology is first classified by HermiT +TO_CLASSIFY=false + +#CALL_HERMIT variable to specify if HermiT is called or not +CALL_HERMIT=true + +#SHELL_MODE to enable query execution from console input +SHELL_MODE=false \ No newline at end of file diff --git a/config/log4j.properties b/config/log4j.properties index 95d64a0..6e88437 100644 --- a/config/log4j.properties +++ b/config/log4j.properties @@ -1,19 +1,25 @@ -#log4j.rootLogger=INFO, CONSOLE -log4j.rootLogger=DEBUG, CONSOLE, FILE +log = . +log4j.rootLogger=DEBUG, CONSOLE, FILE_LAST, FILE log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=%d{yyyy/MM/dd HH:mm:ss} %-5p %c{1}- %m%n +log4j.appender.CONSOLE.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} - %m%n log4j.appender.CONSOLE.Target=System.out log4j.appender.CONSOLE.Threshold=INFO -#log = ./output -log = . +log4j.appender.FILE_LAST=org.apache.log4j.RollingFileAppender +log4j.appender.FILE_LAST.File=${log}/pagoda_last_only.log +log4j.appender.FILE_LAST.MaxFileSize=10MB +log4j.appender.FILE_LAST.MaxBackupIndex=3 +log4j.appender.FILE_LAST.layout=org.apache.log4j.PatternLayout +log4j.appender.FILE_LAST.layout.conversionPattern=[%5p] %d{yyyy-MM-dd HH:mm:ss} %c - %m%n +log4j.appender.FILE_LAST.append=false +log4j.appender.FILE_LAST.Threshold=DEBUG + log4j.appender.FILE=org.apache.log4j.RollingFileAppender -log4j.appender.FILE.File=${log}/log4j.log +log4j.appender.FILE.File=${log}/pagoda.log log4j.appender.FILE.MaxFileSize=10MB log4j.appender.FILE.MaxBackupIndex=3 log4j.appender.FILE.layout=org.apache.log4j.PatternLayout -log4j.appender.FILE.layout.conversionPattern=%m%n -log4j.appender.FILE.append=false -log4j.appender.FILE.Threshold=DEBUG +log4j.appender.FILE.layout.conversionPattern=[%5p] %d{yyyy-MM-dd HH:mm:ss} %c - %m%n +log4j.appender.FILE.Threshold=DEBUG \ No newline at end of file diff --git a/config/lubm.conf b/config/lubm.conf deleted file mode 100644 index 73ed470..0000000 --- a/config/lubm.conf +++ /dev/null @@ -1,20 +0,0 @@ -#DATA variable points to the file that stores data -DATA=data/lubm/lubm1.ttl - -#ONTOLOGY variable points to the file that stores ontology of interest -ONTOLOGY=data/lubm/univ-bench.owl - -#QUERY variable points to the file that stores all queries -QUERY=data/lubm/lubm.sparql - -#ANSWER variable points to the file to output all answers -#ANSWER=data/lubm/lubm.ans - -#TO_CLASSIFY switch for the optimisation to specify if the ontology is first classified by HermiT -TO_CLASSIFY=true - -#CALL_HERMIT variable to specify if HermiT is called or not -CALL_HERMIT=true - -#SHELL_MODE to enable query execution from console input -SHELL_MODE=false \ No newline at end of file diff --git a/config/lubm.properties b/config/lubm.properties new file mode 100644 index 0000000..73ed470 --- /dev/null +++ b/config/lubm.properties @@ -0,0 +1,20 @@ +#DATA variable points to the file that stores data +DATA=data/lubm/lubm1.ttl + +#ONTOLOGY variable points to the file that stores ontology of interest +ONTOLOGY=data/lubm/univ-bench.owl + +#QUERY variable points to the file that stores all queries +QUERY=data/lubm/lubm.sparql + +#ANSWER variable points to the file to output all answers +#ANSWER=data/lubm/lubm.ans + +#TO_CLASSIFY switch for the optimisation to specify if the ontology is first classified by HermiT +TO_CLASSIFY=true + +#CALL_HERMIT variable to specify if HermiT is called or not +CALL_HERMIT=true + +#SHELL_MODE to enable query execution from console input +SHELL_MODE=false \ No newline at end of file diff --git a/config/uobm.conf b/config/uobm.conf deleted file mode 100644 index acbe78e..0000000 --- a/config/uobm.conf +++ /dev/null @@ -1,20 +0,0 @@ -#DATA variable points to the file that stores data -DATA=data/uobm/uobm1.ttl - -#ONTOLOGY variable points to the file that stores ontology of interest -ONTOLOGY=data/uobm/univ-bench-dl.owl - -#QUERY variable points to the file that stores all queries -QUERY=data/uobm/uobm.sparql - -#ANSWER variable points to the file to output all answers -#ANSWER=data/uobm/uobm.ans - -#TO_CLASSIFY switch for the optimisation to specify if the ontology is first classified by HermiT -TO_CLASSIFY=true - -#CALL_HERMIT variable to specify if HermiT is called or not -CALL_HERMIT=true - -#SHELL_MODE to enable query execution from console input -SHELL_MODE=false \ No newline at end of file diff --git a/config/uobm.properties b/config/uobm.properties new file mode 100644 index 0000000..acbe78e --- /dev/null +++ b/config/uobm.properties @@ -0,0 +1,20 @@ +#DATA variable points to the file that stores data +DATA=data/uobm/uobm1.ttl + +#ONTOLOGY variable points to the file that stores ontology of interest +ONTOLOGY=data/uobm/univ-bench-dl.owl + +#QUERY variable points to the file that stores all queries +QUERY=data/uobm/uobm.sparql + +#ANSWER variable points to the file to output all answers +#ANSWER=data/uobm/uobm.ans + +#TO_CLASSIFY switch for the optimisation to specify if the ontology is first classified by HermiT +TO_CLASSIFY=true + +#CALL_HERMIT variable to specify if HermiT is called or not +CALL_HERMIT=true + +#SHELL_MODE to enable query execution from console input +SHELL_MODE=false \ No newline at end of file diff --git a/pom.xml b/pom.xml index 630dfa3..c177403 100644 --- a/pom.xml +++ b/pom.xml @@ -118,5 +118,10 @@ gson 2.3.1 + + net.sf.ehcache + ehcache + 2.10.0 + diff --git a/src/uk/ac/ox/cs/pagoda/approx/RLPlusOntology.java b/src/uk/ac/ox/cs/pagoda/approx/RLPlusOntology.java index a60b664..1e17dac 100644 --- a/src/uk/ac/ox/cs/pagoda/approx/RLPlusOntology.java +++ b/src/uk/ac/ox/cs/pagoda/approx/RLPlusOntology.java @@ -1,64 +1,23 @@ package uk.ac.ox.cs.pagoda.approx; -import java.io.BufferedOutputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.ObjectOutput; -import java.io.ObjectOutputStream; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.Map; -import java.util.Random; -import java.util.Set; - import org.semanticweb.HermiT.Configuration; import org.semanticweb.HermiT.model.DLClause; import org.semanticweb.HermiT.model.DLOntology; import org.semanticweb.HermiT.structural.OWLClausification; -import org.semanticweb.owlapi.model.IRI; -import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; -import org.semanticweb.owlapi.model.OWLAxiom; -import org.semanticweb.owlapi.model.OWLClass; -import org.semanticweb.owlapi.model.OWLClassAssertionAxiom; -import org.semanticweb.owlapi.model.OWLClassExpression; -import org.semanticweb.owlapi.model.OWLDataFactory; -import org.semanticweb.owlapi.model.OWLDataHasValue; -import org.semanticweb.owlapi.model.OWLDataMaxCardinality; -import org.semanticweb.owlapi.model.OWLDataMinCardinality; -import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom; -import org.semanticweb.owlapi.model.OWLDataSomeValuesFrom; -import org.semanticweb.owlapi.model.OWLDatatype; -import org.semanticweb.owlapi.model.OWLDifferentIndividualsAxiom; -import org.semanticweb.owlapi.model.OWLIndividual; -import org.semanticweb.owlapi.model.OWLNamedIndividual; -import org.semanticweb.owlapi.model.OWLObjectAllValuesFrom; -import org.semanticweb.owlapi.model.OWLObjectComplementOf; -import org.semanticweb.owlapi.model.OWLObjectHasValue; -import org.semanticweb.owlapi.model.OWLObjectMaxCardinality; -import org.semanticweb.owlapi.model.OWLObjectMinCardinality; -import org.semanticweb.owlapi.model.OWLObjectOneOf; -import org.semanticweb.owlapi.model.OWLObjectProperty; -import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom; -import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; -import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; -import org.semanticweb.owlapi.model.OWLOntology; -import org.semanticweb.owlapi.model.OWLOntologyCreationException; -import org.semanticweb.owlapi.model.OWLOntologyManager; -import org.semanticweb.owlapi.model.OWLOntologyStorageException; -import org.semanticweb.owlapi.model.OWLSameIndividualAxiom; +import org.semanticweb.owlapi.model.*; import org.semanticweb.owlapi.profiles.OWL2RLProfile; import org.semanticweb.owlapi.profiles.OWLProfileReport; import org.semanticweb.owlapi.profiles.OWLProfileViolation; - import uk.ac.ox.cs.pagoda.constraints.NullaryBottom; import uk.ac.ox.cs.pagoda.constraints.UnaryBottom; import uk.ac.ox.cs.pagoda.owl.OWLHelper; import uk.ac.ox.cs.pagoda.util.Namespace; import uk.ac.ox.cs.pagoda.util.Utility; +import java.io.*; +import java.nio.file.Paths; +import java.util.*; + public class RLPlusOntology implements KnowledgeBase { OWLOntologyManager manager; @@ -111,7 +70,7 @@ public class RLPlusOntology implements KnowledgeBase { if (!tOntoIRI.endsWith(originalExtension)) tOntoIRI += originalExtension; String rlOntologyIRI = originalExtension.isEmpty() ? tOntoIRI + "-RL.owl" : tOntoIRI.replaceFirst(originalExtension, "-RL.owl"); - String rlDocumentIRI = (outputPath = Utility.TempDirectory + "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))); @@ -119,8 +78,8 @@ public class RLPlusOntology implements KnowledgeBase { tBoxOntologyIRI = originalExtension.isEmpty() ? tOntoIRI + "-TBox.owl" : tOntoIRI.replaceFirst(originalExtension, "-TBox.owl"); aBoxOntologyIRI = originalExtension.isEmpty() ? tOntoIRI + "-ABox.owl" : tOntoIRI.replaceFirst(originalExtension, "-ABox.owl"); - String tBoxDocumentIRI = (Utility.TempDirectory + "TBox.owl"); - String aBoxDocumentIRI = (aBoxPath = Utility.TempDirectory + "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)); aBox = manager.createOntology(IRI.create(aBoxOntologyIRI)); manager.setOntologyDocumentIRI(tBox, IRI.create(Utility.toFileIRI(tBoxDocumentIRI))); @@ -488,7 +447,7 @@ public class RLPlusOntology implements KnowledgeBase { addedAxioms.add(factory.getOWLObjectPropertyRangeAxiom(r, tExp)); } else if (botStrategy != BottomStrategy.TOREMOVE) { - OWLClass cls = (OWLClass) ((OWLObjectComplementOf) tExp).getComplementNNF(); + OWLClass cls = (OWLClass) tExp.getComplementNNF(); OWLClass neg; if ((neg = atomic2negation.get(cls)) == null) { neg = getNewConcept(outputOntology, rlCounter); @@ -632,6 +591,6 @@ public class RLPlusOntology implements KnowledgeBase { corrFileName = path; } - private static enum BottomStrategy { TOREMOVE, NULLARY, UNARY } + private enum BottomStrategy { TOREMOVE, NULLARY, UNARY } } diff --git a/src/uk/ac/ox/cs/pagoda/multistage/MultiStageQueryEngine.java b/src/uk/ac/ox/cs/pagoda/multistage/MultiStageQueryEngine.java index 4ba2715..50996d0 100644 --- a/src/uk/ac/ox/cs/pagoda/multistage/MultiStageQueryEngine.java +++ b/src/uk/ac/ox/cs/pagoda/multistage/MultiStageQueryEngine.java @@ -133,8 +133,8 @@ public class MultiStageQueryEngine extends StageQueryEngine { subTimer.reset(); if ((violations = program.isIntegrated(this, incrementally)) == null || violations.size() == 0) { store.clearRulesAndMakeFactsExplicit(); - Utility.logDebug(name + " store after materialising " + programName + ": " + tripleCount + " (" + (tripleCount - tripleCountBeforeMat) + " new)"); - Utility.logInfo(name + " store is DONE for multi-stage materialising in " + t.duration() + " seconds."); + Utility.logInfo(name + " store after materialising " + programName + ": " + tripleCount + " (" + (tripleCount - tripleCountBeforeMat) + " new)"); + Utility.logInfo(name + " store is DONE for multi-stage materialising in " + t.duration() + " seconds."); return isValid() ? 1 : 0; } Utility.logDebug("Time to detect violations: " + subTimer.duration()); diff --git a/src/uk/ac/ox/cs/pagoda/query/QueryRecord.java b/src/uk/ac/ox/cs/pagoda/query/QueryRecord.java index 6c87eb5..15b2c01 100644 --- a/src/uk/ac/ox/cs/pagoda/query/QueryRecord.java +++ b/src/uk/ac/ox/cs/pagoda/query/QueryRecord.java @@ -69,7 +69,7 @@ public class QueryRecord { } public boolean updateLowerBoundAnswers(AnswerTuples answerTuples) { - if (answerTuples == null) return false; + if (answerTuples == null) return false; boolean update = false; for (AnswerTuple tuple; answerTuples.isValid(); answerTuples.moveNext()) { tuple = answerTuples.getTuple(); @@ -77,8 +77,12 @@ public class QueryRecord { soundAnswerTuples.add(tuple); if (gapAnswerTuples != null) gapAnswerTuples.remove(tuple); - update = true; + update = true; } + // TODO could be wrong, but if possible add the check +// else if (! gapAnswerTuples.contains(tuple)) { +// throw new IllegalArgumentException("The lower bound answers must be contained in the upper ones!"); +// } } Utility.logInfo("The number of answers in the lower bound: " + soundAnswerTuples.size()); @@ -103,14 +107,16 @@ public class QueryRecord { for (; answerTuples.isValid(); answerTuples.moveNext()) { ++number; } - Utility.logInfo("The number of answers returned by the upper bound: " + number); + Utility.logInfo("The number of answers returned by an upper bound: " + number); if (number <= soundAnswerTuples.size()) { if (gapAnswerTuples != null) gapAnswerTuples.clear(); else gapAnswerTuples = new HashSet(); - Utility.logInfo("The number of answers in the upper bound: " + (soundAnswerTuples.size() + gapAnswerTuples.size())); + Utility.logInfo("The number of upper bound answers: " + (soundAnswerTuples.size() + gapAnswerTuples.size())); return false; } + else if (number < soundAnswerTuples.size()) + throw new IllegalArgumentException("The upper bound answers must contain all the lower bound ones!"); answerTuples.reset(); } @@ -362,8 +368,8 @@ public class QueryRecord { } public enum Step {LowerBound, UpperBound, ELLowerBound, - Fragment, FragmentRefinement, Summarisation, Dependency, FullReasoning}; - + Fragment, FragmentRefinement, Summarisation, Dependency, FullReasoning} + double[] timer; public void addProcessingTime(Step step, double time) { diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/ConsistencyManager.java b/src/uk/ac/ox/cs/pagoda/reasoner/ConsistencyManager.java index b7a3667..409a2c9 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/ConsistencyManager.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/ConsistencyManager.java @@ -15,6 +15,7 @@ import uk.ac.ox.cs.pagoda.query.AnswerTuples; import uk.ac.ox.cs.pagoda.query.QueryManager; import uk.ac.ox.cs.pagoda.query.QueryRecord; import uk.ac.ox.cs.pagoda.reasoner.full.Checker; +import uk.ac.ox.cs.pagoda.reasoner.light.BasicQueryEngine; import uk.ac.ox.cs.pagoda.rules.UpperDatalogProgram; import uk.ac.ox.cs.pagoda.summary.HermitSummaryFilter; import uk.ac.ox.cs.pagoda.tracking.QueryTracker; @@ -54,7 +55,7 @@ public class ConsistencyManager { if (fullQueryRecord.getNoOfSoundAnswers() > 0) { Utility.logInfo("Answers to bottom in the lower bound: ", fullQueryRecord.outputSoundAnswerTuple()); - return unsatisfiability(t.duration()); + return false; } return true; } @@ -63,39 +64,20 @@ public class ConsistencyManager { 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()); - return unsatisfiability(t.duration()); + return true; } return true; } - - boolean checkLazyUpper() { - if (m_reasoner.lazyUpperStore != null) { - AnswerTuples tuples = null; - try { - tuples = m_reasoner.lazyUpperStore.evaluate(fullQueryRecord.getQueryText(), fullQueryRecord.getAnswerVariables()); - - Utility.logDebug("CheckLazyUpperBound: answerVars=" + fullQueryRecord.getAnswerVariables()); - - if (!tuples.isValid()) { - Utility.logInfo("There are no contradictions derived in the lazy upper bound materialisation."); - return satisfiability(t.duration()); - } - } - finally { - if (tuples != null) tuples.dispose(); - } - } - return false; - } - boolean checkSkolemUpper() { - if (m_reasoner.limitedSkolemUpperStore != null) { + boolean checkUpper(BasicQueryEngine upperStore) { + if (upperStore != null) { AnswerTuples tuples = null; try { - tuples = m_reasoner.limitedSkolemUpperStore.evaluate(fullQueryRecord.getQueryText(), fullQueryRecord.getAnswerVariables()); + tuples = upperStore.evaluate(fullQueryRecord.getQueryText(), fullQueryRecord.getAnswerVariables()); if (!tuples.isValid()) { - Utility.logInfo("There are no contradictions derived in the limited-skolem upper bound materialisation."); - return satisfiability(t.duration()); + Utility.logInfo("There are no contradictions derived in "+ upperStore.getName() +" materialisation."); + Utility.logDebug("The ontology and dataset is satisfiable."); + return true; } } finally { @@ -104,7 +86,11 @@ public class ConsistencyManager { } return false; } - + + void dispose() { + fullQueryRecord.dispose(); + } + boolean check() { // if (!checkRLLowerBound()) return false; // if (!checkELLowerBound()) return false; @@ -119,7 +105,7 @@ public class ConsistencyManager { } if (fullQueryRecord.getNoOfCompleteAnswers() == 0) - return satisfiability(t.duration()); + return true; extractBottomFragment(); @@ -139,7 +125,7 @@ public class ConsistencyManager { checker = new HermitSummaryFilter(r, true); // m_reasoner.factory.getSummarisedReasoner(r); satisfiability = checker.isConsistent(); checker.dispose(); - if (!satisfiability) return unsatisfiability(t.duration()); + if (!satisfiability) return false; } // Checker checker = m_reasoner.factory.getSummarisedReasoner(fullQueryRecord); @@ -147,20 +133,20 @@ public class ConsistencyManager { // checker.dispose(); // if (!satisfiable) return unsatisfiability(t.duration()); - return satisfiability(t.duration()); + return true; } - protected boolean unsatisfiability(double duration) { - fullQueryRecord.dispose(); - Utility.logDebug("The ontology and dataset is unsatisfiable."); - return false; - } +// 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; - } +// protected boolean satisfiability(double duration) { +// fullQueryRecord.dispose(); +// Utility.logDebug("The ontology and dataset is satisfiable."); +// return true; +// } boolean fragmentExtracted = false; diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/ConsistencyManager2.java b/src/uk/ac/ox/cs/pagoda/reasoner/ConsistencyManager2.java index 9c335f3..9191067 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/ConsistencyManager2.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/ConsistencyManager2.java @@ -2,7 +2,6 @@ package uk.ac.ox.cs.pagoda.reasoner; import org.semanticweb.owlapi.model.OWLOntologyCreationException; import org.semanticweb.owlapi.model.OWLOntologyManager; - import uk.ac.ox.cs.pagoda.query.AnswerTuples; import uk.ac.ox.cs.pagoda.query.QueryRecord; import uk.ac.ox.cs.pagoda.reasoner.full.Checker; @@ -31,8 +30,9 @@ public class ConsistencyManager2 extends ConsistencyManager { @Override boolean check() { // if (!checkRLLowerBound()) return false; -// if (!checkELLowerBound()) return false; - if (checkLazyUpper()) return true; +// if (!checkELLowerBound()) return false; + // TODO test + if (checkUpper(m_reasoner.lazyUpperStore) && checkUpper(m_reasoner.limitedSkolemUpperStore)) return true; AnswerTuples iter = null; try { 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 { private Collection predicatesWithGap = null; private Boolean satisfiable; private ConsistencyManager consistency = new ConsistencyManager(this); + private boolean useUpperStores = false; public MyQueryReasoner() { setup(true, true); @@ -101,9 +102,9 @@ public class MyQueryReasoner extends QueryReasoner { // program.getUpper().save(); // program.getGeneral().save(); - if (multiStageTag && !program.getGeneral().isHorn()) { + useUpperStores = multiStageTag && !program.getGeneral().isHorn(); + if (useUpperStores) { lazyUpperStore = getUpperStore("lazy-upper-bound", true); // new MultiStageQueryEngine("lazy-upper-bound", true); // - // TODO CHECK limitedSkolemUpperStore = getUpperStore("limited-skolem-upper-bound", true); } @@ -120,7 +121,7 @@ public class MyQueryReasoner extends QueryReasoner { @Override public boolean preprocess() { t.reset(); - Utility.logInfo("Preprocessing ... checking satisfiability ... "); + Utility.logInfo("Preprocessing... checking satisfiability... "); String name = "data", datafile = importedData.toString(); rlLowerStore.importRDFData(name, datafile); @@ -147,12 +148,11 @@ public class MyQueryReasoner extends QueryReasoner { } if (tag == -1) return false; } - if (consistency.checkLazyUpper()) { + if (consistency.checkUpper(lazyUpperStore)) { satisfiable = true; Utility.logInfo("time for satisfiability checking: " + t.duration()); } - // TODO check if (limitedSkolemUpperStore != null) { limitedSkolemUpperStore.importRDFData(name, datafile); limitedSkolemUpperStore.materialise("saturate named individuals", originalMarkProgram); @@ -163,16 +163,14 @@ public class MyQueryReasoner extends QueryReasoner { } if (tag == -1) return false; } - // FIXME nullPointerException -// if (consistency.checkSkolemUpper()) { -// satisfiable = true; -// Utility.logInfo("time for satisfiability checking: " + t.duration()); -// } + if (consistency.checkUpper(limitedSkolemUpperStore)) { + satisfiable = true; + Utility.logInfo("time for satisfiability checking: " + t.duration()); + } trackingStore.importRDFData(name, datafile); trackingStore.materialise("saturate named individuals", originalMarkProgram); -// materialiseFullUpper(); GapByStore4ID gap = new GapByStore4ID(trackingStore); trackingStore.materialiseFoldedly(program, gap); predicatesWithGap = gap.getPredicatesWithGap(); @@ -192,6 +190,7 @@ public class MyQueryReasoner extends QueryReasoner { return false; consistency.extractBottomFragment(); + consistency.dispose(); return true; } @@ -204,6 +203,9 @@ public class MyQueryReasoner extends QueryReasoner { return satisfiable; } + /** + * Returns the relevant part of the ontology, while computing the bound answers. + * */ private OWLOntology relevantPart(QueryRecord queryRecord) { AnswerTuples rlAnswer = null, elAnswer = null; @@ -216,13 +218,13 @@ public class MyQueryReasoner extends QueryReasoner { if (rlAnswer != null) rlAnswer.dispose(); } queryRecord.addProcessingTime(Step.LowerBound, t.duration()); - rlAnswer = null; t.reset(); BasicQueryEngine upperStore = queryRecord.isBottom() || lazyUpperStore == null ? trackingStore : lazyUpperStore; String[] extendedQuery = queryRecord.getExtendedQueryText(); - + + // TODO why the following??? queryUpperBound(upperStore, queryRecord, queryRecord.getQueryText(), queryRecord.getAnswerVariables()); if (!queryRecord.processed() && !queryRecord.getQueryText().equals(extendedQuery[0])) { @@ -232,25 +234,21 @@ public class MyQueryReasoner extends QueryReasoner { queryUpperBound(upperStore, queryRecord, extendedQuery[1], queryRecord.getDistinguishedVariables()); } - Utility.logDebug(toJsonKeyValuePair("upperBound1", queryRecord)); +// Utility.logDebug(toJsonKeyValuePair("upperBound", queryRecord)); - // TODO check whether it is harmful. In case is not, implement it properly - // BEGIN: trying to intersect + // TODO test intersection and new upper bound if (!queryRecord.isBottom() && lazyUpperStore != null) { queryUpperBound(trackingStore, queryRecord, queryRecord.getQueryText(), queryRecord.getAnswerVariables()); } if (!queryRecord.isBottom() && limitedSkolemUpperStore != null) { queryUpperBound(limitedSkolemUpperStore, queryRecord, queryRecord.getQueryText(), queryRecord.getAnswerVariables()); } - // END: trying to intersect queryRecord.addProcessingTime(Step.UpperBound, t.duration()); if (queryRecord.processed()) { queryRecord.setDifficulty(Step.UpperBound); return null; } - - // TODO add evaluation on new upper store t.reset(); try { @@ -327,15 +325,15 @@ public class MyQueryReasoner extends QueryReasoner { @Override public void evaluate(QueryRecord queryRecord) { - OWLOntology knowledgebase = relevantPart(queryRecord); + OWLOntology knowledgeBase = relevantPart(queryRecord); - if (knowledgebase == null) { + if (knowledgeBase == null) { Utility.logDebug("Difficulty of this query: " + queryRecord.getDifficulty()); return ; } - int aboxcount = knowledgebase.getABoxAxioms(true).size(); - Utility.logDebug("ABox axioms: " + aboxcount + " TBox axioms: " + (knowledgebase.getAxiomCount() - aboxcount)); + int aBoxCount = knowledgeBase.getABoxAxioms(true).size(); + Utility.logDebug("ABox axioms: " + aBoxCount + " TBox axioms: " + (knowledgeBase.getAxiomCount() - aBoxCount)); // queryRecord.saveRelevantOntology("fragment_query" + queryRecord.getQueryID() + ".owl"); Timer t = new Timer(); diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/QueryReasoner.java b/src/uk/ac/ox/cs/pagoda/reasoner/QueryReasoner.java index 326bf7e..97bab50 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/QueryReasoner.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/QueryReasoner.java @@ -25,8 +25,8 @@ public abstract class QueryReasoner { private static boolean defaultMultiStages = true; private static boolean defaultEqualities = true; - public static enum Type { Full, RLU, ELHOU }; - + public enum Type { Full, RLU, ELHOU } + public static QueryReasoner getInstance(Properties p) { OWLOntology ontology = OWLHelper.loadOntology(p.getOntologyPath()); QueryReasoner pagoda = getInstance(ontology, p); @@ -63,7 +63,7 @@ public abstract class QueryReasoner { } public static QueryReasoner getInstance(Type type, OWLOntology o, boolean performMultiStages, boolean considerEqualities) { - Utility.initialise(); +// Utility.initialise(); QueryReasoner reasoner; if (OWLHelper.isInOWL2RL(o)) reasoner = new RLQueryReasoner(); else if (OWLHelper.isInELHO(o)) reasoner = new ELHOQueryReasoner(); @@ -218,9 +218,10 @@ public abstract class QueryReasoner { record.outputAnswerStatistics(); record.outputTimes(); } - // TODO it can handle one call only - // if you call twice, you will end up with a json file with multiple roots + /* TODO it can handle one call only + if you call twice, you will end up with a json file with multiple roots */ if(answerWriter != null) gson.toJson(queryRecords, answerWriter); +// queryRecords.stream().forEach(record -> Utility.logDebug(gson.toJson(record))); queryRecords.stream().forEach(record -> record.dispose()); } @@ -232,7 +233,7 @@ public abstract class QueryReasoner { e.printStackTrace(); } } - Utility.cleanup(); +// Utility.cleanup(); } private QueryManager m_queryManager = new QueryManager(); diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/light/KarmaQueryEngine.java b/src/uk/ac/ox/cs/pagoda/reasoner/light/KarmaQueryEngine.java index f70dde9..f068164 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/light/KarmaQueryEngine.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/light/KarmaQueryEngine.java @@ -1,20 +1,22 @@ -package uk.ac.ox.cs.pagoda.reasoner.light; +package uk.ac.ox.cs.pagoda.reasoner.light; -import java.io.File; -import java.io.FileNotFoundException; -import java.util.*; - -import org.semanticweb.karma2.*; +import org.semanticweb.karma2.MyKarma; import org.semanticweb.karma2.clausifier.OntologyProcesser; import org.semanticweb.karma2.exception.IllegalInputOntologyException; import org.semanticweb.karma2.model.ConjunctiveQuery; import org.semanticweb.owlapi.model.OWLOntology; - -import uk.ac.ox.cs.pagoda.query.*; -import uk.ac.ox.cs.pagoda.util.ConjunctiveQueryHelper; -import uk.ac.ox.cs.pagoda.util.Utility; import uk.ac.ox.cs.JRDFox.JRDFStoreException; import uk.ac.ox.cs.JRDFox.store.DataStore; +import uk.ac.ox.cs.pagoda.query.AnswerTuple; +import uk.ac.ox.cs.pagoda.query.AnswerTuples; +import uk.ac.ox.cs.pagoda.query.AnswerTuplesImp; +import uk.ac.ox.cs.pagoda.util.ConjunctiveQueryHelper; +import uk.ac.ox.cs.pagoda.util.Utility; + +import java.io.File; +import java.io.FileNotFoundException; +import java.nio.file.Paths; +import java.util.Set; public class KarmaQueryEngine extends RDFoxQueryEngine { @@ -29,8 +31,8 @@ public class KarmaQueryEngine extends RDFoxQueryEngine { // int index = (new Random().nextInt() % Base + Base) % Base; // karmaDataFile = "karma_data" + index + ".ttl"; // karmaRuleFile = "karma_rule" + index + ".dlog"; - karmaDataFile = Utility.TempDirectory + "karma_data.ttl"; - karmaRuleFile = Utility.TempDirectory + "karma_rule.dlog"; + karmaDataFile = Paths.get(Utility.getGlobalTempDirAbsolutePath(), "karma_data.ttl").toString(); + karmaRuleFile = Paths.get(Utility.getGlobalTempDirAbsolutePath(), "karma_rule.dlog").toString(); reasoner = new MyKarma(); } 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 70d0cc9..63773d9 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/light/RDFoxQueryEngine.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/light/RDFoxQueryEngine.java @@ -1,8 +1,9 @@ package uk.ac.ox.cs.pagoda.reasoner.light; -import java.io.File; -import java.util.Collection; - +import uk.ac.ox.cs.JRDFox.JRDFStoreException; +import uk.ac.ox.cs.JRDFox.Prefixes; +import uk.ac.ox.cs.JRDFox.store.DataStore; +import uk.ac.ox.cs.JRDFox.store.DataStore.StoreType; import uk.ac.ox.cs.pagoda.MyPrefixes; import uk.ac.ox.cs.pagoda.query.AnswerTuples; import uk.ac.ox.cs.pagoda.reasoner.QueryEngine; @@ -10,16 +11,19 @@ import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner; import uk.ac.ox.cs.pagoda.tracking.AnswerTuplesWriter; import uk.ac.ox.cs.pagoda.util.Timer; import uk.ac.ox.cs.pagoda.util.Utility; -import uk.ac.ox.cs.JRDFox.JRDFStoreException; -import uk.ac.ox.cs.JRDFox.Prefixes; -import uk.ac.ox.cs.JRDFox.store.DataStore; -import uk.ac.ox.cs.JRDFox.store.DataStore.StoreType; + +import java.io.File; +import java.util.Collection; public abstract class RDFoxQueryEngine implements QueryEngine { public static final int matNoOfThreads = Runtime.getRuntime().availableProcessors() * 2; - - protected String name; + + public String getName() { + return name; + } + + protected String name; protected Prefixes prefixes = MyPrefixes.PAGOdAPrefixes.getRDFoxPrefixes(); public RDFoxQueryEngine(String name) { diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/light/RDFoxTripleManager.java b/src/uk/ac/ox/cs/pagoda/reasoner/light/RDFoxTripleManager.java index 232bc31..85f8ef9 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/light/RDFoxTripleManager.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/light/RDFoxTripleManager.java @@ -1,5 +1,8 @@ package uk.ac.ox.cs.pagoda.reasoner.light; +import net.sf.ehcache.Cache; +import net.sf.ehcache.CacheManager; +import net.sf.ehcache.Element; import org.semanticweb.HermiT.model.*; import uk.ac.ox.cs.JRDFox.JRDFStoreException; import uk.ac.ox.cs.JRDFox.model.Datatype; @@ -11,11 +14,20 @@ import uk.ac.ox.cs.JRDFox.store.Resource; import uk.ac.ox.cs.pagoda.owl.OWLHelper; import uk.ac.ox.cs.pagoda.util.Namespace; -import java.util.*; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; public class RDFoxTripleManager { - - UpdateType m_incrementally; + + private final Cache termsCache; + private static final int TERMS_CACHE_SIZE = 10000; + private static final int CACHE_TTL_DEFAULT = 0; + private static final int CACHE_TTI_DEFAULT = 0; + private static final boolean CACHE_ETERNAL = true; + private static final boolean CACHE_USE_DISK = false; + + UpdateType m_incrementally; // boolean m_incrementally; DataStore m_store; @@ -24,7 +36,19 @@ public class RDFoxTripleManager { public RDFoxTripleManager(DataStore store, boolean incrementally) { m_store = store; -// m_incrementally = incrementally; +// m_incrementally = incrementally; + + CacheManager cacheManager = CacheManager.getInstance(); + String cacheName = "RDFoxTripleManager_" + store.hashCode(); + if(! cacheManager.cacheExists(cacheName)) { + termsCache = new Cache(cacheName, + TERMS_CACHE_SIZE, CACHE_USE_DISK, CACHE_ETERNAL, + CACHE_TTL_DEFAULT, CACHE_TTI_DEFAULT); + cacheManager.addCache(termsCache); + } + else + termsCache = cacheManager.getCache(cacheName); + if (incrementally) m_incrementally = UpdateType.ScheduleForAddition; else @@ -164,29 +188,25 @@ public class RDFoxTripleManager { return m_dict.resolveResources(lexicalForms, types)[0]; } - Map termCache = new HashMap(); - Queue termList = new LinkedList(); - int sizeLimit = 10000; +// Map termCache = new HashMap(); +// Queue termQueue = new LinkedList(); private int getResourceID(Term arg, Map assignment) { - // FIXME infinite loop -// while (termCache.size() > sizeLimit) -// termCache.remove(termList.poll()); - if (arg instanceof Variable) return assignment.get(arg); - Integer id = null; - if ((id = termCache.get(arg)) != null) - return id; - + int id = -1; + if(termsCache.isKeyInCache(arg)) + return ((int) termsCache.get(arg).getObjectValue()); + // if (arg instanceof Individual) { try { if (arg instanceof Individual) - termCache.put(arg, id = resolveResource(((Individual) arg).getIRI(), Datatype.IRI_REFERENCE.value())); + termsCache.put(new Element(arg, id = resolveResource(((Individual) arg).getIRI(), Datatype.IRI_REFERENCE.value()))); else if (arg instanceof Constant) - termCache.put(arg, id = resolveResource(((Constant) arg).getLexicalForm(), getDatatypeID(((Constant) arg).getDatatypeURI()))); + termsCache.put(new Element(arg, id = resolveResource(((Constant) arg).getLexicalForm(), getDatatypeID(((Constant) arg).getDatatypeURI())))); } catch (JRDFStoreException e) { e.printStackTrace(); + System.exit(1); } // } diff --git a/src/uk/ac/ox/cs/pagoda/rules/Program.java b/src/uk/ac/ox/cs/pagoda/rules/Program.java index 83cd21a..2e5302b 100644 --- a/src/uk/ac/ox/cs/pagoda/rules/Program.java +++ b/src/uk/ac/ox/cs/pagoda/rules/Program.java @@ -1,39 +1,10 @@ package uk.ac.ox.cs.pagoda.rules; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; - import org.semanticweb.HermiT.Configuration; -import org.semanticweb.HermiT.model.AnnotatedEquality; -import org.semanticweb.HermiT.model.Atom; -import org.semanticweb.HermiT.model.AtomicConcept; -import org.semanticweb.HermiT.model.AtomicDataRange; -import org.semanticweb.HermiT.model.AtomicNegationDataRange; -import org.semanticweb.HermiT.model.AtomicRole; -import org.semanticweb.HermiT.model.ConstantEnumeration; -import org.semanticweb.HermiT.model.DLClause; -import org.semanticweb.HermiT.model.DLOntology; -import org.semanticweb.HermiT.model.DLPredicate; -import org.semanticweb.HermiT.model.Equality; -import org.semanticweb.HermiT.model.Inequality; -import org.semanticweb.HermiT.model.InverseRole; -import org.semanticweb.HermiT.model.Term; -import org.semanticweb.HermiT.model.Variable; +import org.semanticweb.HermiT.model.*; import org.semanticweb.HermiT.structural.OWLClausification; import org.semanticweb.owlapi.model.*; - +import org.semanticweb.simpleETL.SimpleETL; import uk.ac.ox.cs.pagoda.MyPrefixes; import uk.ac.ox.cs.pagoda.approx.KnowledgeBase; import uk.ac.ox.cs.pagoda.approx.RLPlusOntology; @@ -44,7 +15,8 @@ import uk.ac.ox.cs.pagoda.hermit.DLClauseHelper; import uk.ac.ox.cs.pagoda.owl.OWLHelper; import uk.ac.ox.cs.pagoda.util.Utility; -import org.semanticweb.simpleETL.SimpleETL; +import java.io.*; +import java.util.*; public abstract class Program implements KnowledgeBase { @@ -377,7 +349,7 @@ public abstract class Program implements KnowledgeBase { } public final String getDirectory() { - return Utility.TempDirectory; + return Utility.getGlobalTempDirAbsolutePath(); } public void deleteABoxTurtleFile() { diff --git a/src/uk/ac/ox/cs/pagoda/util/Utility.java b/src/uk/ac/ox/cs/pagoda/util/Utility.java index b3a4df1..7b23e0d 100644 --- a/src/uk/ac/ox/cs/pagoda/util/Utility.java +++ b/src/uk/ac/ox/cs/pagoda/util/Utility.java @@ -5,9 +5,9 @@ import org.apache.log4j.Logger; import org.semanticweb.HermiT.model.Atom; import java.io.*; +import java.nio.file.Files; +import java.nio.file.Path; import java.text.SimpleDateFormat; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; import java.util.*; public class Utility { @@ -21,8 +21,9 @@ public class Utility { public static final String JAVA_FILE_SEPARATOR = "/"; public static final String FILE_SEPARATOR = System.getProperty("file.separator"); public static final String LINE_SEPARATOR = System.getProperty("line.separator"); - - public static final String TempDirectory = (new File("tmp" + DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(LocalDateTime.now()))).getAbsolutePath() + FILE_SEPARATOR; + + private static final String TEMP_DIR_PATH= "pagoda_tmp"; + private static String tempDir; public static final int TEST = -1; public static final int FLY = 0; @@ -31,6 +32,20 @@ public class Utility { public static final int AEO = 3; public static final int WINE = 4; + public static String getGlobalTempDirAbsolutePath() { + if(tempDir == null) { + try { + Path path = Files.createTempDirectory(TEMP_DIR_PATH); + tempDir = path.toString(); + new File(tempDir).deleteOnExit(); + } catch (IOException e) { + e.printStackTrace(); + System.exit(1); + } + } + return tempDir; + } + public static Set toSet(Atom[] data) { HashSet ret = new HashSet(); @@ -228,19 +243,19 @@ public class Utility { LOGS.error(getLogMessage(messages)); } - public static void initialise() { - File tmp = new File(TempDirectory); - if (!tmp.exists()) tmp.mkdirs(); - } - - public static void cleanup() { - File tmp = new File(TempDirectory); - if (tmp.exists()) { - for (File file: tmp.listFiles()) - file.delete(); - tmp.delete(); - } - } +// public static void initialise() { +// File tmp = new File(TempDirectory); +// if (!tmp.exists()) tmp.mkdirs(); +// } +// +// public static void cleanup() { +// File tmp = new File(TempDirectory); +// if (tmp.exists()) { +// for (File file: tmp.listFiles()) +// file.delete(); +// tmp.delete(); +// } +// } public static String toFileIRI(String path) { String iri; diff --git a/test/AllTests.xml b/test/AllTests.xml index cb8a0e3..c2567a8 100644 --- a/test/AllTests.xml +++ b/test/AllTests.xml @@ -5,13 +5,13 @@ - + - + diff --git a/test/FullEvaluation.xml b/test/FullEvaluation.xml index f0f047d..c4a3ebe 100644 --- a/test/FullEvaluation.xml +++ b/test/FullEvaluation.xml @@ -5,13 +5,13 @@ - + - + diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/ClauseTester.java b/test/uk/ac/ox/cs/pagoda/global_tests/ClauseTester.java new file mode 100644 index 0000000..abd0741 --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/ClauseTester.java @@ -0,0 +1,158 @@ +package uk.ac.ox.cs.pagoda.global_tests; + +import org.semanticweb.HermiT.model.*; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.testng.Assert; +import org.testng.annotations.Test; +import uk.ac.ox.cs.pagoda.approx.Clause; +import uk.ac.ox.cs.pagoda.approx.Clausifier; + +public class ClauseTester { + + @Test + public void test_simple() { + Variable x = Variable.create("X"), y1 = Variable.create("y1"), y2 = Variable.create("y2"); + AtomicConcept A = AtomicConcept.create("A"); + AtomicRole r = AtomicRole.create("r"); + Atom[] bodyAtoms = new Atom[] { + Atom.create(A, x), + Atom.create(r, x, y1), + Atom.create(r, x, y2) + }; + + Atom[] headAtoms = new Atom[] { + Atom.create(Equality.INSTANCE, y1, y2) + }; + + OWLOntologyManager m = OWLManager.createOWLOntologyManager(); + OWLOntology emptyOntology = null; + try { + emptyOntology = m.createOntology(); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail("failed to create a new ontology"); + } + Clause c = new Clause(Clausifier.getInstance(emptyOntology), DLClause.create(headAtoms, bodyAtoms)); + System.out.println(c.toString()); + } + + @Test + public void test_more() { + Variable x = Variable.create("X"), y1 = Variable.create("y1"), y2 = Variable.create("y2"), y3 = Variable.create("y3"); + AtomicConcept A = AtomicConcept.create("A"); + AtomicRole r = AtomicRole.create("r"); + Atom[] bodyAtoms = new Atom[] { + Atom.create(A, x), + Atom.create(r, x, y1), + Atom.create(r, x, y2), + Atom.create(r, x, y3), + }; + + Atom[] headAtoms = new Atom[] { + Atom.create(Equality.INSTANCE, y1, y2), + Atom.create(Equality.INSTANCE, y1, y3), + Atom.create(Equality.INSTANCE, y2, y3) + }; + + OWLOntologyManager m = OWLManager.createOWLOntologyManager(); + OWLOntology emptyOntology = null; + try { + emptyOntology = m.createOntology(); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail("failed to create a new ontology"); + } + Clause c = new Clause(Clausifier.getInstance(emptyOntology), DLClause.create(headAtoms, bodyAtoms)); + System.out.println(c.toString()); + } + + @Test + public void test_inverse() { + Variable x = Variable.create("X"), y1 = Variable.create("y1"), y2 = Variable.create("y2"); + AtomicConcept A = AtomicConcept.create("A"); + AtomicRole r = AtomicRole.create("r"); + Atom[] bodyAtoms = new Atom[] { + Atom.create(A, x), + Atom.create(r, y1, x), + Atom.create(r, y2, x) + }; + + Atom[] headAtoms = new Atom[] { + Atom.create(Equality.INSTANCE, y1, y2) + }; + + OWLOntologyManager m = OWLManager.createOWLOntologyManager(); + OWLOntology emptyOntology = null; + try { + emptyOntology = m.createOntology(); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail("failed to create a new ontology"); + } + Clause c = new Clause(Clausifier.getInstance(emptyOntology), DLClause.create(headAtoms, bodyAtoms)); + System.out.println(c.toString()); + } + + @Test + public void test_fillter() { + Variable x = Variable.create("X"), y1 = Variable.create("y1"), y2 = Variable.create("y2"); + AtomicConcept A = AtomicConcept.create("A"); + AtomicConcept B = AtomicConcept.create("B"); + AtomicRole r = AtomicRole.create("r"); + Atom[] bodyAtoms = new Atom[] { + Atom.create(A, x), + Atom.create(r, y1, x), + Atom.create(r, y2, x), + Atom.create(B, y1), + Atom.create(B, y2) + }; + + Atom[] headAtoms = new Atom[] { + Atom.create(Equality.INSTANCE, y1, y2) + }; + + OWLOntologyManager m = OWLManager.createOWLOntologyManager(); + OWLOntology emptyOntology = null; + try { + emptyOntology = m.createOntology(); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail("failed to create a new ontology"); + } + Clause c = new Clause(Clausifier.getInstance(emptyOntology), DLClause.create(headAtoms, bodyAtoms)); + System.out.println(c.toString()); + } + + @Test + public void test_negFillter() { + Variable x = Variable.create("X"), y1 = Variable.create("y1"), y2 = Variable.create("y2"); + AtomicConcept A = AtomicConcept.create("A"); + AtomicConcept B = AtomicConcept.create("B"); + AtomicRole r = AtomicRole.create("r"); + Atom[] bodyAtoms = new Atom[] { + Atom.create(A, x), + Atom.create(r, y1, x), + Atom.create(r, y2, x) + }; + + Atom[] headAtoms = new Atom[] { + Atom.create(Equality.INSTANCE, y1, y2), + Atom.create(B, y1), + Atom.create(B, y2) + }; + + OWLOntologyManager m = OWLManager.createOWLOntologyManager(); + OWLOntology emptyOntology = null; + try { + emptyOntology = m.createOntology(); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail("failed to create a new ontology"); + } + Clause c = new Clause(Clausifier.getInstance(emptyOntology), DLClause.create(headAtoms, bodyAtoms)); + System.out.println(c.toString()); + } + +} diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/CostEvaluation.java b/test/uk/ac/ox/cs/pagoda/global_tests/CostEvaluation.java new file mode 100644 index 0000000..01e8203 --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/CostEvaluation.java @@ -0,0 +1,115 @@ +package uk.ac.ox.cs.pagoda.global_tests; + +import org.semanticweb.owlapi.model.OWLOntology; +import org.testng.annotations.Test; +import uk.ac.ox.cs.pagoda.owl.OWLHelper; +import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner; +import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner.Type; +import uk.ac.ox.cs.pagoda.tester.PagodaTester; +import uk.ac.ox.cs.pagoda.util.TestUtil; +import uk.ac.ox.cs.pagoda.util.Timer; +import uk.ac.ox.cs.pagoda.util.Utility; + +public class CostEvaluation { + + @Test + public void lubm100() { + int number = 1; + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( + TestUtil.combinePaths(ontoDir, "lubm/univ-bench.owl"), + TestUtil.combinePaths(ontoDir, "lubm/data/lubm" + number + ".ttl"), + TestUtil.combinePaths(ontoDir, "lubm/queries/test_all_pagoda.sparql") + ); +// AllTests.copy("output/log4j.log", "results-backup/jair/lubm" + number + ".out"); + } + + public void lubm1000() { + int number = 1000; + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + String[] args = new String[] { + TestUtil.combinePaths(ontoDir, "lubm/univ-bench.owl"), + TestUtil.combinePaths(ontoDir, "lubm/data/lubm" + number + ".ttl"), + TestUtil.combinePaths(ontoDir, "lubm/queries/test_all_pagoda.sparql") + }; + OWLOntology ontology = OWLHelper.loadOntology(args[0]); + QueryReasoner reasoner = QueryReasoner.getInstance(Type.ELHOU, ontology, true, true); + Timer t = new Timer(); + reasoner.loadOntology(ontology); + reasoner.importData(args[1]); + if (!reasoner.preprocess()) + return ; + Utility.logInfo("Preprocessing Done in " + t.duration() + " seconds."); + + reasoner.evaluate(reasoner.getQueryManager().collectQueryRecords(args[2])); +// AllTests.copy("output/log4j.log", "results-backup/jair/lubm" + number + ".out"); + } + + @Test + public void uobm5() { + int number = 1; + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + String[] args = new String[] { + TestUtil.combinePaths(ontoDir, "uobm/univ-bench-dl.owl"), + TestUtil.combinePaths(ontoDir, "uobm/data/uobm" + number + ".ttl"), + TestUtil.combinePaths(ontoDir, "uobm/queries/standard_all_pagoda.sparql") + }; + PagodaTester.main(args); +// AllTests.copy("output/log4j.log", "results-backup/jair/uobm" + number + ".out"); + } + + public void uobm100() { + int number = 200; + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + String[] args = new String[] { + TestUtil.combinePaths(ontoDir, "uobm/univ-bench-dl.owl"), + TestUtil.combinePaths(ontoDir, "uobm/data/uobm" + number + ".ttl"), + TestUtil.combinePaths(ontoDir, "uobm/queries/standard_group3_all.sparql") + }; + PagodaTester.main(args); +// AllTests.copy("output/log4j.log", "results-backup/jair/uobm" + number + ".out"); + } + + public void uobm500() { + int number = 500; + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + String[] args = new String[] { + TestUtil.combinePaths(ontoDir, "uobm/univ-bench-dl.owl"), + TestUtil.combinePaths(ontoDir, "uobm/data/uobm" + number + ".ttl"), + TestUtil.combinePaths(ontoDir, "uobm/queries/standard_all_pagoda.sparql") + }; + + OWLOntology ontology = OWLHelper.loadOntology(args[0]); + QueryReasoner reasoner = QueryReasoner.getInstance(Type.ELHOU, ontology, true, true); + Timer t = new Timer(); + reasoner.loadOntology(ontology); + reasoner.importData(args[1]); + if (!reasoner.preprocess()) + return ; + Utility.logInfo("Preprocessing Done in " + t.duration() + " seconds."); + + reasoner.evaluate(reasoner.getQueryManager().collectQueryRecords(args[2])); +// AllTests.copy("output/log4j.log", "results-backup/jair/uobm" + number + ".out"); + } + + + public static void main(String... args) { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + args = new String[] { + TestUtil.combinePaths(ontoDir, "dbpedia/integratedOntology-all-in-one-minus-datatype.owl"), + TestUtil.combinePaths(ontoDir, "dbpedia/data/dbpedia-minus-datatype-new.ttl"), + TestUtil.combinePaths(ontoDir, "dbpedia/queries/atomic_ground.sparql") + }; + + OWLOntology ontology = OWLHelper.loadOntology(args[0]); + QueryReasoner reasoner = QueryReasoner.getInstance(Type.ELHOU, ontology, true, true); + Timer t = new Timer(); + reasoner.loadOntology(ontology); + reasoner.importData(args[1]); + if (!reasoner.preprocess()) + return ; + Utility.logInfo("Preprocessing Done in " + t.duration() + " seconds."); + + reasoner.evaluate(reasoner.getQueryManager().collectQueryRecords(args[2])); + } +} diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/JAIR_PAGOdA.java b/test/uk/ac/ox/cs/pagoda/global_tests/JAIR_PAGOdA.java new file mode 100644 index 0000000..0d77fdb --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/JAIR_PAGOdA.java @@ -0,0 +1,193 @@ +package uk.ac.ox.cs.pagoda.global_tests; + +import org.testng.annotations.Test; +import uk.ac.ox.cs.pagoda.tester.PagodaTester; +import uk.ac.ox.cs.pagoda.util.TestUtil; + +import java.io.IOException; + +public class JAIR_PAGOdA { + + @Test + public void lubm1() throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + String[] args = new String[] { + TestUtil.combinePaths(ontoDir, "lubm/univ-bench.owl"), + TestUtil.combinePaths(ontoDir, "lubm/data/lubm1.ttl"), + TestUtil.combinePaths(ontoDir, "lubm/queries/test.sparql") + }; + PagodaTester.main(args); + TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/lubm1/pagoda"); + } + + @Test + public void lubm1_conj() throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + String[] args = new String[] { + TestUtil.combinePaths(ontoDir, "lubm/univ-bench.owl"), + TestUtil.combinePaths(ontoDir, "lubm/data/lubm1.ttl"), + TestUtil.combinePaths(ontoDir, "lubm/queries/test_pellet.sparql") + }; + PagodaTester.main(args); + TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/lubm1/pagoda_conj"); + } + + @Test + public void lubm1_rolledUp() throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( + "/home/yzhou/backup/20141212/univ-bench-queries.owl", + TestUtil.combinePaths(ontoDir, "lubm/data/lubm1.ttl"), + TestUtil.combinePaths(ontoDir, "lubm/queries/atomic_lubm.sparql") + ); + TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/lubm1/pagoda_rolledUp"); + } + + @Test + public void uobm1() throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + String[] args = new String[] { + TestUtil.combinePaths(ontoDir, "uobm/univ-bench-dl.owl"), + TestUtil.combinePaths(ontoDir, "uobm/data/uobm1.ttl"), + TestUtil.combinePaths(ontoDir, "uobm/queries/standard.sparql") + }; + PagodaTester.main(args); + TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/uobm1/pagoda"); + } + + @Test + public void uobm1_conj() throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + String[] args = new String[] { + TestUtil.combinePaths(ontoDir, "uobm/univ-bench-dl.owl"), + TestUtil.combinePaths(ontoDir, "uobm/data/uobm1.ttl"), + TestUtil.combinePaths(ontoDir, "uobm/queries/standard_pellet.sparql") + }; + PagodaTester.main(args); + TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/uobm1/pagoda_conj"); + } + + @Test + public void uobm1_rolledUp() { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + String[] args = new String[] { + "/home/yzhou/backup/20141212/univ-bench-dl-queries.owl", + TestUtil.combinePaths(ontoDir, "uobm/data/uobm1.ttl"), + TestUtil.combinePaths(ontoDir, "uobm/queries/atomic_uobm.sparql") + }; + PagodaTester.main(args); +// TestUtil.copyFile(("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/uobm1/pagoda_rolledUp"); + } + + @Test + public void fly() { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + String[] args = new String[] { + TestUtil.combinePaths(ontoDir, "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl"), + null, + TestUtil.combinePaths(ontoDir, "fly/queries/fly_pellet.sparql") + }; + PagodaTester.main(args); +// TestUtil.copyFile(("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/fly/pagoda"); + } + + @Test + public void fly_conj() throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + String[] args = new String[] { + TestUtil.combinePaths(ontoDir, "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl"), + null, + TestUtil.combinePaths(ontoDir, "fly/queries/fly_pellet.sparql") + }; + PagodaTester.main(args); + TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/fly/pagoda_conj"); + } + + + public void fly_rolledUp() { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( +// TestUtil.combinePaths(ontoDir, "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl", + TestUtil.combinePaths(ontoDir, "fly/fly-all-in-one_rolledUp.owl"), + null, + TestUtil.combinePaths(ontoDir, "fly/queries/fly_atomic.sparql") + ); +// TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/fly/pagoda_rolledUp"); + } + + public void dbpedia() { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( + TestUtil.combinePaths(ontoDir, "dbpedia/integratedOntology-all-in-one-minus-datatype.owl"), + TestUtil.combinePaths(ontoDir, "dbpedia/data/dbpedia-minus-datatype-new.ttl"), + TestUtil.combinePaths(ontoDir, "dbpedia/queries/atomic_ground.sparql"), + "dbpedia.ans" + ); + +// TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/dbpedia/pagoda"); + } + + public void npd() { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( + TestUtil.combinePaths(ontoDir, "npd/npd-all-minus-datatype.owl"), + TestUtil.combinePaths(ontoDir, "npd/data/npd-data-dump-minus-datatype-new.ttl"), + TestUtil.combinePaths(ontoDir, "npd/queries/atomic_ground.sparql") + , "npd.ans" + ); + +// TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/npd/pagoda"); + } + + public void reactome() throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( + TestUtil.combinePaths(ontoDir, "bio2rdf/reactome/biopax-level3-processed.owl"), + TestUtil.combinePaths(ontoDir, "bio2rdf/reactome/graph sampling/reactome_sample_10.ttl"), +// null, +// TestUtil.combinePaths(ontoDir, "bio2rdf/reactome/queries/atomic_ground.sparql") + TestUtil.combinePaths(ontoDir, "bio2rdf/reactome/queries/example.sparql") + , "pagoda_reactome.ans" + ); + TestUtil.copyFile("log4j.log", "output/jair/pagoda_reactome.example"); + +// TestUtil.copyFile(("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/reactome/pagoda_10p"); + } + + public void chembl() throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( + TestUtil.combinePaths(ontoDir, "bio2rdf/chembl/cco-noDPR.ttl"), + TestUtil.combinePaths(ontoDir, "bio2rdf/chembl/graph sampling/sample_1.nt"), +// TestUtil.combinePaths(ontoDir, "bio2rdf/chembl/queries/atomic_ground.sparql") + TestUtil.combinePaths(ontoDir, "bio2rdf/chembl/queries/example.sparql") + , "pagoda_chembl.ans" + ); + TestUtil.copyFile("log4j.log", "output/jair/pagoda_chembl.example"); +// TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/chembl/pagoda_1p"); + } + + public void uniprot() throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( + TestUtil.combinePaths(ontoDir, "bio2rdf/uniprot/core-sat-processed.owl"), + TestUtil.combinePaths(ontoDir, "bio2rdf/uniprot/graph sampling/sample_1.nt"), +// null, +// TestUtil.combinePaths(ontoDir, "bio2rdf/uniprot/queries/atomic_ground.sparql") + TestUtil.combinePaths(ontoDir, "bio2rdf/uniprot/queries/example.sparql") + , "pagoda_uniprot.ans" + ); + TestUtil.copyFile("log4j.log", "output/jair/pagoda_uniprot.example"); +// TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/uniprot/pagoda_1p"); + } + + + public static void main(String... args) { + try { + new JAIR_PAGOdA().lubm1(); + } catch (IOException e) { + e.printStackTrace(); + } + } + +} diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/JAIR_Scalability.java b/test/uk/ac/ox/cs/pagoda/global_tests/JAIR_Scalability.java new file mode 100644 index 0000000..cdf55bd --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/JAIR_Scalability.java @@ -0,0 +1,91 @@ +package uk.ac.ox.cs.pagoda.global_tests; + +import org.testng.annotations.Test; +import uk.ac.ox.cs.pagoda.tester.PagodaTester; +import uk.ac.ox.cs.pagoda.util.Properties; +import uk.ac.ox.cs.pagoda.util.TestUtil; + +import java.io.IOException; + +public class JAIR_Scalability { + + private static final String date = "_0123"; + + @Test + public void reactome() throws IOException { + testReactome(10, false); + } + + @Test + public void chembl() throws IOException { + testChEMBL(1, false); + } + + @Test + public void uniprot() throws IOException { + testUniProt(1, false); + } + + public void testReactome(int percentage, boolean save) throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + String[] args = new String[] { + TestUtil.combinePaths(ontoDir, "bio2rdf/reactome/biopax-level3-processed.owl"), + TestUtil.combinePaths(ontoDir, "bio2rdf/reactome/graph sampling/simplifed_sample_" + percentage + ".ttl"), + TestUtil.combinePaths(ontoDir, "bio2rdf/reactome/queries/test.sparql") + , "reactome.ans" + }; + if (percentage == 10) + args[1] = args[1].replace("simplifed", "reactome"); + + PagodaTester.main(args); + if (save) + TestUtil.copyFile("log4j.log", "/home/yzhou/java-workspace/test-share/results_new/reactome/pagoda_" + percentage + "p" + date); + } + + public void testChEMBL(int percentage, boolean save) throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + String[] args = new String[] { + TestUtil.combinePaths(ontoDir, "bio2rdf/chembl/cco-noDPR.ttl"), + TestUtil.combinePaths(ontoDir, "bio2rdf/chembl/sample_" + percentage + ".nt"), +// TestUtil.combinePaths(ontoDir, "bio2rdf/chembl/queries/atomic_ground.sparql") + TestUtil.combinePaths(ontoDir, "bio2rdf/chembl/queries/test.sparql") + , "chembl.ans" + }; + if (percentage == 1 || percentage == 10 || percentage == 50) + args[1] = args[1].replace("chembl", "chembl/graph sampling"); + else + if (percentage == 100) + args[1] = "/home/yzhou/RDFData/ChEMBL/facts/ChEMBL.ttl"; + + PagodaTester.main(args); + if (save) + TestUtil.copyFile("log4j.log", "/home/yzhou/java-workspace/test-share/results_new/chembl/pagoda_" + percentage + "p" + date); + } + + public void testUniProt(int percentage, boolean save) throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + String[] args = new String[] { + TestUtil.combinePaths(ontoDir, "bio2rdf/uniprot/core-sat-processed.owl"), + TestUtil.combinePaths(ontoDir, "bio2rdf/uniprot/sample_" + percentage + ".nt"), +// TestUtil.combinePaths(ontoDir, "bio2rdf/uniprot/queries/atomic_ground.sparql") + TestUtil.combinePaths(ontoDir, "bio2rdf/uniprot/queries/test.sparql") + , "uniprot.ans" + }; + + if (percentage == 1 || percentage == 10 || percentage == 50) + args[1] = args[1].replace("uniprot", "uniprot/graph sampling"); + else + if (percentage == 100) + args[1] = "/home/yzhou/krr-nas-share/Yujiao/ontologies/bio2rdf/uniprot/data/uniprot_cleaned.nt"; + + PagodaTester.main(args); + if (save) + TestUtil.copyFile("log4j.log", "/home/yzhou/java-workspace/test-share/results_new/uniprot/pagoda_" + percentage + "p" + date); + } + + public static void main(String... args) throws IOException { + Properties.ShellModeDefault = true; + new JAIR_Scalability().testUniProt(50, false); + } + +} diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/LightEvaluation.java b/test/uk/ac/ox/cs/pagoda/global_tests/LightEvaluation.java new file mode 100644 index 0000000..3ee268e --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/LightEvaluation.java @@ -0,0 +1,67 @@ +package uk.ac.ox.cs.pagoda.global_tests; + +import org.junit.Test; +import uk.ac.ox.cs.pagoda.tester.PagodaTester; +import uk.ac.ox.cs.pagoda.util.TestUtil; + +import java.io.IOException; + +public class LightEvaluation { + + @Test + public void uobm1() throws IOException { + int number = 1; + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( + TestUtil.combinePaths(ontoDir, "uobm/univ-bench-dl.owl"), + TestUtil.combinePaths(ontoDir, "uobm/data/uobm" + number + ".ttl"), + TestUtil.combinePaths(ontoDir, "uobm/queries/standard.sparql") + ); + TestUtil.copyFile("log4j.log", "output/jair/uobm1.out"); + } + + @Test + public void lubm100() throws IOException { + int number = 100; + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( + TestUtil.combinePaths(ontoDir, "lubm/univ-bench.owl"), + TestUtil.combinePaths(ontoDir, "lubm/data/lubm" + number + ".ttl"), + TestUtil.combinePaths(ontoDir, "lubm/queries/test.sparql") + ); + TestUtil.copyFile("log4j.log", "results-backup/current/lubm100.out"); + } + + @Test + public void fly() throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( + TestUtil.combinePaths(ontoDir, "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl"), + TestUtil.combinePaths(ontoDir, "fly/queries/fly.sparql") + ); + TestUtil.copyFile("log4j.log", "results-backup/current/fly.out"); + } + + @Test + public void dbpedia() throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( + TestUtil.combinePaths(ontoDir, "dbpedia/integratedOntology-all-in-one-minus-datatype.owl"), + TestUtil.combinePaths(ontoDir, "dbpedia/data/dbpedia-minus-datatype-new.ttl"), + TestUtil.combinePaths(ontoDir, "dbpedia/atomic.sparql") + ); + TestUtil.copyFile("log4j.log", "results-backup/current/dbpedia.out"); + } + + @Test + public void npdWithoutDataType() throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( + TestUtil.combinePaths(ontoDir, "npd/npd-all-minus-datatype.owl"), + TestUtil.combinePaths(ontoDir, "npd/data/npd-data-dump-minus-datatype-new.ttl"), + TestUtil.combinePaths(ontoDir, "npd/queries/atomic.sparql") + ); + TestUtil.copyFile("log4j.log", "results-backup/current/npd_minus.out"); + } + +} diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/PagodaDBPedia.java b/test/uk/ac/ox/cs/pagoda/global_tests/PagodaDBPedia.java new file mode 100644 index 0000000..2b9cdbd --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/PagodaDBPedia.java @@ -0,0 +1,30 @@ +package uk.ac.ox.cs.pagoda.global_tests; + +import org.junit.Test; +import uk.ac.ox.cs.pagoda.tester.PagodaTester; +import uk.ac.ox.cs.pagoda.tester.Statistics; +import uk.ac.ox.cs.pagoda.util.TestUtil; + +import java.io.IOException; + +import static org.junit.Assert.fail; + +public class PagodaDBPedia { + + @Test + public void test() throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( + TestUtil.combinePaths(ontoDir, "dbpedia/integratedOntology-all-in-one-minus-datatype.owl"), + TestUtil.combinePaths(ontoDir, "dbpedia/data/dbpedia-minus-datatype-new.ttl"), + TestUtil.combinePaths(ontoDir, "dbpedia/atomic.sparql") + ); + + Statistics stat = new Statistics("output/log4j.log"); + String diff = stat.diff("results-backup/benchmark/dbpedia.out"); + TestUtil.copyFile("output/log4j.log", "results-backup/current/dbpedia.out"); + if (!diff.isEmpty()) + fail(diff); + } + +} diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/PagodaELU.java b/test/uk/ac/ox/cs/pagoda/global_tests/PagodaELU.java new file mode 100644 index 0000000..da059f9 --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/PagodaELU.java @@ -0,0 +1,20 @@ +package uk.ac.ox.cs.pagoda.global_tests; + +import org.junit.Test; +import uk.ac.ox.cs.pagoda.tester.PagodaTester; +import uk.ac.ox.cs.pagoda.util.TestUtil; + +public class PagodaELU { + + @Test void test() { + int number = 1; + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( + TestUtil.combinePaths(ontoDir, "uobm/univ-bench-dl.owl"), + TestUtil.combinePaths(ontoDir, "uobm/data/uobm" + number + ".ttl"), + TestUtil.combinePaths(ontoDir, "uobm/queries/standard.sparql") + ); + } + + +} diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/PagodaFLY.java b/test/uk/ac/ox/cs/pagoda/global_tests/PagodaFLY.java new file mode 100644 index 0000000..d558e0f --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/PagodaFLY.java @@ -0,0 +1,25 @@ +package uk.ac.ox.cs.pagoda.global_tests; + +import org.junit.Test; +import uk.ac.ox.cs.pagoda.tester.PagodaTester; +import uk.ac.ox.cs.pagoda.util.TestUtil; + +public class PagodaFLY { + + @Test + public void test() { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( + TestUtil.combinePaths(ontoDir, "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl"), + TestUtil.combinePaths(ontoDir, "fly/queries/fly_pellet.sparql") + ); + +// Statistics stat = new Statistics("output/log4j.log"); +// String diff = stat.diff("results-backup/benchmark/fly.out"); +// AllTests.copy("output/log4j.log", "results-backup/current/fly.out"); +// if (!diff.isEmpty()) +// fail(diff); + } + + +} diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/PagodaLUBM.java b/test/uk/ac/ox/cs/pagoda/global_tests/PagodaLUBM.java new file mode 100644 index 0000000..2014ec1 --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/PagodaLUBM.java @@ -0,0 +1,24 @@ +package uk.ac.ox.cs.pagoda.global_tests; + +import org.testng.annotations.Test; +import uk.ac.ox.cs.pagoda.util.TestUtil; + +import java.io.IOException; +import java.nio.file.Paths; + +public class PagodaLUBM { + + private void testN(int number ) throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + TestGlobalCorrectness.test(Paths.get(ontoDir, "lubm/univ-bench.owl"), + Paths.get(ontoDir, "lubm/data/lubm" + number + ".ttl"), + Paths.get(ontoDir, "lubm/queries/test.sparql"), + Paths.get(ontoDir, "lubm/lubm" + number + ".json")); + } + + @Test + public void test1() throws IOException { + testN(1); + } + +} diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/PagodaNPD.java b/test/uk/ac/ox/cs/pagoda/global_tests/PagodaNPD.java new file mode 100644 index 0000000..17d1e82 --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/PagodaNPD.java @@ -0,0 +1,46 @@ +package uk.ac.ox.cs.pagoda.global_tests; + +import org.junit.Test; +import uk.ac.ox.cs.pagoda.tester.PagodaTester; +import uk.ac.ox.cs.pagoda.tester.Statistics; +import uk.ac.ox.cs.pagoda.util.TestUtil; + +import java.io.IOException; + +import static org.junit.Assert.fail; + +public class PagodaNPD { + + @Test + public void testNPDwithoutDataType() throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( + TestUtil.combinePaths(ontoDir, "npd/npd-all-minus-datatype.owl"), + TestUtil.combinePaths(ontoDir, "npd/data/npd-data-dump-minus-datatype-new.ttl"), + TestUtil.combinePaths(ontoDir, "npd/queries/atomic.sparql") + ); + + Statistics stat = new Statistics("output/log4j.log"); + String diff = stat.diff("results-backup/benchmark/npd_minus.out"); + TestUtil.copyFile("output/log4j.log", "results-backup/current/npd_minus.out"); + if (!diff.isEmpty()) + fail(diff); + } + + @Test + public void testNPD() throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( + TestUtil.combinePaths(ontoDir, "npd/npd-all.owl"), + TestUtil.combinePaths(ontoDir, "npd/data/npd-data-dump-processed.ttl"), + TestUtil.combinePaths(ontoDir, "npd/queries/atomic.sparql") + ); + + Statistics stat = new Statistics("output/log4j.log"); + String diff = stat.diff("results-backup/benchmark/npd.out"); + TestUtil.copyFile("output/log4j.log", "results-backup/current/npd.out"); + if (!diff.isEmpty()) + fail(diff); + } + +} diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/PagodaNPD_bench.java b/test/uk/ac/ox/cs/pagoda/global_tests/PagodaNPD_bench.java new file mode 100644 index 0000000..c908cb4 --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/PagodaNPD_bench.java @@ -0,0 +1,30 @@ +package uk.ac.ox.cs.pagoda.global_tests; + +import org.junit.Test; +import uk.ac.ox.cs.pagoda.tester.PagodaTester; +import uk.ac.ox.cs.pagoda.tester.Statistics; +import uk.ac.ox.cs.pagoda.util.TestUtil; + +import java.io.IOException; + +import static org.junit.Assert.fail; + +public class PagodaNPD_bench { + + @Test + public void test() throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( + TestUtil.combinePaths(ontoDir, "npd-benchmark/npd-v2-ql_a.owl"), + TestUtil.combinePaths(ontoDir, "npd-benchmark/npd-v2-ql_a.ttl"), + TestUtil.combinePaths(ontoDir, "npd-benchmark/queries/all.sparql") + ); + + Statistics stat = new Statistics("output/log4j.log"); + String diff = stat.diff("results-backup/benchmark/npd-bench.out"); + TestUtil.copyFile("output/log4j.log", "results-backup/current/npd-bench.out"); + if (!diff.isEmpty()) + fail(diff); + } + +} diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/PagodaRLU.java b/test/uk/ac/ox/cs/pagoda/global_tests/PagodaRLU.java new file mode 100644 index 0000000..88e0835 --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/PagodaRLU.java @@ -0,0 +1,20 @@ +package uk.ac.ox.cs.pagoda.global_tests; + +import org.junit.Test; +import uk.ac.ox.cs.pagoda.tester.PagodaTester; +import uk.ac.ox.cs.pagoda.util.TestUtil; + +public class PagodaRLU { + + @Test + public void testRL() { + int number = 1; + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( + TestUtil.combinePaths(ontoDir, "uobm/univ-bench-dl.owl"), + TestUtil.combinePaths(ontoDir, "uobm/data/uobm" + number + ".ttl"), + TestUtil.combinePaths(ontoDir, "uobm/queries/standard.sparql") + ); + } + +} diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/PagodaUOBM.java b/test/uk/ac/ox/cs/pagoda/global_tests/PagodaUOBM.java new file mode 100644 index 0000000..065fb29 --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/PagodaUOBM.java @@ -0,0 +1,53 @@ +package uk.ac.ox.cs.pagoda.global_tests; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; +import uk.ac.ox.cs.pagoda.tester.PagodaTester; +import uk.ac.ox.cs.pagoda.util.TestUtil; + +import java.io.IOException; +import java.nio.file.Paths; + +import static uk.ac.ox.cs.pagoda.util.TestUtil.combinePaths; + +public class PagodaUOBM { + + private void testN(int number ) throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + TestGlobalCorrectness.test(Paths.get(ontoDir, "uobm/univ-bench-dl.owl"), + Paths.get(ontoDir, "uobm/data/uobm" + number + ".ttl"), + Paths.get(ontoDir, "uobm/queries/test.sparql"), + Paths.get(ontoDir, "uobm/uobm" + number + ".json")); + } + + @Test + public void test1() throws IOException { + testN(1); + } + + private static final int N_1 = 8; + private static final int N_2 = 10; + + + @DataProvider(name = "uobmNumbers") + public static Object[][] uobmNumbers() { + Integer[][] integers = new Integer[N_2 - N_1 + 1][1]; + for (int i = 0; i < N_2 - N_1 + 1; i++) + integers[i][0]= N_1 + i; + return integers; + } + +// @Test +// public void justExecute3() { +// justExecute(1); +// } + + @Test(dataProvider = "uobmNumbers") + public void justExecute(int number) { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main(combinePaths(ontoDir, "uobm/univ-bench-dl.owl"), + combinePaths(ontoDir, "uobm/data/uobm" + number + ".ttl"), + combinePaths(ontoDir, "uobm/queries/test.sparql")); + } + +} diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/TestGlobalCorrectness.java b/test/uk/ac/ox/cs/pagoda/global_tests/TestGlobalCorrectness.java new file mode 100644 index 0000000..dff2366 --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/TestGlobalCorrectness.java @@ -0,0 +1,53 @@ +package uk.ac.ox.cs.pagoda.global_tests; + +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import org.apache.log4j.Level; +import org.testng.Assert; +import uk.ac.ox.cs.pagoda.query.QueryRecord; +import uk.ac.ox.cs.pagoda.tester.PagodaTester; +import uk.ac.ox.cs.pagoda.util.Utility; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Type; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Set; + +/** + * This is a unit test for TestNG. + *

+ * It tests the correctness on the final output. + * */ +public class TestGlobalCorrectness { + + public static void test(Path ontology, Path data, Path queries, Path givenAnswers) { + try { + Utility.setLogLevel(Level.DEBUG); + Path computedAnswers = Paths.get(File.createTempFile("answers", ".json").getAbsolutePath()); + new File(computedAnswers.toString()).deleteOnExit(); + PagodaTester.main(ontology.toString(), data.toString(), queries.toString(), computedAnswers.toString()); + assertSameContent(computedAnswers, givenAnswers); + } catch (IOException e) { + e.printStackTrace(); + } + } + + private static void assertSameContent(Path computedAnswersFile, Path givenAnswersFile) throws IOException { + BufferedReader computedReader = Files.newBufferedReader(computedAnswersFile); + BufferedReader givenReader = Files.newBufferedReader(givenAnswersFile); + + Gson gson = QueryRecord.GsonCreator.getInstance(); + + Type cqType = new TypeToken>() {}.getType(); + Set computedAnswers = gson.fromJson(computedReader, cqType); + Set givenAnswers = gson.fromJson(givenReader, cqType); + + Assert.assertEquals(computedAnswers, givenAnswers); + } + + +} diff --git a/test/uk/ac/ox/cs/pagoda/test_units/ClauseTester.java b/test/uk/ac/ox/cs/pagoda/test_units/ClauseTester.java deleted file mode 100644 index a0f16d4..0000000 --- a/test/uk/ac/ox/cs/pagoda/test_units/ClauseTester.java +++ /dev/null @@ -1,164 +0,0 @@ -package uk.ac.ox.cs.pagoda.test_units; - -import org.semanticweb.HermiT.model.Atom; -import org.semanticweb.HermiT.model.AtomicConcept; -import org.semanticweb.HermiT.model.AtomicRole; -import org.semanticweb.HermiT.model.DLClause; -import org.semanticweb.HermiT.model.Equality; -import org.semanticweb.HermiT.model.Variable; -import org.semanticweb.owlapi.apibinding.OWLManager; -import org.semanticweb.owlapi.model.OWLOntology; -import org.semanticweb.owlapi.model.OWLOntologyManager; - -import org.testng.Assert; -import org.testng.annotations.Test; -import uk.ac.ox.cs.pagoda.approx.Clause; -import uk.ac.ox.cs.pagoda.approx.Clausifier; - -public class ClauseTester { - - @Test - public void test_simple() { - Variable x = Variable.create("X"), y1 = Variable.create("y1"), y2 = Variable.create("y2"); - AtomicConcept A = AtomicConcept.create("A"); - AtomicRole r = AtomicRole.create("r"); - Atom[] bodyAtoms = new Atom[] { - Atom.create(A, x), - Atom.create(r, x, y1), - Atom.create(r, x, y2) - }; - - Atom[] headAtoms = new Atom[] { - Atom.create(Equality.INSTANCE, y1, y2) - }; - - OWLOntologyManager m = OWLManager.createOWLOntologyManager(); - OWLOntology emptyOntology = null; - try { - emptyOntology = m.createOntology(); - } catch (Exception e) { - e.printStackTrace(); - Assert.fail("failed to create a new ontology"); - } - Clause c = new Clause(Clausifier.getInstance(emptyOntology), DLClause.create(headAtoms, bodyAtoms)); - System.out.println(c.toString()); - } - - @Test - public void test_more() { - Variable x = Variable.create("X"), y1 = Variable.create("y1"), y2 = Variable.create("y2"), y3 = Variable.create("y3"); - AtomicConcept A = AtomicConcept.create("A"); - AtomicRole r = AtomicRole.create("r"); - Atom[] bodyAtoms = new Atom[] { - Atom.create(A, x), - Atom.create(r, x, y1), - Atom.create(r, x, y2), - Atom.create(r, x, y3), - }; - - Atom[] headAtoms = new Atom[] { - Atom.create(Equality.INSTANCE, y1, y2), - Atom.create(Equality.INSTANCE, y1, y3), - Atom.create(Equality.INSTANCE, y2, y3) - }; - - OWLOntologyManager m = OWLManager.createOWLOntologyManager(); - OWLOntology emptyOntology = null; - try { - emptyOntology = m.createOntology(); - } catch (Exception e) { - e.printStackTrace(); - Assert.fail("failed to create a new ontology"); - } - Clause c = new Clause(Clausifier.getInstance(emptyOntology), DLClause.create(headAtoms, bodyAtoms)); - System.out.println(c.toString()); - } - - @Test - public void test_inverse() { - Variable x = Variable.create("X"), y1 = Variable.create("y1"), y2 = Variable.create("y2"); - AtomicConcept A = AtomicConcept.create("A"); - AtomicRole r = AtomicRole.create("r"); - Atom[] bodyAtoms = new Atom[] { - Atom.create(A, x), - Atom.create(r, y1, x), - Atom.create(r, y2, x) - }; - - Atom[] headAtoms = new Atom[] { - Atom.create(Equality.INSTANCE, y1, y2) - }; - - OWLOntologyManager m = OWLManager.createOWLOntologyManager(); - OWLOntology emptyOntology = null; - try { - emptyOntology = m.createOntology(); - } catch (Exception e) { - e.printStackTrace(); - Assert.fail("failed to create a new ontology"); - } - Clause c = new Clause(Clausifier.getInstance(emptyOntology), DLClause.create(headAtoms, bodyAtoms)); - System.out.println(c.toString()); - } - - @Test - public void test_fillter() { - Variable x = Variable.create("X"), y1 = Variable.create("y1"), y2 = Variable.create("y2"); - AtomicConcept A = AtomicConcept.create("A"); - AtomicConcept B = AtomicConcept.create("B"); - AtomicRole r = AtomicRole.create("r"); - Atom[] bodyAtoms = new Atom[] { - Atom.create(A, x), - Atom.create(r, y1, x), - Atom.create(r, y2, x), - Atom.create(B, y1), - Atom.create(B, y2) - }; - - Atom[] headAtoms = new Atom[] { - Atom.create(Equality.INSTANCE, y1, y2) - }; - - OWLOntologyManager m = OWLManager.createOWLOntologyManager(); - OWLOntology emptyOntology = null; - try { - emptyOntology = m.createOntology(); - } catch (Exception e) { - e.printStackTrace(); - Assert.fail("failed to create a new ontology"); - } - Clause c = new Clause(Clausifier.getInstance(emptyOntology), DLClause.create(headAtoms, bodyAtoms)); - System.out.println(c.toString()); - } - - @Test - public void test_negFillter() { - Variable x = Variable.create("X"), y1 = Variable.create("y1"), y2 = Variable.create("y2"); - AtomicConcept A = AtomicConcept.create("A"); - AtomicConcept B = AtomicConcept.create("B"); - AtomicRole r = AtomicRole.create("r"); - Atom[] bodyAtoms = new Atom[] { - Atom.create(A, x), - Atom.create(r, y1, x), - Atom.create(r, y2, x) - }; - - Atom[] headAtoms = new Atom[] { - Atom.create(Equality.INSTANCE, y1, y2), - Atom.create(B, y1), - Atom.create(B, y2) - }; - - OWLOntologyManager m = OWLManager.createOWLOntologyManager(); - OWLOntology emptyOntology = null; - try { - emptyOntology = m.createOntology(); - } catch (Exception e) { - e.printStackTrace(); - Assert.fail("failed to create a new ontology"); - } - Clause c = new Clause(Clausifier.getInstance(emptyOntology), DLClause.create(headAtoms, bodyAtoms)); - System.out.println(c.toString()); - } - -} diff --git a/test/uk/ac/ox/cs/pagoda/test_units/CostEvaluation.java b/test/uk/ac/ox/cs/pagoda/test_units/CostEvaluation.java deleted file mode 100644 index 968cf01..0000000 --- a/test/uk/ac/ox/cs/pagoda/test_units/CostEvaluation.java +++ /dev/null @@ -1,115 +0,0 @@ -package uk.ac.ox.cs.pagoda.test_units; - -import org.semanticweb.owlapi.model.OWLOntology; -import org.testng.annotations.Test; -import uk.ac.ox.cs.pagoda.owl.OWLHelper; -import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner; -import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner.Type; -import uk.ac.ox.cs.pagoda.tester.PagodaTester; -import uk.ac.ox.cs.pagoda.util.TestUtil; -import uk.ac.ox.cs.pagoda.util.Timer; -import uk.ac.ox.cs.pagoda.util.Utility; - -public class CostEvaluation { - - @Test - public void lubm100() { - int number = 1; - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - PagodaTester.main( - TestUtil.combinePaths(ontoDir, "lubm/univ-bench.owl"), - TestUtil.combinePaths(ontoDir, "lubm/data/lubm" + number + ".ttl"), - TestUtil.combinePaths(ontoDir, "lubm/queries/test_all_pagoda.sparql") - ); -// AllTests.copy("output/log4j.log", "results-backup/jair/lubm" + number + ".out"); - } - - public void lubm1000() { - int number = 1000; - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - String[] args = new String[] { - TestUtil.combinePaths(ontoDir, "lubm/univ-bench.owl"), - TestUtil.combinePaths(ontoDir, "lubm/data/lubm" + number + ".ttl"), - TestUtil.combinePaths(ontoDir, "lubm/queries/test_all_pagoda.sparql") - }; - OWLOntology ontology = OWLHelper.loadOntology(args[0]); - QueryReasoner reasoner = QueryReasoner.getInstance(Type.ELHOU, ontology, true, true); - Timer t = new Timer(); - reasoner.loadOntology(ontology); - reasoner.importData(args[1]); - if (!reasoner.preprocess()) - return ; - Utility.logInfo("Preprocessing Done in " + t.duration() + " seconds."); - - reasoner.evaluate(reasoner.getQueryManager().collectQueryRecords(args[2])); -// AllTests.copy("output/log4j.log", "results-backup/jair/lubm" + number + ".out"); - } - - @Test - public void uobm5() { - int number = 1; - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - String[] args = new String[] { - TestUtil.combinePaths(ontoDir, "uobm/univ-bench-dl.owl"), - TestUtil.combinePaths(ontoDir, "uobm/data/uobm" + number + ".ttl"), - TestUtil.combinePaths(ontoDir, "uobm/queries/standard_all_pagoda.sparql") - }; - PagodaTester.main(args); -// AllTests.copy("output/log4j.log", "results-backup/jair/uobm" + number + ".out"); - } - - public void uobm100() { - int number = 200; - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - String[] args = new String[] { - TestUtil.combinePaths(ontoDir, "uobm/univ-bench-dl.owl"), - TestUtil.combinePaths(ontoDir, "uobm/data/uobm" + number + ".ttl"), - TestUtil.combinePaths(ontoDir, "uobm/queries/standard_group3_all.sparql") - }; - PagodaTester.main(args); -// AllTests.copy("output/log4j.log", "results-backup/jair/uobm" + number + ".out"); - } - - public void uobm500() { - int number = 500; - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - String[] args = new String[] { - TestUtil.combinePaths(ontoDir, "uobm/univ-bench-dl.owl"), - TestUtil.combinePaths(ontoDir, "uobm/data/uobm" + number + ".ttl"), - TestUtil.combinePaths(ontoDir, "uobm/queries/standard_all_pagoda.sparql") - }; - - OWLOntology ontology = OWLHelper.loadOntology(args[0]); - QueryReasoner reasoner = QueryReasoner.getInstance(Type.ELHOU, ontology, true, true); - Timer t = new Timer(); - reasoner.loadOntology(ontology); - reasoner.importData(args[1]); - if (!reasoner.preprocess()) - return ; - Utility.logInfo("Preprocessing Done in " + t.duration() + " seconds."); - - reasoner.evaluate(reasoner.getQueryManager().collectQueryRecords(args[2])); -// AllTests.copy("output/log4j.log", "results-backup/jair/uobm" + number + ".out"); - } - - - public static void main(String... args) { - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - args = new String[] { - TestUtil.combinePaths(ontoDir, "dbpedia/integratedOntology-all-in-one-minus-datatype.owl"), - TestUtil.combinePaths(ontoDir, "dbpedia/data/dbpedia-minus-datatype-new.ttl"), - TestUtil.combinePaths(ontoDir, "dbpedia/queries/atomic_ground.sparql") - }; - - OWLOntology ontology = OWLHelper.loadOntology(args[0]); - QueryReasoner reasoner = QueryReasoner.getInstance(Type.ELHOU, ontology, true, true); - Timer t = new Timer(); - reasoner.loadOntology(ontology); - reasoner.importData(args[1]); - if (!reasoner.preprocess()) - return ; - Utility.logInfo("Preprocessing Done in " + t.duration() + " seconds."); - - reasoner.evaluate(reasoner.getQueryManager().collectQueryRecords(args[2])); - } -} diff --git a/test/uk/ac/ox/cs/pagoda/test_units/JAIR_PAGOdA.java b/test/uk/ac/ox/cs/pagoda/test_units/JAIR_PAGOdA.java deleted file mode 100644 index 10ac974..0000000 --- a/test/uk/ac/ox/cs/pagoda/test_units/JAIR_PAGOdA.java +++ /dev/null @@ -1,193 +0,0 @@ -package uk.ac.ox.cs.pagoda.test_units; - -import org.testng.annotations.Test; -import uk.ac.ox.cs.pagoda.tester.PagodaTester; -import uk.ac.ox.cs.pagoda.util.TestUtil; - -import java.io.IOException; - -public class JAIR_PAGOdA { - - @Test - public void lubm1() throws IOException { - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - String[] args = new String[] { - TestUtil.combinePaths(ontoDir, "lubm/univ-bench.owl"), - TestUtil.combinePaths(ontoDir, "lubm/data/lubm1.ttl"), - TestUtil.combinePaths(ontoDir, "lubm/queries/test.sparql") - }; - PagodaTester.main(args); - TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/lubm1/pagoda"); - } - - @Test - public void lubm1_conj() throws IOException { - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - String[] args = new String[] { - TestUtil.combinePaths(ontoDir, "lubm/univ-bench.owl"), - TestUtil.combinePaths(ontoDir, "lubm/data/lubm1.ttl"), - TestUtil.combinePaths(ontoDir, "lubm/queries/test_pellet.sparql") - }; - PagodaTester.main(args); - TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/lubm1/pagoda_conj"); - } - - @Test - public void lubm1_rolledUp() throws IOException { - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - PagodaTester.main( - "/home/yzhou/backup/20141212/univ-bench-queries.owl", - TestUtil.combinePaths(ontoDir, "lubm/data/lubm1.ttl"), - TestUtil.combinePaths(ontoDir, "lubm/queries/atomic_lubm.sparql") - ); - TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/lubm1/pagoda_rolledUp"); - } - - @Test - public void uobm1() throws IOException { - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - String[] args = new String[] { - TestUtil.combinePaths(ontoDir, "uobm/univ-bench-dl.owl"), - TestUtil.combinePaths(ontoDir, "uobm/data/uobm1.ttl"), - TestUtil.combinePaths(ontoDir, "uobm/queries/standard.sparql") - }; - PagodaTester.main(args); - TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/uobm1/pagoda"); - } - - @Test - public void uobm1_conj() throws IOException { - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - String[] args = new String[] { - TestUtil.combinePaths(ontoDir, "uobm/univ-bench-dl.owl"), - TestUtil.combinePaths(ontoDir, "uobm/data/uobm1.ttl"), - TestUtil.combinePaths(ontoDir, "uobm/queries/standard_pellet.sparql") - }; - PagodaTester.main(args); - TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/uobm1/pagoda_conj"); - } - - @Test - public void uobm1_rolledUp() { - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - String[] args = new String[] { - "/home/yzhou/backup/20141212/univ-bench-dl-queries.owl", - TestUtil.combinePaths(ontoDir, "uobm/data/uobm1.ttl"), - TestUtil.combinePaths(ontoDir, "uobm/queries/atomic_uobm.sparql") - }; - PagodaTester.main(args); -// TestUtil.copyFile(("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/uobm1/pagoda_rolledUp"); - } - - @Test - public void fly() { - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - String[] args = new String[] { - TestUtil.combinePaths(ontoDir, "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl"), - null, - TestUtil.combinePaths(ontoDir, "fly/queries/fly_pellet.sparql") - }; - PagodaTester.main(args); -// TestUtil.copyFile(("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/fly/pagoda"); - } - - @Test - public void fly_conj() throws IOException { - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - String[] args = new String[] { - TestUtil.combinePaths(ontoDir, "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl"), - null, - TestUtil.combinePaths(ontoDir, "fly/queries/fly_pellet.sparql") - }; - PagodaTester.main(args); - TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/fly/pagoda_conj"); - } - - - public void fly_rolledUp() { - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - PagodaTester.main( -// TestUtil.combinePaths(ontoDir, "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl", - TestUtil.combinePaths(ontoDir, "fly/fly-all-in-one_rolledUp.owl"), - null, - TestUtil.combinePaths(ontoDir, "fly/queries/fly_atomic.sparql") - ); -// TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/fly/pagoda_rolledUp"); - } - - public void dbpedia() { - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - PagodaTester.main( - TestUtil.combinePaths(ontoDir, "dbpedia/integratedOntology-all-in-one-minus-datatype.owl"), - TestUtil.combinePaths(ontoDir, "dbpedia/data/dbpedia-minus-datatype-new.ttl"), - TestUtil.combinePaths(ontoDir, "dbpedia/queries/atomic_ground.sparql"), - "dbpedia.ans" - ); - -// TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/dbpedia/pagoda"); - } - - public void npd() { - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - PagodaTester.main( - TestUtil.combinePaths(ontoDir, "npd/npd-all-minus-datatype.owl"), - TestUtil.combinePaths(ontoDir, "npd/data/npd-data-dump-minus-datatype-new.ttl"), - TestUtil.combinePaths(ontoDir, "npd/queries/atomic_ground.sparql") - , "npd.ans" - ); - -// TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/npd/pagoda"); - } - - public void reactome() throws IOException { - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - PagodaTester.main( - TestUtil.combinePaths(ontoDir, "bio2rdf/reactome/biopax-level3-processed.owl"), - TestUtil.combinePaths(ontoDir, "bio2rdf/reactome/graph sampling/reactome_sample_10.ttl"), -// null, -// TestUtil.combinePaths(ontoDir, "bio2rdf/reactome/queries/atomic_ground.sparql") - TestUtil.combinePaths(ontoDir, "bio2rdf/reactome/queries/example.sparql") - , "pagoda_reactome.ans" - ); - TestUtil.copyFile("log4j.log", "output/jair/pagoda_reactome.example"); - -// TestUtil.copyFile(("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/reactome/pagoda_10p"); - } - - public void chembl() throws IOException { - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - PagodaTester.main( - TestUtil.combinePaths(ontoDir, "bio2rdf/chembl/cco-noDPR.ttl"), - TestUtil.combinePaths(ontoDir, "bio2rdf/chembl/graph sampling/sample_1.nt"), -// TestUtil.combinePaths(ontoDir, "bio2rdf/chembl/queries/atomic_ground.sparql") - TestUtil.combinePaths(ontoDir, "bio2rdf/chembl/queries/example.sparql") - , "pagoda_chembl.ans" - ); - TestUtil.copyFile("log4j.log", "output/jair/pagoda_chembl.example"); -// TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/chembl/pagoda_1p"); - } - - public void uniprot() throws IOException { - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - PagodaTester.main( - TestUtil.combinePaths(ontoDir, "bio2rdf/uniprot/core-sat-processed.owl"), - TestUtil.combinePaths(ontoDir, "bio2rdf/uniprot/graph sampling/sample_1.nt"), -// null, -// TestUtil.combinePaths(ontoDir, "bio2rdf/uniprot/queries/atomic_ground.sparql") - TestUtil.combinePaths(ontoDir, "bio2rdf/uniprot/queries/example.sparql") - , "pagoda_uniprot.ans" - ); - TestUtil.copyFile("log4j.log", "output/jair/pagoda_uniprot.example"); -// TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/uniprot/pagoda_1p"); - } - - - public static void main(String... args) { - try { - new JAIR_PAGOdA().lubm1(); - } catch (IOException e) { - e.printStackTrace(); - } - } - -} diff --git a/test/uk/ac/ox/cs/pagoda/test_units/JAIR_Scalability.java b/test/uk/ac/ox/cs/pagoda/test_units/JAIR_Scalability.java deleted file mode 100644 index 2cf8446..0000000 --- a/test/uk/ac/ox/cs/pagoda/test_units/JAIR_Scalability.java +++ /dev/null @@ -1,91 +0,0 @@ -package uk.ac.ox.cs.pagoda.test_units; - -import org.testng.annotations.Test; -import uk.ac.ox.cs.pagoda.tester.PagodaTester; -import uk.ac.ox.cs.pagoda.util.Properties; -import uk.ac.ox.cs.pagoda.util.TestUtil; - -import java.io.IOException; - -public class JAIR_Scalability { - - private static final String date = "_0123"; - - @Test - public void reactome() throws IOException { - testReactome(10, false); - } - - @Test - public void chembl() throws IOException { - testChEMBL(1, false); - } - - @Test - public void uniprot() throws IOException { - testUniProt(1, false); - } - - public void testReactome(int percentage, boolean save) throws IOException { - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - String[] args = new String[] { - TestUtil.combinePaths(ontoDir, "bio2rdf/reactome/biopax-level3-processed.owl"), - TestUtil.combinePaths(ontoDir, "bio2rdf/reactome/graph sampling/simplifed_sample_" + percentage + ".ttl"), - TestUtil.combinePaths(ontoDir, "bio2rdf/reactome/queries/test.sparql") - , "reactome.ans" - }; - if (percentage == 10) - args[1] = args[1].replace("simplifed", "reactome"); - - PagodaTester.main(args); - if (save) - TestUtil.copyFile("log4j.log", "/home/yzhou/java-workspace/test-share/results_new/reactome/pagoda_" + percentage + "p" + date); - } - - public void testChEMBL(int percentage, boolean save) throws IOException { - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - String[] args = new String[] { - TestUtil.combinePaths(ontoDir, "bio2rdf/chembl/cco-noDPR.ttl"), - TestUtil.combinePaths(ontoDir, "bio2rdf/chembl/sample_" + percentage + ".nt"), -// TestUtil.combinePaths(ontoDir, "bio2rdf/chembl/queries/atomic_ground.sparql") - TestUtil.combinePaths(ontoDir, "bio2rdf/chembl/queries/test.sparql") - , "chembl.ans" - }; - if (percentage == 1 || percentage == 10 || percentage == 50) - args[1] = args[1].replace("chembl", "chembl/graph sampling"); - else - if (percentage == 100) - args[1] = "/home/yzhou/RDFData/ChEMBL/facts/ChEMBL.ttl"; - - PagodaTester.main(args); - if (save) - TestUtil.copyFile("log4j.log", "/home/yzhou/java-workspace/test-share/results_new/chembl/pagoda_" + percentage + "p" + date); - } - - public void testUniProt(int percentage, boolean save) throws IOException { - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - String[] args = new String[] { - TestUtil.combinePaths(ontoDir, "bio2rdf/uniprot/core-sat-processed.owl"), - TestUtil.combinePaths(ontoDir, "bio2rdf/uniprot/sample_" + percentage + ".nt"), -// TestUtil.combinePaths(ontoDir, "bio2rdf/uniprot/queries/atomic_ground.sparql") - TestUtil.combinePaths(ontoDir, "bio2rdf/uniprot/queries/test.sparql") - , "uniprot.ans" - }; - - if (percentage == 1 || percentage == 10 || percentage == 50) - args[1] = args[1].replace("uniprot", "uniprot/graph sampling"); - else - if (percentage == 100) - args[1] = "/home/yzhou/krr-nas-share/Yujiao/ontologies/bio2rdf/uniprot/data/uniprot_cleaned.nt"; - - PagodaTester.main(args); - if (save) - TestUtil.copyFile("log4j.log", "/home/yzhou/java-workspace/test-share/results_new/uniprot/pagoda_" + percentage + "p" + date); - } - - public static void main(String... args) throws IOException { - Properties.ShellModeDefault = true; - new JAIR_Scalability().testUniProt(50, false); - } - -} diff --git a/test/uk/ac/ox/cs/pagoda/test_units/LightEvaluation.java b/test/uk/ac/ox/cs/pagoda/test_units/LightEvaluation.java deleted file mode 100644 index 932c178..0000000 --- a/test/uk/ac/ox/cs/pagoda/test_units/LightEvaluation.java +++ /dev/null @@ -1,67 +0,0 @@ -package uk.ac.ox.cs.pagoda.test_units; - -import org.junit.Test; -import uk.ac.ox.cs.pagoda.tester.PagodaTester; -import uk.ac.ox.cs.pagoda.util.TestUtil; - -import java.io.IOException; - -public class LightEvaluation { - - @Test - public void uobm1() throws IOException { - int number = 1; - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - PagodaTester.main( - TestUtil.combinePaths(ontoDir, "uobm/univ-bench-dl.owl"), - TestUtil.combinePaths(ontoDir, "uobm/data/uobm" + number + ".ttl"), - TestUtil.combinePaths(ontoDir, "uobm/queries/standard.sparql") - ); - TestUtil.copyFile("log4j.log", "output/jair/uobm1.out"); - } - - @Test - public void lubm100() throws IOException { - int number = 100; - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - PagodaTester.main( - TestUtil.combinePaths(ontoDir, "lubm/univ-bench.owl"), - TestUtil.combinePaths(ontoDir, "lubm/data/lubm" + number + ".ttl"), - TestUtil.combinePaths(ontoDir, "lubm/queries/test.sparql") - ); - TestUtil.copyFile("log4j.log", "results-backup/current/lubm100.out"); - } - - @Test - public void fly() throws IOException { - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - PagodaTester.main( - TestUtil.combinePaths(ontoDir, "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl"), - TestUtil.combinePaths(ontoDir, "fly/queries/fly.sparql") - ); - TestUtil.copyFile("log4j.log", "results-backup/current/fly.out"); - } - - @Test - public void dbpedia() throws IOException { - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - PagodaTester.main( - TestUtil.combinePaths(ontoDir, "dbpedia/integratedOntology-all-in-one-minus-datatype.owl"), - TestUtil.combinePaths(ontoDir, "dbpedia/data/dbpedia-minus-datatype-new.ttl"), - TestUtil.combinePaths(ontoDir, "dbpedia/atomic.sparql") - ); - TestUtil.copyFile("log4j.log", "results-backup/current/dbpedia.out"); - } - - @Test - public void npdWithoutDataType() throws IOException { - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - PagodaTester.main( - TestUtil.combinePaths(ontoDir, "npd/npd-all-minus-datatype.owl"), - TestUtil.combinePaths(ontoDir, "npd/data/npd-data-dump-minus-datatype-new.ttl"), - TestUtil.combinePaths(ontoDir, "npd/queries/atomic.sparql") - ); - TestUtil.copyFile("log4j.log", "results-backup/current/npd_minus.out"); - } - -} diff --git a/test/uk/ac/ox/cs/pagoda/test_units/PagodaDBPedia.java b/test/uk/ac/ox/cs/pagoda/test_units/PagodaDBPedia.java deleted file mode 100644 index 1673179..0000000 --- a/test/uk/ac/ox/cs/pagoda/test_units/PagodaDBPedia.java +++ /dev/null @@ -1,30 +0,0 @@ -package uk.ac.ox.cs.pagoda.test_units; - -import org.junit.Test; -import uk.ac.ox.cs.pagoda.tester.PagodaTester; -import uk.ac.ox.cs.pagoda.tester.Statistics; -import uk.ac.ox.cs.pagoda.util.TestUtil; - -import java.io.IOException; - -import static org.junit.Assert.fail; - -public class PagodaDBPedia { - - @Test - public void test() throws IOException { - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - PagodaTester.main( - TestUtil.combinePaths(ontoDir, "dbpedia/integratedOntology-all-in-one-minus-datatype.owl"), - TestUtil.combinePaths(ontoDir, "dbpedia/data/dbpedia-minus-datatype-new.ttl"), - TestUtil.combinePaths(ontoDir, "dbpedia/atomic.sparql") - ); - - Statistics stat = new Statistics("output/log4j.log"); - String diff = stat.diff("results-backup/benchmark/dbpedia.out"); - TestUtil.copyFile("output/log4j.log", "results-backup/current/dbpedia.out"); - if (!diff.isEmpty()) - fail(diff); - } - -} diff --git a/test/uk/ac/ox/cs/pagoda/test_units/PagodaELU.java b/test/uk/ac/ox/cs/pagoda/test_units/PagodaELU.java deleted file mode 100644 index 70d531d..0000000 --- a/test/uk/ac/ox/cs/pagoda/test_units/PagodaELU.java +++ /dev/null @@ -1,20 +0,0 @@ -package uk.ac.ox.cs.pagoda.test_units; - -import org.junit.Test; -import uk.ac.ox.cs.pagoda.tester.PagodaTester; -import uk.ac.ox.cs.pagoda.util.TestUtil; - -public class PagodaELU { - - @Test void test() { - int number = 1; - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - PagodaTester.main( - TestUtil.combinePaths(ontoDir, "uobm/univ-bench-dl.owl"), - TestUtil.combinePaths(ontoDir, "uobm/data/uobm" + number + ".ttl"), - TestUtil.combinePaths(ontoDir, "uobm/queries/standard.sparql") - ); - } - - -} diff --git a/test/uk/ac/ox/cs/pagoda/test_units/PagodaFLY.java b/test/uk/ac/ox/cs/pagoda/test_units/PagodaFLY.java deleted file mode 100644 index bad533f..0000000 --- a/test/uk/ac/ox/cs/pagoda/test_units/PagodaFLY.java +++ /dev/null @@ -1,25 +0,0 @@ -package uk.ac.ox.cs.pagoda.test_units; - -import org.junit.Test; -import uk.ac.ox.cs.pagoda.tester.PagodaTester; -import uk.ac.ox.cs.pagoda.util.TestUtil; - -public class PagodaFLY { - - @Test - public void test() { - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - PagodaTester.main( - TestUtil.combinePaths(ontoDir, "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl"), - TestUtil.combinePaths(ontoDir, "fly/queries/fly_pellet.sparql") - ); - -// Statistics stat = new Statistics("output/log4j.log"); -// String diff = stat.diff("results-backup/benchmark/fly.out"); -// AllTests.copy("output/log4j.log", "results-backup/current/fly.out"); -// if (!diff.isEmpty()) -// fail(diff); - } - - -} diff --git a/test/uk/ac/ox/cs/pagoda/test_units/PagodaLUBM.java b/test/uk/ac/ox/cs/pagoda/test_units/PagodaLUBM.java deleted file mode 100644 index 1aded5b..0000000 --- a/test/uk/ac/ox/cs/pagoda/test_units/PagodaLUBM.java +++ /dev/null @@ -1,24 +0,0 @@ -package uk.ac.ox.cs.pagoda.test_units; - -import org.testng.annotations.Test; -import uk.ac.ox.cs.pagoda.util.TestUtil; - -import java.io.IOException; -import java.nio.file.Paths; - -public class PagodaLUBM { - - private void testN(int number ) throws IOException { - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - TestGlobalCorrectness.test(Paths.get(ontoDir, "lubm/univ-bench.owl"), - Paths.get(ontoDir, "lubm/data/lubm" + number + ".ttl"), - Paths.get(ontoDir, "lubm/queries/test.sparql"), - Paths.get(ontoDir, "lubm/lubm" + number + ".json")); - } - - @Test - public void test1() throws IOException { - testN(1); - } - -} diff --git a/test/uk/ac/ox/cs/pagoda/test_units/PagodaNPD.java b/test/uk/ac/ox/cs/pagoda/test_units/PagodaNPD.java deleted file mode 100644 index 5f89162..0000000 --- a/test/uk/ac/ox/cs/pagoda/test_units/PagodaNPD.java +++ /dev/null @@ -1,46 +0,0 @@ -package uk.ac.ox.cs.pagoda.test_units; - -import org.junit.Test; -import uk.ac.ox.cs.pagoda.tester.PagodaTester; -import uk.ac.ox.cs.pagoda.tester.Statistics; -import uk.ac.ox.cs.pagoda.util.TestUtil; - -import java.io.IOException; - -import static org.junit.Assert.fail; - -public class PagodaNPD { - - @Test - public void testNPDwithoutDataType() throws IOException { - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - PagodaTester.main( - TestUtil.combinePaths(ontoDir, "npd/npd-all-minus-datatype.owl"), - TestUtil.combinePaths(ontoDir, "npd/data/npd-data-dump-minus-datatype-new.ttl"), - TestUtil.combinePaths(ontoDir, "npd/queries/atomic.sparql") - ); - - Statistics stat = new Statistics("output/log4j.log"); - String diff = stat.diff("results-backup/benchmark/npd_minus.out"); - TestUtil.copyFile("output/log4j.log", "results-backup/current/npd_minus.out"); - if (!diff.isEmpty()) - fail(diff); - } - - @Test - public void testNPD() throws IOException { - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - PagodaTester.main( - TestUtil.combinePaths(ontoDir, "npd/npd-all.owl"), - TestUtil.combinePaths(ontoDir, "npd/data/npd-data-dump-processed.ttl"), - TestUtil.combinePaths(ontoDir, "npd/queries/atomic.sparql") - ); - - Statistics stat = new Statistics("output/log4j.log"); - String diff = stat.diff("results-backup/benchmark/npd.out"); - TestUtil.copyFile("output/log4j.log", "results-backup/current/npd.out"); - if (!diff.isEmpty()) - fail(diff); - } - -} diff --git a/test/uk/ac/ox/cs/pagoda/test_units/PagodaNPD_bench.java b/test/uk/ac/ox/cs/pagoda/test_units/PagodaNPD_bench.java deleted file mode 100644 index 1aca36a..0000000 --- a/test/uk/ac/ox/cs/pagoda/test_units/PagodaNPD_bench.java +++ /dev/null @@ -1,30 +0,0 @@ -package uk.ac.ox.cs.pagoda.test_units; - -import org.junit.Test; -import uk.ac.ox.cs.pagoda.tester.PagodaTester; -import uk.ac.ox.cs.pagoda.tester.Statistics; -import uk.ac.ox.cs.pagoda.util.TestUtil; - -import java.io.IOException; - -import static org.junit.Assert.fail; - -public class PagodaNPD_bench { - - @Test - public void test() throws IOException { - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - PagodaTester.main( - TestUtil.combinePaths(ontoDir, "npd-benchmark/npd-v2-ql_a.owl"), - TestUtil.combinePaths(ontoDir, "npd-benchmark/npd-v2-ql_a.ttl"), - TestUtil.combinePaths(ontoDir, "npd-benchmark/queries/all.sparql") - ); - - Statistics stat = new Statistics("output/log4j.log"); - String diff = stat.diff("results-backup/benchmark/npd-bench.out"); - TestUtil.copyFile("output/log4j.log", "results-backup/current/npd-bench.out"); - if (!diff.isEmpty()) - fail(diff); - } - -} diff --git a/test/uk/ac/ox/cs/pagoda/test_units/PagodaRLU.java b/test/uk/ac/ox/cs/pagoda/test_units/PagodaRLU.java deleted file mode 100644 index c365196..0000000 --- a/test/uk/ac/ox/cs/pagoda/test_units/PagodaRLU.java +++ /dev/null @@ -1,20 +0,0 @@ -package uk.ac.ox.cs.pagoda.test_units; - -import org.junit.Test; -import uk.ac.ox.cs.pagoda.tester.PagodaTester; -import uk.ac.ox.cs.pagoda.util.TestUtil; - -public class PagodaRLU { - - @Test - public void testRL() { - int number = 1; - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - PagodaTester.main( - TestUtil.combinePaths(ontoDir, "uobm/univ-bench-dl.owl"), - TestUtil.combinePaths(ontoDir, "uobm/data/uobm" + number + ".ttl"), - TestUtil.combinePaths(ontoDir, "uobm/queries/standard.sparql") - ); - } - -} diff --git a/test/uk/ac/ox/cs/pagoda/test_units/PagodaUOBM.java b/test/uk/ac/ox/cs/pagoda/test_units/PagodaUOBM.java deleted file mode 100644 index ee9cf13..0000000 --- a/test/uk/ac/ox/cs/pagoda/test_units/PagodaUOBM.java +++ /dev/null @@ -1,24 +0,0 @@ -package uk.ac.ox.cs.pagoda.test_units; - -import org.testng.annotations.Test; -import uk.ac.ox.cs.pagoda.util.TestUtil; - -import java.io.IOException; -import java.nio.file.Paths; - -public class PagodaUOBM { - - private void testN(int number ) throws IOException { - String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); - TestGlobalCorrectness.test(Paths.get(ontoDir, "uobm/univ-bench-dl.owl"), - Paths.get(ontoDir, "uobm/data/uobm" + number + ".ttl"), - Paths.get(ontoDir, "uobm/queries/test.sparql"), - Paths.get(ontoDir, "uobm/uobm" + number + ".json")); - } - - @Test - public void test1() throws IOException { - testN(1); - } - -} diff --git a/test/uk/ac/ox/cs/pagoda/test_units/TestGlobalCorrectness.java b/test/uk/ac/ox/cs/pagoda/test_units/TestGlobalCorrectness.java deleted file mode 100644 index ffaf8fc..0000000 --- a/test/uk/ac/ox/cs/pagoda/test_units/TestGlobalCorrectness.java +++ /dev/null @@ -1,52 +0,0 @@ -package uk.ac.ox.cs.pagoda.test_units; - -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; -import org.apache.log4j.Level; -import org.testng.Assert; -import uk.ac.ox.cs.pagoda.query.QueryRecord; -import uk.ac.ox.cs.pagoda.tester.PagodaTester; -import uk.ac.ox.cs.pagoda.util.Utility; - -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.lang.reflect.Type; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Set; - -/** - * This is a unit test for TestNG. - *

- * It tests the correctness on the final output. - * */ -public class TestGlobalCorrectness { - - public static void test(Path ontology, Path data, Path queries, Path givenAnswers) { - try { - Utility.setLogLevel(Level.DEBUG); - Path computedAnswers = Paths.get(File.createTempFile("answers", ".json").getAbsolutePath()); - PagodaTester.main(ontology.toString(), data.toString(), queries.toString(), computedAnswers.toString()); - assertSameContent(computedAnswers, givenAnswers); - } catch (IOException e) { - e.printStackTrace(); - } - } - - private static void assertSameContent(Path computedAnswersFile, Path givenAnswersFile) throws IOException { - BufferedReader computedReader = Files.newBufferedReader(computedAnswersFile); - BufferedReader givenReader = Files.newBufferedReader(givenAnswersFile); - - Gson gson = QueryRecord.GsonCreator.getInstance(); - - Type cqType = new TypeToken>() {}.getType(); - Set computedAnswers = gson.fromJson(computedReader, cqType); - Set givenAnswers = gson.fromJson(givenReader, cqType); - - Assert.assertEquals(computedAnswers, givenAnswers); - } - - -} diff --git a/test/uk/ac/ox/cs/pagoda/tester/PagodaTester.java b/test/uk/ac/ox/cs/pagoda/tester/PagodaTester.java index 5e49f79..b97d85e 100644 --- a/test/uk/ac/ox/cs/pagoda/tester/PagodaTester.java +++ b/test/uk/ac/ox/cs/pagoda/tester/PagodaTester.java @@ -94,11 +94,11 @@ public class PagodaTester { if (args.length == 0) { // args = new String[] {test_tbox, test_abox, test_query}; // args = new String[] {lubm_tbox, lubm_abox, lubm_query}; - args = new String[] {uobm_tbox, uobm_abox, uobm_query, "/home/alessandro/Desktop/uobm1.ans"}; -// args = new String[] {fly, "null", fly_query.replace(".sparql", "_pellet.sparql") }; +// args = new String[] {uobm_tbox, uobm_abox, uobm_query}; +// args = new String[] {fly, "null", fly_query}; // args = new String[] {dbpedia_tbox, dbpedia_abox, dbpedia_query}; // args = new String[] {travel_tbox, null, dbpedia_query274}; -// args = new String[] {fly, null, fly_query}; + args = new String[] {fly, fly_query}; // args = new String[] {npd_tbox, npd_abox, npd_query}; // args = new String[] {npd_bench_tbox, npd_bench_abox, npd_bench_query}; // args = new String[] {"../SemFacet/WebContent/WEB-INF/data/dbpedia.owl", "../SemFacet/WebContent/WEB-INF/data/dbpediaA.nt", null}; @@ -119,7 +119,7 @@ public class PagodaTester { // args[2] = args[2].replace(".sparql", "_pellet.sparql"); } - Properties properties = new Properties("config/uobm.conf"); + Properties properties = new Properties("config/uobm.properties"); int index = 0; if (args.length > index) properties.setOntologyPath(args[index++]); @@ -157,7 +157,7 @@ public class PagodaTester { if (pagoda != null) pagoda.dispose(); } - Utility.closeCurrentOut(); +// Utility.closeCurrentOut(); if (properties.getShellMode()) System.exit(0); } -- cgit v1.2.3