aboutsummaryrefslogtreecommitdiff
path: root/src/uk/ac/ox/cs/pagoda/Pagoda.java
diff options
context:
space:
mode:
authorRncLsn <rnc.lsn@gmail.com>2015-07-03 19:09:31 +0100
committerRncLsn <rnc.lsn@gmail.com>2015-07-03 19:09:31 +0100
commit39b60d4225f5efa4e0287a2c6ce69d90391c69db (patch)
tree18c5b05726f39baa4d3ca8b228e24ad1f0182f2a /src/uk/ac/ox/cs/pagoda/Pagoda.java
parent133dab6e21f263df2baca913d3d0b7a4fd152d08 (diff)
downloadACQuA-39b60d4225f5efa4e0287a2c6ce69d90391c69db.tar.gz
ACQuA-39b60d4225f5efa4e0287a2c6ce69d90391c69db.zip
Many little changes.
Diffstat (limited to 'src/uk/ac/ox/cs/pagoda/Pagoda.java')
-rw-r--r--src/uk/ac/ox/cs/pagoda/Pagoda.java58
1 files changed, 47 insertions, 11 deletions
diff --git a/src/uk/ac/ox/cs/pagoda/Pagoda.java b/src/uk/ac/ox/cs/pagoda/Pagoda.java
index f5dce15..7d2317d 100644
--- a/src/uk/ac/ox/cs/pagoda/Pagoda.java
+++ b/src/uk/ac/ox/cs/pagoda/Pagoda.java
@@ -1,12 +1,21 @@
1package uk.ac.ox.cs.pagoda; 1package uk.ac.ox.cs.pagoda;
2 2
3import org.apache.commons.cli.*; 3import org.apache.commons.cli.*;
4import org.apache.commons.io.FilenameUtils;
5import uk.ac.ox.cs.pagoda.query.QueryRecord;
4import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner; 6import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner;
5import uk.ac.ox.cs.pagoda.util.PagodaProperties; 7import uk.ac.ox.cs.pagoda.util.PagodaProperties;
6import uk.ac.ox.cs.pagoda.util.Timer; 8import uk.ac.ox.cs.pagoda.util.Timer;
7import uk.ac.ox.cs.pagoda.util.Utility; 9import uk.ac.ox.cs.pagoda.util.Utility;
8 10
11import java.io.BufferedWriter;
12import java.io.IOException;
13import java.nio.file.Files;
9import java.nio.file.Path; 14import java.nio.file.Path;
15import java.nio.file.Paths;
16import java.util.Collection;
17import java.util.HashMap;
18import java.util.Map;
10 19
11/** 20/**
12 * Executable command line user interface. 21 * Executable command line user interface.
@@ -23,7 +32,7 @@ public class Pagoda implements Runnable {
23 32
24 /** 33 /**
25 * Do not use it 34 * Do not use it
26 * */ 35 */
27 private Pagoda() { 36 private Pagoda() {
28 properties = new PagodaProperties(); 37 properties = new PagodaProperties();
29 } 38 }
@@ -85,7 +94,7 @@ public class Pagoda implements Runnable {
85 94
86 /** 95 /**
87 * Get a builder. 96 * Get a builder.
88 * */ 97 */
89 public static PagodaBuilder builder() { 98 public static PagodaBuilder builder() {
90 return new PagodaBuilder(); 99 return new PagodaBuilder();
91 } 100 }
@@ -102,21 +111,48 @@ public class Pagoda implements Runnable {
102 try { 111 try {
103 Timer t = new Timer(); 112 Timer t = new Timer();
104 pagoda = QueryReasoner.getInstance(properties); 113 pagoda = QueryReasoner.getInstance(properties);
105 if (pagoda == null) return; 114 if(pagoda == null) return;
106 115
107 Utility.logInfo("Preprocessing Done in " + t.duration() + " seconds."); 116 Utility.logInfo("Preprocessing Done in " + t.duration() + " seconds.");
108 117
109 if (properties.getQueryPath() != null) 118 if(properties.getQueryPath() != null) {
110 for (String queryFile: properties.getQueryPath().split(";")) 119 for(String queryFile : properties.getQueryPath().split(";")) {
111 pagoda.evaluate(pagoda.getQueryManager().collectQueryRecords(queryFile)); 120 Collection<QueryRecord> queryRecords = pagoda.getQueryManager().collectQueryRecords(queryFile);
121 pagoda.evaluate(queryRecords);
122
123 if(PagodaProperties.isDebuggingMode()) {
124 HashMap<String, Map<String, String>> statistics = new HashMap<>();
125 for(QueryRecord queryRecord : queryRecords) {
126 statistics.put(queryRecord.getQueryID(), queryRecord.getStatistics());
127 }
128 String statisticsFilename = getStatisticsFilename(properties, queryFile);
129 try(BufferedWriter writer = Files.newBufferedWriter(Paths.get(statisticsFilename))) {
130 QueryRecord.GsonCreator.getInstance().toJson(statistics, writer);
131 } catch(IOException e) {
132 Utility.logError("Unable to save statistics");
133 }
134 }
135 }
136 }
112 } finally { 137 } finally {
113 if (pagoda != null) pagoda.dispose(); 138 if(pagoda != null) pagoda.dispose();
114 } 139 }
115 } 140 }
116 141
142 private String getStatisticsFilename(PagodaProperties properties, String queryFile) {
143 String statisticsFilename = "statistics_" +
144 FilenameUtils.removeExtension(FilenameUtils.getName(properties.getOntologyPath().replaceAll("_", "-")));
145 statisticsFilename += "_" + FilenameUtils.removeExtension(FilenameUtils.getName(queryFile).replaceAll("_", "-"));
146 statisticsFilename += "_" + ((properties.getUseSkolemUpperBound()) ? "skolem" : "");
147 statisticsFilename += ".json";
148 statisticsFilename = FilenameUtils.concat(properties.getStatisticsDir().toString(),
149 statisticsFilename);
150 return statisticsFilename;
151 }
152
117 /** 153 /**
118 * Allows to set the parameters before creating a Pagoda instance. 154 * Allows to set the parameters before creating a Pagoda instance.
119 * */ 155 */
120 public static class PagodaBuilder { 156 public static class PagodaBuilder {
121 157
122 private Pagoda instance; 158 private Pagoda instance;