diff options
| author | RncLsn <rnc.lsn@gmail.com> | 2015-05-07 19:26:24 +0100 |
|---|---|---|
| committer | RncLsn <rnc.lsn@gmail.com> | 2015-05-07 19:26:24 +0100 |
| commit | 5be5fd3daa0d50980fb3791e904e035cdbca254f (patch) | |
| tree | 8109fdd92d6a8f3b59b47f147d21e23b84301494 | |
| parent | 11a432bfc3cb11e07c68c4298fcec060ff1e25fa (diff) | |
| download | ACQuA-5be5fd3daa0d50980fb3791e904e035cdbca254f.tar.gz ACQuA-5be5fd3daa0d50980fb3791e904e035cdbca254f.zip | |
Making the output machine-readable (JSON).
22 files changed, 588 insertions, 411 deletions
diff --git a/.idea/libraries/Maven__com_google_code_gson_gson_2_3_1.xml b/.idea/libraries/Maven__com_google_code_gson_gson_2_3_1.xml new file mode 100644 index 0000000..d7b5038 --- /dev/null +++ b/.idea/libraries/Maven__com_google_code_gson_gson_2_3_1.xml | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | <component name="libraryTable"> | ||
| 2 | <library name="Maven: com.google.code.gson:gson:2.3.1"> | ||
| 3 | <CLASSES> | ||
| 4 | <root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.3.1/gson-2.3.1.jar!/" /> | ||
| 5 | </CLASSES> | ||
| 6 | <JAVADOC> | ||
| 7 | <root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.3.1/gson-2.3.1-javadoc.jar!/" /> | ||
| 8 | </JAVADOC> | ||
| 9 | <SOURCES> | ||
| 10 | <root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.3.1/gson-2.3.1-sources.jar!/" /> | ||
| 11 | </SOURCES> | ||
| 12 | </library> | ||
| 13 | </component> \ No newline at end of file | ||
diff --git a/.idea/libraries/Maven__com_googlecode_json_simple_json_simple_1_1_1.xml b/.idea/libraries/Maven__com_googlecode_json_simple_json_simple_1_1_1.xml new file mode 100644 index 0000000..f3f3738 --- /dev/null +++ b/.idea/libraries/Maven__com_googlecode_json_simple_json_simple_1_1_1.xml | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | <component name="libraryTable"> | ||
| 2 | <library name="Maven: com.googlecode.json-simple:json-simple:1.1.1"> | ||
| 3 | <CLASSES> | ||
| 4 | <root url="jar://$MAVEN_REPOSITORY$/com/googlecode/json-simple/json-simple/1.1.1/json-simple-1.1.1.jar!/" /> | ||
| 5 | </CLASSES> | ||
| 6 | <JAVADOC> | ||
| 7 | <root url="jar://$MAVEN_REPOSITORY$/com/googlecode/json-simple/json-simple/1.1.1/json-simple-1.1.1-javadoc.jar!/" /> | ||
| 8 | </JAVADOC> | ||
| 9 | <SOURCES> | ||
| 10 | <root url="jar://$MAVEN_REPOSITORY$/com/googlecode/json-simple/json-simple/1.1.1/json-simple-1.1.1-sources.jar!/" /> | ||
| 11 | </SOURCES> | ||
| 12 | </library> | ||
| 13 | </component> \ No newline at end of file | ||
| @@ -108,5 +108,15 @@ | |||
| 108 | <artifactId>testng</artifactId> | 108 | <artifactId>testng</artifactId> |
| 109 | <version>6.7</version> | 109 | <version>6.7</version> |
| 110 | </dependency> | 110 | </dependency> |
| 111 | <dependency> | ||
| 112 | <groupId>com.googlecode.json-simple</groupId> | ||
| 113 | <artifactId>json-simple</artifactId> | ||
| 114 | <version>1.1.1</version> | ||
| 115 | </dependency> | ||
| 116 | <dependency> | ||
| 117 | <groupId>com.google.code.gson</groupId> | ||
| 118 | <artifactId>gson</artifactId> | ||
| 119 | <version>2.3.1</version> | ||
| 120 | </dependency> | ||
| 111 | </dependencies> | 121 | </dependencies> |
| 112 | </project> | 122 | </project> |
diff --git a/src/uk/ac/ox/cs/pagoda/query/AnswerTuple.java b/src/uk/ac/ox/cs/pagoda/query/AnswerTuple.java index 8d7e0b1..183cbe1 100644 --- a/src/uk/ac/ox/cs/pagoda/query/AnswerTuple.java +++ b/src/uk/ac/ox/cs/pagoda/query/AnswerTuple.java | |||
| @@ -1,13 +1,10 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.query; | 1 | package uk.ac.ox.cs.pagoda.query; |
| 2 | 2 | ||
| 3 | import java.util.HashMap; | 3 | import com.google.gson.*; |
| 4 | import java.util.Map; | ||
| 5 | |||
| 6 | import org.semanticweb.HermiT.model.Constant; | 4 | import org.semanticweb.HermiT.model.Constant; |
| 7 | import org.semanticweb.HermiT.model.Individual; | 5 | import org.semanticweb.HermiT.model.Individual; |
| 8 | import org.semanticweb.HermiT.model.Term; | 6 | import org.semanticweb.HermiT.model.Term; |
| 9 | import org.semanticweb.HermiT.model.Variable; | 7 | import org.semanticweb.HermiT.model.Variable; |
| 10 | |||
| 11 | import uk.ac.ox.cs.JRDFox.JRDFStoreException; | 8 | import uk.ac.ox.cs.JRDFox.JRDFStoreException; |
| 12 | import uk.ac.ox.cs.JRDFox.model.Datatype; | 9 | import uk.ac.ox.cs.JRDFox.model.Datatype; |
| 13 | import uk.ac.ox.cs.JRDFox.model.GroundTerm; | 10 | import uk.ac.ox.cs.JRDFox.model.GroundTerm; |
| @@ -15,6 +12,10 @@ import uk.ac.ox.cs.JRDFox.model.Literal; | |||
| 15 | import uk.ac.ox.cs.JRDFox.store.TupleIterator; | 12 | import uk.ac.ox.cs.JRDFox.store.TupleIterator; |
| 16 | import uk.ac.ox.cs.pagoda.util.Namespace; | 13 | import uk.ac.ox.cs.pagoda.util.Namespace; |
| 17 | 14 | ||
| 15 | import java.lang.reflect.Type; | ||
| 16 | import java.util.HashMap; | ||
| 17 | import java.util.Map; | ||
| 18 | |||
| 18 | public class AnswerTuple { | 19 | public class AnswerTuple { |
| 19 | 20 | ||
| 20 | public static final String SEPARATOR = "\t"; | 21 | public static final String SEPARATOR = "\t"; |
| @@ -40,17 +41,21 @@ public class AnswerTuple { | |||
| 40 | m_tuple = new GroundTerm[arity]; | 41 | m_tuple = new GroundTerm[arity]; |
| 41 | for (int i = 0; i < arity; ++i) m_tuple[i] = sup.m_tuple[i]; | 42 | for (int i = 0; i < arity; ++i) m_tuple[i] = sup.m_tuple[i]; |
| 42 | } | 43 | } |
| 44 | |||
| 45 | private AnswerTuple(String m_str) { | ||
| 46 | this.m_str = m_str; | ||
| 47 | } | ||
| 43 | 48 | ||
| 44 | public int getArity() { | 49 | public int getArity() { |
| 45 | return m_tuple.length; | 50 | return m_tuple.length; |
| 46 | } | 51 | } |
| 47 | 52 | ||
| 48 | public int hashCode() { | 53 | public int hashCode() { |
| 49 | // return toString().hashCode(); | 54 | return toString().hashCode(); |
| 50 | int code = 0; | 55 | // int code = 0; |
| 51 | for (int i = 0; i < m_tuple.length; ++i) | 56 | // for (int i = 0; i < m_tuple.length; ++i) |
| 52 | code = code * 1997 + m_tuple[i].hashCode(); | 57 | // code = code * 1997 + m_tuple[i].hashCode(); |
| 53 | return code; | 58 | // return code; |
| 54 | } | 59 | } |
| 55 | 60 | ||
| 56 | public boolean equals(Object obj) { | 61 | public boolean equals(Object obj) { |
| @@ -131,5 +136,21 @@ public class AnswerTuple { | |||
| 131 | if (length == extendedTuple.getArity()) return extendedTuple; | 136 | if (length == extendedTuple.getArity()) return extendedTuple; |
| 132 | else return new AnswerTuple(extendedTuple, length); | 137 | else return new AnswerTuple(extendedTuple, length); |
| 133 | } | 138 | } |
| 134 | 139 | ||
| 140 | |||
| 141 | public static class AnswerTupleSerializer implements JsonSerializer<AnswerTuple> { | ||
| 142 | |||
| 143 | public JsonElement serialize(AnswerTuple src, Type typeOfSrc, JsonSerializationContext context) { | ||
| 144 | return new JsonPrimitive(src.toString()); | ||
| 145 | } | ||
| 146 | |||
| 147 | } | ||
| 148 | |||
| 149 | public class AnswerTupleDeserializer implements JsonDeserializer<AnswerTuple> { | ||
| 150 | public AnswerTuple deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) | ||
| 151 | throws JsonParseException { | ||
| 152 | return new AnswerTuple(json.getAsJsonPrimitive().getAsString()); | ||
| 153 | } | ||
| 154 | } | ||
| 155 | |||
| 135 | } | 156 | } |
diff --git a/src/uk/ac/ox/cs/pagoda/query/QueryRecord.java b/src/uk/ac/ox/cs/pagoda/query/QueryRecord.java index ce92a67..4b55046 100644 --- a/src/uk/ac/ox/cs/pagoda/query/QueryRecord.java +++ b/src/uk/ac/ox/cs/pagoda/query/QueryRecord.java | |||
| @@ -1,37 +1,9 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.query; | 1 | package uk.ac.ox.cs.pagoda.query; |
| 2 | 2 | ||
| 3 | import java.io.BufferedWriter; | 3 | import com.google.gson.*; |
| 4 | import java.io.FileNotFoundException; | 4 | import com.google.gson.reflect.TypeToken; |
| 5 | import java.io.FileOutputStream; | 5 | import org.semanticweb.HermiT.model.*; |
| 6 | import java.io.IOException; | 6 | import org.semanticweb.owlapi.model.*; |
| 7 | import java.io.OutputStreamWriter; | ||
| 8 | import java.util.Collection; | ||
| 9 | import java.util.HashMap; | ||
| 10 | import java.util.HashSet; | ||
| 11 | import java.util.Iterator; | ||
| 12 | import java.util.LinkedList; | ||
| 13 | import java.util.Map; | ||
| 14 | import java.util.Set; | ||
| 15 | |||
| 16 | import org.semanticweb.HermiT.model.Atom; | ||
| 17 | import org.semanticweb.HermiT.model.AtomicConcept; | ||
| 18 | import org.semanticweb.HermiT.model.AtomicRole; | ||
| 19 | import org.semanticweb.HermiT.model.DLClause; | ||
| 20 | import org.semanticweb.HermiT.model.DLPredicate; | ||
| 21 | import org.semanticweb.HermiT.model.Variable; | ||
| 22 | import org.semanticweb.owlapi.model.OWLAxiom; | ||
| 23 | import org.semanticweb.owlapi.model.OWLClass; | ||
| 24 | import org.semanticweb.owlapi.model.OWLClassAssertionAxiom; | ||
| 25 | import org.semanticweb.owlapi.model.OWLDataProperty; | ||
| 26 | import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom; | ||
| 27 | import org.semanticweb.owlapi.model.OWLIndividual; | ||
| 28 | import org.semanticweb.owlapi.model.OWLLiteral; | ||
| 29 | import org.semanticweb.owlapi.model.OWLObjectProperty; | ||
| 30 | import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom; | ||
| 31 | import org.semanticweb.owlapi.model.OWLOntology; | ||
| 32 | import org.semanticweb.owlapi.model.OWLOntologyManager; | ||
| 33 | import org.semanticweb.owlapi.model.OWLOntologyStorageException; | ||
| 34 | |||
| 35 | import uk.ac.ox.cs.pagoda.hermit.DLClauseHelper; | 7 | import uk.ac.ox.cs.pagoda.hermit.DLClauseHelper; |
| 36 | import uk.ac.ox.cs.pagoda.reasoner.light.RDFoxAnswerTuples; | 8 | import uk.ac.ox.cs.pagoda.reasoner.light.RDFoxAnswerTuples; |
| 37 | import uk.ac.ox.cs.pagoda.rules.GeneralProgram; | 9 | import uk.ac.ox.cs.pagoda.rules.GeneralProgram; |
| @@ -39,6 +11,10 @@ import uk.ac.ox.cs.pagoda.util.ConjunctiveQueryHelper; | |||
| 39 | import uk.ac.ox.cs.pagoda.util.Namespace; | 11 | import uk.ac.ox.cs.pagoda.util.Namespace; |
| 40 | import uk.ac.ox.cs.pagoda.util.Utility; | 12 | import uk.ac.ox.cs.pagoda.util.Utility; |
| 41 | 13 | ||
| 14 | import java.io.*; | ||
| 15 | import java.lang.reflect.Type; | ||
| 16 | import java.util.*; | ||
| 17 | |||
| 42 | public class QueryRecord { | 18 | public class QueryRecord { |
| 43 | 19 | ||
| 44 | public static final String botQueryText = "SELECT ?X WHERE { ?X <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Nothing> }"; | 20 | public static final String botQueryText = "SELECT ?X WHERE { ?X <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Nothing> }"; |
| @@ -47,11 +23,12 @@ public class QueryRecord { | |||
| 47 | 23 | ||
| 48 | private String queryText; | 24 | private String queryText; |
| 49 | private int queryID = -1; | 25 | private int queryID = -1; |
| 50 | private String[][] answerVariables = null; | 26 | |
| 51 | private Set<AnswerTuple> soundAnswerTuples = new HashSet<AnswerTuple>(); | 27 | private String[][] answerVariables = null; |
| 28 | private Set<AnswerTuple> soundAnswerTuples = new HashSet<AnswerTuple>(); | ||
| 52 | private Set<AnswerTuple> gapAnswerTuples = null; | 29 | private Set<AnswerTuple> gapAnswerTuples = null; |
| 53 | 30 | ||
| 54 | private QueryManager m_manager; | 31 | private QueryManager m_manager; |
| 55 | 32 | ||
| 56 | public QueryRecord(QueryManager manager, String text, int id, int subID) { | 33 | public QueryRecord(QueryManager manager, String text, int id, int subID) { |
| 57 | m_manager =manager; | 34 | m_manager =manager; |
| @@ -178,7 +155,7 @@ public class QueryRecord { | |||
| 178 | // str.contains("internal:def"); | 155 | // str.contains("internal:def"); |
| 179 | // } | 156 | // } |
| 180 | 157 | ||
| 181 | boolean processed = false; | 158 | boolean processed = false; |
| 182 | 159 | ||
| 183 | public void markAsProcessed() { | 160 | public void markAsProcessed() { |
| 184 | processed = true; | 161 | processed = true; |
| @@ -205,7 +182,7 @@ public class QueryRecord { | |||
| 205 | return queryText; | 182 | return queryText; |
| 206 | } | 183 | } |
| 207 | 184 | ||
| 208 | String stringQueryID = null; | 185 | String stringQueryID = null; |
| 209 | 186 | ||
| 210 | public String getQueryID() { | 187 | public String getQueryID() { |
| 211 | return stringQueryID; | 188 | return stringQueryID; |
| @@ -233,27 +210,27 @@ public class QueryRecord { | |||
| 233 | writer.newLine(); | 210 | writer.newLine(); |
| 234 | writer.write(queryText); | 211 | writer.write(queryText); |
| 235 | writer.newLine(); | 212 | writer.newLine(); |
| 236 | StringBuilder space = new StringBuilder(); | 213 | StringBuilder space = new StringBuilder(); |
| 237 | int arity = getArity(), varSpace = 0; | 214 | int arity = getArity(), varSpace = 0; |
| 238 | for (int i = 0; i < arity; ++i) | 215 | for (int i = 0; i < arity; ++i) |
| 239 | varSpace += answerVariables[0][i].length(); | 216 | varSpace += answerVariables[0][i].length(); |
| 240 | for (int i = 0; i < (SEPARATOR.length() - varSpace) / (arity + 1); ++i) | 217 | for (int i = 0; i < (SEPARATOR.length() - varSpace) / (arity + 1); ++i) |
| 241 | space.append(" "); | 218 | space.append(" "); |
| 242 | for (int i = 0; i < getArity(); ++i) { | 219 | for (int i = 0; i < getArity(); ++i) { |
| 243 | writer.write(space.toString()); | 220 | writer.write(space.toString()); |
| 244 | writer.write(answerVariables[0][i]); | 221 | writer.write(answerVariables[0][i]); |
| 245 | } | 222 | } |
| 246 | writer.newLine(); | 223 | writer.newLine(); |
| 247 | writer.write(SEPARATOR); | 224 | writer.write(SEPARATOR); |
| 248 | writer.newLine(); | 225 | writer.newLine(); |
| 249 | for (AnswerTuple tuple: soundAnswerTuples) { | 226 | for (AnswerTuple tuple: soundAnswerTuples) { |
| 250 | writer.write(tuple.toString()); | 227 | writer.write(tuple.toString()); |
| 251 | writer.newLine(); | 228 | writer.newLine(); |
| 252 | } | 229 | } |
| 253 | if (!processed()) | 230 | if (!processed()) |
| 254 | for (AnswerTuple tuple: gapAnswerTuples) { | 231 | for (AnswerTuple tuple: gapAnswerTuples) { |
| 255 | writer.write("*"); | 232 | writer.write("*"); |
| 256 | writer.write(tuple.toString()); | 233 | writer.write(tuple.toString()); |
| 257 | writer.newLine(); | 234 | writer.newLine(); |
| 258 | } | 235 | } |
| 259 | // writer.write(SEPARATOR); | 236 | // writer.write(SEPARATOR); |
| @@ -261,6 +238,38 @@ public class QueryRecord { | |||
| 261 | } | 238 | } |
| 262 | 239 | ||
| 263 | } | 240 | } |
| 241 | |||
| 242 | public void outputAnswerStatistics() { | ||
| 243 | |||
| 244 | int answerCounter = soundAnswerTuples.size(); | ||
| 245 | if (!processed()) answerCounter += gapAnswerTuples.size(); | ||
| 246 | |||
| 247 | Utility.logInfo("The number of answer tuples: " + answerCounter); | ||
| 248 | // if (jsonAnswers != null) { | ||
| 249 | // JSONObject jsonAnswer = new JSONObject(); | ||
| 250 | // | ||
| 251 | // jsonAnswer.put("queryID", queryID); | ||
| 252 | // jsonAnswer.put("queryText", queryText); | ||
| 253 | // | ||
| 254 | // JSONArray answerVars = new JSONArray(); | ||
| 255 | // int arity = getArity(), varSpace = 0; | ||
| 256 | // for (int i = 0; i < getArity(); i++) | ||
| 257 | // answerVars.add(answerVariables[0][i]); | ||
| 258 | // jsonAnswer.put("answerVars", answerVars); | ||
| 259 | // | ||
| 260 | // JSONArray answerTuples = new JSONArray(); | ||
| 261 | // soundAnswerTuples.stream().forEach(t -> answerTuples.add(t)); | ||
| 262 | // jsonAnswer.put("answerTuples", answerTuples); | ||
| 263 | // | ||
| 264 | // if (!processed) { | ||
| 265 | // JSONArray gapAnswerTuples = new JSONArray(); | ||
| 266 | // gapAnswerTuples.stream().forEach(t -> gapAnswerTuples.add(t)); | ||
| 267 | // } | ||
| 268 | // jsonAnswer.put("gapAnswerTuples", gapAnswerTuples); | ||
| 269 | // | ||
| 270 | // jsonAnswers.put(Integer.toString(queryID), jsonAnswer); | ||
| 271 | // } | ||
| 272 | } | ||
| 264 | 273 | ||
| 265 | public void outputTimes() { | 274 | public void outputTimes() { |
| 266 | for (Step step: Step.values()) { | 275 | for (Step step: Step.values()) { |
| @@ -290,8 +299,8 @@ public class QueryRecord { | |||
| 290 | return diffculty; | 299 | return diffculty; |
| 291 | } | 300 | } |
| 292 | 301 | ||
| 293 | OWLOntology relevantOntology = null; | 302 | OWLOntology relevantOntology = null; |
| 294 | Set<DLClause> relevantClauses = new HashSet<DLClause>(); | 303 | Set<DLClause> relevantClauses = new HashSet<DLClause>(); |
| 295 | 304 | ||
| 296 | public void setRelevantOntology(OWLOntology knowledgebase) { | 305 | public void setRelevantOntology(OWLOntology knowledgebase) { |
| 297 | relevantOntology = knowledgebase; | 306 | relevantOntology = knowledgebase; |
| @@ -355,7 +364,7 @@ public class QueryRecord { | |||
| 355 | public enum Step {LowerBound, UpperBound, ELLowerBound, | 364 | public enum Step {LowerBound, UpperBound, ELLowerBound, |
| 356 | Fragment, FragmentRefinement, Summarisation, Dependency, FullReasoning}; | 365 | Fragment, FragmentRefinement, Summarisation, Dependency, FullReasoning}; |
| 357 | 366 | ||
| 358 | double[] timer; | 367 | double[] timer; |
| 359 | 368 | ||
| 360 | public void addProcessingTime(Step step, double time) { | 369 | public void addProcessingTime(Step step, double time) { |
| 361 | timer[step.ordinal()] += time; | 370 | timer[step.ordinal()] += time; |
| @@ -431,14 +440,14 @@ public class QueryRecord { | |||
| 431 | } | 440 | } |
| 432 | } | 441 | } |
| 433 | 442 | ||
| 434 | int subID; | 443 | int subID; |
| 435 | 444 | ||
| 436 | public void updateSubID() { | 445 | public void updateSubID() { |
| 437 | ++subID; | 446 | ++subID; |
| 438 | stringQueryID = String.valueOf(queryID) + "_" + subID; | 447 | stringQueryID = String.valueOf(queryID) + "_" + subID; |
| 439 | } | 448 | } |
| 440 | 449 | ||
| 441 | DLClause queryClause = null; | 450 | DLClause queryClause = null; |
| 442 | 451 | ||
| 443 | public DLClause getClause() { | 452 | public DLClause getClause() { |
| 444 | if (queryClause != null) | 453 | if (queryClause != null) |
| @@ -557,6 +566,88 @@ public class QueryRecord { | |||
| 557 | public boolean hasNonAnsDistinguishedVariables() { | 566 | public boolean hasNonAnsDistinguishedVariables() { |
| 558 | return answerVariables[1].length > answerVariables[0].length; | 567 | return answerVariables[1].length > answerVariables[0].length; |
| 559 | } | 568 | } |
| 560 | |||
| 561 | 569 | ||
| 570 | public static class QueryRecordSerializer implements JsonSerializer<QueryRecord> { | ||
| 571 | |||
| 572 | public JsonElement serialize(QueryRecord src, Type typeOfSrc, JsonSerializationContext context) { | ||
| 573 | Gson gson = new GsonBuilder().setPrettyPrinting().create(); | ||
| 574 | JsonObject object = new JsonObject(); | ||
| 575 | object.addProperty("queryID", src.queryID); | ||
| 576 | object.addProperty("queryText", src.queryText); | ||
| 577 | object.addProperty("difficulty", src.diffculty.toString()); | ||
| 578 | |||
| 579 | object.add("answerVariables", context.serialize(src.getAnswerVariables())); | ||
| 580 | object.add("answers", context.serialize(src.soundAnswerTuples)); | ||
| 581 | object.add("gapAnswers", context.serialize(src.gapAnswerTuples)); | ||
| 582 | |||
| 583 | return object; | ||
| 584 | } | ||
| 585 | } | ||
| 586 | |||
| 587 | private QueryRecord() { } | ||
| 588 | |||
| 589 | public class QueryRecordDeserializer implements JsonDeserializer<QueryRecord> { | ||
| 590 | |||
| 591 | public QueryRecord deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) | ||
| 592 | throws JsonParseException { | ||
| 593 | |||
| 594 | QueryRecord record = new QueryRecord(); | ||
| 595 | JsonObject object = json.getAsJsonObject(); | ||
| 596 | record.queryID = object.getAsJsonPrimitive("queryID").getAsInt(); | ||
| 597 | record.queryText = object.getAsJsonPrimitive("queryText").getAsString(); | ||
| 598 | |||
| 599 | JsonArray answerVariablesJson = object.getAsJsonArray("answerVariables"); | ||
| 600 | record.answerVariables = new String[2][]; | ||
| 601 | record.answerVariables[0] = new String[answerVariablesJson.size()]; | ||
| 602 | for(int i = 0; i < answerVariablesJson.size(); i++) | ||
| 603 | record.answerVariables[0][i] = answerVariablesJson.get(i).getAsString(); | ||
| 604 | |||
| 605 | record.soundAnswerTuples = context.deserialize(object.getAsJsonObject("answers"), | ||
| 606 | new TypeToken<Set<AnswerTuple>>() {}.getType()); | ||
| 607 | |||
| 608 | record.gapAnswerTuples = context.deserialize(object.getAsJsonObject("gapAnswers"), | ||
| 609 | new TypeToken<Set<AnswerTuple>>() {}.getType()); | ||
| 610 | return null; | ||
| 611 | } | ||
| 612 | } | ||
| 613 | |||
| 614 | /* | ||
| 615 | * Two QueryRecords are equal iff | ||
| 616 | * they have the same queryText and | ||
| 617 | * their AnswerTuples have the same string representation | ||
| 618 | * */ | ||
| 619 | @Override | ||
| 620 | public boolean equals(Object o) { | ||
| 621 | if(!o.getClass().equals(getClass())) return false; | ||
| 622 | QueryRecord that = (QueryRecord) o; | ||
| 623 | |||
| 624 | if(!this.queryText.equals(that.queryText)) return false; | ||
| 625 | |||
| 626 | if(soundAnswerTuples.size() != that.soundAnswerTuples.size()) return false; | ||
| 627 | if(gapAnswerTuples.size() != that.gapAnswerTuples.size()) return false; | ||
| 628 | |||
| 629 | ArrayList<AnswerTuple> thisSoundAnswers = new ArrayList<>(soundAnswerTuples); | ||
| 630 | Collections.sort(thisSoundAnswers, (AnswerTuple t1, AnswerTuple t2) -> t1.m_str.compareTo(t2.m_str)); | ||
| 631 | |||
| 632 | ArrayList<AnswerTuple> thatSoundAnswers = new ArrayList<>(that.soundAnswerTuples); | ||
| 633 | Collections.sort(thatSoundAnswers, (AnswerTuple t1, AnswerTuple t2) -> t1.m_str.compareTo(t2.m_str)); | ||
| 634 | |||
| 635 | Iterator<AnswerTuple> soundIt1 = this.soundAnswerTuples.iterator(); | ||
| 636 | Iterator<AnswerTuple> soundIt2 = that.soundAnswerTuples.iterator(); | ||
| 637 | while(soundIt1.hasNext() && soundIt2.hasNext()) | ||
| 638 | if(!soundIt1.next().m_str.equals(soundIt2.next().m_str)) return false; | ||
| 639 | |||
| 640 | ArrayList<AnswerTuple> thisGapAnswers = new ArrayList<>(gapAnswerTuples); | ||
| 641 | Collections.sort(thisGapAnswers, (AnswerTuple t1, AnswerTuple t2) -> t1.m_str.compareTo(t2.m_str)); | ||
| 642 | |||
| 643 | ArrayList<AnswerTuple> thatGapAnswers = new ArrayList<>(that.gapAnswerTuples); | ||
| 644 | Collections.sort(thatGapAnswers, (AnswerTuple t1, AnswerTuple t2) -> t1.m_str.compareTo(t2.m_str)); | ||
| 645 | |||
| 646 | Iterator<AnswerTuple> gapIt1 = this.gapAnswerTuples.iterator(); | ||
| 647 | Iterator<AnswerTuple> gapIt2 = that.gapAnswerTuples.iterator(); | ||
| 648 | while(gapIt1.hasNext() && gapIt2.hasNext()) | ||
| 649 | if(!gapIt1.next().m_str.equals(gapIt2.next().m_str)) return false; | ||
| 650 | |||
| 651 | return true; | ||
| 652 | } | ||
| 562 | } | 653 | } |
diff --git a/src/uk/ac/ox/cs/pagoda/reasoner/QueryReasoner.java b/src/uk/ac/ox/cs/pagoda/reasoner/QueryReasoner.java index f2b7251..1f08fdf 100644 --- a/src/uk/ac/ox/cs/pagoda/reasoner/QueryReasoner.java +++ b/src/uk/ac/ox/cs/pagoda/reasoner/QueryReasoner.java | |||
| @@ -1,16 +1,10 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.reasoner; | 1 | package uk.ac.ox.cs.pagoda.reasoner; |
| 2 | 2 | ||
| 3 | import java.io.BufferedWriter; | 3 | import com.google.gson.Gson; |
| 4 | import java.io.File; | 4 | import com.google.gson.GsonBuilder; |
| 5 | import java.io.FileNotFoundException; | ||
| 6 | import java.io.FileOutputStream; | ||
| 7 | import java.io.IOException; | ||
| 8 | import java.io.OutputStreamWriter; | ||
| 9 | import java.util.Collection; | ||
| 10 | |||
| 11 | import org.semanticweb.owlapi.model.OWLOntology; | 5 | import org.semanticweb.owlapi.model.OWLOntology; |
| 12 | |||
| 13 | import uk.ac.ox.cs.pagoda.owl.OWLHelper; | 6 | import uk.ac.ox.cs.pagoda.owl.OWLHelper; |
| 7 | import uk.ac.ox.cs.pagoda.query.AnswerTuple; | ||
| 14 | import uk.ac.ox.cs.pagoda.query.AnswerTuples; | 8 | import uk.ac.ox.cs.pagoda.query.AnswerTuples; |
| 15 | import uk.ac.ox.cs.pagoda.query.QueryManager; | 9 | import uk.ac.ox.cs.pagoda.query.QueryManager; |
| 16 | import uk.ac.ox.cs.pagoda.query.QueryRecord; | 10 | import uk.ac.ox.cs.pagoda.query.QueryRecord; |
| @@ -18,6 +12,13 @@ import uk.ac.ox.cs.pagoda.util.Properties; | |||
| 18 | import uk.ac.ox.cs.pagoda.util.Timer; | 12 | import uk.ac.ox.cs.pagoda.util.Timer; |
| 19 | import uk.ac.ox.cs.pagoda.util.Utility; | 13 | import uk.ac.ox.cs.pagoda.util.Utility; |
| 20 | 14 | ||
| 15 | import java.io.BufferedWriter; | ||
| 16 | import java.io.File; | ||
| 17 | import java.io.IOException; | ||
| 18 | import java.nio.file.Files; | ||
| 19 | import java.nio.file.Paths; | ||
| 20 | import java.util.Collection; | ||
| 21 | |||
| 21 | public abstract class QueryReasoner { | 22 | public abstract class QueryReasoner { |
| 22 | 23 | ||
| 23 | // protected boolean forSemFacet = false; | 24 | // protected boolean forSemFacet = false; |
| @@ -179,28 +180,33 @@ public abstract class QueryReasoner { | |||
| 179 | 180 | ||
| 180 | } | 181 | } |
| 181 | 182 | ||
| 183 | // public void evaluate(Collection<QueryRecord> queryRecords) { | ||
| 184 | // evaluate(queryRecords); | ||
| 185 | // } | ||
| 186 | |||
| 187 | BufferedWriter answerWriter = null; | ||
| 188 | |||
| 182 | public void evaluate(Collection<QueryRecord> queryRecords) { | 189 | public void evaluate(Collection<QueryRecord> queryRecords) { |
| 183 | evaluate(queryRecords, null); | ||
| 184 | } | ||
| 185 | |||
| 186 | BufferedWriter answerWriter = null; | ||
| 187 | |||
| 188 | public void evaluate(Collection<QueryRecord> queryRecords, String answerFile) { | ||
| 189 | if (!isConsistent()) { | 190 | if (!isConsistent()) { |
| 190 | Utility.logDebug("The ontology and dataset is inconsistent."); | 191 | Utility.logDebug("The ontology and dataset is inconsistent."); |
| 191 | return ; | 192 | return ; |
| 192 | } | 193 | } |
| 193 | 194 | ||
| 194 | if (answerWriter == null && answerFile != null) { | 195 | if(properties.getAnswerPath() != null && answerWriter == null) { |
| 195 | try { | 196 | try { |
| 196 | answerWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(answerFile))); | 197 | answerWriter = Files.newBufferedWriter(Paths.get(properties.getAnswerPath())); |
| 197 | } catch (FileNotFoundException e) { | 198 | } catch (IOException e) { |
| 198 | Utility.logInfo("The answer file not found! " + answerFile); | 199 | Utility.logError("The answer path is not valid!"); |
| 199 | return ; | 200 | e.printStackTrace(); |
| 200 | } | 201 | } |
| 201 | } | 202 | } |
| 202 | 203 | ||
| 203 | Timer t = new Timer(); | 204 | Timer t = new Timer(); |
| 205 | Gson gson = new GsonBuilder() | ||
| 206 | .registerTypeAdapter(AnswerTuple.class, new AnswerTuple.AnswerTupleSerializer()) | ||
| 207 | .registerTypeAdapter(QueryRecord.class, new QueryRecord.QueryRecordSerializer()) | ||
| 208 | .setPrettyPrinting() | ||
| 209 | .create(); | ||
| 204 | for (QueryRecord record: queryRecords) { | 210 | for (QueryRecord record: queryRecords) { |
| 205 | // if (Integer.parseInt(record.getQueryID()) != 218) continue; | 211 | // if (Integer.parseInt(record.getQueryID()) != 218) continue; |
| 206 | Utility.logInfo("---------- start evaluating Query " + record.getQueryID() + " ----------", | 212 | Utility.logInfo("---------- start evaluating Query " + record.getQueryID() + " ----------", |
| @@ -215,24 +221,23 @@ public abstract class QueryReasoner { | |||
| 215 | continue; | 221 | continue; |
| 216 | } | 222 | } |
| 217 | } | 223 | } |
| 218 | // FIXME: change the argument below | 224 | record.outputAnswerStatistics(); |
| 219 | try { | ||
| 220 | record.outputAnswers(answerWriter); | ||
| 221 | } catch (IOException e) { | ||
| 222 | Utility.logInfo("Error in outputing answers " + answerFile); | ||
| 223 | } | ||
| 224 | record.outputTimes(); | 225 | record.outputTimes(); |
| 225 | record.dispose(); | ||
| 226 | } | 226 | } |
| 227 | // TODO it can handle one call only | ||
| 228 | // if you call twice, you will end up with a json file with multiple roots | ||
| 229 | gson.toJson(queryRecords, answerWriter); | ||
| 230 | queryRecords.stream().forEach(record -> record.dispose()); | ||
| 227 | } | 231 | } |
| 228 | 232 | ||
| 229 | public void dispose() { | 233 | public void dispose() { |
| 230 | if (answerWriter != null) | 234 | if (answerWriter != null) { |
| 231 | try { | 235 | try { |
| 232 | answerWriter.close(); | 236 | answerWriter.close(); |
| 233 | } catch (IOException e) { | 237 | } catch (IOException e) { |
| 234 | e.printStackTrace(); | 238 | e.printStackTrace(); |
| 235 | } | 239 | } |
| 240 | } | ||
| 236 | Utility.cleanup(); | 241 | Utility.cleanup(); |
| 237 | } | 242 | } |
| 238 | 243 | ||
diff --git a/src/uk/ac/ox/cs/pagoda/util/Utility.java b/src/uk/ac/ox/cs/pagoda/util/Utility.java index 7138ca9..6d50ee0 100644 --- a/src/uk/ac/ox/cs/pagoda/util/Utility.java +++ b/src/uk/ac/ox/cs/pagoda/util/Utility.java | |||
| @@ -1,32 +1,13 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.util; | 1 | package uk.ac.ox.cs.pagoda.util; |
| 2 | 2 | ||
| 3 | import java.io.BufferedReader; | ||
| 4 | import java.io.BufferedWriter; | ||
| 5 | import java.io.File; | ||
| 6 | import java.io.FileInputStream; | ||
| 7 | import java.io.FileNotFoundException; | ||
| 8 | import java.io.FileOutputStream; | ||
| 9 | import java.io.IOException; | ||
| 10 | import java.io.InputStreamReader; | ||
| 11 | import java.io.OutputStreamWriter; | ||
| 12 | import java.io.PrintStream; | ||
| 13 | import java.nio.file.Files; | ||
| 14 | import java.nio.file.Paths; | ||
| 15 | import java.text.SimpleDateFormat; | ||
| 16 | import java.time.LocalDateTime; | ||
| 17 | import java.time.format.DateTimeFormatter; | ||
| 18 | import java.util.Collection; | ||
| 19 | import java.util.Date; | ||
| 20 | import java.util.HashSet; | ||
| 21 | import java.util.LinkedList; | ||
| 22 | import java.util.Scanner; | ||
| 23 | import java.util.Set; | ||
| 24 | import java.util.Stack; | ||
| 25 | |||
| 26 | import org.apache.log4j.Logger; | 3 | import org.apache.log4j.Logger; |
| 27 | import org.semanticweb.HermiT.model.Atom; | 4 | import org.semanticweb.HermiT.model.Atom; |
| 28 | 5 | ||
| 29 | import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; | 6 | import java.io.*; |
| 7 | import java.text.SimpleDateFormat; | ||
| 8 | import java.time.LocalDateTime; | ||
| 9 | import java.time.format.DateTimeFormatter; | ||
| 10 | import java.util.*; | ||
| 30 | 11 | ||
| 31 | public class Utility { | 12 | public class Utility { |
| 32 | 13 | ||
| @@ -259,14 +240,4 @@ public class Utility { | |||
| 259 | return iri.replace(FILE_SEPARATOR, JAVA_FILE_SEPARATOR).replace(" ", "%20"); | 240 | return iri.replace(FILE_SEPARATOR, JAVA_FILE_SEPARATOR).replace(" ", "%20"); |
| 260 | } | 241 | } |
| 261 | 242 | ||
| 262 | public static String combinePaths(String path1, String path2) { | ||
| 263 | File file1 = new File(path1); | ||
| 264 | File file2 = new File(file1, path2); | ||
| 265 | return file2.getPath(); | ||
| 266 | } | ||
| 267 | |||
| 268 | public static void copyFile(String src, String dst) throws IOException { | ||
| 269 | Files.copy(Paths.get(src), Paths.get(dst), REPLACE_EXISTING); | ||
| 270 | } | ||
| 271 | |||
| 272 | } | 243 | } |
diff --git a/test/uk/ac/ox/cs/pagoda/test_units/CostEvaluation.java b/test/uk/ac/ox/cs/pagoda/test_units/CostEvaluation.java index 4e32297..968cf01 100644 --- a/test/uk/ac/ox/cs/pagoda/test_units/CostEvaluation.java +++ b/test/uk/ac/ox/cs/pagoda/test_units/CostEvaluation.java | |||
| @@ -1,12 +1,12 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.test_units; | 1 | package uk.ac.ox.cs.pagoda.test_units; |
| 2 | 2 | ||
| 3 | import org.semanticweb.owlapi.model.OWLOntology; | 3 | import org.semanticweb.owlapi.model.OWLOntology; |
| 4 | |||
| 5 | import org.testng.annotations.Test; | 4 | import org.testng.annotations.Test; |
| 6 | import uk.ac.ox.cs.pagoda.owl.OWLHelper; | 5 | import uk.ac.ox.cs.pagoda.owl.OWLHelper; |
| 7 | import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner; | 6 | import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner; |
| 8 | import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner.Type; | 7 | import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner.Type; |
| 9 | import uk.ac.ox.cs.pagoda.tester.PagodaTester; | 8 | import uk.ac.ox.cs.pagoda.tester.PagodaTester; |
| 9 | import uk.ac.ox.cs.pagoda.util.TestUtil; | ||
| 10 | import uk.ac.ox.cs.pagoda.util.Timer; | 10 | import uk.ac.ox.cs.pagoda.util.Timer; |
| 11 | import uk.ac.ox.cs.pagoda.util.Utility; | 11 | import uk.ac.ox.cs.pagoda.util.Utility; |
| 12 | 12 | ||
| @@ -15,20 +15,22 @@ public class CostEvaluation { | |||
| 15 | @Test | 15 | @Test |
| 16 | public void lubm100() { | 16 | public void lubm100() { |
| 17 | int number = 1; | 17 | int number = 1; |
| 18 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | ||
| 18 | PagodaTester.main( | 19 | PagodaTester.main( |
| 19 | PagodaTester.onto_dir + "lubm/univ-bench.owl", | 20 | TestUtil.combinePaths(ontoDir, "lubm/univ-bench.owl"), |
| 20 | PagodaTester.onto_dir + "lubm/data/lubm" + number + ".ttl", | 21 | TestUtil.combinePaths(ontoDir, "lubm/data/lubm" + number + ".ttl"), |
| 21 | PagodaTester.onto_dir + "lubm/queries/test_all_pagoda.sparql" | 22 | TestUtil.combinePaths(ontoDir, "lubm/queries/test_all_pagoda.sparql") |
| 22 | ); | 23 | ); |
| 23 | // AllTests.copy("output/log4j.log", "results-backup/jair/lubm" + number + ".out"); | 24 | // AllTests.copy("output/log4j.log", "results-backup/jair/lubm" + number + ".out"); |
| 24 | } | 25 | } |
| 25 | 26 | ||
| 26 | public void lubm1000() { | 27 | public void lubm1000() { |
| 27 | int number = 1000; | 28 | int number = 1000; |
| 29 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | ||
| 28 | String[] args = new String[] { | 30 | String[] args = new String[] { |
| 29 | PagodaTester.onto_dir + "lubm/univ-bench.owl", | 31 | TestUtil.combinePaths(ontoDir, "lubm/univ-bench.owl"), |
| 30 | PagodaTester.onto_dir + "lubm/data/lubm" + number + ".ttl", | 32 | TestUtil.combinePaths(ontoDir, "lubm/data/lubm" + number + ".ttl"), |
| 31 | PagodaTester.onto_dir + "lubm/queries/test_all_pagoda.sparql" | 33 | TestUtil.combinePaths(ontoDir, "lubm/queries/test_all_pagoda.sparql") |
| 32 | }; | 34 | }; |
| 33 | OWLOntology ontology = OWLHelper.loadOntology(args[0]); | 35 | OWLOntology ontology = OWLHelper.loadOntology(args[0]); |
| 34 | QueryReasoner reasoner = QueryReasoner.getInstance(Type.ELHOU, ontology, true, true); | 36 | QueryReasoner reasoner = QueryReasoner.getInstance(Type.ELHOU, ontology, true, true); |
| @@ -46,10 +48,11 @@ public class CostEvaluation { | |||
| 46 | @Test | 48 | @Test |
| 47 | public void uobm5() { | 49 | public void uobm5() { |
| 48 | int number = 1; | 50 | int number = 1; |
| 51 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | ||
| 49 | String[] args = new String[] { | 52 | String[] args = new String[] { |
| 50 | PagodaTester.onto_dir + "uobm/univ-bench-dl.owl", | 53 | TestUtil.combinePaths(ontoDir, "uobm/univ-bench-dl.owl"), |
| 51 | PagodaTester.onto_dir + "uobm/data/uobm" + number + ".ttl", | 54 | TestUtil.combinePaths(ontoDir, "uobm/data/uobm" + number + ".ttl"), |
| 52 | PagodaTester.onto_dir + "uobm/queries/standard_all_pagoda.sparql" | 55 | TestUtil.combinePaths(ontoDir, "uobm/queries/standard_all_pagoda.sparql") |
| 53 | }; | 56 | }; |
| 54 | PagodaTester.main(args); | 57 | PagodaTester.main(args); |
| 55 | // AllTests.copy("output/log4j.log", "results-backup/jair/uobm" + number + ".out"); | 58 | // AllTests.copy("output/log4j.log", "results-backup/jair/uobm" + number + ".out"); |
| @@ -57,10 +60,11 @@ public class CostEvaluation { | |||
| 57 | 60 | ||
| 58 | public void uobm100() { | 61 | public void uobm100() { |
| 59 | int number = 200; | 62 | int number = 200; |
| 63 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | ||
| 60 | String[] args = new String[] { | 64 | String[] args = new String[] { |
| 61 | PagodaTester.onto_dir + "uobm/univ-bench-dl.owl", | 65 | TestUtil.combinePaths(ontoDir, "uobm/univ-bench-dl.owl"), |
| 62 | PagodaTester.onto_dir + "uobm/data/uobm" + number + ".ttl", | 66 | TestUtil.combinePaths(ontoDir, "uobm/data/uobm" + number + ".ttl"), |
| 63 | PagodaTester.onto_dir + "uobm/queries/standard_group3_all.sparql" | 67 | TestUtil.combinePaths(ontoDir, "uobm/queries/standard_group3_all.sparql") |
| 64 | }; | 68 | }; |
| 65 | PagodaTester.main(args); | 69 | PagodaTester.main(args); |
| 66 | // AllTests.copy("output/log4j.log", "results-backup/jair/uobm" + number + ".out"); | 70 | // AllTests.copy("output/log4j.log", "results-backup/jair/uobm" + number + ".out"); |
| @@ -68,10 +72,11 @@ public class CostEvaluation { | |||
| 68 | 72 | ||
| 69 | public void uobm500() { | 73 | public void uobm500() { |
| 70 | int number = 500; | 74 | int number = 500; |
| 75 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | ||
| 71 | String[] args = new String[] { | 76 | String[] args = new String[] { |
| 72 | PagodaTester.onto_dir + "uobm/univ-bench-dl.owl", | 77 | TestUtil.combinePaths(ontoDir, "uobm/univ-bench-dl.owl"), |
| 73 | PagodaTester.onto_dir + "uobm/data/uobm" + number + ".ttl", | 78 | TestUtil.combinePaths(ontoDir, "uobm/data/uobm" + number + ".ttl"), |
| 74 | PagodaTester.onto_dir + "uobm/queries/standard_all_pagoda.sparql" | 79 | TestUtil.combinePaths(ontoDir, "uobm/queries/standard_all_pagoda.sparql") |
| 75 | }; | 80 | }; |
| 76 | 81 | ||
| 77 | OWLOntology ontology = OWLHelper.loadOntology(args[0]); | 82 | OWLOntology ontology = OWLHelper.loadOntology(args[0]); |
| @@ -89,10 +94,11 @@ public class CostEvaluation { | |||
| 89 | 94 | ||
| 90 | 95 | ||
| 91 | public static void main(String... args) { | 96 | public static void main(String... args) { |
| 97 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | ||
| 92 | args = new String[] { | 98 | args = new String[] { |
| 93 | PagodaTester.onto_dir + "dbpedia/integratedOntology-all-in-one-minus-datatype.owl", | 99 | TestUtil.combinePaths(ontoDir, "dbpedia/integratedOntology-all-in-one-minus-datatype.owl"), |
| 94 | PagodaTester.onto_dir + "dbpedia/data/dbpedia-minus-datatype-new.ttl", | 100 | TestUtil.combinePaths(ontoDir, "dbpedia/data/dbpedia-minus-datatype-new.ttl"), |
| 95 | PagodaTester.onto_dir + "dbpedia/queries/atomic_ground.sparql" | 101 | TestUtil.combinePaths(ontoDir, "dbpedia/queries/atomic_ground.sparql") |
| 96 | }; | 102 | }; |
| 97 | 103 | ||
| 98 | OWLOntology ontology = OWLHelper.loadOntology(args[0]); | 104 | OWLOntology ontology = OWLHelper.loadOntology(args[0]); |
diff --git a/test/uk/ac/ox/cs/pagoda/test_units/JAIR_PAGOdA.java b/test/uk/ac/ox/cs/pagoda/test_units/JAIR_PAGOdA.java index ff616f7..10ac974 100644 --- a/test/uk/ac/ox/cs/pagoda/test_units/JAIR_PAGOdA.java +++ b/test/uk/ac/ox/cs/pagoda/test_units/JAIR_PAGOdA.java | |||
| @@ -2,7 +2,7 @@ package uk.ac.ox.cs.pagoda.test_units; | |||
| 2 | 2 | ||
| 3 | import org.testng.annotations.Test; | 3 | import org.testng.annotations.Test; |
| 4 | import uk.ac.ox.cs.pagoda.tester.PagodaTester; | 4 | import uk.ac.ox.cs.pagoda.tester.PagodaTester; |
| 5 | import uk.ac.ox.cs.pagoda.util.Utility; | 5 | import uk.ac.ox.cs.pagoda.util.TestUtil; |
| 6 | 6 | ||
| 7 | import java.io.IOException; | 7 | import java.io.IOException; |
| 8 | 8 | ||
| @@ -10,162 +10,175 @@ public class JAIR_PAGOdA { | |||
| 10 | 10 | ||
| 11 | @Test | 11 | @Test |
| 12 | public void lubm1() throws IOException { | 12 | public void lubm1() throws IOException { |
| 13 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | ||
| 13 | String[] args = new String[] { | 14 | String[] args = new String[] { |
| 14 | PagodaTester.onto_dir + "lubm/univ-bench.owl", | 15 | TestUtil.combinePaths(ontoDir, "lubm/univ-bench.owl"), |
| 15 | PagodaTester.onto_dir + "lubm/data/lubm1.ttl", | 16 | TestUtil.combinePaths(ontoDir, "lubm/data/lubm1.ttl"), |
| 16 | PagodaTester.onto_dir + "lubm/queries/test.sparql" | 17 | TestUtil.combinePaths(ontoDir, "lubm/queries/test.sparql") |
| 17 | }; | 18 | }; |
| 18 | PagodaTester.main(args); | 19 | PagodaTester.main(args); |
| 19 | Utility.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/lubm1/pagoda"); | 20 | TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/lubm1/pagoda"); |
| 20 | } | 21 | } |
| 21 | 22 | ||
| 22 | @Test | 23 | @Test |
| 23 | public void lubm1_conj() throws IOException { | 24 | public void lubm1_conj() throws IOException { |
| 25 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | ||
| 24 | String[] args = new String[] { | 26 | String[] args = new String[] { |
| 25 | PagodaTester.onto_dir + "lubm/univ-bench.owl", | 27 | TestUtil.combinePaths(ontoDir, "lubm/univ-bench.owl"), |
| 26 | PagodaTester.onto_dir + "lubm/data/lubm1.ttl", | 28 | TestUtil.combinePaths(ontoDir, "lubm/data/lubm1.ttl"), |
| 27 | PagodaTester.onto_dir + "lubm/queries/test_pellet.sparql" | 29 | TestUtil.combinePaths(ontoDir, "lubm/queries/test_pellet.sparql") |
| 28 | }; | 30 | }; |
| 29 | PagodaTester.main(args); | 31 | PagodaTester.main(args); |
| 30 | Utility.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/lubm1/pagoda_conj"); | 32 | TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/lubm1/pagoda_conj"); |
| 31 | } | 33 | } |
| 32 | 34 | ||
| 33 | @Test | 35 | @Test |
| 34 | public void lubm1_rolledUp() throws IOException { | 36 | public void lubm1_rolledUp() throws IOException { |
| 35 | String[] args = new String[] { | 37 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); |
| 38 | PagodaTester.main( | ||
| 36 | "/home/yzhou/backup/20141212/univ-bench-queries.owl", | 39 | "/home/yzhou/backup/20141212/univ-bench-queries.owl", |
| 37 | PagodaTester.onto_dir + "lubm/data/lubm1.ttl", | 40 | TestUtil.combinePaths(ontoDir, "lubm/data/lubm1.ttl"), |
| 38 | PagodaTester.onto_dir + "lubm/queries/atomic_lubm.sparql" | 41 | TestUtil.combinePaths(ontoDir, "lubm/queries/atomic_lubm.sparql") |
| 39 | }; | 42 | ); |
| 40 | PagodaTester.main(args); | 43 | TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/lubm1/pagoda_rolledUp"); |
| 41 | Utility.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/lubm1/pagoda_rolledUp"); | ||
| 42 | } | 44 | } |
| 43 | 45 | ||
| 44 | @Test | 46 | @Test |
| 45 | public void uobm1() throws IOException { | 47 | public void uobm1() throws IOException { |
| 48 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | ||
| 46 | String[] args = new String[] { | 49 | String[] args = new String[] { |
| 47 | PagodaTester.onto_dir + "uobm/univ-bench-dl.owl", | 50 | TestUtil.combinePaths(ontoDir, "uobm/univ-bench-dl.owl"), |
| 48 | PagodaTester.onto_dir + "uobm/data/uobm1.ttl", | 51 | TestUtil.combinePaths(ontoDir, "uobm/data/uobm1.ttl"), |
| 49 | PagodaTester.onto_dir + "uobm/queries/standard.sparql" | 52 | TestUtil.combinePaths(ontoDir, "uobm/queries/standard.sparql") |
| 50 | }; | 53 | }; |
| 51 | PagodaTester.main(args); | 54 | PagodaTester.main(args); |
| 52 | Utility.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/uobm1/pagoda"); | 55 | TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/uobm1/pagoda"); |
| 53 | } | 56 | } |
| 54 | 57 | ||
| 55 | @Test | 58 | @Test |
| 56 | public void uobm1_conj() throws IOException { | 59 | public void uobm1_conj() throws IOException { |
| 60 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | ||
| 57 | String[] args = new String[] { | 61 | String[] args = new String[] { |
| 58 | PagodaTester.onto_dir + "uobm/univ-bench-dl.owl", | 62 | TestUtil.combinePaths(ontoDir, "uobm/univ-bench-dl.owl"), |
| 59 | PagodaTester.onto_dir + "uobm/data/uobm1.ttl", | 63 | TestUtil.combinePaths(ontoDir, "uobm/data/uobm1.ttl"), |
| 60 | PagodaTester.onto_dir + "uobm/queries/standard_pellet.sparql" | 64 | TestUtil.combinePaths(ontoDir, "uobm/queries/standard_pellet.sparql") |
| 61 | }; | 65 | }; |
| 62 | PagodaTester.main(args); | 66 | PagodaTester.main(args); |
| 63 | Utility.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/uobm1/pagoda_conj"); | 67 | TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/uobm1/pagoda_conj"); |
| 64 | } | 68 | } |
| 65 | 69 | ||
| 66 | @Test | 70 | @Test |
| 67 | public void uobm1_rolledUp() { | 71 | public void uobm1_rolledUp() { |
| 72 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | ||
| 68 | String[] args = new String[] { | 73 | String[] args = new String[] { |
| 69 | "/home/yzhou/backup/20141212/univ-bench-dl-queries.owl", | 74 | "/home/yzhou/backup/20141212/univ-bench-dl-queries.owl", |
| 70 | PagodaTester.onto_dir + "uobm/data/uobm1.ttl", | 75 | TestUtil.combinePaths(ontoDir, "uobm/data/uobm1.ttl"), |
| 71 | PagodaTester.onto_dir + "uobm/queries/atomic_uobm.sparql" | 76 | TestUtil.combinePaths(ontoDir, "uobm/queries/atomic_uobm.sparql") |
| 72 | }; | 77 | }; |
| 73 | PagodaTester.main(args); | 78 | PagodaTester.main(args); |
| 74 | // AllTests.copy("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/uobm1/pagoda_rolledUp"); | 79 | // TestUtil.copyFile(("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/uobm1/pagoda_rolledUp"); |
| 75 | } | 80 | } |
| 76 | 81 | ||
| 77 | @Test | 82 | @Test |
| 78 | public void fly() { | 83 | public void fly() { |
| 84 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | ||
| 79 | String[] args = new String[] { | 85 | String[] args = new String[] { |
| 80 | PagodaTester.onto_dir + "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl", | 86 | TestUtil.combinePaths(ontoDir, "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl"), |
| 81 | null, | 87 | null, |
| 82 | PagodaTester.onto_dir + "fly/queries/fly_pellet.sparql" | 88 | TestUtil.combinePaths(ontoDir, "fly/queries/fly_pellet.sparql") |
| 83 | }; | 89 | }; |
| 84 | PagodaTester.main(args); | 90 | PagodaTester.main(args); |
| 85 | // AllTests.copy("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/fly/pagoda"); | 91 | // TestUtil.copyFile(("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/fly/pagoda"); |
| 86 | } | 92 | } |
| 87 | 93 | ||
| 88 | @Test | 94 | @Test |
| 89 | public void fly_conj() throws IOException { | 95 | public void fly_conj() throws IOException { |
| 96 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | ||
| 90 | String[] args = new String[] { | 97 | String[] args = new String[] { |
| 91 | PagodaTester.onto_dir + "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl", | 98 | TestUtil.combinePaths(ontoDir, "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl"), |
| 92 | null, | 99 | null, |
| 93 | PagodaTester.onto_dir + "fly/queries/fly_pellet.sparql" | 100 | TestUtil.combinePaths(ontoDir, "fly/queries/fly_pellet.sparql") |
| 94 | }; | 101 | }; |
| 95 | PagodaTester.main(args); | 102 | PagodaTester.main(args); |
| 96 | Utility.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/fly/pagoda_conj"); | 103 | TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/fly/pagoda_conj"); |
| 97 | } | 104 | } |
| 98 | 105 | ||
| 99 | 106 | ||
| 100 | public void fly_rolledUp() { | 107 | public void fly_rolledUp() { |
| 101 | PagodaTester.main(new String[] { | 108 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); |
| 102 | // PagodaTester.onto_dir + "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl", | 109 | PagodaTester.main( |
| 103 | PagodaTester.onto_dir + "fly/fly-all-in-one_rolledUp.owl", | 110 | // TestUtil.combinePaths(ontoDir, "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl", |
| 111 | TestUtil.combinePaths(ontoDir, "fly/fly-all-in-one_rolledUp.owl"), | ||
| 104 | null, | 112 | null, |
| 105 | PagodaTester.onto_dir + "fly/queries/fly_atomic.sparql" | 113 | TestUtil.combinePaths(ontoDir, "fly/queries/fly_atomic.sparql") |
| 106 | }); | 114 | ); |
| 107 | // Utility.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/fly/pagoda_rolledUp"); | 115 | // TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/fly/pagoda_rolledUp"); |
| 108 | } | 116 | } |
| 109 | 117 | ||
| 110 | public void dbpedia() { | 118 | public void dbpedia() { |
| 119 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | ||
| 111 | PagodaTester.main( | 120 | PagodaTester.main( |
| 112 | PagodaTester.onto_dir + "dbpedia/integratedOntology-all-in-one-minus-datatype.owl", | 121 | TestUtil.combinePaths(ontoDir, "dbpedia/integratedOntology-all-in-one-minus-datatype.owl"), |
| 113 | PagodaTester.onto_dir + "dbpedia/data/dbpedia-minus-datatype-new.ttl", | 122 | TestUtil.combinePaths(ontoDir, "dbpedia/data/dbpedia-minus-datatype-new.ttl"), |
| 114 | PagodaTester.onto_dir + "dbpedia/queries/atomic_ground.sparql" | 123 | TestUtil.combinePaths(ontoDir, "dbpedia/queries/atomic_ground.sparql"), |
| 115 | , "dbpedia.ans" | 124 | "dbpedia.ans" |
| 116 | ); | 125 | ); |
| 117 | 126 | ||
| 118 | // Utility.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/dbpedia/pagoda"); | 127 | // TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/dbpedia/pagoda"); |
| 119 | } | 128 | } |
| 120 | 129 | ||
| 121 | public void npd() { | 130 | public void npd() { |
| 131 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | ||
| 122 | PagodaTester.main( | 132 | PagodaTester.main( |
| 123 | PagodaTester.onto_dir + "npd/npd-all-minus-datatype.owl", | 133 | TestUtil.combinePaths(ontoDir, "npd/npd-all-minus-datatype.owl"), |
| 124 | PagodaTester.onto_dir + "npd/data/npd-data-dump-minus-datatype-new.ttl", | 134 | TestUtil.combinePaths(ontoDir, "npd/data/npd-data-dump-minus-datatype-new.ttl"), |
| 125 | PagodaTester.onto_dir + "npd/queries/atomic_ground.sparql" | 135 | TestUtil.combinePaths(ontoDir, "npd/queries/atomic_ground.sparql") |
| 126 | , "npd.ans" | 136 | , "npd.ans" |
| 127 | ); | 137 | ); |
| 128 | 138 | ||
| 129 | // Utility.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/npd/pagoda"); | 139 | // TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/npd/pagoda"); |
| 130 | } | 140 | } |
| 131 | 141 | ||
| 132 | public void reactome() throws IOException { | 142 | public void reactome() throws IOException { |
| 143 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | ||
| 133 | PagodaTester.main( | 144 | PagodaTester.main( |
| 134 | PagodaTester.onto_dir + "bio2rdf/reactome/biopax-level3-processed.owl", | 145 | TestUtil.combinePaths(ontoDir, "bio2rdf/reactome/biopax-level3-processed.owl"), |
| 135 | PagodaTester.onto_dir + "bio2rdf/reactome/graph sampling/reactome_sample_10.ttl", | 146 | TestUtil.combinePaths(ontoDir, "bio2rdf/reactome/graph sampling/reactome_sample_10.ttl"), |
| 136 | // null, | 147 | // null, |
| 137 | // PagodaTester.onto_dir + "bio2rdf/reactome/queries/atomic_ground.sparql" | 148 | // TestUtil.combinePaths(ontoDir, "bio2rdf/reactome/queries/atomic_ground.sparql") |
| 138 | PagodaTester.onto_dir + "bio2rdf/reactome/queries/example.sparql" | 149 | TestUtil.combinePaths(ontoDir, "bio2rdf/reactome/queries/example.sparql") |
| 139 | , "pagoda_reactome.ans" | 150 | , "pagoda_reactome.ans" |
| 140 | ); | 151 | ); |
| 141 | Utility.copyFile("log4j.log", "output/jair/pagoda_reactome.example"); | 152 | TestUtil.copyFile("log4j.log", "output/jair/pagoda_reactome.example"); |
| 142 | 153 | ||
| 143 | // AllTests.copy("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/reactome/pagoda_10p"); | 154 | // TestUtil.copyFile(("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/reactome/pagoda_10p"); |
| 144 | } | 155 | } |
| 145 | 156 | ||
| 146 | public void chembl() throws IOException { | 157 | public void chembl() throws IOException { |
| 158 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | ||
| 147 | PagodaTester.main( | 159 | PagodaTester.main( |
| 148 | PagodaTester.onto_dir + "bio2rdf/chembl/cco-noDPR.ttl", | 160 | TestUtil.combinePaths(ontoDir, "bio2rdf/chembl/cco-noDPR.ttl"), |
| 149 | PagodaTester.onto_dir + "bio2rdf/chembl/graph sampling/sample_1.nt", | 161 | TestUtil.combinePaths(ontoDir, "bio2rdf/chembl/graph sampling/sample_1.nt"), |
| 150 | // PagodaTester.onto_dir + "bio2rdf/chembl/queries/atomic_ground.sparql" | 162 | // TestUtil.combinePaths(ontoDir, "bio2rdf/chembl/queries/atomic_ground.sparql") |
| 151 | PagodaTester.onto_dir + "bio2rdf/chembl/queries/example.sparql" | 163 | TestUtil.combinePaths(ontoDir, "bio2rdf/chembl/queries/example.sparql") |
| 152 | , "pagoda_chembl.ans" | 164 | , "pagoda_chembl.ans" |
| 153 | ); | 165 | ); |
| 154 | Utility.copyFile("log4j.log", "output/jair/pagoda_chembl.example"); | 166 | TestUtil.copyFile("log4j.log", "output/jair/pagoda_chembl.example"); |
| 155 | // Utility.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/chembl/pagoda_1p"); | 167 | // TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/chembl/pagoda_1p"); |
| 156 | } | 168 | } |
| 157 | 169 | ||
| 158 | public void uniprot() throws IOException { | 170 | public void uniprot() throws IOException { |
| 171 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | ||
| 159 | PagodaTester.main( | 172 | PagodaTester.main( |
| 160 | PagodaTester.onto_dir + "bio2rdf/uniprot/core-sat-processed.owl", | 173 | TestUtil.combinePaths(ontoDir, "bio2rdf/uniprot/core-sat-processed.owl"), |
| 161 | PagodaTester.onto_dir + "bio2rdf/uniprot/graph sampling/sample_1.nt", | 174 | TestUtil.combinePaths(ontoDir, "bio2rdf/uniprot/graph sampling/sample_1.nt"), |
| 162 | // null, | 175 | // null, |
| 163 | // PagodaTester.onto_dir + "bio2rdf/uniprot/queries/atomic_ground.sparql" | 176 | // TestUtil.combinePaths(ontoDir, "bio2rdf/uniprot/queries/atomic_ground.sparql") |
| 164 | PagodaTester.onto_dir + "bio2rdf/uniprot/queries/example.sparql" | 177 | TestUtil.combinePaths(ontoDir, "bio2rdf/uniprot/queries/example.sparql") |
| 165 | , "pagoda_uniprot.ans" | 178 | , "pagoda_uniprot.ans" |
| 166 | ); | 179 | ); |
| 167 | Utility.copyFile("log4j.log", "output/jair/pagoda_uniprot.example"); | 180 | TestUtil.copyFile("log4j.log", "output/jair/pagoda_uniprot.example"); |
| 168 | // AllTests.copy("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/uniprot/pagoda_1p"); | 181 | // TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/uniprot/pagoda_1p"); |
| 169 | } | 182 | } |
| 170 | 183 | ||
| 171 | 184 | ||
diff --git a/test/uk/ac/ox/cs/pagoda/test_units/JAIR_Scalability.java b/test/uk/ac/ox/cs/pagoda/test_units/JAIR_Scalability.java index 43cb810..2cf8446 100644 --- a/test/uk/ac/ox/cs/pagoda/test_units/JAIR_Scalability.java +++ b/test/uk/ac/ox/cs/pagoda/test_units/JAIR_Scalability.java | |||
| @@ -3,7 +3,7 @@ package uk.ac.ox.cs.pagoda.test_units; | |||
| 3 | import org.testng.annotations.Test; | 3 | import org.testng.annotations.Test; |
| 4 | import uk.ac.ox.cs.pagoda.tester.PagodaTester; | 4 | import uk.ac.ox.cs.pagoda.tester.PagodaTester; |
| 5 | import uk.ac.ox.cs.pagoda.util.Properties; | 5 | import uk.ac.ox.cs.pagoda.util.Properties; |
| 6 | import uk.ac.ox.cs.pagoda.util.Utility; | 6 | import uk.ac.ox.cs.pagoda.util.TestUtil; |
| 7 | 7 | ||
| 8 | import java.io.IOException; | 8 | import java.io.IOException; |
| 9 | 9 | ||
| @@ -27,10 +27,11 @@ public class JAIR_Scalability { | |||
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | public void testReactome(int percentage, boolean save) throws IOException { | 29 | public void testReactome(int percentage, boolean save) throws IOException { |
| 30 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | ||
| 30 | String[] args = new String[] { | 31 | String[] args = new String[] { |
| 31 | PagodaTester.onto_dir + "bio2rdf/reactome/biopax-level3-processed.owl", | 32 | TestUtil.combinePaths(ontoDir, "bio2rdf/reactome/biopax-level3-processed.owl"), |
| 32 | PagodaTester.onto_dir + "bio2rdf/reactome/graph sampling/simplifed_sample_" + percentage + ".ttl", | 33 | TestUtil.combinePaths(ontoDir, "bio2rdf/reactome/graph sampling/simplifed_sample_" + percentage + ".ttl"), |
| 33 | PagodaTester.onto_dir + "bio2rdf/reactome/queries/test.sparql" | 34 | TestUtil.combinePaths(ontoDir, "bio2rdf/reactome/queries/test.sparql") |
| 34 | , "reactome.ans" | 35 | , "reactome.ans" |
| 35 | }; | 36 | }; |
| 36 | if (percentage == 10) | 37 | if (percentage == 10) |
| @@ -38,15 +39,16 @@ public class JAIR_Scalability { | |||
| 38 | 39 | ||
| 39 | PagodaTester.main(args); | 40 | PagodaTester.main(args); |
| 40 | if (save) | 41 | if (save) |
| 41 | Utility.copyFile("log4j.log", "/home/yzhou/java-workspace/test-share/results_new/reactome/pagoda_" + percentage + "p" + date); | 42 | TestUtil.copyFile("log4j.log", "/home/yzhou/java-workspace/test-share/results_new/reactome/pagoda_" + percentage + "p" + date); |
| 42 | } | 43 | } |
| 43 | 44 | ||
| 44 | public void testChEMBL(int percentage, boolean save) throws IOException { | 45 | public void testChEMBL(int percentage, boolean save) throws IOException { |
| 46 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | ||
| 45 | String[] args = new String[] { | 47 | String[] args = new String[] { |
| 46 | PagodaTester.onto_dir + "bio2rdf/chembl/cco-noDPR.ttl", | 48 | TestUtil.combinePaths(ontoDir, "bio2rdf/chembl/cco-noDPR.ttl"), |
| 47 | PagodaTester.onto_dir + "bio2rdf/chembl/sample_" + percentage + ".nt", | 49 | TestUtil.combinePaths(ontoDir, "bio2rdf/chembl/sample_" + percentage + ".nt"), |
| 48 | // PagodaTester.onto_dir + "bio2rdf/chembl/queries/atomic_ground.sparql" | 50 | // TestUtil.combinePaths(ontoDir, "bio2rdf/chembl/queries/atomic_ground.sparql") |
| 49 | PagodaTester.onto_dir + "bio2rdf/chembl/queries/test.sparql" | 51 | TestUtil.combinePaths(ontoDir, "bio2rdf/chembl/queries/test.sparql") |
| 50 | , "chembl.ans" | 52 | , "chembl.ans" |
| 51 | }; | 53 | }; |
| 52 | if (percentage == 1 || percentage == 10 || percentage == 50) | 54 | if (percentage == 1 || percentage == 10 || percentage == 50) |
| @@ -57,15 +59,16 @@ public class JAIR_Scalability { | |||
| 57 | 59 | ||
| 58 | PagodaTester.main(args); | 60 | PagodaTester.main(args); |
| 59 | if (save) | 61 | if (save) |
| 60 | Utility.copyFile("log4j.log", "/home/yzhou/java-workspace/test-share/results_new/chembl/pagoda_" + percentage + "p" + date); | 62 | TestUtil.copyFile("log4j.log", "/home/yzhou/java-workspace/test-share/results_new/chembl/pagoda_" + percentage + "p" + date); |
| 61 | } | 63 | } |
| 62 | 64 | ||
| 63 | public void testUniProt(int percentage, boolean save) throws IOException { | 65 | public void testUniProt(int percentage, boolean save) throws IOException { |
| 66 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | ||
| 64 | String[] args = new String[] { | 67 | String[] args = new String[] { |
| 65 | PagodaTester.onto_dir + "bio2rdf/uniprot/core-sat-processed.owl", | 68 | TestUtil.combinePaths(ontoDir, "bio2rdf/uniprot/core-sat-processed.owl"), |
| 66 | PagodaTester.onto_dir + "bio2rdf/uniprot/sample_" + percentage + ".nt", | 69 | TestUtil.combinePaths(ontoDir, "bio2rdf/uniprot/sample_" + percentage + ".nt"), |
| 67 | // PagodaTester.onto_dir + "bio2rdf/uniprot/queries/atomic_ground.sparql" | 70 | // TestUtil.combinePaths(ontoDir, "bio2rdf/uniprot/queries/atomic_ground.sparql") |
| 68 | PagodaTester.onto_dir + "bio2rdf/uniprot/queries/test.sparql" | 71 | TestUtil.combinePaths(ontoDir, "bio2rdf/uniprot/queries/test.sparql") |
| 69 | , "uniprot.ans" | 72 | , "uniprot.ans" |
| 70 | }; | 73 | }; |
| 71 | 74 | ||
| @@ -77,7 +80,7 @@ public class JAIR_Scalability { | |||
| 77 | 80 | ||
| 78 | PagodaTester.main(args); | 81 | PagodaTester.main(args); |
| 79 | if (save) | 82 | if (save) |
| 80 | Utility.copyFile("log4j.log", "/home/yzhou/java-workspace/test-share/results_new/uniprot/pagoda_" + percentage + "p" + date); | 83 | TestUtil.copyFile("log4j.log", "/home/yzhou/java-workspace/test-share/results_new/uniprot/pagoda_" + percentage + "p" + date); |
| 81 | } | 84 | } |
| 82 | 85 | ||
| 83 | public static void main(String... args) throws IOException { | 86 | public static void main(String... args) throws IOException { |
diff --git a/test/uk/ac/ox/cs/pagoda/test_units/LightEvaluation.java b/test/uk/ac/ox/cs/pagoda/test_units/LightEvaluation.java index 29006de..932c178 100644 --- a/test/uk/ac/ox/cs/pagoda/test_units/LightEvaluation.java +++ b/test/uk/ac/ox/cs/pagoda/test_units/LightEvaluation.java | |||
| @@ -2,7 +2,7 @@ package uk.ac.ox.cs.pagoda.test_units; | |||
| 2 | 2 | ||
| 3 | import org.junit.Test; | 3 | import org.junit.Test; |
| 4 | import uk.ac.ox.cs.pagoda.tester.PagodaTester; | 4 | import uk.ac.ox.cs.pagoda.tester.PagodaTester; |
| 5 | import uk.ac.ox.cs.pagoda.util.Utility; | 5 | import uk.ac.ox.cs.pagoda.util.TestUtil; |
| 6 | 6 | ||
| 7 | import java.io.IOException; | 7 | import java.io.IOException; |
| 8 | 8 | ||
| @@ -11,52 +11,57 @@ public class LightEvaluation { | |||
| 11 | @Test | 11 | @Test |
| 12 | public void uobm1() throws IOException { | 12 | public void uobm1() throws IOException { |
| 13 | int number = 1; | 13 | int number = 1; |
| 14 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | ||
| 14 | PagodaTester.main( | 15 | PagodaTester.main( |
| 15 | PagodaTester.onto_dir + "uobm/univ-bench-dl.owl", | 16 | TestUtil.combinePaths(ontoDir, "uobm/univ-bench-dl.owl"), |
| 16 | PagodaTester.onto_dir + "uobm/data/uobm" + number + ".ttl", | 17 | TestUtil.combinePaths(ontoDir, "uobm/data/uobm" + number + ".ttl"), |
| 17 | PagodaTester.onto_dir + "uobm/queries/standard.sparql" | 18 | TestUtil.combinePaths(ontoDir, "uobm/queries/standard.sparql") |
| 18 | ); | 19 | ); |
| 19 | Utility.copyFile("log4j.log", "output/jair/uobm1.out"); | 20 | TestUtil.copyFile("log4j.log", "output/jair/uobm1.out"); |
| 20 | } | 21 | } |
| 21 | 22 | ||
| 22 | @Test | 23 | @Test |
| 23 | public void lubm100() throws IOException { | 24 | public void lubm100() throws IOException { |
| 24 | int number = 100; | 25 | int number = 100; |
| 26 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | ||
| 25 | PagodaTester.main( | 27 | PagodaTester.main( |
| 26 | PagodaTester.onto_dir + "lubm/univ-bench.owl", | 28 | TestUtil.combinePaths(ontoDir, "lubm/univ-bench.owl"), |
| 27 | PagodaTester.onto_dir + "lubm/data/lubm" + number + ".ttl", | 29 | TestUtil.combinePaths(ontoDir, "lubm/data/lubm" + number + ".ttl"), |
| 28 | PagodaTester.onto_dir + "lubm/queries/test.sparql" | 30 | TestUtil.combinePaths(ontoDir, "lubm/queries/test.sparql") |
| 29 | ); | 31 | ); |
| 30 | Utility.copyFile("log4j.log", "results-backup/current/lubm100.out"); | 32 | TestUtil.copyFile("log4j.log", "results-backup/current/lubm100.out"); |
| 31 | } | 33 | } |
| 32 | 34 | ||
| 33 | @Test | 35 | @Test |
| 34 | public void fly() throws IOException { | 36 | public void fly() throws IOException { |
| 37 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | ||
| 35 | PagodaTester.main( | 38 | PagodaTester.main( |
| 36 | PagodaTester.onto_dir + "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl", | 39 | TestUtil.combinePaths(ontoDir, "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl"), |
| 37 | PagodaTester.onto_dir + "fly/queries/fly.sparql" | 40 | TestUtil.combinePaths(ontoDir, "fly/queries/fly.sparql") |
| 38 | ); | 41 | ); |
| 39 | Utility.copyFile("log4j.log", "results-backup/current/fly.out"); | 42 | TestUtil.copyFile("log4j.log", "results-backup/current/fly.out"); |
| 40 | } | 43 | } |
| 41 | 44 | ||
| 42 | @Test | 45 | @Test |
| 43 | public void dbpedia() throws IOException { | 46 | public void dbpedia() throws IOException { |
| 47 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | ||
| 44 | PagodaTester.main( | 48 | PagodaTester.main( |
| 45 | PagodaTester.onto_dir + "dbpedia/integratedOntology-all-in-one-minus-datatype.owl", | 49 | TestUtil.combinePaths(ontoDir, "dbpedia/integratedOntology-all-in-one-minus-datatype.owl"), |
| 46 | PagodaTester.onto_dir + "dbpedia/data/dbpedia-minus-datatype-new.ttl", | 50 | TestUtil.combinePaths(ontoDir, "dbpedia/data/dbpedia-minus-datatype-new.ttl"), |
| 47 | PagodaTester.onto_dir + "dbpedia/atomic.sparql" | 51 | TestUtil.combinePaths(ontoDir, "dbpedia/atomic.sparql") |
| 48 | ); | 52 | ); |
| 49 | Utility.copyFile("log4j.log", "results-backup/current/dbpedia.out"); | 53 | TestUtil.copyFile("log4j.log", "results-backup/current/dbpedia.out"); |
| 50 | } | 54 | } |
| 51 | 55 | ||
| 52 | @Test | 56 | @Test |
| 53 | public void npdWithoutDataType() throws IOException { | 57 | public void npdWithoutDataType() throws IOException { |
| 58 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | ||
| 54 | PagodaTester.main( | 59 | PagodaTester.main( |
| 55 | PagodaTester.onto_dir + "npd/npd-all-minus-datatype.owl", | 60 | TestUtil.combinePaths(ontoDir, "npd/npd-all-minus-datatype.owl"), |
| 56 | PagodaTester.onto_dir + "npd/data/npd-data-dump-minus-datatype-new.ttl", | 61 | TestUtil.combinePaths(ontoDir, "npd/data/npd-data-dump-minus-datatype-new.ttl"), |
| 57 | PagodaTester.onto_dir + "npd/queries/atomic.sparql" | 62 | TestUtil.combinePaths(ontoDir, "npd/queries/atomic.sparql") |
| 58 | ); | 63 | ); |
| 59 | Utility.copyFile("log4j.log", "results-backup/current/npd_minus.out"); | 64 | TestUtil.copyFile("log4j.log", "results-backup/current/npd_minus.out"); |
| 60 | } | 65 | } |
| 61 | 66 | ||
| 62 | } | 67 | } |
diff --git a/test/uk/ac/ox/cs/pagoda/test_units/PagodaDBPedia.java b/test/uk/ac/ox/cs/pagoda/test_units/PagodaDBPedia.java index aaf542e..1673179 100644 --- a/test/uk/ac/ox/cs/pagoda/test_units/PagodaDBPedia.java +++ b/test/uk/ac/ox/cs/pagoda/test_units/PagodaDBPedia.java | |||
| @@ -1,28 +1,28 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.test_units; | 1 | package uk.ac.ox.cs.pagoda.test_units; |
| 2 | 2 | ||
| 3 | import static org.junit.Assert.fail; | ||
| 4 | |||
| 5 | import org.junit.Test; | 3 | import org.junit.Test; |
| 6 | |||
| 7 | import uk.ac.ox.cs.pagoda.tester.PagodaTester; | 4 | import uk.ac.ox.cs.pagoda.tester.PagodaTester; |
| 8 | import uk.ac.ox.cs.pagoda.tester.Statistics; | 5 | import uk.ac.ox.cs.pagoda.tester.Statistics; |
| 9 | import uk.ac.ox.cs.pagoda.util.Utility; | 6 | import uk.ac.ox.cs.pagoda.util.TestUtil; |
| 10 | 7 | ||
| 11 | import java.io.IOException; | 8 | import java.io.IOException; |
| 12 | 9 | ||
| 10 | import static org.junit.Assert.fail; | ||
| 11 | |||
| 13 | public class PagodaDBPedia { | 12 | public class PagodaDBPedia { |
| 14 | 13 | ||
| 15 | @Test | 14 | @Test |
| 16 | public void test() throws IOException { | 15 | public void test() throws IOException { |
| 16 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | ||
| 17 | PagodaTester.main( | 17 | PagodaTester.main( |
| 18 | PagodaTester.onto_dir + "dbpedia/integratedOntology-all-in-one-minus-datatype.owl", | 18 | TestUtil.combinePaths(ontoDir, "dbpedia/integratedOntology-all-in-one-minus-datatype.owl"), |
| 19 | PagodaTester.onto_dir + "dbpedia/data/dbpedia-minus-datatype-new.ttl", | 19 | TestUtil.combinePaths(ontoDir, "dbpedia/data/dbpedia-minus-datatype-new.ttl"), |
| 20 | PagodaTester.onto_dir + "dbpedia/atomic.sparql" | 20 | TestUtil.combinePaths(ontoDir, "dbpedia/atomic.sparql") |
| 21 | ); | 21 | ); |
| 22 | 22 | ||
| 23 | Statistics stat = new Statistics("output/log4j.log"); | 23 | Statistics stat = new Statistics("output/log4j.log"); |
| 24 | String diff = stat.diff("results-backup/benchmark/dbpedia.out"); | 24 | String diff = stat.diff("results-backup/benchmark/dbpedia.out"); |
| 25 | Utility.copyFile("output/log4j.log", "results-backup/current/dbpedia.out"); | 25 | TestUtil.copyFile("output/log4j.log", "results-backup/current/dbpedia.out"); |
| 26 | if (!diff.isEmpty()) | 26 | if (!diff.isEmpty()) |
| 27 | fail(diff); | 27 | fail(diff); |
| 28 | } | 28 | } |
diff --git a/test/uk/ac/ox/cs/pagoda/test_units/PagodaELU.java b/test/uk/ac/ox/cs/pagoda/test_units/PagodaELU.java index c2fa838..70d531d 100644 --- a/test/uk/ac/ox/cs/pagoda/test_units/PagodaELU.java +++ b/test/uk/ac/ox/cs/pagoda/test_units/PagodaELU.java | |||
| @@ -2,15 +2,17 @@ package uk.ac.ox.cs.pagoda.test_units; | |||
| 2 | 2 | ||
| 3 | import org.junit.Test; | 3 | import org.junit.Test; |
| 4 | import uk.ac.ox.cs.pagoda.tester.PagodaTester; | 4 | import uk.ac.ox.cs.pagoda.tester.PagodaTester; |
| 5 | import uk.ac.ox.cs.pagoda.util.TestUtil; | ||
| 5 | 6 | ||
| 6 | public class PagodaELU { | 7 | public class PagodaELU { |
| 7 | 8 | ||
| 8 | @Test void test() { | 9 | @Test void test() { |
| 9 | int number = 1; | 10 | int number = 1; |
| 11 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | ||
| 10 | PagodaTester.main( | 12 | PagodaTester.main( |
| 11 | PagodaTester.onto_dir + "uobm/univ-bench-dl.owl", | 13 | TestUtil.combinePaths(ontoDir, "uobm/univ-bench-dl.owl"), |
| 12 | PagodaTester.onto_dir + "uobm/data/uobm" + number + ".ttl", | 14 | TestUtil.combinePaths(ontoDir, "uobm/data/uobm" + number + ".ttl"), |
| 13 | PagodaTester.onto_dir + "uobm/queries/standard.sparql" | 15 | TestUtil.combinePaths(ontoDir, "uobm/queries/standard.sparql") |
| 14 | ); | 16 | ); |
| 15 | } | 17 | } |
| 16 | 18 | ||
diff --git a/test/uk/ac/ox/cs/pagoda/test_units/PagodaFLY.java b/test/uk/ac/ox/cs/pagoda/test_units/PagodaFLY.java index 2fe07f0..bad533f 100644 --- a/test/uk/ac/ox/cs/pagoda/test_units/PagodaFLY.java +++ b/test/uk/ac/ox/cs/pagoda/test_units/PagodaFLY.java | |||
| @@ -1,16 +1,17 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.test_units; | 1 | package uk.ac.ox.cs.pagoda.test_units; |
| 2 | 2 | ||
| 3 | import org.junit.Test; | 3 | import org.junit.Test; |
| 4 | |||
| 5 | import uk.ac.ox.cs.pagoda.tester.PagodaTester; | 4 | import uk.ac.ox.cs.pagoda.tester.PagodaTester; |
| 5 | import uk.ac.ox.cs.pagoda.util.TestUtil; | ||
| 6 | 6 | ||
| 7 | public class PagodaFLY { | 7 | public class PagodaFLY { |
| 8 | 8 | ||
| 9 | @Test | 9 | @Test |
| 10 | public void test() { | 10 | public void test() { |
| 11 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | ||
| 11 | PagodaTester.main( | 12 | PagodaTester.main( |
| 12 | PagodaTester.onto_dir + "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl", | 13 | TestUtil.combinePaths(ontoDir, "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl"), |
| 13 | PagodaTester.onto_dir + "fly/queries/fly_pellet.sparql" | 14 | TestUtil.combinePaths(ontoDir, "fly/queries/fly_pellet.sparql") |
| 14 | ); | 15 | ); |
| 15 | 16 | ||
| 16 | // Statistics stat = new Statistics("output/log4j.log"); | 17 | // Statistics stat = new Statistics("output/log4j.log"); |
diff --git a/test/uk/ac/ox/cs/pagoda/test_units/PagodaLUBM.java b/test/uk/ac/ox/cs/pagoda/test_units/PagodaLUBM.java index f40e41b..29abc87 100644 --- a/test/uk/ac/ox/cs/pagoda/test_units/PagodaLUBM.java +++ b/test/uk/ac/ox/cs/pagoda/test_units/PagodaLUBM.java | |||
| @@ -1,68 +1,24 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.test_units; | 1 | package uk.ac.ox.cs.pagoda.test_units; |
| 2 | 2 | ||
| 3 | import org.testng.Assert; | ||
| 4 | import org.testng.annotations.Test; | 3 | import org.testng.annotations.Test; |
| 5 | import uk.ac.ox.cs.pagoda.tester.PagodaTester; | 4 | import uk.ac.ox.cs.pagoda.util.TestUtil; |
| 6 | import uk.ac.ox.cs.pagoda.tester.Statistics; | ||
| 7 | import uk.ac.ox.cs.pagoda.util.Utility; | ||
| 8 | 5 | ||
| 9 | import java.io.FileInputStream; | ||
| 10 | import java.io.IOException; | 6 | import java.io.IOException; |
| 11 | import java.util.Properties; | 7 | import java.nio.file.Paths; |
| 12 | 8 | ||
| 13 | public class PagodaLUBM { | 9 | public class PagodaLUBM { |
| 14 | 10 | ||
| 15 | public static final String CONFIG_FILE = "config/test.properties"; | 11 | private void testN(int number ) throws IOException { |
| 16 | 12 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | |
| 17 | private static boolean isInit = false; | 13 | TestGlobalCorrectness.test(Paths.get(ontoDir, "lubm/univ-bench.owl"), |
| 18 | private static String ontoDir; | 14 | Paths.get(ontoDir, "lubm/data/lubm" + number + ".ttl"), |
| 19 | 15 | Paths.get(ontoDir, "lubm/queries/test.sparql"), | |
| 20 | private static void init() { | 16 | Paths.get(ontoDir, "lubm/lubm" + number + ".ans")); |
| 21 | if(isInit) return; | ||
| 22 | isInit = true; | ||
| 23 | |||
| 24 | Properties config = new Properties(); | ||
| 25 | |||
| 26 | try(FileInputStream in = new FileInputStream(CONFIG_FILE)) { | ||
| 27 | config.load(in); | ||
| 28 | in.close(); | ||
| 29 | } catch (IOException e) { | ||
| 30 | e.printStackTrace(); | ||
| 31 | } | ||
| 32 | |||
| 33 | ontoDir = config.getProperty("ontoDir"); | ||
| 34 | } | ||
| 35 | |||
| 36 | private void test_all(int number) { | ||
| 37 | init(); | ||
| 38 | PagodaTester.main( | ||
| 39 | Utility.combinePaths(ontoDir, "lubm/univ-bench.owl"), | ||
| 40 | Utility.combinePaths(ontoDir, "lubm/data/lubm" + number + ".ttl"), | ||
| 41 | Utility.combinePaths(ontoDir, "lubm/queries/test.sparql") | ||
| 42 | ); | ||
| 43 | |||
| 44 | // assertTrue(false); | ||
| 45 | // AllTests.copy("log4j.log", "output/jair/lubm" + number + ".out"); | ||
| 46 | } | 17 | } |
| 47 | 18 | ||
| 48 | @Test | 19 | @Test |
| 49 | public void test1() { | 20 | public void test1() throws IOException { |
| 50 | test_all(1); | 21 | testN(1); |
| 51 | } | ||
| 52 | |||
| 53 | // @Test | ||
| 54 | // public void test() { | ||
| 55 | // int number = 100; | ||
| 56 | // test_all(number); | ||
| 57 | // } | ||
| 58 | |||
| 59 | private void check(int number) throws IOException { | ||
| 60 | Statistics stat = new Statistics("output/log4j.log"); | ||
| 61 | // TODO insert proper file | ||
| 62 | String diff = stat.diff("results-backup/benchmark/lubm" + number + ".out"); | ||
| 63 | Utility.copyFile("output/log4j.log", "results-backup/current/lubm" + number + ".out"); | ||
| 64 | if (!diff.isEmpty()) | ||
| 65 | Assert.fail(diff); | ||
| 66 | } | 22 | } |
| 67 | 23 | ||
| 68 | } | 24 | } |
diff --git a/test/uk/ac/ox/cs/pagoda/test_units/PagodaNPD.java b/test/uk/ac/ox/cs/pagoda/test_units/PagodaNPD.java index 8fbe793..5f89162 100644 --- a/test/uk/ac/ox/cs/pagoda/test_units/PagodaNPD.java +++ b/test/uk/ac/ox/cs/pagoda/test_units/PagodaNPD.java | |||
| @@ -1,43 +1,44 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.test_units; | 1 | package uk.ac.ox.cs.pagoda.test_units; |
| 2 | 2 | ||
| 3 | import static org.junit.Assert.fail; | ||
| 4 | |||
| 5 | import org.junit.Test; | 3 | import org.junit.Test; |
| 6 | |||
| 7 | import uk.ac.ox.cs.pagoda.tester.PagodaTester; | 4 | import uk.ac.ox.cs.pagoda.tester.PagodaTester; |
| 8 | import uk.ac.ox.cs.pagoda.tester.Statistics; | 5 | import uk.ac.ox.cs.pagoda.tester.Statistics; |
| 9 | import uk.ac.ox.cs.pagoda.util.Utility; | 6 | import uk.ac.ox.cs.pagoda.util.TestUtil; |
| 10 | 7 | ||
| 11 | import java.io.IOException; | 8 | import java.io.IOException; |
| 12 | 9 | ||
| 10 | import static org.junit.Assert.fail; | ||
| 11 | |||
| 13 | public class PagodaNPD { | 12 | public class PagodaNPD { |
| 14 | 13 | ||
| 15 | @Test | 14 | @Test |
| 16 | public void testNPDwithoutDataType() throws IOException { | 15 | public void testNPDwithoutDataType() throws IOException { |
| 16 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | ||
| 17 | PagodaTester.main( | 17 | PagodaTester.main( |
| 18 | PagodaTester.onto_dir + "npd/npd-all-minus-datatype.owl", | 18 | TestUtil.combinePaths(ontoDir, "npd/npd-all-minus-datatype.owl"), |
| 19 | PagodaTester.onto_dir + "npd/data/npd-data-dump-minus-datatype-new.ttl", | 19 | TestUtil.combinePaths(ontoDir, "npd/data/npd-data-dump-minus-datatype-new.ttl"), |
| 20 | PagodaTester.onto_dir + "npd/queries/atomic.sparql" | 20 | TestUtil.combinePaths(ontoDir, "npd/queries/atomic.sparql") |
| 21 | ); | 21 | ); |
| 22 | 22 | ||
| 23 | Statistics stat = new Statistics("output/log4j.log"); | 23 | Statistics stat = new Statistics("output/log4j.log"); |
| 24 | String diff = stat.diff("results-backup/benchmark/npd_minus.out"); | 24 | String diff = stat.diff("results-backup/benchmark/npd_minus.out"); |
| 25 | Utility.copyFile("output/log4j.log", "results-backup/current/npd_minus.out"); | 25 | TestUtil.copyFile("output/log4j.log", "results-backup/current/npd_minus.out"); |
| 26 | if (!diff.isEmpty()) | 26 | if (!diff.isEmpty()) |
| 27 | fail(diff); | 27 | fail(diff); |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | @Test | 30 | @Test |
| 31 | public void testNPD() throws IOException { | 31 | public void testNPD() throws IOException { |
| 32 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | ||
| 32 | PagodaTester.main( | 33 | PagodaTester.main( |
| 33 | PagodaTester.onto_dir + "npd/npd-all.owl", | 34 | TestUtil.combinePaths(ontoDir, "npd/npd-all.owl"), |
| 34 | PagodaTester.onto_dir + "npd/data/npd-data-dump-processed.ttl", | 35 | TestUtil.combinePaths(ontoDir, "npd/data/npd-data-dump-processed.ttl"), |
| 35 | PagodaTester.onto_dir + "npd/queries/atomic.sparql" | 36 | TestUtil.combinePaths(ontoDir, "npd/queries/atomic.sparql") |
| 36 | ); | 37 | ); |
| 37 | 38 | ||
| 38 | Statistics stat = new Statistics("output/log4j.log"); | 39 | Statistics stat = new Statistics("output/log4j.log"); |
| 39 | String diff = stat.diff("results-backup/benchmark/npd.out"); | 40 | String diff = stat.diff("results-backup/benchmark/npd.out"); |
| 40 | Utility.copyFile("output/log4j.log", "results-backup/current/npd.out"); | 41 | TestUtil.copyFile("output/log4j.log", "results-backup/current/npd.out"); |
| 41 | if (!diff.isEmpty()) | 42 | if (!diff.isEmpty()) |
| 42 | fail(diff); | 43 | fail(diff); |
| 43 | } | 44 | } |
diff --git a/test/uk/ac/ox/cs/pagoda/test_units/PagodaNPD_bench.java b/test/uk/ac/ox/cs/pagoda/test_units/PagodaNPD_bench.java index 1243180..1aca36a 100644 --- a/test/uk/ac/ox/cs/pagoda/test_units/PagodaNPD_bench.java +++ b/test/uk/ac/ox/cs/pagoda/test_units/PagodaNPD_bench.java | |||
| @@ -1,28 +1,28 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.test_units; | 1 | package uk.ac.ox.cs.pagoda.test_units; |
| 2 | 2 | ||
| 3 | import static org.junit.Assert.fail; | ||
| 4 | |||
| 5 | import org.junit.Test; | 3 | import org.junit.Test; |
| 6 | |||
| 7 | import uk.ac.ox.cs.pagoda.tester.PagodaTester; | 4 | import uk.ac.ox.cs.pagoda.tester.PagodaTester; |
| 8 | import uk.ac.ox.cs.pagoda.tester.Statistics; | 5 | import uk.ac.ox.cs.pagoda.tester.Statistics; |
| 9 | import uk.ac.ox.cs.pagoda.util.Utility; | 6 | import uk.ac.ox.cs.pagoda.util.TestUtil; |
| 10 | 7 | ||
| 11 | import java.io.IOException; | 8 | import java.io.IOException; |
| 12 | 9 | ||
| 10 | import static org.junit.Assert.fail; | ||
| 11 | |||
| 13 | public class PagodaNPD_bench { | 12 | public class PagodaNPD_bench { |
| 14 | 13 | ||
| 15 | @Test | 14 | @Test |
| 16 | public void test() throws IOException { | 15 | public void test() throws IOException { |
| 16 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | ||
| 17 | PagodaTester.main( | 17 | PagodaTester.main( |
| 18 | PagodaTester.onto_dir + "npd-benchmark/npd-v2-ql_a.owl", | 18 | TestUtil.combinePaths(ontoDir, "npd-benchmark/npd-v2-ql_a.owl"), |
| 19 | PagodaTester.onto_dir + "npd-benchmark/npd-v2-ql_a.ttl", | 19 | TestUtil.combinePaths(ontoDir, "npd-benchmark/npd-v2-ql_a.ttl"), |
| 20 | PagodaTester.onto_dir + "npd-benchmark/queries/all.sparql" | 20 | TestUtil.combinePaths(ontoDir, "npd-benchmark/queries/all.sparql") |
| 21 | ); | 21 | ); |
| 22 | 22 | ||
| 23 | Statistics stat = new Statistics("output/log4j.log"); | 23 | Statistics stat = new Statistics("output/log4j.log"); |
| 24 | String diff = stat.diff("results-backup/benchmark/npd-bench.out"); | 24 | String diff = stat.diff("results-backup/benchmark/npd-bench.out"); |
| 25 | Utility.copyFile("output/log4j.log", "results-backup/current/npd-bench.out"); | 25 | TestUtil.copyFile("output/log4j.log", "results-backup/current/npd-bench.out"); |
| 26 | if (!diff.isEmpty()) | 26 | if (!diff.isEmpty()) |
| 27 | fail(diff); | 27 | fail(diff); |
| 28 | } | 28 | } |
diff --git a/test/uk/ac/ox/cs/pagoda/test_units/PagodaRLU.java b/test/uk/ac/ox/cs/pagoda/test_units/PagodaRLU.java index 8b31c99..c365196 100644 --- a/test/uk/ac/ox/cs/pagoda/test_units/PagodaRLU.java +++ b/test/uk/ac/ox/cs/pagoda/test_units/PagodaRLU.java | |||
| @@ -2,17 +2,19 @@ package uk.ac.ox.cs.pagoda.test_units; | |||
| 2 | 2 | ||
| 3 | import org.junit.Test; | 3 | import org.junit.Test; |
| 4 | import uk.ac.ox.cs.pagoda.tester.PagodaTester; | 4 | import uk.ac.ox.cs.pagoda.tester.PagodaTester; |
| 5 | import uk.ac.ox.cs.pagoda.util.TestUtil; | ||
| 5 | 6 | ||
| 6 | public class PagodaRLU { | 7 | public class PagodaRLU { |
| 7 | 8 | ||
| 8 | @Test | 9 | @Test |
| 9 | public void testRL() { | 10 | public void testRL() { |
| 10 | int number = 1; | 11 | int number = 1; |
| 12 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | ||
| 11 | PagodaTester.main( | 13 | PagodaTester.main( |
| 12 | PagodaTester.onto_dir + "uobm/univ-bench-dl.owl", | 14 | TestUtil.combinePaths(ontoDir, "uobm/univ-bench-dl.owl"), |
| 13 | PagodaTester.onto_dir + "uobm/data/uobm" + number + ".ttl", | 15 | TestUtil.combinePaths(ontoDir, "uobm/data/uobm" + number + ".ttl"), |
| 14 | PagodaTester.onto_dir + "uobm/queries/standard.sparql" | 16 | TestUtil.combinePaths(ontoDir, "uobm/queries/standard.sparql") |
| 15 | ); | 17 | ); |
| 16 | } | 18 | } |
| 17 | 19 | ||
| 18 | } | 20 | } |
diff --git a/test/uk/ac/ox/cs/pagoda/test_units/PagodaUOBM.java b/test/uk/ac/ox/cs/pagoda/test_units/PagodaUOBM.java index 29a9056..f53ed7e 100644 --- a/test/uk/ac/ox/cs/pagoda/test_units/PagodaUOBM.java +++ b/test/uk/ac/ox/cs/pagoda/test_units/PagodaUOBM.java | |||
| @@ -1,79 +1,24 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.test_units; | 1 | package uk.ac.ox.cs.pagoda.test_units; |
| 2 | 2 | ||
| 3 | import org.testng.annotations.Test; | 3 | import org.testng.annotations.Test; |
| 4 | import uk.ac.ox.cs.pagoda.tester.PagodaTester; | 4 | import uk.ac.ox.cs.pagoda.util.TestUtil; |
| 5 | import uk.ac.ox.cs.pagoda.tester.Statistics; | ||
| 6 | import uk.ac.ox.cs.pagoda.util.Utility; | ||
| 7 | 5 | ||
| 8 | import java.io.FileInputStream; | ||
| 9 | import java.io.IOException; | 6 | import java.io.IOException; |
| 10 | import java.util.Properties; | 7 | import java.nio.file.Paths; |
| 11 | 8 | ||
| 12 | public class PagodaUOBM { | 9 | public class PagodaUOBM { |
| 13 | 10 | ||
| 14 | public static final String CONFIG_FILE = "config/test.properties"; | 11 | private void testN(int number ) throws IOException { |
| 15 | 12 | String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); | |
| 16 | private static boolean isInit = false; | 13 | TestGlobalCorrectness.test(Paths.get(ontoDir, "uobm/univ-bench-dl.owl"), |
| 17 | private static String ontoDir; | 14 | Paths.get(ontoDir, "uobm/data/uobm" + number + ".ttl"), |
| 18 | 15 | Paths.get(ontoDir, "uobm/queries/test.sparql"), | |
| 19 | private static void init() { | 16 | Paths.get(ontoDir, "uobm/uobm" + number + ".ans")); |
| 20 | if(isInit) return; | ||
| 21 | isInit = true; | ||
| 22 | |||
| 23 | Properties config = new Properties(); | ||
| 24 | |||
| 25 | try(FileInputStream in = new FileInputStream(CONFIG_FILE)) { | ||
| 26 | config.load(in); | ||
| 27 | in.close(); | ||
| 28 | } catch (IOException e) { | ||
| 29 | e.printStackTrace(); | ||
| 30 | } | ||
| 31 | |||
| 32 | ontoDir = config.getProperty("ontoDir"); | ||
| 33 | } | ||
| 34 | |||
| 35 | private void test_all(int number ) { | ||
| 36 | init(); | ||
| 37 | |||
| 38 | PagodaTester.main( | ||
| 39 | Utility.combinePaths(ontoDir, "uobm/univ-bench-dl.owl"), | ||
| 40 | Utility.combinePaths(ontoDir, "uobm/data/uobm" + number + ".ttl"), | ||
| 41 | Utility.combinePaths(ontoDir, "uobm/queries/test.sparql") | ||
| 42 | // + ";" + | ||
| 43 | // Utility.combinePaths(ontoDir, "uobm/queries/standard_group3_all_less.sparql") + ";" + | ||
| 44 | // Utility.combinePaths(ontoDir, "uobm/queries/G3.sparql") + ";" + | ||
| 45 | // Utility.combinePaths(ontoDir, "uobm/queries/last.sparql") | ||
| 46 | ); | ||
| 47 | |||
| 48 | // AllTests.copy("log4j.log", "output/jair/newuobm/uobm" + number + ".out"); | ||
| 49 | } | ||
| 50 | |||
| 51 | private void test_upToSum(int number) { | ||
| 52 | init(); | ||
| 53 | |||
| 54 | PagodaTester.main( | ||
| 55 | PagodaTester.onto_dir + "uobm/univ-bench-dl.owl", | ||
| 56 | PagodaTester.onto_dir + "uobm/data/uobm" + number + ".ttl", | ||
| 57 | PagodaTester.onto_dir + "uobm/queries/standard_group3_all.sparql" | ||
| 58 | ); | ||
| 59 | |||
| 60 | // AllTests.copy("log4j.log", "output/jair/uobm" + number + ".out"); | ||
| 61 | } | 17 | } |
| 62 | 18 | ||
| 63 | @Test | 19 | @Test |
| 64 | public void test1() { test_all(1); } | 20 | public void test1() throws IOException { |
| 65 | 21 | testN(1); | |
| 66 | // @Test | ||
| 67 | public void test500() { test_upToSum(500); } | ||
| 68 | |||
| 69 | // public static void main(String... args) { | ||
| 70 | // new PagodaUOBM().test_all(1); | ||
| 71 | // } | ||
| 72 | |||
| 73 | private void check() { | ||
| 74 | Statistics stat = new Statistics("results-backup/current/uobm1.out"); | ||
| 75 | String diff = stat.diff("results-backup/benchmark/uobm1.out"); | ||
| 76 | System.out.println(diff); | ||
| 77 | } | 22 | } |
| 78 | 23 | ||
| 79 | } | 24 | } |
diff --git a/test/uk/ac/ox/cs/pagoda/test_units/TestGlobalCorrectness.java b/test/uk/ac/ox/cs/pagoda/test_units/TestGlobalCorrectness.java new file mode 100644 index 0000000..34ec8cd --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/test_units/TestGlobalCorrectness.java | |||
| @@ -0,0 +1,55 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.test_units; | ||
| 2 | |||
| 3 | import com.google.gson.Gson; | ||
| 4 | import com.google.gson.GsonBuilder; | ||
| 5 | import com.google.gson.reflect.TypeToken; | ||
| 6 | import org.apache.log4j.Logger; | ||
| 7 | import org.testng.Assert; | ||
| 8 | import uk.ac.ox.cs.pagoda.query.AnswerTuple; | ||
| 9 | import uk.ac.ox.cs.pagoda.query.QueryRecord; | ||
| 10 | import uk.ac.ox.cs.pagoda.tester.PagodaTester; | ||
| 11 | |||
| 12 | import java.io.BufferedReader; | ||
| 13 | import java.io.File; | ||
| 14 | import java.io.IOException; | ||
| 15 | import java.lang.reflect.Type; | ||
| 16 | import java.nio.file.Files; | ||
| 17 | import java.nio.file.Path; | ||
| 18 | import java.nio.file.Paths; | ||
| 19 | import java.util.Collection; | ||
| 20 | import java.util.Set; | ||
| 21 | |||
| 22 | /* | ||
| 23 | * This is a unit test for TestNG. | ||
| 24 | * <p> | ||
| 25 | * It tests the correctness on the final output. | ||
| 26 | * */ | ||
| 27 | public class TestGlobalCorrectness { | ||
| 28 | |||
| 29 | public static final Logger logger = Logger.getLogger(TestGlobalCorrectness.class); | ||
| 30 | |||
| 31 | public static void test(Path ontology, Path data, Path queries, Path givenAnswers) { | ||
| 32 | try { | ||
| 33 | Path computedAnswers = Paths.get(File.createTempFile("answers", ".tmp").getAbsolutePath()); | ||
| 34 | PagodaTester.main(ontology.toString(), data.toString(), queries.toString(), computedAnswers.toString()); | ||
| 35 | Assert.assertTrue(checkSameContent(computedAnswers, givenAnswers)); | ||
| 36 | } catch (IOException e) { | ||
| 37 | e.printStackTrace(); | ||
| 38 | } | ||
| 39 | } | ||
| 40 | |||
| 41 | private static boolean checkSameContent(Path computedAnswersFile, Path givenAnswersFile) throws IOException { | ||
| 42 | BufferedReader computedReader = Files.newBufferedReader(computedAnswersFile); | ||
| 43 | BufferedReader givenReader = Files.newBufferedReader(givenAnswersFile); | ||
| 44 | |||
| 45 | Gson gson = new GsonBuilder().create(); | ||
| 46 | |||
| 47 | Type cqType = new TypeToken<Set<AnswerTuple>>() {}.getType(); | ||
| 48 | Collection<QueryRecord> computedAnswers = gson.fromJson(computedReader, cqType); | ||
| 49 | Collection<QueryRecord> givenAnswers = gson.fromJson(givenReader, cqType); | ||
| 50 | |||
| 51 | return computedAnswers.equals(givenAnswers); | ||
| 52 | } | ||
| 53 | |||
| 54 | |||
| 55 | } | ||
diff --git a/test/uk/ac/ox/cs/pagoda/tester/PagodaTester.java b/test/uk/ac/ox/cs/pagoda/tester/PagodaTester.java index 51b41f9..7dacdac 100644 --- a/test/uk/ac/ox/cs/pagoda/tester/PagodaTester.java +++ b/test/uk/ac/ox/cs/pagoda/tester/PagodaTester.java | |||
| @@ -1,17 +1,17 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.tester; | 1 | package uk.ac.ox.cs.pagoda.tester; |
| 2 | 2 | ||
| 3 | import java.io.File; | ||
| 4 | import java.io.FileNotFoundException; | ||
| 5 | import java.io.IOException; | ||
| 6 | import java.util.Scanner; | ||
| 7 | |||
| 8 | import uk.ac.ox.cs.pagoda.query.AnswerTuple; | 3 | import uk.ac.ox.cs.pagoda.query.AnswerTuple; |
| 9 | import uk.ac.ox.cs.pagoda.query.AnswerTuples; | 4 | import uk.ac.ox.cs.pagoda.query.AnswerTuples; |
| 10 | import uk.ac.ox.cs.pagoda.reasoner.*; | 5 | import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner; |
| 11 | import uk.ac.ox.cs.pagoda.util.Properties; | 6 | import uk.ac.ox.cs.pagoda.util.Properties; |
| 12 | import uk.ac.ox.cs.pagoda.util.Timer; | 7 | import uk.ac.ox.cs.pagoda.util.Timer; |
| 13 | import uk.ac.ox.cs.pagoda.util.Utility; | 8 | import uk.ac.ox.cs.pagoda.util.Utility; |
| 14 | 9 | ||
| 10 | import java.io.File; | ||
| 11 | import java.io.FileNotFoundException; | ||
| 12 | import java.io.IOException; | ||
| 13 | import java.util.Scanner; | ||
| 14 | |||
| 15 | public class PagodaTester { | 15 | public class PagodaTester { |
| 16 | 16 | ||
| 17 | // public static final String onto_dir = "/media/RDFData/yzhou/"; | 17 | // public static final String onto_dir = "/media/RDFData/yzhou/"; |
| @@ -93,7 +93,7 @@ public class PagodaTester { | |||
| 93 | public static void main(String... args) { | 93 | public static void main(String... args) { |
| 94 | if (args.length == 0) { | 94 | if (args.length == 0) { |
| 95 | // args = new String[] {test_tbox, test_abox, test_query}; | 95 | // args = new String[] {test_tbox, test_abox, test_query}; |
| 96 | args = new String[] {lubm_tbox, lubm_abox, lubm_query}; | 96 | args = new String[] {lubm_tbox, lubm_abox, lubm_query, "/home/alessandro/Desktop/lubm1.ans"}; |
| 97 | // args = new String[] {uobm_tbox, uobm_abox, uobm_query.replace(".sparql", "_all_pagoda.sparql")}; | 97 | // args = new String[] {uobm_tbox, uobm_abox, uobm_query.replace(".sparql", "_all_pagoda.sparql")}; |
| 98 | // args = new String[] {fly, "null", fly_query.replace(".sparql", "_pellet.sparql") }; | 98 | // args = new String[] {fly, "null", fly_query.replace(".sparql", "_pellet.sparql") }; |
| 99 | // args = new String[] {dbpedia_tbox, dbpedia_abox, dbpedia_query}; | 99 | // args = new String[] {dbpedia_tbox, dbpedia_abox, dbpedia_query}; |
| @@ -145,7 +145,7 @@ public class PagodaTester { | |||
| 145 | 145 | ||
| 146 | if (properties.getQueryPath() != null) | 146 | if (properties.getQueryPath() != null) |
| 147 | for (String queryFile: properties.getQueryPath().split(";")) | 147 | for (String queryFile: properties.getQueryPath().split(";")) |
| 148 | pagoda.evaluate(pagoda.getQueryManager().collectQueryRecords(queryFile), properties.getAnswerPath()); | 148 | pagoda.evaluate(pagoda.getQueryManager().collectQueryRecords(queryFile)); |
| 149 | 149 | ||
| 150 | if (properties.getShellMode()) | 150 | if (properties.getShellMode()) |
| 151 | try { | 151 | try { |
diff --git a/test/uk/ac/ox/cs/pagoda/util/TestUtil.java b/test/uk/ac/ox/cs/pagoda/util/TestUtil.java new file mode 100644 index 0000000..227398b --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/util/TestUtil.java | |||
| @@ -0,0 +1,64 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.util; | ||
| 2 | |||
| 3 | import org.apache.log4j.Appender; | ||
| 4 | import org.apache.log4j.FileAppender; | ||
| 5 | import org.apache.log4j.Logger; | ||
| 6 | |||
| 7 | import java.io.File; | ||
| 8 | import java.io.FileInputStream; | ||
| 9 | import java.io.IOException; | ||
| 10 | import java.nio.file.Files; | ||
| 11 | import java.nio.file.Paths; | ||
| 12 | import java.util.Enumeration; | ||
| 13 | import java.util.Properties; | ||
| 14 | |||
| 15 | import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; | ||
| 16 | |||
| 17 | /** | ||
| 18 | * A collection of utility methods for testing. | ||
| 19 | */ | ||
| 20 | public class TestUtil { | ||
| 21 | |||
| 22 | public static final String CONFIG_FILE = "config/test.properties"; | ||
| 23 | |||
| 24 | private static boolean isConfigLoaded = false; | ||
| 25 | private static Properties config; | ||
| 26 | |||
| 27 | public static Properties getConfig() { | ||
| 28 | if(!isConfigLoaded) { | ||
| 29 | try (FileInputStream in = new FileInputStream(CONFIG_FILE)) { | ||
| 30 | config = new java.util.Properties(); | ||
| 31 | config.load(in); | ||
| 32 | in.close(); | ||
| 33 | isConfigLoaded = true; | ||
| 34 | } catch (IOException e) { | ||
| 35 | e.printStackTrace(); | ||
| 36 | } | ||
| 37 | } | ||
| 38 | return config; | ||
| 39 | } | ||
| 40 | |||
| 41 | public static String combinePaths(String path1, String path2) { | ||
| 42 | File file1 = new File(path1); | ||
| 43 | File file2 = new File(file1, path2); | ||
| 44 | return file2.getPath(); | ||
| 45 | } | ||
| 46 | |||
| 47 | public static void copyFile(String src, String dst) throws IOException { | ||
| 48 | Files.copy(Paths.get(src), Paths.get(dst), REPLACE_EXISTING); | ||
| 49 | } | ||
| 50 | |||
| 51 | /* | ||
| 52 | * Get the log file, which is assumed unique. | ||
| 53 | * */ | ||
| 54 | public static String getLogFileName() { | ||
| 55 | Enumeration e = Logger.getRootLogger().getAllAppenders(); | ||
| 56 | while (e.hasMoreElements()){ | ||
| 57 | Appender app = (Appender)e.nextElement(); | ||
| 58 | if (app instanceof FileAppender){ | ||
| 59 | return ((FileAppender)app).getFile(); | ||
| 60 | } | ||
| 61 | } | ||
| 62 | return null; | ||
| 63 | } | ||
| 64 | } | ||
