From c7dbc7c61c7094ea4ec49bd630023f23b92fd9d1 Mon Sep 17 00:00:00 2001 From: RncLsn Date: Mon, 18 May 2015 18:27:32 +0100 Subject: Configured Maven and improved executable class and tests. --- .classpath | 30 -- .../libraries/Maven__com_beust_jcommander_1_12.xml | 13 - .../libraries/Maven__com_beust_jcommander_1_27.xml | 13 + .../Maven__commons_cli_commons_cli_1_3.xml | 13 + .idea/libraries/Maven__org_testng_testng_6_7.xml | 13 - .idea/libraries/Maven__org_testng_testng_6_8_8.xml | 13 + .idea/libraries/Maven__org_yaml_snakeyaml_1_6.xml | 13 - .project | 23 - README.md | 7 +- config/fly.properties | 19 - config/log4j.properties | 25 -- config/lubm.properties | 20 - config/test.properties | 1 - config/uobm.properties | 20 - lib/RDFox/Linux/JRDFox.jar | Bin 5015178 -> 0 bytes lib/RDFox/Mac/JRDFox.jar | Bin 3582609 -> 0 bytes lib/RDFox/RDFox.zip | Bin 81224594 -> 0 bytes lib/RDFox/Win/JRDFox.jar | Bin 1715610 -> 0 bytes lib/ore/OREv2ReasonerWrapper.jar | Bin 433263 -> 0 bytes pom.xml | 49 ++- src/resources/fly.properties | 19 + src/resources/log4j.properties | 25 ++ src/resources/lubm.properties | 20 + src/resources/uobm.properties | 20 + src/uk/ac/ox/cs/pagoda/Pagoda.java | 164 +++++++ src/uk/ac/ox/cs/pagoda/reasoner/QueryReasoner.java | 1 + .../rules/approximators/SkolemTermsManager.java | 1 + src/uk/ac/ox/cs/pagoda/util/Properties.java | 4 +- test/AllTests.xml | 18 - test/FullEvaluation.xml | 18 - test/resources/AllTests.xml | 18 + test/resources/FullEvaluation.xml | 18 + test/resources/test.properties | 1 + test/uk/ac/ox/cs/hermit/JAIR_HermiT.java | 69 +-- .../global_tests/CheckAnswersOverDataset.java | 48 +++ .../cs/pagoda/global_tests/JAIR_Scalability.java | 2 +- .../ox/cs/pagoda/global_tests/LightEvaluation.java | 64 +-- .../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 --- .../cs/pagoda/global_tests/TestPagodaDBPedia.java | 33 ++ .../ox/cs/pagoda/global_tests/TestPagodaFLY.java | 28 ++ .../ox/cs/pagoda/global_tests/TestPagodaLUBM.java | 45 ++ .../ox/cs/pagoda/global_tests/TestPagodaNPD.java | 38 ++ .../ox/cs/pagoda/global_tests/TestPagodaUOBM.java | 53 +++ test/uk/ac/ox/cs/pagoda/ore/PagodaOWLReasoner.java | 470 --------------------- .../ac/ox/cs/pagoda/ore/PagodaReasonerFactory.java | 39 -- test/uk/ac/ox/cs/pagoda/tester/PagodaTester.java | 276 +----------- test/uk/ac/ox/cs/pagoda/util/TestUtil.java | 7 +- 55 files changed, 678 insertions(+), 1394 deletions(-) delete mode 100644 .classpath delete mode 100644 .idea/libraries/Maven__com_beust_jcommander_1_12.xml create mode 100644 .idea/libraries/Maven__com_beust_jcommander_1_27.xml create mode 100644 .idea/libraries/Maven__commons_cli_commons_cli_1_3.xml delete mode 100644 .idea/libraries/Maven__org_testng_testng_6_7.xml create mode 100644 .idea/libraries/Maven__org_testng_testng_6_8_8.xml delete mode 100644 .idea/libraries/Maven__org_yaml_snakeyaml_1_6.xml delete mode 100644 .project delete mode 100644 config/fly.properties delete mode 100644 config/log4j.properties delete mode 100644 config/lubm.properties delete mode 100644 config/test.properties delete mode 100644 config/uobm.properties delete mode 100644 lib/RDFox/Linux/JRDFox.jar delete mode 100644 lib/RDFox/Mac/JRDFox.jar delete mode 100644 lib/RDFox/RDFox.zip delete mode 100644 lib/RDFox/Win/JRDFox.jar delete mode 100644 lib/ore/OREv2ReasonerWrapper.jar create mode 100644 src/resources/fly.properties create mode 100644 src/resources/log4j.properties create mode 100644 src/resources/lubm.properties create mode 100644 src/resources/uobm.properties create mode 100644 src/uk/ac/ox/cs/pagoda/Pagoda.java delete mode 100644 test/AllTests.xml delete mode 100644 test/FullEvaluation.xml create mode 100644 test/resources/AllTests.xml create mode 100644 test/resources/FullEvaluation.xml create mode 100644 test/resources/test.properties create mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/CheckAnswersOverDataset.java delete mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/PagodaDBPedia.java delete mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/PagodaELU.java delete mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/PagodaFLY.java delete mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/PagodaLUBM.java delete mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/PagodaNPD.java delete mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/PagodaNPD_bench.java delete mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/PagodaRLU.java delete mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/PagodaUOBM.java delete mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/TestGlobalCorrectness.java create mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaDBPedia.java create mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaFLY.java create mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaLUBM.java create mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaNPD.java create mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaUOBM.java delete mode 100644 test/uk/ac/ox/cs/pagoda/ore/PagodaOWLReasoner.java delete mode 100644 test/uk/ac/ox/cs/pagoda/ore/PagodaReasonerFactory.java diff --git a/.classpath b/.classpath deleted file mode 100644 index 1d0a725..0000000 --- a/.classpath +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/.idea/libraries/Maven__com_beust_jcommander_1_12.xml b/.idea/libraries/Maven__com_beust_jcommander_1_12.xml deleted file mode 100644 index 2b9ea17..0000000 --- a/.idea/libraries/Maven__com_beust_jcommander_1_12.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__com_beust_jcommander_1_27.xml b/.idea/libraries/Maven__com_beust_jcommander_1_27.xml new file mode 100644 index 0000000..f0f9060 --- /dev/null +++ b/.idea/libraries/Maven__com_beust_jcommander_1_27.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__commons_cli_commons_cli_1_3.xml b/.idea/libraries/Maven__commons_cli_commons_cli_1_3.xml new file mode 100644 index 0000000..49e7d40 --- /dev/null +++ b/.idea/libraries/Maven__commons_cli_commons_cli_1_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_testng_testng_6_7.xml b/.idea/libraries/Maven__org_testng_testng_6_7.xml deleted file mode 100644 index 264ea06..0000000 --- a/.idea/libraries/Maven__org_testng_testng_6_7.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_testng_testng_6_8_8.xml b/.idea/libraries/Maven__org_testng_testng_6_8_8.xml new file mode 100644 index 0000000..9ea815a --- /dev/null +++ b/.idea/libraries/Maven__org_testng_testng_6_8_8.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_yaml_snakeyaml_1_6.xml b/.idea/libraries/Maven__org_yaml_snakeyaml_1_6.xml deleted file mode 100644 index 0f8bd19..0000000 --- a/.idea/libraries/Maven__org_yaml_snakeyaml_1_6.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.project b/.project deleted file mode 100644 index f706d1e..0000000 --- a/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - krrPAGOdA - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.m2e.core.maven2Nature - - diff --git a/README.md b/README.md index 9c35c3f..5e908fb 100644 --- a/README.md +++ b/README.md @@ -9,14 +9,13 @@ Project dependencies/requirements - JavaSE 8 - Maven -- Eclipse Luna How to compile the project from source in Eclipse? ===== -- In order to compile the project make sure that you have JavaSE 8 and Eclipse Luna installed on your computer. -- After cloning the repository by command git clone https://github.com/yujiaoz/PAGOdA.git, you need to load the project into Eclipse and convert it into Maven project. +- In order to compile the project make sure that you have JavaSE 8 and Maven installed on your computer. +- After cloning the repository by command git clone https://github.com/yujiaoz/PAGOdA.git, you need to install it using the command "maven install". - The project depends on a library JRDFox.jar that is not in central maven repository. The library for different operating systems can be found in lib directory. You need to include the correct one for your computer and add it to the build path. Alternative, if you have maven installed on your computer, you could add it into your local maven repository, modify maven dependencies and make sure that you remove it from the build path. If the provided JRDFox.jar doesn't work, you might need to follow the instruction below to compile the project JRDFox by yourself. @@ -27,7 +26,7 @@ How to compile RDFox? - Extract all files in the zip. - Go to the directory RDFox/RDFox. - Run command "ant". -- You will find JRDFox.jar in the diretory build/release/lib. +- You will find JRDFox.jar in the directory build/release/lib. How to run the project? diff --git a/config/fly.properties b/config/fly.properties deleted file mode 100644 index 88c85c3..0000000 --- a/config/fly.properties +++ /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/log4j.properties b/config/log4j.properties deleted file mode 100644 index 6e88437..0000000 --- a/config/log4j.properties +++ /dev/null @@ -1,25 +0,0 @@ -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} - %m%n -log4j.appender.CONSOLE.Target=System.out -log4j.appender.CONSOLE.Threshold=INFO - -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}/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=[%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.properties b/config/lubm.properties deleted file mode 100644 index 73ed470..0000000 --- a/config/lubm.properties +++ /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/test.properties b/config/test.properties deleted file mode 100644 index c4a25d0..0000000 --- a/config/test.properties +++ /dev/null @@ -1 +0,0 @@ -ontoDir=/home/alessandro/Big_files/Ontologies/ \ No newline at end of file diff --git a/config/uobm.properties b/config/uobm.properties deleted file mode 100644 index acbe78e..0000000 --- a/config/uobm.properties +++ /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/lib/RDFox/Linux/JRDFox.jar b/lib/RDFox/Linux/JRDFox.jar deleted file mode 100644 index 3339750..0000000 Binary files a/lib/RDFox/Linux/JRDFox.jar and /dev/null differ diff --git a/lib/RDFox/Mac/JRDFox.jar b/lib/RDFox/Mac/JRDFox.jar deleted file mode 100644 index 0db4b9a..0000000 Binary files a/lib/RDFox/Mac/JRDFox.jar and /dev/null differ diff --git a/lib/RDFox/RDFox.zip b/lib/RDFox/RDFox.zip deleted file mode 100644 index f40f325..0000000 Binary files a/lib/RDFox/RDFox.zip and /dev/null differ diff --git a/lib/RDFox/Win/JRDFox.jar b/lib/RDFox/Win/JRDFox.jar deleted file mode 100644 index 26145db..0000000 Binary files a/lib/RDFox/Win/JRDFox.jar and /dev/null differ diff --git a/lib/ore/OREv2ReasonerWrapper.jar b/lib/ore/OREv2ReasonerWrapper.jar deleted file mode 100644 index 635dacc..0000000 Binary files a/lib/ore/OREv2ReasonerWrapper.jar and /dev/null differ diff --git a/pom.xml b/pom.xml index c177403..ad8c2b1 100644 --- a/pom.xml +++ b/pom.xml @@ -3,11 +3,22 @@ 4.0.0 uk.ac.ox.cs.pagoda pagoda - 2.0.0 + 2.1.0-SNAPSHOT + jar PAGOdA src test + + + src/resources + + + + + test/resources + + maven-compiler-plugin @@ -21,6 +32,19 @@ maven-project-info-reports-plugin 2.7 + + maven-assembly-plugin + + + + uk.ac.ox.cs.pagoda.Pagoda + + + + jar-with-dependencies + + + @@ -67,6 +91,11 @@ + + commons-cli + commons-cli + 1.3 + com.hermit-reasoner org.semanticweb.hermit @@ -106,7 +135,8 @@ org.testng testng - 6.7 + 6.8.8 + test @@ -123,5 +153,20 @@ ehcache 2.10.0 + + uk.ac.ox.cs.jrdfox + jrdfox + 1.0 + + + + + + + + + + + diff --git a/src/resources/fly.properties b/src/resources/fly.properties new file mode 100644 index 0000000..88c85c3 --- /dev/null +++ b/src/resources/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/src/resources/log4j.properties b/src/resources/log4j.properties new file mode 100644 index 0000000..3bfd32e --- /dev/null +++ b/src/resources/log4j.properties @@ -0,0 +1,25 @@ +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} %c - %m%n +log4j.appender.CONSOLE.Target=System.out +log4j.appender.CONSOLE.Threshold=INFO + +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}/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=[%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/src/resources/lubm.properties b/src/resources/lubm.properties new file mode 100644 index 0000000..73ed470 --- /dev/null +++ b/src/resources/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/src/resources/uobm.properties b/src/resources/uobm.properties new file mode 100644 index 0000000..acbe78e --- /dev/null +++ b/src/resources/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/src/uk/ac/ox/cs/pagoda/Pagoda.java b/src/uk/ac/ox/cs/pagoda/Pagoda.java new file mode 100644 index 0000000..3263c03 --- /dev/null +++ b/src/uk/ac/ox/cs/pagoda/Pagoda.java @@ -0,0 +1,164 @@ +package uk.ac.ox.cs.pagoda; + +import org.apache.commons.cli.*; +import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner; +import uk.ac.ox.cs.pagoda.util.Properties; +import uk.ac.ox.cs.pagoda.util.Timer; +import uk.ac.ox.cs.pagoda.util.Utility; + +import java.nio.file.Path; + +/** + * The main class + */ +public class Pagoda implements Runnable { + + private static final String OPTION_ONTOLOGY = "o"; + private static final String OPTION_DATA = "d"; + private static final String OPTION_QUERY = "q"; + private static final String OPTION_ANSWER = "a"; + private static final String OPTION_CLASSIFY = "c"; + private static final String OPTION_HERMIT = "f"; + + public static void main(String... args) { + + Options options = new Options(); + options.addOption(Option.builder(OPTION_ONTOLOGY).argName(OPTION_ONTOLOGY).required().hasArg().desc("The ontology path").build()); + options.addOption(Option.builder(OPTION_DATA).argName(OPTION_DATA).hasArg().desc("The data path").build()); + options.addOption(Option.builder(OPTION_QUERY).argName(OPTION_QUERY).required().hasArg().desc("The query path").build()); + options.addOption(Option.builder(OPTION_ANSWER).argName(OPTION_ANSWER).hasArg().desc("The answer path").build()); + options.addOption(Option.builder(OPTION_CLASSIFY).argName(OPTION_CLASSIFY).desc("Tell whether to classify").type(Boolean.class).build()); + options.addOption(Option.builder(OPTION_HERMIT).argName(OPTION_HERMIT).desc("Tell whether to call Hermit").type(Boolean.class).build()); + + CommandLineParser parser = new DefaultParser(); + try { + CommandLine cmd = parser.parse( options, args ); + PagodaBuilder pagodaBuilder = Pagoda.builder() + .ontology(cmd.getOptionValue(OPTION_ONTOLOGY)) + .query(cmd.getOptionValue(OPTION_QUERY)); + if(cmd.hasOption(OPTION_DATA)) pagodaBuilder.data(cmd.getOptionValue(OPTION_DATA)); + if(cmd.hasOption(OPTION_ANSWER)) pagodaBuilder.answer(cmd.getOptionValue(OPTION_ANSWER)); + if(cmd.hasOption(OPTION_CLASSIFY)) pagodaBuilder.classify(Boolean.parseBoolean(cmd.getOptionValue(OPTION_CLASSIFY))); + if(cmd.hasOption(OPTION_HERMIT)) pagodaBuilder.hermit(Boolean.parseBoolean(cmd.getOptionValue(OPTION_HERMIT))); + + pagodaBuilder.build().run(); + } + catch( ParseException exp ) { + HelpFormatter formatter = new HelpFormatter(); + formatter.printHelp("PAGOdA", options); + Utility.logError("Parsing failed. Reason: " + exp.getMessage()); + System.exit(0); + } + } + + /** + * Do not use it + * */ + private Pagoda() { + properties = new Properties(); + } + + private final Properties properties; + + /** + * Get a builder. + * */ + public static PagodaBuilder builder() { + return new PagodaBuilder(); + } + + @Override + public void run() { + Utility.logInfo("Ontology file: " + properties.getOntologyPath()); + Utility.logInfo("Data files: " + properties.getDataPath()); + Utility.logInfo("Query files: " + properties.getQueryPath()); + Utility.logInfo("Answer file: " + properties.getAnswerPath()); + + QueryReasoner pagoda = null; + + try { + Timer t = new Timer(); + pagoda = QueryReasoner.getInstance(properties); + if (pagoda == null) return; + + Utility.logInfo("Preprocessing Done in " + t.duration() + " seconds."); + + if (properties.getQueryPath() != null) + for (String queryFile: properties.getQueryPath().split(";")) + pagoda.evaluate(pagoda.getQueryManager().collectQueryRecords(queryFile)); + } finally { + if (pagoda != null) pagoda.dispose(); + } + } + + /** + * Allows to set the parameters before creating a Pagoda instance. + * */ + public static class PagodaBuilder { + + private Pagoda instance; + + private PagodaBuilder() { + instance = new Pagoda(); + } + + public PagodaBuilder ontology(String ontologyPath) { + if(instance == null) return null; + instance.properties.setOntologyPath(ontologyPath); + return this; + } + + public PagodaBuilder ontology(Path ontologyPath) { + return ontology(ontologyPath.toString()); + } + + public PagodaBuilder data(String dataPath) { + if(instance == null) return null; + instance.properties.setDataPath(dataPath); + return this; + } + + public PagodaBuilder data(Path dataPath) { + return data(dataPath.toString()); + } + + public PagodaBuilder query(String queryPath) { + if(instance == null) return null; + instance.properties.setQueryPath(queryPath); + return this; + } + + public PagodaBuilder query(Path queryPath) { + return query(queryPath.toString()); + } + + public PagodaBuilder answer(String answerPath) { + if(instance == null) return null; + instance.properties.setAnswerPath(answerPath); + return this; + } + + public PagodaBuilder answer(Path answerPath) { + return answer(answerPath.toString()); + } + + public PagodaBuilder classify(Boolean toClassify) { + if(instance == null) return null; + instance.properties.setToClassify(toClassify); + return this; + } + + public PagodaBuilder hermit(Boolean callHermit) { + if(instance == null) return null; + instance.properties.setToCallHermiT(callHermit); + return this; + } + + public Pagoda build() { + Pagoda builtInstance = instance; + instance = null; + return builtInstance; + } + + } +} diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/QueryReasoner.java b/src/uk/ac/ox/cs/pagoda/reasoner/QueryReasoner.java index 97bab50..dfe0c5f 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/QueryReasoner.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/QueryReasoner.java @@ -17,6 +17,7 @@ import java.nio.file.Files; import java.nio.file.Paths; import java.util.Collection; +// TODO clean APIs public abstract class QueryReasoner { // protected boolean forSemFacet = false; diff --git a/src/uk/ac/ox/cs/pagoda/rules/approximators/SkolemTermsManager.java b/src/uk/ac/ox/cs/pagoda/rules/approximators/SkolemTermsManager.java index 0413e65..0c12a27 100644 --- a/src/uk/ac/ox/cs/pagoda/rules/approximators/SkolemTermsManager.java +++ b/src/uk/ac/ox/cs/pagoda/rules/approximators/SkolemTermsManager.java @@ -22,6 +22,7 @@ public class SkolemTermsManager { private int dependenciesCounter = 0; // replace with hashcode. in case of collision you get only a different upper bound model. + // or, better, use perfect hashing (i.e. devise an ad-hoc hash function without collisions) private Map, Integer> mapDependencyToId = new HashMap<>(); /** diff --git a/src/uk/ac/ox/cs/pagoda/util/Properties.java b/src/uk/ac/ox/cs/pagoda/util/Properties.java index b687b53..9ebebb6 100644 --- a/src/uk/ac/ox/cs/pagoda/util/Properties.java +++ b/src/uk/ac/ox/cs/pagoda/util/Properties.java @@ -30,9 +30,9 @@ public class Properties { public boolean getToCallHermiT() { return toCallHermiT; } public void setToCallHermiT(boolean flag) { toCallHermiT = flag; } - public static boolean ShellModeDefault = false; + public static boolean shellModeDefault = false; - boolean shellMode = ShellModeDefault; + boolean shellMode = shellModeDefault; public boolean getShellMode() { return shellMode; } public void setShellMode(boolean flag) { shellMode = flag; } diff --git a/test/AllTests.xml b/test/AllTests.xml deleted file mode 100644 index c2567a8..0000000 --- a/test/AllTests.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/test/FullEvaluation.xml b/test/FullEvaluation.xml deleted file mode 100644 index c4a3ebe..0000000 --- a/test/FullEvaluation.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/test/resources/AllTests.xml b/test/resources/AllTests.xml new file mode 100644 index 0000000..bc3e5cc --- /dev/null +++ b/test/resources/AllTests.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/resources/FullEvaluation.xml b/test/resources/FullEvaluation.xml new file mode 100644 index 0000000..c4a3ebe --- /dev/null +++ b/test/resources/FullEvaluation.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/resources/test.properties b/test/resources/test.properties new file mode 100644 index 0000000..c4a25d0 --- /dev/null +++ b/test/resources/test.properties @@ -0,0 +1 @@ +ontoDir=/home/alessandro/Big_files/Ontologies/ \ No newline at end of file diff --git a/test/uk/ac/ox/cs/hermit/JAIR_HermiT.java b/test/uk/ac/ox/cs/hermit/JAIR_HermiT.java index 2fc478d..a3264ba 100644 --- a/test/uk/ac/ox/cs/hermit/JAIR_HermiT.java +++ b/test/uk/ac/ox/cs/hermit/JAIR_HermiT.java @@ -1,17 +1,17 @@ package uk.ac.ox.cs.hermit; import org.junit.Test; - -import uk.ac.ox.cs.pagoda.tester.PagodaTester; +import uk.ac.ox.cs.pagoda.util.TestUtil; public class JAIR_HermiT { @Test public void lubm1() throws Exception { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); String[] args = new String[] { - PagodaTester.onto_dir + "lubm/univ-bench.owl", - PagodaTester.onto_dir + "lubm/data/lubm1_owl", - PagodaTester.onto_dir + "lubm/queries/test.sparql" + TestUtil.combinePaths(ontoDir, "lubm/univ-bench.owl"), + TestUtil.combinePaths(ontoDir, "lubm/data/lubm1_owl"), + TestUtil.combinePaths(ontoDir, "lubm/queries/test.sparql") // , "/home/yzhou/java-workspace/test-share/results_new/lubm1/hermit" }; HermitQueryReasoner.main(args); @@ -19,10 +19,11 @@ public class JAIR_HermiT { @Test public void lubm1_rolledUp() throws Exception { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); String[] args = new String[] { "/home/yzhou/backup/20141212/univ-bench-queries.owl", - PagodaTester.onto_dir + "lubm/data/lubm1_owl", - PagodaTester.onto_dir + "lubm/queries/atomic_lubm.sparql" + TestUtil.combinePaths(ontoDir, "lubm/data/lubm1_owl"), + TestUtil.combinePaths(ontoDir, "lubm/queries/atomic_lubm.sparql") // , "/home/yzhou/java-workspace/test-share/results_new/lubm1/hermit_rolledUp" }; HermitQueryReasoner.main(args); @@ -30,10 +31,11 @@ public class JAIR_HermiT { @Test public void uobm1() throws Exception { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); String[] args = new String[] { - PagodaTester.onto_dir + "uobm/univ-bench-dl.owl", - PagodaTester.onto_dir + "uobm/data/uobm1_owl_withDeclaration", - PagodaTester.onto_dir + "uobm/queries/standard.sparql" + TestUtil.combinePaths(ontoDir, "uobm/univ-bench-dl.owl"), + TestUtil.combinePaths(ontoDir, "uobm/data/uobm1_owl_withDeclaration"), + TestUtil.combinePaths(ontoDir, "uobm/queries/standard.sparql") // , "hermit_uobm1.out" // , "/home/yzhou/java-workspace/test-share/results_new/uobm1/hermit" }; @@ -42,10 +44,11 @@ public class JAIR_HermiT { @Test public void uobm1_rolledUp() throws Exception { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); String[] args = new String[] { "/home/yzhou/backup/20141212/univ-bench-dl-queries.owl", - PagodaTester.onto_dir + "uobm/data/uobm1_owl_withDeclaration", - PagodaTester.onto_dir + "uobm/queries/atomic_uobm.sparql" + TestUtil.combinePaths(ontoDir, "uobm/data/uobm1_owl_withDeclaration"), + TestUtil.combinePaths(ontoDir, "uobm/queries/atomic_uobm.sparql") , "hermit_uobm1_rolledUp.out" // , "/home/yzhou/java-workspace/test-share/results_new/uobm1/hermit_rolledUp" }; @@ -54,21 +57,23 @@ public class JAIR_HermiT { @Test public void fly_rolledUp() throws Exception { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); HermitQueryReasoner.main( - PagodaTester.onto_dir + "fly/fly-all-in-one_rolledUp.owl", -// PagodaTester.onto_dir + "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl", + TestUtil.combinePaths(ontoDir, "fly/fly-all-in-one_rolledUp.owl"), +// TestUtil.combinePaths(ontoDir, "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl", null, - PagodaTester.onto_dir + "fly/queries/fly_atomic.sparql" + TestUtil.combinePaths(ontoDir, "fly/queries/fly_atomic.sparql") , "hermit_fly.out" ); } @Test public void npd() throws Exception { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); HermitQueryReasoner.main( - PagodaTester.onto_dir + "npd/npd-all-minus-datatype.owl", - PagodaTester.onto_dir + "npd/data/npd-data-dump-minus-datatype-new.ttl", - PagodaTester.onto_dir + "npd/queries/atomic_ground.sparql" + 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") , "hermit_npd.out" // , "/home/yzhou/java-workspace/test-share/results_new/npd/hermit" ); @@ -76,31 +81,34 @@ public class JAIR_HermiT { @Test public void dbpedia() throws Exception { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); HermitQueryReasoner.main( - PagodaTester.onto_dir + "dbpedia/integratedOntology-all-in-one-minus-datatype.owl", - PagodaTester.onto_dir + "dbpedia/data/dbpedia-minus-datatype-new.ttl", - PagodaTester.onto_dir + "dbpedia/queries/atomic_ground.sparql" + 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") , "/home/yzhou/java-workspace/test-share/results_new/dbpedia/hermit" ); } @Test public void reactome() throws Exception { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); HermitQueryReasoner.main( - PagodaTester.onto_dir + "bio2rdf/reactome/biopax-level3-processed.owl", - PagodaTester.onto_dir + "bio2rdf/reactome/graph sampling/reactome_sample_10.ttl", - PagodaTester.onto_dir + "bio2rdf/reactome/queries/atomic_ground.sparql" + TestUtil.combinePaths(ontoDir, "bio2rdf/reactome/biopax-level3-processed.owl"), + TestUtil.combinePaths(ontoDir, "bio2rdf/reactome/graph sampling/reactome_sample_10.ttl"), + TestUtil.combinePaths(ontoDir, "bio2rdf/reactome/queries/atomic_ground.sparql") , "/home/yzhou/java-workspace/test-share/results_new/reactome/hermit_10p" ); } @Test public void chembl() throws Exception { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); HermitQueryReasoner.main( - PagodaTester.onto_dir + "bio2rdf/chembl/cco-noDPR.ttl", + TestUtil.combinePaths(ontoDir, "bio2rdf/chembl/cco-noDPR.ttl"), // null, - PagodaTester.onto_dir + "bio2rdf/chembl/graph sampling/sample_1.nt", - PagodaTester.onto_dir + "bio2rdf/chembl/queries/atomic_ground.sparql" + TestUtil.combinePaths(ontoDir, "bio2rdf/chembl/graph sampling/sample_1.nt"), + TestUtil.combinePaths(ontoDir, "bio2rdf/chembl/queries/atomic_ground.sparql") , "hermit_chembl.out" // , "/home/yzhou/java-workspace/test-share/results_new/chembl/hermit_1p" ); @@ -108,10 +116,11 @@ public class JAIR_HermiT { @Test public void uniprot() throws Exception { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); HermitQueryReasoner.main( - PagodaTester.onto_dir + "bio2rdf/uniprot/core-sat.owl", - PagodaTester.onto_dir + "bio2rdf/uniprot/graph sampling/sample_1.nt", - PagodaTester.onto_dir + "bio2rdf/uniprot/queries/atomic_ground.sparql" + TestUtil.combinePaths(ontoDir, "bio2rdf/uniprot/core-sat.owl"), + TestUtil.combinePaths(ontoDir, "bio2rdf/uniprot/graph sampling/sample_1.nt"), + TestUtil.combinePaths(ontoDir, "bio2rdf/uniprot/queries/atomic_ground.sparql") , "hermit_uniprot.out" // , "/home/yzhou/java-workspace/test-share/results_new/uniprot/hermit_1p" ); diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/CheckAnswersOverDataset.java b/test/uk/ac/ox/cs/pagoda/global_tests/CheckAnswersOverDataset.java new file mode 100644 index 0000000..424afa2 --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/CheckAnswersOverDataset.java @@ -0,0 +1,48 @@ +package uk.ac.ox.cs.pagoda.global_tests; + +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import org.testng.Assert; +import uk.ac.ox.cs.pagoda.Pagoda; +import uk.ac.ox.cs.pagoda.query.QueryRecord; + +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; + +/** + * Given an instance of Pagoda, it checks the returned answers. + * */ +public class CheckAnswersOverDataset { + + public static void check(Pagoda pagoda, Path givenAnswers) { + try { +// Utility.setLogLevel(Level.DEBUG); // uncomment for outputting partial results + Path computedAnswers = Paths.get(File.createTempFile("answers", ".json").getAbsolutePath()); + new File(computedAnswers.toString()).deleteOnExit(); + + pagoda.run(); + 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/global_tests/JAIR_Scalability.java b/test/uk/ac/ox/cs/pagoda/global_tests/JAIR_Scalability.java index cdf55bd..687ffee 100644 --- a/test/uk/ac/ox/cs/pagoda/global_tests/JAIR_Scalability.java +++ b/test/uk/ac/ox/cs/pagoda/global_tests/JAIR_Scalability.java @@ -84,7 +84,7 @@ public class JAIR_Scalability { } public static void main(String... args) throws IOException { - Properties.ShellModeDefault = true; + 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 index 3ee268e..b073a26 100644 --- a/test/uk/ac/ox/cs/pagoda/global_tests/LightEvaluation.java +++ b/test/uk/ac/ox/cs/pagoda/global_tests/LightEvaluation.java @@ -1,67 +1,17 @@ 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 org.testng.annotations.Test; 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"); + public void evaluation() throws IOException { + new TestPagodaUOBM().test(1); + new TestPagodaLUBM().test(100); + new TestPagodaFLY().test(); + new TestPagodaDBPedia().test(); + new TestPagodaNPD().testNPDwithoutDataType(); } - - @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 deleted file mode 100644 index 2b9cdbd..0000000 --- a/test/uk/ac/ox/cs/pagoda/global_tests/PagodaDBPedia.java +++ /dev/null @@ -1,30 +0,0 @@ -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 deleted file mode 100644 index da059f9..0000000 --- a/test/uk/ac/ox/cs/pagoda/global_tests/PagodaELU.java +++ /dev/null @@ -1,20 +0,0 @@ -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 deleted file mode 100644 index d558e0f..0000000 --- a/test/uk/ac/ox/cs/pagoda/global_tests/PagodaFLY.java +++ /dev/null @@ -1,25 +0,0 @@ -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 deleted file mode 100644 index 2014ec1..0000000 --- a/test/uk/ac/ox/cs/pagoda/global_tests/PagodaLUBM.java +++ /dev/null @@ -1,24 +0,0 @@ -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 deleted file mode 100644 index 17d1e82..0000000 --- a/test/uk/ac/ox/cs/pagoda/global_tests/PagodaNPD.java +++ /dev/null @@ -1,46 +0,0 @@ -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 deleted file mode 100644 index c908cb4..0000000 --- a/test/uk/ac/ox/cs/pagoda/global_tests/PagodaNPD_bench.java +++ /dev/null @@ -1,30 +0,0 @@ -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 deleted file mode 100644 index 88e0835..0000000 --- a/test/uk/ac/ox/cs/pagoda/global_tests/PagodaRLU.java +++ /dev/null @@ -1,20 +0,0 @@ -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 deleted file mode 100644 index 065fb29..0000000 --- a/test/uk/ac/ox/cs/pagoda/global_tests/PagodaUOBM.java +++ /dev/null @@ -1,53 +0,0 @@ -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 deleted file mode 100644 index dff2366..0000000 --- a/test/uk/ac/ox/cs/pagoda/global_tests/TestGlobalCorrectness.java +++ /dev/null @@ -1,53 +0,0 @@ -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/global_tests/TestPagodaDBPedia.java b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaDBPedia.java new file mode 100644 index 0000000..04c9f3b --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaDBPedia.java @@ -0,0 +1,33 @@ +package uk.ac.ox.cs.pagoda.global_tests; + +import org.testng.annotations.Test; +import uk.ac.ox.cs.pagoda.Pagoda; +import uk.ac.ox.cs.pagoda.util.TestUtil; + +import java.io.IOException; +import java.nio.file.Paths; + +public class TestPagodaDBPedia { + + public static final String ANSWER_PATH = "~/TestPagodaDEBPedia.json"; + + @Test + public void just_execute() throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + Pagoda pagoda = Pagoda.builder() + .ontology(Paths.get(ontoDir, "dbpedia/integratedOntology-all-in-one-minus-datatype.owl")) + .data(Paths.get(ontoDir, "dbpedia/data/dbpedia-minus-datatype-new.ttl")) + .query(Paths.get(ontoDir, "dbpedia/atomic.sparql")) + .answer(ANSWER_PATH) + .classify(true) + .hermit(true) + .build(); + pagoda.run(); + } + + @Test + public void test() { + // TODO implement + } + +} diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaFLY.java b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaFLY.java new file mode 100644 index 0000000..623034e --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaFLY.java @@ -0,0 +1,28 @@ +package uk.ac.ox.cs.pagoda.global_tests; + +import org.testng.annotations.Test; +import uk.ac.ox.cs.pagoda.Pagoda; +import uk.ac.ox.cs.pagoda.util.TestUtil; + +public class TestPagodaFLY { + + public static final String ANSWER_PATH = "~/TestPagodaFLY.json"; + + @Test + public void just_execute() { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + Pagoda pagoda = Pagoda.builder() + .ontology(TestUtil.combinePaths(ontoDir, "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl")) + .query(TestUtil.combinePaths(ontoDir, "fly/queries/fly.sparql")) +// .answer(ANSWER_PATH) + .classify(true) + .hermit(true) + .build(); + pagoda.run(); + } + + @Test + public void test() { + // TODO implement + } +} diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaLUBM.java b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaLUBM.java new file mode 100644 index 0000000..bb58681 --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaLUBM.java @@ -0,0 +1,45 @@ +package uk.ac.ox.cs.pagoda.global_tests; + +import org.testng.annotations.Test; +import uk.ac.ox.cs.pagoda.Pagoda; +import uk.ac.ox.cs.pagoda.util.TestUtil; + +import java.io.IOException; +import java.nio.file.Paths; + +public class TestPagodaLUBM { + + public void test(int number) throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + Pagoda pagoda = Pagoda.builder() + .ontology(Paths.get(ontoDir, "lubm/univ-bench.owl")) + .data(Paths.get(ontoDir, "lubm/data/lubm" + number + ".ttl")) + .query(Paths.get(ontoDir, "lubm/queries/test.sparql")) + .classify(true) + .hermit(true) + .build(); + CheckAnswersOverDataset.check(pagoda, Paths.get(ontoDir, "lubm/lubm" + number + ".json")); + } + + @Test + public void test_1() throws IOException { + test(1); + } + + public void justExecute_100() { + int number = 100; + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + Pagoda pagoda = Pagoda.builder() + .ontology(Paths.get(ontoDir, "lubm/univ-bench.owl")) + .data(Paths.get(ontoDir, "lubm/data/lubm" + number + ".ttl")) + .query(Paths.get(ontoDir, "lubm/queries/test.sparql")) + .classify(true) + .hermit(true) + .build(); + pagoda.run(); + } + + public static void main(String... args) { + new TestPagodaLUBM().justExecute_100(); + } +} diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaNPD.java b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaNPD.java new file mode 100644 index 0000000..939ee6e --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaNPD.java @@ -0,0 +1,38 @@ +package uk.ac.ox.cs.pagoda.global_tests; + +import org.testng.annotations.Test; +import uk.ac.ox.cs.pagoda.Pagoda; +import uk.ac.ox.cs.pagoda.util.TestUtil; + +import java.io.IOException; +import java.nio.file.Paths; + +public class TestPagodaNPD { + + public static final String ANSWER_PATH = "~/PagodaNPDWithoutDatatype.json"; + + @Test + public void justExecuteNPDWithoutDataType() { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + Pagoda pagoda = Pagoda.builder() + .ontology(Paths.get(ontoDir, "npd/npd-all-minus-datatype.owl")) + .data(Paths.get(ontoDir, "npd/data/npd-data-dump-minus-datatype-new.ttl")) + .query(Paths.get(ontoDir, "npd/queries/atomic.sparql")) + .answer(ANSWER_PATH) + .classify(true) + .hermit(true) + .build(); + pagoda.run(); + } + + @Test + public void testNPDwithoutDataType() throws IOException { + // TODO implement + } + + @Test + public void testNPD() throws IOException { + // TODO implement + } + +} diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaUOBM.java b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaUOBM.java new file mode 100644 index 0000000..61235d3 --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaUOBM.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.Pagoda; +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 TestPagodaUOBM { + + public void test(int number) throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + Pagoda pagoda = Pagoda.builder() + .ontology(Paths.get(ontoDir, "uobm/univ-bench-dl.owl")) + .data(Paths.get(ontoDir, "uobm/data/uobm" + number + ".ttl")) + .query(Paths.get(ontoDir, "uobm/queries/test.sparql")) + .classify(true) + .hermit(true) + .build(); + CheckAnswersOverDataset.check(pagoda, + Paths.get(ontoDir, "uobm/uobm" + number + ".json")); + } + + @Test + public void test_1() throws IOException { + test(1); + } + + private static final int N_1 = 1; + 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(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/ore/PagodaOWLReasoner.java b/test/uk/ac/ox/cs/pagoda/ore/PagodaOWLReasoner.java deleted file mode 100644 index a07323d..0000000 --- a/test/uk/ac/ox/cs/pagoda/ore/PagodaOWLReasoner.java +++ /dev/null @@ -1,470 +0,0 @@ -package uk.ac.ox.cs.pagoda.ore; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.semanticweb.owlapi.model.AxiomType; -import org.semanticweb.owlapi.model.IRI; -import org.semanticweb.owlapi.model.OWLAxiom; -import org.semanticweb.owlapi.model.OWLClass; -import org.semanticweb.owlapi.model.OWLClassExpression; -import org.semanticweb.owlapi.model.OWLDataFactory; -import org.semanticweb.owlapi.model.OWLDataProperty; -import org.semanticweb.owlapi.model.OWLDataPropertyExpression; -import org.semanticweb.owlapi.model.OWLLiteral; -import org.semanticweb.owlapi.model.OWLNamedIndividual; -import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; -import org.semanticweb.owlapi.model.OWLOntology; -import org.semanticweb.owlapi.model.OWLOntologyChange; -import org.semanticweb.owlapi.reasoner.AxiomNotInProfileException; -import org.semanticweb.owlapi.reasoner.BufferingMode; -import org.semanticweb.owlapi.reasoner.ClassExpressionNotInProfileException; -import org.semanticweb.owlapi.reasoner.FreshEntitiesException; -import org.semanticweb.owlapi.reasoner.FreshEntityPolicy; -import org.semanticweb.owlapi.reasoner.InconsistentOntologyException; -import org.semanticweb.owlapi.reasoner.IndividualNodeSetPolicy; -import org.semanticweb.owlapi.reasoner.InferenceType; -import org.semanticweb.owlapi.reasoner.Node; -import org.semanticweb.owlapi.reasoner.NodeSet; -import org.semanticweb.owlapi.reasoner.OWLReasoner; -import org.semanticweb.owlapi.reasoner.ReasonerInterruptedException; -import org.semanticweb.owlapi.reasoner.TimeOutException; -import org.semanticweb.owlapi.reasoner.UnsupportedEntailmentTypeException; -import org.semanticweb.owlapi.reasoner.impl.OWLClassNodeSet; -import org.semanticweb.owlapi.util.Version; - -import uk.ac.ox.cs.JRDFox.model.GroundTerm; -import uk.ac.ox.cs.JRDFox.model.Individual; -import uk.ac.ox.cs.pagoda.query.AnswerTuples; -import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner; -import uk.ac.ox.cs.pagoda.util.Utility; - -public class PagodaOWLReasoner implements OWLReasoner { - - QueryReasoner reasoner; - OWLOntology ontology; - OWLDataFactory factory; - boolean sat; - - public PagodaOWLReasoner(OWLOntology ontology) { - this.ontology = ontology; - factory = ontology.getOWLOntologyManager().getOWLDataFactory(); - reasoner = QueryReasoner.getInstance(ontology); - reasoner.setToClassify(false); - reasoner.loadOntology(ontology); - sat = reasoner.preprocess(); - thing = new OWLClassNodeSet(factory.getOWLThing()); - } - - @Override - public String getReasonerName() { - return "PAGOdA"; - } - - @Override - public Version getReasonerVersion() { - return null; - } - - @Override - public BufferingMode getBufferingMode() { - // TODO Auto-generated method stub - return null; - } - - @Override - public void flush() { - // TODO Auto-generated method stub - - } - - @Override - public List getPendingChanges() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Set getPendingAxiomAdditions() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Set getPendingAxiomRemovals() { - // TODO Auto-generated method stub - return null; - } - - @Override - public OWLOntology getRootOntology() { - return ontology; - } - - @Override - public void interrupt() { - // TODO Auto-generated method stub - - } - - @Override - public void precomputeInferences(InferenceType... inferenceTypes) throws ReasonerInterruptedException, TimeOutException, InconsistentOntologyException { - if (!sat) { - throw new InconsistentOntologyException(); - } - if (inferenceTypes.length == 1 && inferenceTypes[0].equals(InferenceType.CLASS_ASSERTIONS) && types.isEmpty()) { - Set queriedClasses = new HashSet(); - for (OWLOntology onto: ontology.getImportsClosure()) - for (OWLClass cls: onto.getClassesInSignature(true)) { -// if (cls.toStringID().equals("http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Meritage")); -// else continue; - if (!cls.equals(factory.getOWLThing()) && !queriedClasses.contains(cls)) { - queriedClasses.add(cls); - AnswerTuples tuples = null; - try { - tuples = reasoner.evaluate(String.format("select distinct ?x where { ?x <%s> .}", cls.toStringID())); - int cnt = 0; - for (GroundTerm t; tuples.isValid(); tuples.moveNext()) { - t = tuples.getTuple().getGroundTerm(0); - if (t instanceof Individual) { - addType(((Individual) t).getIRI(), cls); - ++cnt; - } - } - Utility.logInfo("The number of answers: " + cnt); - } finally { - if (tuples != null) tuples.dispose(); - } - } - } - } - } - - private void addType(String iri, OWLClass cls) { - OWLNamedIndividual ind = factory.getOWLNamedIndividual(IRI.create(iri)); - OWLClassNodeSet set; - if (types.containsKey(ind)) { - set = types.get(ind); - } - else { - set = new OWLClassNodeSet(factory.getOWLThing()); - types.put(ind, set); - } - set.addEntity(cls); - } - - @Override - public boolean isPrecomputed(InferenceType inferenceType) { - // TODO Auto-generated method stub - return false; - } - - @Override - public Set getPrecomputableInferenceTypes() { - return java.util.Collections.singleton(InferenceType.CLASS_ASSERTIONS); - } - - @Override - public boolean isConsistent() throws ReasonerInterruptedException, TimeOutException { - return sat; - } - - @Override - public boolean isSatisfiable(OWLClassExpression classExpression) throws ReasonerInterruptedException, TimeOutException, ClassExpressionNotInProfileException, FreshEntitiesException, InconsistentOntologyException { - // TODO Auto-generated method stub - return false; - } - - @Override - public Node getUnsatisfiableClasses() throws ReasonerInterruptedException, TimeOutException, InconsistentOntologyException { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean isEntailed(OWLAxiom axiom) - throws ReasonerInterruptedException, - UnsupportedEntailmentTypeException, TimeOutException, - AxiomNotInProfileException, FreshEntitiesException, - InconsistentOntologyException { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isEntailed(Set axioms) - throws ReasonerInterruptedException, - UnsupportedEntailmentTypeException, TimeOutException, - AxiomNotInProfileException, FreshEntitiesException, - InconsistentOntologyException { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isEntailmentCheckingSupported(AxiomType axiomType) { - // TODO Auto-generated method stub - return false; - } - - @Override - public Node getTopClassNode() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Node getBottomClassNode() { - // TODO Auto-generated method stub - return null; - } - - @Override - public NodeSet getSubClasses(OWLClassExpression ce, boolean direct) - throws ReasonerInterruptedException, TimeOutException, - FreshEntitiesException, InconsistentOntologyException, - ClassExpressionNotInProfileException { - // TODO Auto-generated method stub - return null; - } - - @Override - public NodeSet getSuperClasses(OWLClassExpression ce, - boolean direct) throws InconsistentOntologyException, - ClassExpressionNotInProfileException, FreshEntitiesException, - ReasonerInterruptedException, TimeOutException { - // TODO Auto-generated method stub - return null; - } - - @Override - public Node getEquivalentClasses(OWLClassExpression ce) - throws InconsistentOntologyException, - ClassExpressionNotInProfileException, FreshEntitiesException, - ReasonerInterruptedException, TimeOutException { - // TODO Auto-generated method stub - return null; - } - - @Override - public NodeSet getDisjointClasses(OWLClassExpression ce) - throws ReasonerInterruptedException, TimeOutException, - FreshEntitiesException, InconsistentOntologyException { - // TODO Auto-generated method stub - return null; - } - - @Override - public Node getTopObjectPropertyNode() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Node getBottomObjectPropertyNode() { - // TODO Auto-generated method stub - return null; - } - - @Override - public NodeSet getSubObjectProperties( - OWLObjectPropertyExpression pe, boolean direct) - throws InconsistentOntologyException, FreshEntitiesException, - ReasonerInterruptedException, TimeOutException { - // TODO Auto-generated method stub - return null; - } - - @Override - public NodeSet getSuperObjectProperties( - OWLObjectPropertyExpression pe, boolean direct) - throws InconsistentOntologyException, FreshEntitiesException, - ReasonerInterruptedException, TimeOutException { - // TODO Auto-generated method stub - return null; - } - - @Override - public Node getEquivalentObjectProperties( - OWLObjectPropertyExpression pe) - throws InconsistentOntologyException, FreshEntitiesException, - ReasonerInterruptedException, TimeOutException { - // TODO Auto-generated method stub - return null; - } - - @Override - public NodeSet getDisjointObjectProperties( - OWLObjectPropertyExpression pe) - throws InconsistentOntologyException, FreshEntitiesException, - ReasonerInterruptedException, TimeOutException { - // TODO Auto-generated method stub - return null; - } - - @Override - public Node getInverseObjectProperties( - OWLObjectPropertyExpression pe) - throws InconsistentOntologyException, FreshEntitiesException, - ReasonerInterruptedException, TimeOutException { - // TODO Auto-generated method stub - return null; - } - - @Override - public NodeSet getObjectPropertyDomains( - OWLObjectPropertyExpression pe, boolean direct) - throws InconsistentOntologyException, FreshEntitiesException, - ReasonerInterruptedException, TimeOutException { - // TODO Auto-generated method stub - return null; - } - - @Override - public NodeSet getObjectPropertyRanges( - OWLObjectPropertyExpression pe, boolean direct) - throws InconsistentOntologyException, FreshEntitiesException, - ReasonerInterruptedException, TimeOutException { - // TODO Auto-generated method stub - return null; - } - - @Override - public Node getTopDataPropertyNode() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Node getBottomDataPropertyNode() { - // TODO Auto-generated method stub - return null; - } - - @Override - public NodeSet getSubDataProperties(OWLDataProperty pe, - boolean direct) throws InconsistentOntologyException, - FreshEntitiesException, ReasonerInterruptedException, - TimeOutException { - // TODO Auto-generated method stub - return null; - } - - @Override - public NodeSet getSuperDataProperties(OWLDataProperty pe, - boolean direct) throws InconsistentOntologyException, - FreshEntitiesException, ReasonerInterruptedException, - TimeOutException { - // TODO Auto-generated method stub - return null; - } - - @Override - public Node getEquivalentDataProperties(OWLDataProperty pe) - throws InconsistentOntologyException, FreshEntitiesException, - ReasonerInterruptedException, TimeOutException { - // TODO Auto-generated method stub - return null; - } - - @Override - public NodeSet getDisjointDataProperties( - OWLDataPropertyExpression pe) throws InconsistentOntologyException, - FreshEntitiesException, ReasonerInterruptedException, - TimeOutException { - // TODO Auto-generated method stub - return null; - } - - @Override - public NodeSet getDataPropertyDomains(OWLDataProperty pe, - boolean direct) throws InconsistentOntologyException, - FreshEntitiesException, ReasonerInterruptedException, - TimeOutException { - // TODO Auto-generated method stub - return null; - } - - private Map types = new HashMap(); - private OWLClassNodeSet thing; - - @Override - public NodeSet getTypes(OWLNamedIndividual ind, boolean direct) throws InconsistentOntologyException, FreshEntitiesException, ReasonerInterruptedException, TimeOutException { - if (!sat) { - throw new InconsistentOntologyException(); - } - if (types.containsKey(ind)) return types.get(ind); - return thing; - } - - @Override - public NodeSet getInstances(OWLClassExpression ce, - boolean direct) throws InconsistentOntologyException, - ClassExpressionNotInProfileException, FreshEntitiesException, - ReasonerInterruptedException, TimeOutException { - // TODO Auto-generated method stub - return null; - } - - @Override - public NodeSet getObjectPropertyValues( - OWLNamedIndividual ind, OWLObjectPropertyExpression pe) - throws InconsistentOntologyException, FreshEntitiesException, - ReasonerInterruptedException, TimeOutException { - // TODO Auto-generated method stub - return null; - } - - @Override - public Set getDataPropertyValues(OWLNamedIndividual ind, - OWLDataProperty pe) throws InconsistentOntologyException, - FreshEntitiesException, ReasonerInterruptedException, - TimeOutException { - // TODO Auto-generated method stub - return null; - } - - @Override - public Node getSameIndividuals(OWLNamedIndividual ind) - throws InconsistentOntologyException, FreshEntitiesException, - ReasonerInterruptedException, TimeOutException { - // TODO Auto-generated method stub - return null; - } - - @Override - public NodeSet getDifferentIndividuals( - OWLNamedIndividual ind) throws InconsistentOntologyException, - FreshEntitiesException, ReasonerInterruptedException, - TimeOutException { - // TODO Auto-generated method stub - return null; - } - - @Override - public long getTimeOut() { - // TODO Auto-generated method stub - return 0; - } - - @Override - public FreshEntityPolicy getFreshEntityPolicy() { - // TODO Auto-generated method stub - return null; - } - - @Override - public IndividualNodeSetPolicy getIndividualNodeSetPolicy() { - // TODO Auto-generated method stub - return null; - } - - @Override - public void dispose() { - reasoner.dispose(); - } - -} diff --git a/test/uk/ac/ox/cs/pagoda/ore/PagodaReasonerFactory.java b/test/uk/ac/ox/cs/pagoda/ore/PagodaReasonerFactory.java deleted file mode 100644 index 8ecdf1d..0000000 --- a/test/uk/ac/ox/cs/pagoda/ore/PagodaReasonerFactory.java +++ /dev/null @@ -1,39 +0,0 @@ -package uk.ac.ox.cs.pagoda.ore; - -import org.semanticweb.owlapi.model.OWLOntology; -import org.semanticweb.owlapi.reasoner.IllegalConfigurationException; -import org.semanticweb.owlapi.reasoner.OWLReasoner; -import org.semanticweb.owlapi.reasoner.OWLReasonerConfiguration; -import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; - -public class PagodaReasonerFactory implements OWLReasonerFactory { - - @Override - public String getReasonerName() { - return "PAGOdA"; - } - - @Override - public OWLReasoner createNonBufferingReasoner(OWLOntology ontology) { - // TODO Auto-generated method stub - return null; - } - - @Override - public OWLReasoner createReasoner(OWLOntology ontology) { - return new PagodaOWLReasoner(ontology); - } - - @Override - public OWLReasoner createNonBufferingReasoner(OWLOntology ontology, OWLReasonerConfiguration config) throws IllegalConfigurationException { - // TODO Auto-generated method stub - return null; - } - - @Override - public OWLReasoner createReasoner(OWLOntology ontology, OWLReasonerConfiguration config) throws IllegalConfigurationException { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/test/uk/ac/ox/cs/pagoda/tester/PagodaTester.java b/test/uk/ac/ox/cs/pagoda/tester/PagodaTester.java index b97d85e..7d9b49c 100644 --- a/test/uk/ac/ox/cs/pagoda/tester/PagodaTester.java +++ b/test/uk/ac/ox/cs/pagoda/tester/PagodaTester.java @@ -1,126 +1,18 @@ package uk.ac.ox.cs.pagoda.tester; -import uk.ac.ox.cs.pagoda.query.AnswerTuple; -import uk.ac.ox.cs.pagoda.query.AnswerTuples; import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner; import uk.ac.ox.cs.pagoda.util.Properties; import uk.ac.ox.cs.pagoda.util.Timer; import uk.ac.ox.cs.pagoda.util.Utility; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.Scanner; - +// TODO clean it, or code another one public class PagodaTester { -// public static final String onto_dir = "/media/RDFData/yzhou/"; -// public static final String onto_dir = "/users/yzhou/ontologies/"; -// public static final String onto_dir = "/home/scratch/yzhou/ontologies/"; - public static final String onto_dir = "/home/alessandro/Big_files/Ontologies/"; - - public static final String fly = onto_dir + "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl"; - public static final String fly_query = onto_dir + "fly/queries/fly.sparql"; - - public static final String test_tbox = onto_dir + "smallExampleFromAna/dummy.owl"; - public static final String test_abox = onto_dir + "smallExampleFromAna/initialABox.ttl"; - public static final String test_query = onto_dir + "smallExampleFromAna/queries.dlog"; - - public static final int lubm_number = 1; - public static final String lubm_tbox = onto_dir + "lubm/univ-bench.owl"; - public static final String lubm_abox = onto_dir + "lubm/data/lubm" + lubm_number + ".ttl"; - public static final String lubm_abox_copy = onto_dir + "lubm/data/lubm" + lubm_number + " (copy).ttl"; - public static final String lubm_query = onto_dir + "lubm/queries/test.sparql"; - public static final String lubm_query6 = onto_dir + "lubm/queries/test_q6.sparql"; - public static final String lubm_query20 = onto_dir + "lubm/queries/test_q16.sparql"; - - public static final int uobm_number = 1; - public static final String uobm_tbox = onto_dir + "uobm/univ-bench-dl.owl"; - public static final String uobm_abox = onto_dir + "uobm/data/uobm" + uobm_number + ".ttl"; - public static final String uobm_query = onto_dir + "uobm/queries/test.sparql"; - public static final String uobm_query_temp = onto_dir + "uobm/queries/temp.sparql"; - public static final String uobm_query2 = onto_dir + "uobm/queries/standard_q2.sparql"; - public static final String uobm_query9 = onto_dir + "uobm/queries/standard_q9.sparql"; - public static final String uobm_query11 = onto_dir + "uobm/queries/standard_q11.sparql"; - public static final String uobm_query12 = onto_dir + "uobm/queries/standard_q12.sparql"; - public static final String uobm_query14 = onto_dir + "uobm/queries/standard_q14.sparql"; - public static final String uobm_query15 = onto_dir + "uobm/queries/standard_q15.sparql"; - public static final String uobm_query_multi = onto_dir + "uobm/queries/standard_multi.sparql"; - public static final String uobm_generated_query1 = onto_dir + "uobm/queries/generated_q1.sparql"; - public static final String uobm_query_group3 = onto_dir + "uobm/queries/standard_group3.sparql"; - - public static final String npd_tbox = onto_dir + "npd/npd-all-minus-datatype.owl"; - // "npd/npd-all.owl"; - // "npd-all-minus-datatype.owl"; - public static final String npd_abox = onto_dir + "npd/data/npd-data-dump-minus-datatype-new.ttl"; - // "npd/data/npd-data-dump-processed.ttl"; - // "npd-data-dump-minus-datatype-old.ttl"; - public static final String npd_query = onto_dir + "npd/queries/atomic.sparql"; - - public static final String npd_bench_tbox = onto_dir + "npd-benchmark/npd-v2-ql_a.owl"; // npd-all-minus-datatype.owl"; - public static final String npd_bench_abox = onto_dir + "npd-benchmark/npd-v2-ql_a.ttl"; // npd-data-dump-minus-datatype-old.ttl"; - public static final String npd_bench_query = onto_dir + "npd-benchmark/queries/all.sparql"; - - public static final String dbpedia_tbox = onto_dir + "dbpedia/integratedOntology-all-in-one-minus-datatype.owl"; - public static final String dbpedia_abox = onto_dir + "dbpedia/data/dbpedia-minus-datatype-new.ttl"; - public static final String dbpedia_query = onto_dir + "dbpedia/queries/atomic_ground.sparql"; - public static final String dbpedia_query274 = onto_dir + "dbpedia/atomic_q274.sparql"; - - public static final String dbpedia_latest_tbox = onto_dir + "dbpedia/dbpedia_2014.owl"; - public static final String travel_tbox = onto_dir + "dbpedia/travel.owl"; - public static final String dbpedia_tbox_simple = onto_dir + "dbpedia/dbpedia_simple.owl"; - - public static final String bioModels_tbox = onto_dir + "biomodels/biomodels-21.owl"; - public static final String bioModels_abox = onto_dir + "biomodels/data_processed_1.ttl"; - public static final String bioModels_queries = onto_dir + "biomodels/queries/queries.sparql"; - - public static final String chembl_tbox = onto_dir + "bio2rdf/chembl/cco-processed-noDPR-noDPD.ttl"; - public static final String chembl_abox = onto_dir + "bio2rdf/chembl/graph sampling old/sample_100.nt"; - public static final String chembl_queries = onto_dir + "bio2rdf/chembl/queries/problematic.sparql"; //"bio2rdf/chembl/queries/atomic_one_filtered.sparql"; // - - public static final String reactome_tbox = onto_dir + "bio2rdf/reactome/biopax-level3-processed.owl"; - public static final String reactome_abox = onto_dir + "bio2rdf/reactome/graph sampling old/sample.ttl"; //data/data.ttl"; //graph sampling old/reactome_sample_10.ttl"; // - public static final String reactome_queries = onto_dir +"bio2rdf/reactome/queries/atomic.sparql"; - - public static final String uniprot_tbox = onto_dir + "bio2rdf/uniprot/core-processed.owl"; - public static final String uniprot_abox = onto_dir + "bio2rdf/uniprot/graph sampling/sample_1.nt"; - public static final String uniprot_queries = onto_dir + "bio2rdf/uniprot/queries/atomic_one.sparql"; - - public static final String atlas_tbox = onto_dir + "bio2rdf/atlas/gxaterms.owl"; - public static final String atlas_abox = onto_dir + "bio2rdf/atlas/graph sampling/sample_1.nt"; - public static final String atlas_queries = onto_dir + "bio2rdf/atlas/queries/atomic_one.sparql"; - public static void main(String... args) { - 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}; -// 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, 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}; -// args = new String[] {"../core/WebContent/WEB-INF/data/fly.owl", "../core/WebContent/WEB-INF/data/fly-data.nt", null}; -// args = new String[] {"data/lubm/univ-bench.owl", "data/lubm/lubm1.ttl", "data/lubm/lubm.sparql", "lubm.ans"}; -// args = new String[] {"data/uobm/univ-bench-dl.owl", "data/uobm/uobm1.ttl", "data/uobm/uobm.sparql", "uobm.ans"}; -// args = new String[] {"data/fly/fly_anatomy_XP_with_GJ_FC_individuals.owl", "data/fly/fly.sparql", "fly.ans"}; -// args = new String[] {bioModels_tbox, bioModels_abox, bioModels_queries}; -// args = new String[] {chembl_tbox, chembl_abox, chembl_queries}; -// args = new String[] {reactome_tbox, reactome_abox, reactome_queries}; -// args = new String[] {reactome_tbox, "/users/yzhou/temp/reactome_debug.ttl", onto_dir +"bio2rdf/reactome/queries/atomic_one_q65.sparql"}; -// args = new String[] {uniprot_tbox.replace(".owl", "-noDis.owl"), "/users/yzhou/temp/uniprot_debug/sample_1_string.nt", uniprot_queries}; -// args = new String[] {uniprot_tbox.replace(".owl", "-noDis.owl"), uniprot_abox, uniprot_queries}; -// args = new String[] {atlas_tbox, atlas_abox, atlas_queries}; -// args = new String[] {onto_dir + "test/unsatisfiable.owl", null, onto_dir + "test/unsatisfiable_queries.sparql"}; -// args = new String[] {onto_dir + "test/jair-example.owl", null, onto_dir + "test/jair-example_query.sparql"}; -// args[2] = args[2].replace(".sparql", "_all_pagoda.sparql"); -// args[2] = args[2].replace(".sparql", "_pellet.sparql"); - } +// Properties properties = new Properties(PagodaTester.class. +// getClassLoader().getResource("uobm.properties").getPath()); + Properties properties = new Properties(); - Properties properties = new Properties("config/uobm.properties"); - int index = 0; if (args.length > index) properties.setOntologyPath(args[index++]); if (args.length > index && (args[index].endsWith(".ttl") || args[index].endsWith(".nt"))) properties.setDataPath(args[index++]); @@ -146,169 +38,9 @@ public class PagodaTester { if (properties.getQueryPath() != null) for (String queryFile: properties.getQueryPath().split(";")) pagoda.evaluate(pagoda.getQueryManager().collectQueryRecords(queryFile)); - - if (properties.getShellMode()) - try { - evaluateConsoleQuery(pagoda); - } catch (IOException e) { - e.printStackTrace(); - } } finally { if (pagoda != null) pagoda.dispose(); } - -// Utility.closeCurrentOut(); - - if (properties.getShellMode()) System.exit(0); - } - -// private void printPredicatesWithGap() { -// for (String p: ((MyQueryReasoner) pagoda).getPredicatesWithGap()) { -// System.out.println(p); -// } -// } - - private static void evaluateConsoleQuery(QueryReasoner pagoda) throws IOException { - int ending = (int) '$', symbol; - while (true) { - Utility.logInfo("Input your query ending with $"); - StringBuilder queryBuilder = new StringBuilder(); - while ((symbol = System.in.read()) != ending) { - queryBuilder.append((char) symbol); - } - System.in.read(); - if (queryBuilder.length() == 0) return ; - pagoda.evaluate_shell(queryBuilder.toString()); - } - } - - void testReactomeQueries() { - evaluate("select ?x where { ?x . }"); - evaluate("select ?y ?z where { ?y ?z . }"); - evaluate("select ?y where { ?y . }", true); - - } - - void testSemFacetQueries() { -// try { -// BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("query.line"))); -// for (String line; (line = reader.readLine()) != null && !line.isEmpty(); ) -// evaluate(line, true); -// reader.close(); -// } catch (FileNotFoundException e) { -// e.printStackTrace(); -// } catch (IOException e) { -// e.printStackTrace(); -// } - evaluate("select ?x ?z where { ?x ?z }", true); - evaluate("select distinct ?y where { ?x ?y ?z }", true); - evaluate("select distinct ?z where { ?x ?z }", true); - evaluate("select ?y ?z where { ?y ?z .}", true); - } - - void testISGQueries() { - evaluate("select ?z where { ?z .}", false); - evaluate("select ?x where {?x .}", false); - } - - void testSomeTravelQueries() { - evaluate("select ?y ?z where { ?y ?z. }", true); - evaluate("select ?x where {?x . }"); - evaluate("select ?x where {?x . }"); - } - - void testSomeFlyQueries() { - evaluate("select ?x where { ?x . }", false); - - evaluate("select DISTINCT ?z where { ?x ?any . ?any ?z . ?x . } ", true); - - evaluate("Select ?x where { ?x " - + ". ?x " - + " ?any . ?any " - + " " - + " . }", true); - - evaluate("Select ?x where {?x " - + " . ?x " - + " ?any . ?any " - + " " - + " . }", true); - -// evaluate("Select ?x where { " -// + "?x . " -// + "?x ?any . " -// + "?any . }", true); - - evaluate("select DISTINCT ?z where { ?x ?any . " - + "?any ?z . " - + "?x . } ", true); - - evaluate("Select * where {" - + " . " - + " ?z }", true); - - evaluate("SELECT DISTINCT ?x ?z WHERE {?x ?z}", true); - evaluate("SELECT DISTINCT ?x ?z WHERE {?x ?z}", true); - - evaluate("select DISTINCT ?y where { ?x ?y ?z . " - + "?x }", true); - - evaluateQueriesFromFile("/users/yzhou/Downloads/logs(1).log"); - evaluateQueriesFromFile("/users/yzhou/Downloads/logs.log"); - - evaluate("SELECT DISTINCT ?x ?z WHERE {?x ?z}", true); - evaluate("SELECT DISTINCT ?x ?z WHERE {?x ?z}", true); - - evaluate("select ?x ?z where { ?x ?z } ", true); - evaluate("select ?x ?z where { ?x ?z } ", true); - } - - public void evaluateQueriesFromFile(String fileName) { - Scanner scanner = null; - try { - scanner = new Scanner(new File(fileName)); - String line; - while (scanner.hasNextLine()) { - line = scanner.nextLine(); - if (line.startsWith("select")) - evaluate(line, true); - } - } catch (FileNotFoundException e) { - e.printStackTrace(); - } finally { - if (scanner != null) - scanner.close(); - } - } - - QueryReasoner pagoda; - - public PagodaTester(QueryReasoner reasoner) { - pagoda = reasoner; - } - - Timer timer = new Timer(); - - private void evaluate(String query) { - evaluate(query, false); - } - - private void evaluate(String query, boolean tag) { - timer.reset(); - AnswerTuples tuples = pagoda.evaluate(query, tag); - int arity = tuples.getArity(); - int count = 0; - for (AnswerTuple tuple; tuples.isValid(); tuples.moveNext()) { - tuple = tuples.getTuple(); - for (int i = 0; i < arity; ++i) - tuple.getGroundTerm(i).toString(); -// System.out.print(tuple.getGroundTerm(i).toString() + "\t"); -// System.out.println(); - ++count; - } - tuples.dispose(); - Utility.logInfo("The number of answers for this SemFacet query: " + count); - Utility.logInfo("Total time for this SemFacet query: " + timer.duration()); } } diff --git a/test/uk/ac/ox/cs/pagoda/util/TestUtil.java b/test/uk/ac/ox/cs/pagoda/util/TestUtil.java index 06d391a..1802147 100644 --- a/test/uk/ac/ox/cs/pagoda/util/TestUtil.java +++ b/test/uk/ac/ox/cs/pagoda/util/TestUtil.java @@ -5,8 +5,8 @@ import org.apache.log4j.FileAppender; import org.apache.log4j.Logger; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Paths; import java.util.Enumeration; @@ -19,14 +19,15 @@ import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; */ public class TestUtil { - public static final String CONFIG_FILE = "config/test.properties"; + public static final String CONFIG_FILE = "test.properties"; private static boolean isConfigLoaded = false; private static Properties config; public static Properties getConfig() { if(!isConfigLoaded) { - try (FileInputStream in = new FileInputStream(CONFIG_FILE)) { + try (InputStream in = TestUtil.class.getClassLoader() + .getResourceAsStream(CONFIG_FILE)) { config = new java.util.Properties(); config.load(in); in.close(); -- cgit v1.2.3