diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/resources/fly.properties | 19 | ||||
| -rw-r--r-- | src/resources/log4j.properties | 25 | ||||
| -rw-r--r-- | src/resources/lubm.properties | 20 | ||||
| -rw-r--r-- | src/resources/uobm.properties | 20 | ||||
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/Pagoda.java | 164 | ||||
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/reasoner/QueryReasoner.java | 1 | ||||
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/rules/approximators/SkolemTermsManager.java | 1 | ||||
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/util/Properties.java | 4 |
8 files changed, 252 insertions, 2 deletions
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 @@ | |||
| 1 | #ONTOLOGY variable points to the file that stores ontology of interest | ||
| 2 | ONTOLOGY=data/fly/fly_anatomy_XP_with_GJ_FC_individuals.owl | ||
| 3 | #ONTOLOGY=data/fly/fbbt_vfb_ind_pr_nr.owl | ||
| 4 | |||
| 5 | #QUERY variable points to the file that stores all queries | ||
| 6 | QUERY=data/fly/fly.sparql | ||
| 7 | #QUERY=data/fly/test.sparql | ||
| 8 | |||
| 9 | #ANSWER variable points to the file to output all answers | ||
| 10 | #ANSWER=data/fly/fly.ans | ||
| 11 | |||
| 12 | #TO_CLASSIFY switch for the optimisation to specify if the ontology is first classified by HermiT | ||
| 13 | TO_CLASSIFY=false | ||
| 14 | |||
| 15 | #CALL_HERMIT variable to specify if HermiT is called or not | ||
| 16 | CALL_HERMIT=true | ||
| 17 | |||
| 18 | #SHELL_MODE to enable query execution from console input | ||
| 19 | 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 @@ | |||
| 1 | log = . | ||
| 2 | log4j.rootLogger=DEBUG, CONSOLE, FILE_LAST, FILE | ||
| 3 | |||
| 4 | log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender | ||
| 5 | log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout | ||
| 6 | log4j.appender.CONSOLE.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %c - %m%n | ||
| 7 | log4j.appender.CONSOLE.Target=System.out | ||
| 8 | log4j.appender.CONSOLE.Threshold=INFO | ||
| 9 | |||
| 10 | log4j.appender.FILE_LAST=org.apache.log4j.RollingFileAppender | ||
| 11 | log4j.appender.FILE_LAST.File=${log}/pagoda_last_only.log | ||
| 12 | log4j.appender.FILE_LAST.MaxFileSize=10MB | ||
| 13 | log4j.appender.FILE_LAST.MaxBackupIndex=3 | ||
| 14 | log4j.appender.FILE_LAST.layout=org.apache.log4j.PatternLayout | ||
| 15 | log4j.appender.FILE_LAST.layout.conversionPattern=[%5p] %d{yyyy-MM-dd HH:mm:ss} %c - %m%n | ||
| 16 | log4j.appender.FILE_LAST.append=false | ||
| 17 | log4j.appender.FILE_LAST.Threshold=DEBUG | ||
| 18 | |||
| 19 | log4j.appender.FILE=org.apache.log4j.RollingFileAppender | ||
| 20 | log4j.appender.FILE.File=${log}/pagoda.log | ||
| 21 | log4j.appender.FILE.MaxFileSize=10MB | ||
| 22 | log4j.appender.FILE.MaxBackupIndex=3 | ||
| 23 | log4j.appender.FILE.layout=org.apache.log4j.PatternLayout | ||
| 24 | log4j.appender.FILE.layout.conversionPattern=[%5p] %d{yyyy-MM-dd HH:mm:ss} %c - %m%n | ||
| 25 | 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 @@ | |||
| 1 | #DATA variable points to the file that stores data | ||
| 2 | DATA=data/lubm/lubm1.ttl | ||
| 3 | |||
| 4 | #ONTOLOGY variable points to the file that stores ontology of interest | ||
| 5 | ONTOLOGY=data/lubm/univ-bench.owl | ||
| 6 | |||
| 7 | #QUERY variable points to the file that stores all queries | ||
| 8 | QUERY=data/lubm/lubm.sparql | ||
| 9 | |||
| 10 | #ANSWER variable points to the file to output all answers | ||
| 11 | #ANSWER=data/lubm/lubm.ans | ||
| 12 | |||
| 13 | #TO_CLASSIFY switch for the optimisation to specify if the ontology is first classified by HermiT | ||
| 14 | TO_CLASSIFY=true | ||
| 15 | |||
| 16 | #CALL_HERMIT variable to specify if HermiT is called or not | ||
| 17 | CALL_HERMIT=true | ||
| 18 | |||
| 19 | #SHELL_MODE to enable query execution from console input | ||
| 20 | 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 @@ | |||
| 1 | #DATA variable points to the file that stores data | ||
| 2 | DATA=data/uobm/uobm1.ttl | ||
| 3 | |||
| 4 | #ONTOLOGY variable points to the file that stores ontology of interest | ||
| 5 | ONTOLOGY=data/uobm/univ-bench-dl.owl | ||
| 6 | |||
| 7 | #QUERY variable points to the file that stores all queries | ||
| 8 | QUERY=data/uobm/uobm.sparql | ||
| 9 | |||
| 10 | #ANSWER variable points to the file to output all answers | ||
| 11 | #ANSWER=data/uobm/uobm.ans | ||
| 12 | |||
| 13 | #TO_CLASSIFY switch for the optimisation to specify if the ontology is first classified by HermiT | ||
| 14 | TO_CLASSIFY=true | ||
| 15 | |||
| 16 | #CALL_HERMIT variable to specify if HermiT is called or not | ||
| 17 | CALL_HERMIT=true | ||
| 18 | |||
| 19 | #SHELL_MODE to enable query execution from console input | ||
| 20 | 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 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda; | ||
| 2 | |||
| 3 | import org.apache.commons.cli.*; | ||
| 4 | import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner; | ||
| 5 | import uk.ac.ox.cs.pagoda.util.Properties; | ||
| 6 | import uk.ac.ox.cs.pagoda.util.Timer; | ||
| 7 | import uk.ac.ox.cs.pagoda.util.Utility; | ||
| 8 | |||
| 9 | import java.nio.file.Path; | ||
| 10 | |||
| 11 | /** | ||
| 12 | * The main class | ||
| 13 | */ | ||
| 14 | public class Pagoda implements Runnable { | ||
| 15 | |||
| 16 | private static final String OPTION_ONTOLOGY = "o"; | ||
| 17 | private static final String OPTION_DATA = "d"; | ||
| 18 | private static final String OPTION_QUERY = "q"; | ||
| 19 | private static final String OPTION_ANSWER = "a"; | ||
| 20 | private static final String OPTION_CLASSIFY = "c"; | ||
| 21 | private static final String OPTION_HERMIT = "f"; | ||
| 22 | |||
| 23 | public static void main(String... args) { | ||
| 24 | |||
| 25 | Options options = new Options(); | ||
| 26 | options.addOption(Option.builder(OPTION_ONTOLOGY).argName(OPTION_ONTOLOGY).required().hasArg().desc("The ontology path").build()); | ||
| 27 | options.addOption(Option.builder(OPTION_DATA).argName(OPTION_DATA).hasArg().desc("The data path").build()); | ||
| 28 | options.addOption(Option.builder(OPTION_QUERY).argName(OPTION_QUERY).required().hasArg().desc("The query path").build()); | ||
| 29 | options.addOption(Option.builder(OPTION_ANSWER).argName(OPTION_ANSWER).hasArg().desc("The answer path").build()); | ||
| 30 | options.addOption(Option.builder(OPTION_CLASSIFY).argName(OPTION_CLASSIFY).desc("Tell whether to classify").type(Boolean.class).build()); | ||
| 31 | options.addOption(Option.builder(OPTION_HERMIT).argName(OPTION_HERMIT).desc("Tell whether to call Hermit").type(Boolean.class).build()); | ||
| 32 | |||
| 33 | CommandLineParser parser = new DefaultParser(); | ||
| 34 | try { | ||
| 35 | CommandLine cmd = parser.parse( options, args ); | ||
| 36 | PagodaBuilder pagodaBuilder = Pagoda.builder() | ||
| 37 | .ontology(cmd.getOptionValue(OPTION_ONTOLOGY)) | ||
| 38 | .query(cmd.getOptionValue(OPTION_QUERY)); | ||
| 39 | if(cmd.hasOption(OPTION_DATA)) pagodaBuilder.data(cmd.getOptionValue(OPTION_DATA)); | ||
| 40 | if(cmd.hasOption(OPTION_ANSWER)) pagodaBuilder.answer(cmd.getOptionValue(OPTION_ANSWER)); | ||
| 41 | if(cmd.hasOption(OPTION_CLASSIFY)) pagodaBuilder.classify(Boolean.parseBoolean(cmd.getOptionValue(OPTION_CLASSIFY))); | ||
| 42 | if(cmd.hasOption(OPTION_HERMIT)) pagodaBuilder.hermit(Boolean.parseBoolean(cmd.getOptionValue(OPTION_HERMIT))); | ||
| 43 | |||
| 44 | pagodaBuilder.build().run(); | ||
| 45 | } | ||
| 46 | catch( ParseException exp ) { | ||
| 47 | HelpFormatter formatter = new HelpFormatter(); | ||
| 48 | formatter.printHelp("PAGOdA", options); | ||
| 49 | Utility.logError("Parsing failed. Reason: " + exp.getMessage()); | ||
| 50 | System.exit(0); | ||
| 51 | } | ||
| 52 | } | ||
| 53 | |||
| 54 | /** | ||
| 55 | * Do not use it | ||
| 56 | * */ | ||
| 57 | private Pagoda() { | ||
| 58 | properties = new Properties(); | ||
| 59 | } | ||
| 60 | |||
| 61 | private final Properties properties; | ||
| 62 | |||
| 63 | /** | ||
| 64 | * Get a builder. | ||
| 65 | * */ | ||
| 66 | public static PagodaBuilder builder() { | ||
| 67 | return new PagodaBuilder(); | ||
| 68 | } | ||
| 69 | |||
| 70 | @Override | ||
| 71 | public void run() { | ||
| 72 | Utility.logInfo("Ontology file: " + properties.getOntologyPath()); | ||
| 73 | Utility.logInfo("Data files: " + properties.getDataPath()); | ||
| 74 | Utility.logInfo("Query files: " + properties.getQueryPath()); | ||
| 75 | Utility.logInfo("Answer file: " + properties.getAnswerPath()); | ||
| 76 | |||
| 77 | QueryReasoner pagoda = null; | ||
| 78 | |||
| 79 | try { | ||
| 80 | Timer t = new Timer(); | ||
| 81 | pagoda = QueryReasoner.getInstance(properties); | ||
| 82 | if (pagoda == null) return; | ||
| 83 | |||
| 84 | Utility.logInfo("Preprocessing Done in " + t.duration() + " seconds."); | ||
| 85 | |||
| 86 | if (properties.getQueryPath() != null) | ||
| 87 | for (String queryFile: properties.getQueryPath().split(";")) | ||
| 88 | pagoda.evaluate(pagoda.getQueryManager().collectQueryRecords(queryFile)); | ||
| 89 | } finally { | ||
| 90 | if (pagoda != null) pagoda.dispose(); | ||
| 91 | } | ||
| 92 | } | ||
| 93 | |||
| 94 | /** | ||
| 95 | * Allows to set the parameters before creating a Pagoda instance. | ||
| 96 | * */ | ||
| 97 | public static class PagodaBuilder { | ||
| 98 | |||
| 99 | private Pagoda instance; | ||
| 100 | |||
| 101 | private PagodaBuilder() { | ||
| 102 | instance = new Pagoda(); | ||
| 103 | } | ||
| 104 | |||
| 105 | public PagodaBuilder ontology(String ontologyPath) { | ||
| 106 | if(instance == null) return null; | ||
| 107 | instance.properties.setOntologyPath(ontologyPath); | ||
| 108 | return this; | ||
| 109 | } | ||
| 110 | |||
| 111 | public PagodaBuilder ontology(Path ontologyPath) { | ||
| 112 | return ontology(ontologyPath.toString()); | ||
| 113 | } | ||
| 114 | |||
| 115 | public PagodaBuilder data(String dataPath) { | ||
| 116 | if(instance == null) return null; | ||
| 117 | instance.properties.setDataPath(dataPath); | ||
| 118 | return this; | ||
| 119 | } | ||
| 120 | |||
| 121 | public PagodaBuilder data(Path dataPath) { | ||
| 122 | return data(dataPath.toString()); | ||
| 123 | } | ||
| 124 | |||
| 125 | public PagodaBuilder query(String queryPath) { | ||
| 126 | if(instance == null) return null; | ||
| 127 | instance.properties.setQueryPath(queryPath); | ||
| 128 | return this; | ||
| 129 | } | ||
| 130 | |||
| 131 | public PagodaBuilder query(Path queryPath) { | ||
| 132 | return query(queryPath.toString()); | ||
| 133 | } | ||
| 134 | |||
| 135 | public PagodaBuilder answer(String answerPath) { | ||
| 136 | if(instance == null) return null; | ||
| 137 | instance.properties.setAnswerPath(answerPath); | ||
| 138 | return this; | ||
| 139 | } | ||
| 140 | |||
| 141 | public PagodaBuilder answer(Path answerPath) { | ||
| 142 | return answer(answerPath.toString()); | ||
| 143 | } | ||
| 144 | |||
| 145 | public PagodaBuilder classify(Boolean toClassify) { | ||
| 146 | if(instance == null) return null; | ||
| 147 | instance.properties.setToClassify(toClassify); | ||
| 148 | return this; | ||
| 149 | } | ||
| 150 | |||
| 151 | public PagodaBuilder hermit(Boolean callHermit) { | ||
| 152 | if(instance == null) return null; | ||
| 153 | instance.properties.setToCallHermiT(callHermit); | ||
| 154 | return this; | ||
| 155 | } | ||
| 156 | |||
| 157 | public Pagoda build() { | ||
| 158 | Pagoda builtInstance = instance; | ||
| 159 | instance = null; | ||
| 160 | return builtInstance; | ||
| 161 | } | ||
| 162 | |||
| 163 | } | ||
| 164 | } | ||
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; | |||
| 17 | import java.nio.file.Paths; | 17 | import java.nio.file.Paths; |
| 18 | import java.util.Collection; | 18 | import java.util.Collection; |
| 19 | 19 | ||
| 20 | // TODO clean APIs | ||
| 20 | public abstract class QueryReasoner { | 21 | public abstract class QueryReasoner { |
| 21 | 22 | ||
| 22 | // protected boolean forSemFacet = false; | 23 | // 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 { | |||
| 22 | private int dependenciesCounter = 0; | 22 | private int dependenciesCounter = 0; |
| 23 | 23 | ||
| 24 | // replace with hashcode. in case of collision you get only a different upper bound model. | 24 | // replace with hashcode. in case of collision you get only a different upper bound model. |
| 25 | // or, better, use perfect hashing (i.e. devise an ad-hoc hash function without collisions) | ||
| 25 | private Map<Tuple<Individual>, Integer> mapDependencyToId = new HashMap<>(); | 26 | private Map<Tuple<Individual>, Integer> mapDependencyToId = new HashMap<>(); |
| 26 | 27 | ||
| 27 | /** | 28 | /** |
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 { | |||
| 30 | public boolean getToCallHermiT() { return toCallHermiT; } | 30 | public boolean getToCallHermiT() { return toCallHermiT; } |
| 31 | public void setToCallHermiT(boolean flag) { toCallHermiT = flag; } | 31 | public void setToCallHermiT(boolean flag) { toCallHermiT = flag; } |
| 32 | 32 | ||
| 33 | public static boolean ShellModeDefault = false; | 33 | public static boolean shellModeDefault = false; |
| 34 | 34 | ||
| 35 | boolean shellMode = ShellModeDefault; | 35 | boolean shellMode = shellModeDefault; |
| 36 | public boolean getShellMode() { return shellMode; } | 36 | public boolean getShellMode() { return shellMode; } |
| 37 | public void setShellMode(boolean flag) { shellMode = flag; } | 37 | public void setShellMode(boolean flag) { shellMode = flag; } |
| 38 | 38 | ||
