diff options
| author | RncLsn <rnc.lsn@gmail.com> | 2015-08-01 18:53:23 +0100 |
|---|---|---|
| committer | RncLsn <rnc.lsn@gmail.com> | 2015-08-01 18:53:23 +0100 |
| commit | 3d1c8553f61747b54a8304a39f401f9b77f8cf57 (patch) | |
| tree | 1e1374da8ae640b7e5c4aff86a5ab2d8d413f2ac /src | |
| parent | 3d44aee6069175038266c65f945147569e6343f6 (diff) | |
| download | ACQuA-3d1c8553f61747b54a8304a39f401f9b77f8cf57.tar.gz ACQuA-3d1c8553f61747b54a8304a39f401f9b77f8cf57.zip | |
Option for SkolemUpperBound application and for skolemisation depth (from file pagoda.properties).
Diffstat (limited to 'src')
| -rw-r--r-- | src/resources/pagoda.properties | 5 | ||||
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/Pagoda.java | 14 | ||||
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/query/QueryRecord.java | 3 | ||||
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java | 12 | ||||
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/rules/approximators/LimitedSkolemisationApproximator.java | 5 | ||||
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/util/PagodaProperties.java | 416 | ||||
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/util/data_structures/Graph.java | 38 |
7 files changed, 287 insertions, 206 deletions
diff --git a/src/resources/pagoda.properties b/src/resources/pagoda.properties index e49aa35..07a0eac 100644 --- a/src/resources/pagoda.properties +++ b/src/resources/pagoda.properties | |||
| @@ -1,6 +1,9 @@ | |||
| 1 | debug=true | 1 | debug=true |
| 2 | useAlwaysSimpleUpperBound=false | 2 | useAlwaysSimpleUpperBound=false |
| 3 | useSkolemUpperBound=false | 3 | skolemUpperBound=DISABLED |
| 4 | skolemDepth=1 | ||
| 5 | #skolemUpperBound=BEFORE_SUMMARISATION | ||
| 6 | #skolemUpperBound=AFTER_SUMMARISATION | ||
| 4 | toCallHermit=true | 7 | toCallHermit=true |
| 5 | 8 | ||
| 6 | statisticsDir=/home/alessandro/Dropbox/Oxford/PAGOdA/statistics \ No newline at end of file | 9 | statisticsDir=/home/alessandro/Dropbox/Oxford/PAGOdA/statistics \ 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 index 7d2317d..08b2cba 100644 --- a/src/uk/ac/ox/cs/pagoda/Pagoda.java +++ b/src/uk/ac/ox/cs/pagoda/Pagoda.java | |||
| @@ -143,7 +143,9 @@ public class Pagoda implements Runnable { | |||
| 143 | String statisticsFilename = "statistics_" + | 143 | String statisticsFilename = "statistics_" + |
| 144 | FilenameUtils.removeExtension(FilenameUtils.getName(properties.getOntologyPath().replaceAll("_", "-"))); | 144 | FilenameUtils.removeExtension(FilenameUtils.getName(properties.getOntologyPath().replaceAll("_", "-"))); |
| 145 | statisticsFilename += "_" + FilenameUtils.removeExtension(FilenameUtils.getName(queryFile).replaceAll("_", "-")); | 145 | statisticsFilename += "_" + FilenameUtils.removeExtension(FilenameUtils.getName(queryFile).replaceAll("_", "-")); |
| 146 | statisticsFilename += "_" + ((properties.getUseSkolemUpperBound()) ? "skolem" : ""); | 146 | statisticsFilename += "_" + ((properties.getSkolemUpperBound() == PagodaProperties.SkolemUpperBoundOptions.DISABLED) |
| 147 | ? "" : (properties.getSkolemUpperBound() == PagodaProperties.SkolemUpperBoundOptions.BEFORE_SUMMARISATION) | ||
| 148 | ? "before" : "after"); | ||
| 147 | statisticsFilename += ".json"; | 149 | statisticsFilename += ".json"; |
| 148 | statisticsFilename = FilenameUtils.concat(properties.getStatisticsDir().toString(), | 150 | statisticsFilename = FilenameUtils.concat(properties.getStatisticsDir().toString(), |
| 149 | statisticsFilename); | 151 | statisticsFilename); |
| @@ -213,9 +215,15 @@ public class Pagoda implements Runnable { | |||
| 213 | return this; | 215 | return this; |
| 214 | } | 216 | } |
| 215 | 217 | ||
| 216 | public PagodaBuilder skolem(Boolean isEnabled) { | 218 | public PagodaBuilder skolem(PagodaProperties.SkolemUpperBoundOptions option) { |
| 217 | if(instance == null) return null; | 219 | if(instance == null) return null; |
| 218 | instance.properties.setUseSkolemUpperBound(isEnabled); | 220 | instance.properties.setSkolemUpperBound(option); |
| 221 | return this; | ||
| 222 | } | ||
| 223 | |||
| 224 | public PagodaBuilder skolemDepth(int depth) { | ||
| 225 | if(instance == null) return null; | ||
| 226 | instance.properties.setSkolemDepth(depth); | ||
| 219 | return this; | 227 | return this; |
| 220 | } | 228 | } |
| 221 | 229 | ||
diff --git a/src/uk/ac/ox/cs/pagoda/query/QueryRecord.java b/src/uk/ac/ox/cs/pagoda/query/QueryRecord.java index d88376f..f702d5c 100644 --- a/src/uk/ac/ox/cs/pagoda/query/QueryRecord.java +++ b/src/uk/ac/ox/cs/pagoda/query/QueryRecord.java | |||
| @@ -802,7 +802,7 @@ public class QueryRecord extends Disposable { | |||
| 802 | } | 802 | } |
| 803 | 803 | ||
| 804 | public static Gson getInstance() { | 804 | public static Gson getInstance() { |
| 805 | if(gson == null) { | 805 | if (gson == null) { |
| 806 | gson = new GsonBuilder() | 806 | gson = new GsonBuilder() |
| 807 | .registerTypeAdapter(AnswerTuple.class, new AnswerTuple.AnswerTupleSerializer()) | 807 | .registerTypeAdapter(AnswerTuple.class, new AnswerTuple.AnswerTupleSerializer()) |
| 808 | .registerTypeAdapter(QueryRecord.class, new QueryRecord.QueryRecordSerializer()) | 808 | .registerTypeAdapter(QueryRecord.class, new QueryRecord.QueryRecordSerializer()) |
| @@ -820,4 +820,5 @@ public class QueryRecord extends Disposable { | |||
| 820 | // } | 820 | // } |
| 821 | 821 | ||
| 822 | } | 822 | } |
| 823 | |||
| 823 | } | 824 | } |
diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java b/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java index 6b1921c..8e28142 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java | |||
| @@ -18,6 +18,7 @@ import uk.ac.ox.cs.pagoda.tracking.QueryTracker; | |||
| 18 | import uk.ac.ox.cs.pagoda.tracking.TrackingRuleEncoder; | 18 | import uk.ac.ox.cs.pagoda.tracking.TrackingRuleEncoder; |
| 19 | import uk.ac.ox.cs.pagoda.tracking.TrackingRuleEncoderDisjVar1; | 19 | import uk.ac.ox.cs.pagoda.tracking.TrackingRuleEncoderDisjVar1; |
| 20 | import uk.ac.ox.cs.pagoda.tracking.TrackingRuleEncoderWithGap; | 20 | import uk.ac.ox.cs.pagoda.tracking.TrackingRuleEncoderWithGap; |
| 21 | import uk.ac.ox.cs.pagoda.util.PagodaProperties; | ||
| 21 | import uk.ac.ox.cs.pagoda.util.Timer; | 22 | import uk.ac.ox.cs.pagoda.util.Timer; |
| 22 | import uk.ac.ox.cs.pagoda.util.Utility; | 23 | import uk.ac.ox.cs.pagoda.util.Utility; |
| 23 | import uk.ac.ox.cs.pagoda.util.disposable.DisposedException; | 24 | import uk.ac.ox.cs.pagoda.util.disposable.DisposedException; |
| @@ -193,6 +194,11 @@ class MyQueryReasoner extends QueryReasoner { | |||
| 193 | // queryRecord.saveRelevantOntology("/home/alessandro/Desktop/test-relevant-ontology-"+relevantOntologiesCounter+".owl"); | 194 | // queryRecord.saveRelevantOntology("/home/alessandro/Desktop/test-relevant-ontology-"+relevantOntologiesCounter+".owl"); |
| 194 | // relevantOntologiesCounter++; | 195 | // relevantOntologiesCounter++; |
| 195 | 196 | ||
| 197 | if(properties.getSkolemUpperBound() == PagodaProperties.SkolemUpperBoundOptions.BEFORE_SUMMARISATION | ||
| 198 | && querySkolemisedRelevantSubset(relevantOntologySubset, queryRecord)) { | ||
| 199 | return; | ||
| 200 | } | ||
| 201 | |||
| 196 | Utility.logInfo(">> Summarisation <<"); | 202 | Utility.logInfo(">> Summarisation <<"); |
| 197 | HermitSummaryFilter summarisedChecker = new HermitSummaryFilter(queryRecord, properties.getToCallHermiT()); | 203 | HermitSummaryFilter summarisedChecker = new HermitSummaryFilter(queryRecord, properties.getToCallHermiT()); |
| 198 | if(summarisedChecker.check(queryRecord.getGapAnswers()) == 0) { | 204 | if(summarisedChecker.check(queryRecord.getGapAnswers()) == 0) { |
| @@ -200,8 +206,8 @@ class MyQueryReasoner extends QueryReasoner { | |||
| 200 | return; | 206 | return; |
| 201 | } | 207 | } |
| 202 | 208 | ||
| 203 | if(properties.getUseSkolemUpperBound() && | 209 | if(properties.getSkolemUpperBound() == PagodaProperties.SkolemUpperBoundOptions.AFTER_SUMMARISATION |
| 204 | querySkolemisedRelevantSubset(relevantOntologySubset, queryRecord)) { | 210 | && querySkolemisedRelevantSubset(relevantOntologySubset, queryRecord)) { |
| 205 | summarisedChecker.dispose(); | 211 | summarisedChecker.dispose(); |
| 206 | return; | 212 | return; |
| 207 | } | 213 | } |
| @@ -390,7 +396,7 @@ class MyQueryReasoner extends QueryReasoner { | |||
| 390 | relevantStore.importDataFromABoxOf(relevantSubset); | 396 | relevantStore.importDataFromABoxOf(relevantSubset); |
| 391 | String relevantOriginalMarkProgram = OWLHelper.getOriginalMarkProgram(relevantSubset); | 397 | String relevantOriginalMarkProgram = OWLHelper.getOriginalMarkProgram(relevantSubset); |
| 392 | 398 | ||
| 393 | int queryDependentMaxTermDepth = 3; // TODO make it dynamic | 399 | int queryDependentMaxTermDepth = properties.getSkolemDepth(); |
| 394 | relevantStore.materialise("Mark original individuals", relevantOriginalMarkProgram); | 400 | relevantStore.materialise("Mark original individuals", relevantOriginalMarkProgram); |
| 395 | int materialisationTag = relevantStore.materialiseSkolemly(relevantProgram, null, | 401 | int materialisationTag = relevantStore.materialiseSkolemly(relevantProgram, null, |
| 396 | queryDependentMaxTermDepth); | 402 | queryDependentMaxTermDepth); |
diff --git a/src/uk/ac/ox/cs/pagoda/rules/approximators/LimitedSkolemisationApproximator.java b/src/uk/ac/ox/cs/pagoda/rules/approximators/LimitedSkolemisationApproximator.java index d694b61..2c8e23d 100644 --- a/src/uk/ac/ox/cs/pagoda/rules/approximators/LimitedSkolemisationApproximator.java +++ b/src/uk/ac/ox/cs/pagoda/rules/approximators/LimitedSkolemisationApproximator.java | |||
| @@ -3,7 +3,6 @@ package uk.ac.ox.cs.pagoda.rules.approximators; | |||
| 3 | import org.semanticweb.HermiT.model.*; | 3 | import org.semanticweb.HermiT.model.*; |
| 4 | import uk.ac.ox.cs.pagoda.multistage.MultiStageUpperProgram; | 4 | import uk.ac.ox.cs.pagoda.multistage.MultiStageUpperProgram; |
| 5 | import uk.ac.ox.cs.pagoda.rules.ExistConstantApproximator; | 5 | import uk.ac.ox.cs.pagoda.rules.ExistConstantApproximator; |
| 6 | import uk.ac.ox.cs.pagoda.util.Utility; | ||
| 7 | import uk.ac.ox.cs.pagoda.util.tuples.Tuple; | 6 | import uk.ac.ox.cs.pagoda.util.tuples.Tuple; |
| 8 | import uk.ac.ox.cs.pagoda.util.tuples.TupleBuilder; | 7 | import uk.ac.ox.cs.pagoda.util.tuples.TupleBuilder; |
| 9 | 8 | ||
| @@ -65,10 +64,8 @@ public class LimitedSkolemisationApproximator implements TupleDependentApproxima | |||
| 65 | private Collection<DLClause> overApprox(DLClause clause, DLClause originalClause, Collection<Tuple<Individual>> violationTuples) { | 64 | private Collection<DLClause> overApprox(DLClause clause, DLClause originalClause, Collection<Tuple<Individual>> violationTuples) { |
| 66 | ArrayList<DLClause> result = new ArrayList<>(); | 65 | ArrayList<DLClause> result = new ArrayList<>(); |
| 67 | for(Tuple<Individual> violationTuple : violationTuples) { | 66 | for(Tuple<Individual> violationTuple : violationTuples) { |
| 68 | if(getMaxDepth(violationTuple) < maxTermDepth) { | 67 | if(getMaxDepth(violationTuple) < maxTermDepth) |
| 69 | result.addAll(getGroundSkolemisation(clause, originalClause, violationTuple)); | 68 | result.addAll(getGroundSkolemisation(clause, originalClause, violationTuple)); |
| 70 | Utility.logDebug("Approximating maximal individual by a constant in rule:" + originalClause); | ||
| 71 | } | ||
| 72 | else | 69 | else |
| 73 | result.addAll(alternativeApproximator.convert(clause, originalClause, null)); | 70 | result.addAll(alternativeApproximator.convert(clause, originalClause, null)); |
| 74 | } | 71 | } |
diff --git a/src/uk/ac/ox/cs/pagoda/util/PagodaProperties.java b/src/uk/ac/ox/cs/pagoda/util/PagodaProperties.java index 7b68400..18469ff 100644 --- a/src/uk/ac/ox/cs/pagoda/util/PagodaProperties.java +++ b/src/uk/ac/ox/cs/pagoda/util/PagodaProperties.java | |||
| @@ -11,198 +11,226 @@ import java.util.Properties; | |||
| 11 | 11 | ||
| 12 | public class PagodaProperties { | 12 | public class PagodaProperties { |
| 13 | 13 | ||
| 14 | public static final String CONFIG_FILE = "pagoda.properties"; | 14 | public enum SkolemUpperBoundOptions {DISABLED, BEFORE_SUMMARISATION, AFTER_SUMMARISATION} |
| 15 | public static final boolean DEFAULT_DEBUG = false; | 15 | |
| 16 | private static final boolean DEFAULT_USE_ALWAYS_SIMPLE_UPPER_BOUND; | 16 | public static final String CONFIG_FILE = "pagoda.properties"; |
| 17 | private static final boolean DEFAULT_USE_SKOLEM_UPPER_BOUND; | 17 | public static final boolean DEFAULT_DEBUG = false; |
| 18 | private static final boolean DEFAULT_TO_CALL_HERMIT; | 18 | private static final boolean DEFAULT_USE_ALWAYS_SIMPLE_UPPER_BOUND; |
| 19 | private static final Path DEFAULT_STATISTICS_DIR; | 19 | private static final SkolemUpperBoundOptions DEFAULT_SKOLEM_UPPER_BOUND; |
| 20 | 20 | private static final int DEFAULT_SKOLEM_DEPTH; | |
| 21 | public static boolean shellModeDefault = false; | 21 | private static final boolean DEFAULT_TO_CALL_HERMIT; |
| 22 | private static boolean debug = DEFAULT_DEBUG; | 22 | private static final Path DEFAULT_STATISTICS_DIR; |
| 23 | 23 | ||
| 24 | static { | 24 | public static boolean shellModeDefault = false; |
| 25 | boolean defaultUseAlwaysSimpleUpperBound = false; | 25 | private static boolean debug = DEFAULT_DEBUG; |
| 26 | boolean defaultUseSkolemUpperBound = true; | 26 | |
| 27 | boolean toCallHermit = true; | 27 | static { |
| 28 | Path defaultStatisticsDir = null; | 28 | boolean defaultUseAlwaysSimpleUpperBound = false; |
| 29 | 29 | SkolemUpperBoundOptions defaultSkolemUpperBound = SkolemUpperBoundOptions.DISABLED; | |
| 30 | try(InputStream in = PagodaProperties.class.getClassLoader().getResourceAsStream(CONFIG_FILE)) { | 30 | int defaultSkolemDepth = 1; |
| 31 | Properties config = new Properties(); | 31 | boolean toCallHermit = true; |
| 32 | config.load(in); | 32 | Path defaultStatisticsDir = null; |
| 33 | in.close(); | 33 | |
| 34 | Logger logger = Logger.getLogger("PagodaProperties"); | 34 | try (InputStream in = PagodaProperties.class.getClassLoader().getResourceAsStream(CONFIG_FILE)) { |
| 35 | if(config.containsKey("debug")) { | 35 | Properties config = new Properties(); |
| 36 | debug = Boolean.parseBoolean(config.getProperty("debug")); | 36 | config.load(in); |
| 37 | logger.info("Debugging mode is enabled"); | 37 | in.close(); |
| 38 | 38 | Logger logger = Logger.getLogger("PagodaProperties"); | |
| 39 | if(config.containsKey("statisticsDir")) { | 39 | if (config.containsKey("debug")) { |
| 40 | defaultStatisticsDir = Paths.get(config.getProperty("statisticsDir")); | 40 | debug = Boolean.parseBoolean(config.getProperty("debug")); |
| 41 | logger.info("The directory where statistics are saved is: \"" + defaultStatisticsDir + "\""); | 41 | logger.info("Debugging mode is enabled"); |
| 42 | } | 42 | |
| 43 | } | 43 | if (config.containsKey("statisticsDir")) { |
| 44 | if(config.containsKey("useAlwaysSimpleUpperBound")) { | 44 | defaultStatisticsDir = Paths.get(config.getProperty("statisticsDir")); |
| 45 | defaultUseAlwaysSimpleUpperBound = | 45 | logger.info("The directory where statistics are saved is: \"" + defaultStatisticsDir + "\""); |
| 46 | Boolean.parseBoolean(config.getProperty("useAlwaysSimpleUpperBound")); | 46 | } |
| 47 | if(defaultUseAlwaysSimpleUpperBound) | 47 | } |
| 48 | logger.debug("By default the simple upper bound is always used"); | 48 | if (config.containsKey("useAlwaysSimpleUpperBound")) { |
| 49 | } | 49 | defaultUseAlwaysSimpleUpperBound = |
| 50 | if(config.containsKey("useSkolemUpperBound")) { | 50 | Boolean.parseBoolean(config.getProperty("useAlwaysSimpleUpperBound")); |
| 51 | defaultUseSkolemUpperBound = Boolean.parseBoolean(config.getProperty("useSkolemUpperBound")); | 51 | if (defaultUseAlwaysSimpleUpperBound) |
| 52 | if(defaultUseSkolemUpperBound) | 52 | logger.debug("By default the simple upper bound is always used"); |
| 53 | logger.debug("By default the Skolem upper bound is enabled"); | 53 | } |
| 54 | else | 54 | if (config.containsKey("skolemUpperBound")) { |
| 55 | logger.debug("By default the Skolem upper bound is disabled"); | 55 | defaultSkolemUpperBound = SkolemUpperBoundOptions.valueOf(config.getProperty("skolemUpperBound")); |
| 56 | } | 56 | switch (defaultSkolemUpperBound) { |
| 57 | if(config.containsKey("toCallHermit")) { | 57 | case AFTER_SUMMARISATION: |
| 58 | toCallHermit = Boolean.parseBoolean(config.getProperty("toCallHermit")); | 58 | logger.debug("By default the Skolem upper bound is applied AFTER Summarisation"); |
| 59 | if(toCallHermit) | 59 | break; |
| 60 | logger.debug("By default Hermit is enabled"); | 60 | case BEFORE_SUMMARISATION: |
| 61 | else | 61 | logger.debug("By default the Skolem upper bound is applied BEFORE Summarisation"); |
| 62 | logger.debug("By default Hermit is disabled"); | 62 | break; |
| 63 | } | 63 | default: |
| 64 | 64 | defaultSkolemUpperBound = SkolemUpperBoundOptions.DISABLED; | |
| 65 | } catch(IOException e) { | 65 | case DISABLED: |
| 66 | e.printStackTrace(); | 66 | logger.debug("By default the Skolem upper bound is disabled"); |
| 67 | } | 67 | } |
| 68 | DEFAULT_USE_ALWAYS_SIMPLE_UPPER_BOUND = defaultUseAlwaysSimpleUpperBound; | 68 | } |
| 69 | DEFAULT_USE_SKOLEM_UPPER_BOUND = defaultUseSkolemUpperBound; | 69 | if (config.containsKey("toCallHermit")) { |
| 70 | DEFAULT_TO_CALL_HERMIT = toCallHermit; | 70 | toCallHermit = Boolean.parseBoolean(config.getProperty("toCallHermit")); |
| 71 | DEFAULT_STATISTICS_DIR = defaultStatisticsDir; | 71 | if (toCallHermit) |
| 72 | } | 72 | logger.debug("By default Hermit is enabled"); |
| 73 | 73 | else | |
| 74 | String dataPath = null; | 74 | logger.debug("By default Hermit is disabled"); |
| 75 | String ontologyPath; | 75 | } |
| 76 | String queryPath = null; | 76 | if (config.containsKey("skolemDepth")) { |
| 77 | String answerPath = null; | 77 | defaultSkolemDepth = Integer.parseInt(config.getProperty("skolemDepth")); |
| 78 | boolean toClassify = true; | 78 | logger.debug("By default the max skolemisation depth is " + defaultSkolemDepth); |
| 79 | boolean toCallHermiT = DEFAULT_TO_CALL_HERMIT; | 79 | } |
| 80 | boolean shellMode = shellModeDefault; | 80 | |
| 81 | private boolean useAlwaysSimpleUpperBound = DEFAULT_USE_ALWAYS_SIMPLE_UPPER_BOUND; | 81 | } catch (IOException e) { |
| 82 | private boolean useSkolemUpperBound = DEFAULT_USE_SKOLEM_UPPER_BOUND; | 82 | e.printStackTrace(); |
| 83 | private Path statisticsDir = DEFAULT_STATISTICS_DIR; | 83 | } |
| 84 | 84 | DEFAULT_USE_ALWAYS_SIMPLE_UPPER_BOUND = defaultUseAlwaysSimpleUpperBound; | |
| 85 | public PagodaProperties(String path) { | 85 | DEFAULT_SKOLEM_UPPER_BOUND = defaultSkolemUpperBound; |
| 86 | java.util.Properties m_properties = new java.util.Properties(); | 86 | DEFAULT_TO_CALL_HERMIT = toCallHermit; |
| 87 | InputStream inputStream = null; | 87 | DEFAULT_STATISTICS_DIR = defaultStatisticsDir; |
| 88 | try { | 88 | DEFAULT_SKOLEM_DEPTH = defaultSkolemDepth; |
| 89 | inputStream = new FileInputStream(path); | 89 | } |
| 90 | m_properties.load(inputStream); | 90 | |
| 91 | 91 | String dataPath = null; | |
| 92 | setOntologyPath(m_properties.getProperty("ONTOLOGY")); | 92 | String ontologyPath; |
| 93 | setDataPath(m_properties.getProperty("DATA")); | 93 | String queryPath = null; |
| 94 | setQueryPath(m_properties.getProperty("QUERY")); | 94 | String answerPath = null; |
| 95 | setAnswerPath(m_properties.getProperty("ANSWER")); | 95 | boolean toClassify = true; |
| 96 | setToClassify(Boolean.parseBoolean(m_properties.getProperty("TO_CLASSIFY"))); | 96 | boolean toCallHermiT = DEFAULT_TO_CALL_HERMIT; |
| 97 | setToCallHermiT(Boolean.parseBoolean(m_properties.getProperty("CALL_HERMIT"))); | 97 | |
| 98 | 98 | public int getSkolemDepth() { | |
| 99 | } catch (IOException e) { | 99 | return skolemDepth; |
| 100 | e.printStackTrace(); | 100 | } |
| 101 | } finally { | 101 | |
| 102 | if (inputStream != null) | 102 | public void setSkolemDepth(int skolemDepth) { |
| 103 | try { | 103 | this.skolemDepth = skolemDepth; |
| 104 | inputStream.close(); | 104 | } |
| 105 | } catch (IOException e) { | 105 | |
| 106 | e.printStackTrace(); | 106 | int skolemDepth = DEFAULT_SKOLEM_DEPTH; |
| 107 | } | 107 | boolean shellMode = shellModeDefault; |
| 108 | } | 108 | private boolean useAlwaysSimpleUpperBound = DEFAULT_USE_ALWAYS_SIMPLE_UPPER_BOUND; |
| 109 | } | 109 | private SkolemUpperBoundOptions skolemUpperBound = DEFAULT_SKOLEM_UPPER_BOUND; |
| 110 | public PagodaProperties() { | 110 | private Path statisticsDir = DEFAULT_STATISTICS_DIR; |
| 111 | } | 111 | |
| 112 | 112 | public PagodaProperties(String path) { | |
| 113 | public static boolean isDebuggingMode() { | 113 | java.util.Properties m_properties = new java.util.Properties(); |
| 114 | return debug; | 114 | InputStream inputStream = null; |
| 115 | } | 115 | try { |
| 116 | 116 | inputStream = new FileInputStream(path); | |
| 117 | public static boolean getDefaultUseAlwaysSimpleUpperBound() { | 117 | m_properties.load(inputStream); |
| 118 | return DEFAULT_USE_ALWAYS_SIMPLE_UPPER_BOUND; | 118 | |
| 119 | } | 119 | setOntologyPath(m_properties.getProperty("ONTOLOGY")); |
| 120 | 120 | setDataPath(m_properties.getProperty("DATA")); | |
| 121 | public static Path getDefaultStatisticsDir() { | 121 | setQueryPath(m_properties.getProperty("QUERY")); |
| 122 | return DEFAULT_STATISTICS_DIR; | 122 | setAnswerPath(m_properties.getProperty("ANSWER")); |
| 123 | } | 123 | setToClassify(Boolean.parseBoolean(m_properties.getProperty("TO_CLASSIFY"))); |
| 124 | 124 | setToCallHermiT(Boolean.parseBoolean(m_properties.getProperty("CALL_HERMIT"))); | |
| 125 | public static boolean getDefaultUseSkolemUpperBound() { | 125 | |
| 126 | return DEFAULT_USE_SKOLEM_UPPER_BOUND; | 126 | } catch (IOException e) { |
| 127 | } | 127 | e.printStackTrace(); |
| 128 | 128 | } finally { | |
| 129 | public String getDataPath() { | 129 | if (inputStream != null) |
| 130 | return dataPath; | 130 | try { |
| 131 | } | 131 | inputStream.close(); |
| 132 | 132 | } catch (IOException e) { | |
| 133 | public void setDataPath(String path) { | 133 | e.printStackTrace(); |
| 134 | dataPath = path; | 134 | } |
| 135 | } | 135 | } |
| 136 | 136 | } | |
| 137 | public String getOntologyPath() { | 137 | |
| 138 | return ontologyPath; | 138 | public PagodaProperties() { |
| 139 | } | 139 | } |
| 140 | 140 | ||
| 141 | public void setOntologyPath(String path) { | 141 | public static boolean isDebuggingMode() { |
| 142 | ontologyPath = path; | 142 | return debug; |
| 143 | } | 143 | } |
| 144 | 144 | ||
| 145 | public String getQueryPath() { | 145 | public static boolean getDefaultUseAlwaysSimpleUpperBound() { |
| 146 | return queryPath; | 146 | return DEFAULT_USE_ALWAYS_SIMPLE_UPPER_BOUND; |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | public void setQueryPath(String path) { | 149 | public static Path getDefaultStatisticsDir() { |
| 150 | queryPath = path; | 150 | return DEFAULT_STATISTICS_DIR; |
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | public String getAnswerPath() { | 153 | public static SkolemUpperBoundOptions getDefaultSkolemUpperBound() { |
| 154 | return answerPath; | 154 | return DEFAULT_SKOLEM_UPPER_BOUND; |
| 155 | } | 155 | } |
| 156 | 156 | ||
| 157 | public void setAnswerPath(String path) { | 157 | public String getDataPath() { |
| 158 | answerPath = path; | 158 | return dataPath; |
| 159 | } | 159 | } |
| 160 | 160 | ||
| 161 | public boolean getToClassify() { | 161 | public void setDataPath(String path) { |
| 162 | return toClassify; | 162 | dataPath = path; |
| 163 | } | 163 | } |
| 164 | 164 | ||
| 165 | public void setToClassify(boolean flag) { | 165 | public String getOntologyPath() { |
| 166 | toClassify = flag; | 166 | return ontologyPath; |
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | public boolean getToCallHermiT() { | 169 | public void setOntologyPath(String path) { |
| 170 | return toCallHermiT; | 170 | ontologyPath = path; |
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | public void setToCallHermiT(boolean flag) { | 173 | public String getQueryPath() { |
| 174 | toCallHermiT = flag; | 174 | return queryPath; |
| 175 | } | 175 | } |
| 176 | 176 | ||
| 177 | public boolean getShellMode() { | 177 | public void setQueryPath(String path) { |
| 178 | return shellMode; | 178 | queryPath = path; |
| 179 | } | 179 | } |
| 180 | 180 | ||
| 181 | public void setShellMode(boolean flag) { | 181 | public String getAnswerPath() { |
| 182 | shellMode = flag; | 182 | return answerPath; |
| 183 | } | 183 | } |
| 184 | 184 | ||
| 185 | public boolean getUseAlwaysSimpleUpperBound() { | 185 | public void setAnswerPath(String path) { |
| 186 | return useAlwaysSimpleUpperBound; | 186 | answerPath = path; |
| 187 | } | 187 | } |
| 188 | 188 | ||
| 189 | public void setUseAlwaysSimpleUpperBound(boolean flag) { | 189 | public boolean getToClassify() { |
| 190 | useAlwaysSimpleUpperBound = flag; | 190 | return toClassify; |
| 191 | } | 191 | } |
| 192 | 192 | ||
| 193 | public boolean getUseSkolemUpperBound() { | 193 | public void setToClassify(boolean flag) { |
| 194 | return useSkolemUpperBound; | 194 | toClassify = flag; |
| 195 | } | 195 | } |
| 196 | 196 | ||
| 197 | public void setUseSkolemUpperBound(boolean flag) { | 197 | public boolean getToCallHermiT() { |
| 198 | useSkolemUpperBound = flag; | 198 | return toCallHermiT; |
| 199 | } | 199 | } |
| 200 | 200 | ||
| 201 | public Path getStatisticsDir() { | 201 | public void setToCallHermiT(boolean flag) { |
| 202 | return statisticsDir; | 202 | toCallHermiT = flag; |
| 203 | } | 203 | } |
| 204 | 204 | ||
| 205 | public void setStatisticsDir(Path statisticsDir) { | 205 | public boolean getShellMode() { |
| 206 | this.statisticsDir = statisticsDir; | 206 | return shellMode; |
| 207 | } | 207 | } |
| 208 | |||
| 209 | public void setShellMode(boolean flag) { | ||
| 210 | shellMode = flag; | ||
| 211 | } | ||
| 212 | |||
| 213 | public boolean getUseAlwaysSimpleUpperBound() { | ||
| 214 | return useAlwaysSimpleUpperBound; | ||
| 215 | } | ||
| 216 | |||
| 217 | public void setUseAlwaysSimpleUpperBound(boolean flag) { | ||
| 218 | useAlwaysSimpleUpperBound = flag; | ||
| 219 | } | ||
| 220 | |||
| 221 | public SkolemUpperBoundOptions getSkolemUpperBound() { | ||
| 222 | return skolemUpperBound; | ||
| 223 | } | ||
| 224 | |||
| 225 | public void setSkolemUpperBound(SkolemUpperBoundOptions flag) { | ||
| 226 | skolemUpperBound = flag; | ||
| 227 | } | ||
| 228 | |||
| 229 | public Path getStatisticsDir() { | ||
| 230 | return statisticsDir; | ||
| 231 | } | ||
| 232 | |||
| 233 | public void setStatisticsDir(Path statisticsDir) { | ||
| 234 | this.statisticsDir = statisticsDir; | ||
| 235 | } | ||
| 208 | } | 236 | } |
diff --git a/src/uk/ac/ox/cs/pagoda/util/data_structures/Graph.java b/src/uk/ac/ox/cs/pagoda/util/data_structures/Graph.java new file mode 100644 index 0000000..4f454df --- /dev/null +++ b/src/uk/ac/ox/cs/pagoda/util/data_structures/Graph.java | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.util.data_structures; | ||
| 2 | |||
| 3 | import java.util.*; | ||
| 4 | |||
| 5 | public class Graph<V> { | ||
| 6 | |||
| 7 | private final boolean isDirected; | ||
| 8 | |||
| 9 | private Map<V, Set<V>> outEdgesOf = new HashMap<>(); | ||
| 10 | public Graph(boolean isDirected) { | ||
| 11 | this.isDirected = isDirected; | ||
| 12 | } | ||
| 13 | |||
| 14 | public Graph() { | ||
| 15 | this(false); | ||
| 16 | } | ||
| 17 | public void addNode(V v) { | ||
| 18 | if(!outEdgesOf.containsKey(v)) | ||
| 19 | outEdgesOf.put(v, new HashSet<V>()); | ||
| 20 | } | ||
| 21 | |||
| 22 | public void addEdge(V v, V u) { | ||
| 23 | addNode(v); | ||
| 24 | addNode(u); | ||
| 25 | outEdgesOf.get(v).add(u); | ||
| 26 | |||
| 27 | if(isDirected) | ||
| 28 | outEdgesOf.get(u).add(v); | ||
| 29 | } | ||
| 30 | |||
| 31 | public Iterator<V> getOutNeighbors(V v) { | ||
| 32 | return outEdgesOf.get(v).iterator(); | ||
| 33 | } | ||
| 34 | |||
| 35 | public boolean isDirected() { | ||
| 36 | return isDirected; | ||
| 37 | } | ||
| 38 | } | ||
