aboutsummaryrefslogtreecommitdiff
path: root/test/uk/ac/ox/cs/pagoda
diff options
context:
space:
mode:
authoryzhou <yujiao.zhou@gmail.com>2015-04-21 10:34:27 +0100
committeryzhou <yujiao.zhou@gmail.com>2015-04-21 10:34:27 +0100
commit9ce65c5a963b03ee97fe9cb6c5aa65a3c04a80a8 (patch)
tree47511c0fb89dccff0db4b5990522e04f294d795b /test/uk/ac/ox/cs/pagoda
parentb1ac207612ee8b045244253fb94b866104bc34f2 (diff)
downloadACQuA-9ce65c5a963b03ee97fe9cb6c5aa65a3c04a80a8.tar.gz
ACQuA-9ce65c5a963b03ee97fe9cb6c5aa65a3c04a80a8.zip
initial version
Diffstat (limited to 'test/uk/ac/ox/cs/pagoda')
-rw-r--r--test/uk/ac/ox/cs/pagoda/approx/ApproxTester.java158
-rw-r--r--test/uk/ac/ox/cs/pagoda/approx/ClauseTester.java38
-rw-r--r--test/uk/ac/ox/cs/pagoda/junit/AllTests.java50
-rw-r--r--test/uk/ac/ox/cs/pagoda/junit/ClauseTester.java165
-rw-r--r--test/uk/ac/ox/cs/pagoda/junit/CostEvaluation.java109
-rw-r--r--test/uk/ac/ox/cs/pagoda/junit/FullEvaluation.java14
-rw-r--r--test/uk/ac/ox/cs/pagoda/junit/JAIR_PAGOdA.java173
-rw-r--r--test/uk/ac/ox/cs/pagoda/junit/JAIR_Scalability.java85
-rw-r--r--test/uk/ac/ox/cs/pagoda/junit/LightEvaluation.java59
-rw-r--r--test/uk/ac/ox/cs/pagoda/junit/PagodaDBPedia.java27
-rw-r--r--test/uk/ac/ox/cs/pagoda/junit/PagodaELU.java18
-rw-r--r--test/uk/ac/ox/cs/pagoda/junit/PagodaFLY.java24
-rw-r--r--test/uk/ac/ox/cs/pagoda/junit/PagodaLUBM.java38
-rw-r--r--test/uk/ac/ox/cs/pagoda/junit/PagodaNPD.java42
-rw-r--r--test/uk/ac/ox/cs/pagoda/junit/PagodaNPD_bench.java27
-rw-r--r--test/uk/ac/ox/cs/pagoda/junit/PagodaRLU.java18
-rw-r--r--test/uk/ac/ox/cs/pagoda/junit/PagodaUOBM.java48
-rw-r--r--test/uk/ac/ox/cs/pagoda/summary/SummaryTester.java139
-rw-r--r--test/uk/ac/ox/cs/pagoda/tester/ORETester.java29
-rw-r--r--test/uk/ac/ox/cs/pagoda/tester/OWLTester.java29
-rw-r--r--test/uk/ac/ox/cs/pagoda/tester/PagodaTester.java336
-rw-r--r--test/uk/ac/ox/cs/pagoda/tester/Statistics.java59
22 files changed, 1685 insertions, 0 deletions
diff --git a/test/uk/ac/ox/cs/pagoda/approx/ApproxTester.java b/test/uk/ac/ox/cs/pagoda/approx/ApproxTester.java
new file mode 100644
index 0000000..63fe7b7
--- /dev/null
+++ b/test/uk/ac/ox/cs/pagoda/approx/ApproxTester.java
@@ -0,0 +1,158 @@
1package uk.ac.ox.cs.pagoda.approx;
2
3import java.io.IOException;
4
5import org.semanticweb.owlapi.model.OWLOntology;
6
7import uk.ac.ox.cs.pagoda.approx.KnowledgeBase;
8import uk.ac.ox.cs.pagoda.approx.RLOntology;
9import uk.ac.ox.cs.pagoda.approx.RLPlusOntology;
10import uk.ac.ox.cs.pagoda.constraints.NullaryBottom;
11import uk.ac.ox.cs.pagoda.owl.OWLHelper;
12import uk.ac.ox.cs.pagoda.rules.DisjunctiveProgram;
13import uk.ac.ox.cs.pagoda.rules.ExistentialProgram;
14import uk.ac.ox.cs.pagoda.rules.ExistentialToDisjunctive;
15import uk.ac.ox.cs.pagoda.rules.GeneralProgram;
16import uk.ac.ox.cs.pagoda.rules.LowerDatalogProgram;
17import uk.ac.ox.cs.pagoda.rules.UpperDatalogProgram;
18import uk.ac.ox.cs.pagoda.util.Utility;
19
20public class ApproxTester {
21
22 private static ApproxType description = ApproxType.DATALOGPMOR;
23
24 private static String ontoFile = null;
25
26 public static void main(String[] args) throws IOException
27 {
28 args = new String[] {
29 "-tbox",
30// "/home/yzhou/krr-nas-share/Yujiao/ontologies/bio2rdf/chembl/cco-noDPR.ttl",
31// "/home/yzhou/krr-nas-share/Yujiao/ontologies/bio2rdf/reactome/biopax-level3-processed.owl",
32// "/media/krr-nas-share/Yujiao/ontologies/bio2rdf/atlas/gxaterms.owl",
33// "/media/krr-nas-share/Yujiao/ontologies/bio2rdf/uniprot/core-sat-processed.owl",
34// PagodaTester.npd_tbox,
35// "/users/yzhou/temp/ontologies/core.RLor.rdf",
36 "datatype.owl",
37 "-dest", ApproxType.DATALOGPMOR.toString()
38 };
39
40 long startTime = System.currentTimeMillis();
41
42 if (args.length > 0) {
43 if (args.length % 2 != 0) {
44 System.out.println("arguments error...");
45 return ;
46 }
47 for (int i = 0; i < args.length ; i = i + 2)
48 if (!setArgument(args[i], args[i + 1])) {
49 System.out.println("arguments error...");
50 return ;
51 }
52 }
53
54// Utility.redirectSystemOut();
55
56 System.setProperty("entityExpansionLimit", String.valueOf(Integer.MAX_VALUE));
57
58 String directory = ontoFile.substring(0, ontoFile.lastIndexOf(Utility.FILE_SEPARATOR) + 1);
59
60 KnowledgeBase program = null;
61 switch (description) {
62 case OWL2RLPLUS: program = new RLPlusOntology(); break;
63 case OWL2RL: program = new RLOntology(); break;
64 case DATALOG_UPPER: program = new UpperDatalogProgram(); break;
65 case DATALOG_LOWER: program = new LowerDatalogProgram(); break;
66 case EXISTENTIAL: program = new ExistentialProgram(); break;
67 case DISJUNCTIVE: program = new DisjunctiveProgram(); break;
68 case DATALOGPMOR: program = new GeneralProgram(); break;
69 case EXIST2DISJ: program = new ExistentialToDisjunctive(); break;
70 default:
71 System.exit(0);
72 }
73
74 if (program instanceof RLPlusOntology)
75 ((RLPlusOntology) program).setCorrespondenceFileLoc(directory + "correspondence");
76 OWLOntology ontology = OWLHelper.loadOntology(ontoFile);
77 program.load(ontology, new NullaryBottom());
78
79 program.transform();
80
81 program.save();
82
83 System.out.println("Time to transform the rules: " + (System.currentTimeMillis() - startTime) / 1000.);
84
85 Utility.closeCurrentOut();
86 }
87
88 private static boolean setArgument(String key, String value) {
89 if (key.equalsIgnoreCase("-dest"))
90 if (value.equalsIgnoreCase("OWL2RL+")) description = ApproxType.OWL2RLPLUS;
91 else if (value.equalsIgnoreCase("OWL2RL")) description = ApproxType.OWL2RL;
92 else if (value.equalsIgnoreCase("UPPERDATALOG")) description = ApproxType.DATALOG_UPPER;
93 else if (value.equalsIgnoreCase("LOWERDATALOG")) description = ApproxType.DATALOG_LOWER;
94 else if (value.equalsIgnoreCase("DATALOGPMOR")) description = ApproxType.DATALOGPMOR;
95 else if (value.equalsIgnoreCase("EXISTENTIALRULES")) description = ApproxType.EXISTENTIAL;
96 else if (value.equalsIgnoreCase("DISJUNCTIVE")) description = ApproxType.DISJUNCTIVE;
97 else if (value.equalsIgnoreCase("EXIST2DISJ")) description = ApproxType.EXIST2DISJ;
98 else {
99 System.out.println("illegal destination argument...");
100 return false;
101 }
102 else if (key.equalsIgnoreCase("-tbox"))
103 ontoFile = value;
104 else {
105 System.out.println("unrecognisable type of argument...");
106 return false;
107 }
108
109 return true;
110 }
111
112 public enum ApproxType {
113 /**
114 * approx to (RL + self + top being the subClassExp)
115 */
116 OWL2RLPLUS,
117
118 /**
119 * approx to RL
120 */
121 OWL2RL,
122
123 /**
124 * approx to datalog by replacing existential quantified variables
125 * by fresh constants and replacing disjunctions by conjunctions
126 */
127 DATALOG_UPPER,
128
129 /**
130 * approx to datalog by ignoring existential and disjunctive axiom
131 */
132 DATALOG_LOWER,
133
134 /**
135 * approx to existential rules by replacing disjunctions by
136 * conjunctions
137 */
138 EXISTENTIAL,
139
140 /**
141 * approx to disjunctive datalog program by replacing existential
142 * quantified variables by fresh constants (DNF)
143 */
144 DISJUNCTIVE,
145
146 /**
147 * transform into rules, no approximation at all
148 */
149 DATALOGPMOR,
150
151 /**
152 * approx existential quantifiers by disjunctions
153 */
154 EXIST2DISJ
155
156 };
157
158}
diff --git a/test/uk/ac/ox/cs/pagoda/approx/ClauseTester.java b/test/uk/ac/ox/cs/pagoda/approx/ClauseTester.java
new file mode 100644
index 0000000..cff1d1c
--- /dev/null
+++ b/test/uk/ac/ox/cs/pagoda/approx/ClauseTester.java
@@ -0,0 +1,38 @@
1package uk.ac.ox.cs.pagoda.approx;
2
3import org.semanticweb.HermiT.model.DLClause;
4import org.semanticweb.owlapi.model.OWLOntology;
5
6import uk.ac.ox.cs.pagoda.constraints.NullaryBottom;
7import uk.ac.ox.cs.pagoda.owl.OWLHelper;
8import uk.ac.ox.cs.pagoda.rules.GeneralProgram;
9
10public class ClauseTester {
11
12 public static void main(String... args) {
13 args = new String[] {
14// "/home/yzhou/krr-nas-share/Yujiao/ontologies/bio2rdf/chembl/cco-noDPR.ttl",
15 "/home/yzhou/krr-nas-share/Yujiao/ontologies/bio2rdf/reactome/biopax-level3-processed.owl",
16// "/media/krr-nas-share/Yujiao/ontologies/bio2rdf/atlas/gxaterms.owl",
17// "/media/krr-nas-share/Yujiao/ontologies/bio2rdf/uniprot/core-sat-processed.owl",
18// PagodaTester.npd_tbox,
19// "/users/yzhou/temp/ontologies/core.RLor.rdf",
20// "datatype.owl"
21 };
22
23 String ontoFile = args[0];
24 OWLOntology ontology = OWLHelper.loadOntology(ontoFile);
25 GeneralProgram program = new GeneralProgram();;
26 program.load(ontology, new NullaryBottom());
27 program.transform();
28 program.save();
29 if (program instanceof GeneralProgram) {
30 GeneralProgram gp = ((GeneralProgram) program);
31 for (DLClause clause: gp.getClauses()) {
32 System.out.println(clause);
33 System.out.println(OWLHelper.getOWLAxiom(ontology, clause));
34 }
35 }
36 }
37
38}
diff --git a/test/uk/ac/ox/cs/pagoda/junit/AllTests.java b/test/uk/ac/ox/cs/pagoda/junit/AllTests.java
new file mode 100644
index 0000000..6884081
--- /dev/null
+++ b/test/uk/ac/ox/cs/pagoda/junit/AllTests.java
@@ -0,0 +1,50 @@
1package uk.ac.ox.cs.pagoda.junit;
2
3import java.io.BufferedWriter;
4import java.io.FileInputStream;
5import java.io.FileNotFoundException;
6import java.io.FileOutputStream;
7import java.io.IOException;
8import java.io.InputStream;
9import java.io.OutputStream;
10import java.io.OutputStreamWriter;
11
12import org.junit.runner.RunWith;
13import org.junit.runners.Suite;
14import org.junit.runners.Suite.SuiteClasses;
15
16import uk.ac.ox.cs.data.WriteIntoTurtle;
17
18@RunWith(Suite.class)
19@SuiteClasses({ WriteIntoTurtle.class, PagodaUOBM.class
20 })
21public class AllTests {
22
23 public static void copy(String source, String dest) {
24 InputStream is = null;
25 OutputStream os = null;
26 try {
27 is = new FileInputStream(source);
28 os = new FileOutputStream(dest);
29 byte[] buffer = new byte[1024];
30 int length;
31 while ((length = is.read(buffer)) > 0) {
32 os.write(buffer, 0, length);
33 }
34 is.close();
35 os.close();
36
37 BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(source)));
38 writer.write("");
39 writer.close();
40 } catch (FileNotFoundException e) {
41 e.printStackTrace();
42 } catch (IOException e) {
43 e.printStackTrace();
44 }
45
46// File src = new File(source);
47// src.delete();
48 }
49
50}
diff --git a/test/uk/ac/ox/cs/pagoda/junit/ClauseTester.java b/test/uk/ac/ox/cs/pagoda/junit/ClauseTester.java
new file mode 100644
index 0000000..d23f186
--- /dev/null
+++ b/test/uk/ac/ox/cs/pagoda/junit/ClauseTester.java
@@ -0,0 +1,165 @@
1package uk.ac.ox.cs.pagoda.junit;
2
3import static org.junit.Assert.*;
4
5import org.junit.Test;
6import org.semanticweb.HermiT.model.Atom;
7import org.semanticweb.HermiT.model.AtomicConcept;
8import org.semanticweb.HermiT.model.AtomicRole;
9import org.semanticweb.HermiT.model.DLClause;
10import org.semanticweb.HermiT.model.Equality;
11import org.semanticweb.HermiT.model.Variable;
12import org.semanticweb.owlapi.apibinding.OWLManager;
13import org.semanticweb.owlapi.model.OWLOntology;
14import org.semanticweb.owlapi.model.OWLOntologyManager;
15
16import uk.ac.ox.cs.pagoda.approx.Clause;
17import uk.ac.ox.cs.pagoda.approx.Clausifier;
18
19public class ClauseTester {
20
21 @Test
22 public void test_simple() {
23 Variable x = Variable.create("X"), y1 = Variable.create("y1"), y2 = Variable.create("y2");
24 AtomicConcept A = AtomicConcept.create("A");
25 AtomicRole r = AtomicRole.create("r");
26 Atom[] bodyAtoms = new Atom[] {
27 Atom.create(A, x),
28 Atom.create(r, x, y1),
29 Atom.create(r, x, y2)
30 };
31
32 Atom[] headAtoms = new Atom[] {
33 Atom.create(Equality.INSTANCE, y1, y2)
34 };
35
36 OWLOntologyManager m = OWLManager.createOWLOntologyManager();
37 OWLOntology emptyOntology = null;
38 try {
39 emptyOntology = m.createOntology();
40 } catch (Exception e) {
41 e.printStackTrace();
42 fail("failed to create a new ontology");
43 }
44 Clause c = new Clause(Clausifier.getInstance(emptyOntology), DLClause.create(headAtoms, bodyAtoms));
45 System.out.println(c.toString());
46 }
47
48 @Test
49 public void test_more() {
50 Variable x = Variable.create("X"), y1 = Variable.create("y1"), y2 = Variable.create("y2"), y3 = Variable.create("y3");
51 AtomicConcept A = AtomicConcept.create("A");
52 AtomicRole r = AtomicRole.create("r");
53 Atom[] bodyAtoms = new Atom[] {
54 Atom.create(A, x),
55 Atom.create(r, x, y1),
56 Atom.create(r, x, y2),
57 Atom.create(r, x, y3),
58 };
59
60 Atom[] headAtoms = new Atom[] {
61 Atom.create(Equality.INSTANCE, y1, y2),
62 Atom.create(Equality.INSTANCE, y1, y3),
63 Atom.create(Equality.INSTANCE, y2, y3)
64 };
65
66 OWLOntologyManager m = OWLManager.createOWLOntologyManager();
67 OWLOntology emptyOntology = null;
68 try {
69 emptyOntology = m.createOntology();
70 } catch (Exception e) {
71 e.printStackTrace();
72 fail("failed to create a new ontology");
73 }
74 Clause c = new Clause(Clausifier.getInstance(emptyOntology), DLClause.create(headAtoms, bodyAtoms));
75 System.out.println(c.toString());
76 }
77
78 @Test
79 public void test_inverse() {
80 Variable x = Variable.create("X"), y1 = Variable.create("y1"), y2 = Variable.create("y2");
81 AtomicConcept A = AtomicConcept.create("A");
82 AtomicRole r = AtomicRole.create("r");
83 Atom[] bodyAtoms = new Atom[] {
84 Atom.create(A, x),
85 Atom.create(r, y1, x),
86 Atom.create(r, y2, x)
87 };
88
89 Atom[] headAtoms = new Atom[] {
90 Atom.create(Equality.INSTANCE, y1, y2)
91 };
92
93 OWLOntologyManager m = OWLManager.createOWLOntologyManager();
94 OWLOntology emptyOntology = null;
95 try {
96 emptyOntology = m.createOntology();
97 } catch (Exception e) {
98 e.printStackTrace();
99 fail("failed to create a new ontology");
100 }
101 Clause c = new Clause(Clausifier.getInstance(emptyOntology), DLClause.create(headAtoms, bodyAtoms));
102 System.out.println(c.toString());
103 }
104
105 @Test
106 public void test_fillter() {
107 Variable x = Variable.create("X"), y1 = Variable.create("y1"), y2 = Variable.create("y2");
108 AtomicConcept A = AtomicConcept.create("A");
109 AtomicConcept B = AtomicConcept.create("B");
110 AtomicRole r = AtomicRole.create("r");
111 Atom[] bodyAtoms = new Atom[] {
112 Atom.create(A, x),
113 Atom.create(r, y1, x),
114 Atom.create(r, y2, x),
115 Atom.create(B, y1),
116 Atom.create(B, y2)
117 };
118
119 Atom[] headAtoms = new Atom[] {
120 Atom.create(Equality.INSTANCE, y1, y2)
121 };
122
123 OWLOntologyManager m = OWLManager.createOWLOntologyManager();
124 OWLOntology emptyOntology = null;
125 try {
126 emptyOntology = m.createOntology();
127 } catch (Exception e) {
128 e.printStackTrace();
129 fail("failed to create a new ontology");
130 }
131 Clause c = new Clause(Clausifier.getInstance(emptyOntology), DLClause.create(headAtoms, bodyAtoms));
132 System.out.println(c.toString());
133 }
134
135 @Test
136 public void test_negFillter() {
137 Variable x = Variable.create("X"), y1 = Variable.create("y1"), y2 = Variable.create("y2");
138 AtomicConcept A = AtomicConcept.create("A");
139 AtomicConcept B = AtomicConcept.create("B");
140 AtomicRole r = AtomicRole.create("r");
141 Atom[] bodyAtoms = new Atom[] {
142 Atom.create(A, x),
143 Atom.create(r, y1, x),
144 Atom.create(r, y2, x)
145 };
146
147 Atom[] headAtoms = new Atom[] {
148 Atom.create(Equality.INSTANCE, y1, y2),
149 Atom.create(B, y1),
150 Atom.create(B, y2)
151 };
152
153 OWLOntologyManager m = OWLManager.createOWLOntologyManager();
154 OWLOntology emptyOntology = null;
155 try {
156 emptyOntology = m.createOntology();
157 } catch (Exception e) {
158 e.printStackTrace();
159 fail("failed to create a new ontology");
160 }
161 Clause c = new Clause(Clausifier.getInstance(emptyOntology), DLClause.create(headAtoms, bodyAtoms));
162 System.out.println(c.toString());
163 }
164
165}
diff --git a/test/uk/ac/ox/cs/pagoda/junit/CostEvaluation.java b/test/uk/ac/ox/cs/pagoda/junit/CostEvaluation.java
new file mode 100644
index 0000000..87b01ed
--- /dev/null
+++ b/test/uk/ac/ox/cs/pagoda/junit/CostEvaluation.java
@@ -0,0 +1,109 @@
1package uk.ac.ox.cs.pagoda.junit;
2
3import org.junit.Test;
4import org.semanticweb.owlapi.model.OWLOntology;
5
6import uk.ac.ox.cs.pagoda.owl.OWLHelper;
7import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner;
8import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner.Type;
9import uk.ac.ox.cs.pagoda.tester.PagodaTester;
10import uk.ac.ox.cs.pagoda.util.Timer;
11import uk.ac.ox.cs.pagoda.util.Utility;
12
13public class CostEvaluation {
14
15 @Test
16 public void lubm100() {
17 int number = 1;
18 PagodaTester.main(
19 PagodaTester.onto_dir + "lubm/univ-bench.owl",
20 PagodaTester.onto_dir + "lubm/data/lubm" + number + ".ttl",
21 PagodaTester.onto_dir + "lubm/queries/test_all_pagoda.sparql"
22 );
23// AllTests.copy("output/log4j.log", "results-backup/jair/lubm" + number + ".out");
24 }
25
26 public void lubm1000() {
27 int number = 1000;
28 String[] args = new String[] {
29 PagodaTester.onto_dir + "lubm/univ-bench.owl",
30 PagodaTester.onto_dir + "lubm/data/lubm" + number + ".ttl",
31 PagodaTester.onto_dir + "lubm/queries/test_all_pagoda.sparql"
32 };
33 OWLOntology ontology = OWLHelper.loadOntology(args[0]);
34 QueryReasoner reasoner = QueryReasoner.getInstance(Type.ELHOU, ontology, true, true);
35 Timer t = new Timer();
36 reasoner.loadOntology(ontology);
37 reasoner.importData(args[1]);
38 if (!reasoner.preprocess())
39 return ;
40 Utility.logInfo("Preprocessing Done in " + t.duration() + " seconds.");
41
42 reasoner.evaluate(reasoner.getQueryManager().collectQueryRecords(args[2]));
43// AllTests.copy("output/log4j.log", "results-backup/jair/lubm" + number + ".out");
44 }
45
46 @Test
47 public void uobm5() {
48 int number = 1;
49 String[] args = new String[] {
50 PagodaTester.onto_dir + "uobm/univ-bench-dl.owl",
51 PagodaTester.onto_dir + "uobm/data/uobm" + number + ".ttl",
52 PagodaTester.onto_dir + "uobm/queries/standard_all_pagoda.sparql"
53 };
54 PagodaTester.main(args);
55// AllTests.copy("output/log4j.log", "results-backup/jair/uobm" + number + ".out");
56 }
57
58 public void uobm100() {
59 int number = 200;
60 String[] args = new String[] {
61 PagodaTester.onto_dir + "uobm/univ-bench-dl.owl",
62 PagodaTester.onto_dir + "uobm/data/uobm" + number + ".ttl",
63 PagodaTester.onto_dir + "uobm/queries/standard_group3_all.sparql"
64 };
65 PagodaTester.main(args);
66// AllTests.copy("output/log4j.log", "results-backup/jair/uobm" + number + ".out");
67 }
68
69 public void uobm500() {
70 int number = 500;
71 String[] args = new String[] {
72 PagodaTester.onto_dir + "uobm/univ-bench-dl.owl",
73 PagodaTester.onto_dir + "uobm/data/uobm" + number + ".ttl",
74 PagodaTester.onto_dir + "uobm/queries/standard_all_pagoda.sparql"
75 };
76
77 OWLOntology ontology = OWLHelper.loadOntology(args[0]);
78 QueryReasoner reasoner = QueryReasoner.getInstance(Type.ELHOU, ontology, true, true);
79 Timer t = new Timer();
80 reasoner.loadOntology(ontology);
81 reasoner.importData(args[1]);
82 if (!reasoner.preprocess())
83 return ;
84 Utility.logInfo("Preprocessing Done in " + t.duration() + " seconds.");
85
86 reasoner.evaluate(reasoner.getQueryManager().collectQueryRecords(args[2]));
87// AllTests.copy("output/log4j.log", "results-backup/jair/uobm" + number + ".out");
88 }
89
90
91 public static void main(String... args) {
92 args = new String[] {
93 PagodaTester.onto_dir + "dbpedia/integratedOntology-all-in-one-minus-datatype.owl",
94 PagodaTester.onto_dir + "dbpedia/data/dbpedia-minus-datatype-new.ttl",
95 PagodaTester.onto_dir + "dbpedia/queries/atomic_ground.sparql"
96 };
97
98 OWLOntology ontology = OWLHelper.loadOntology(args[0]);
99 QueryReasoner reasoner = QueryReasoner.getInstance(Type.ELHOU, ontology, true, true);
100 Timer t = new Timer();
101 reasoner.loadOntology(ontology);
102 reasoner.importData(args[1]);
103 if (!reasoner.preprocess())
104 return ;
105 Utility.logInfo("Preprocessing Done in " + t.duration() + " seconds.");
106
107 reasoner.evaluate(reasoner.getQueryManager().collectQueryRecords(args[2]));
108 }
109}
diff --git a/test/uk/ac/ox/cs/pagoda/junit/FullEvaluation.java b/test/uk/ac/ox/cs/pagoda/junit/FullEvaluation.java
new file mode 100644
index 0000000..3406ed2
--- /dev/null
+++ b/test/uk/ac/ox/cs/pagoda/junit/FullEvaluation.java
@@ -0,0 +1,14 @@
1package uk.ac.ox.cs.pagoda.junit;
2
3import org.junit.runner.RunWith;
4import org.junit.runners.Suite;
5import org.junit.runners.Suite.SuiteClasses;
6
7@RunWith(Suite.class)
8@SuiteClasses({ LightEvaluation.class,
9 CostEvaluation.class
10 })
11
12public class FullEvaluation {
13
14}
diff --git a/test/uk/ac/ox/cs/pagoda/junit/JAIR_PAGOdA.java b/test/uk/ac/ox/cs/pagoda/junit/JAIR_PAGOdA.java
new file mode 100644
index 0000000..2a148cc
--- /dev/null
+++ b/test/uk/ac/ox/cs/pagoda/junit/JAIR_PAGOdA.java
@@ -0,0 +1,173 @@
1package uk.ac.ox.cs.pagoda.junit;
2
3import org.junit.Test;
4
5import uk.ac.ox.cs.pagoda.tester.PagodaTester;
6
7public class JAIR_PAGOdA {
8
9 public void lubm1() {
10 String[] args = new String[] {
11 PagodaTester.onto_dir + "lubm/univ-bench.owl",
12 PagodaTester.onto_dir + "lubm/data/lubm1.ttl",
13 PagodaTester.onto_dir + "lubm/queries/test.sparql"
14 };
15 PagodaTester.main(args);
16 AllTests.copy("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/lubm1/pagoda");
17 }
18
19
20 public void lubm1_conj() {
21 String[] args = new String[] {
22 PagodaTester.onto_dir + "lubm/univ-bench.owl",
23 PagodaTester.onto_dir + "lubm/data/lubm1.ttl",
24 PagodaTester.onto_dir + "lubm/queries/test_pellet.sparql"
25 };
26 PagodaTester.main(args);
27 AllTests.copy("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/lubm1/pagoda_conj");
28 }
29
30
31 public void lubm1_rolledUp() {
32 String[] args = new String[] {
33 "/home/yzhou/backup/20141212/univ-bench-queries.owl",
34 PagodaTester.onto_dir + "lubm/data/lubm1.ttl",
35 PagodaTester.onto_dir + "lubm/queries/atomic_lubm.sparql"
36 };
37 PagodaTester.main(args);
38 AllTests.copy("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/lubm1/pagoda_rolledUp");
39 }
40
41
42 public void uobm1() {
43 String[] args = new String[] {
44 PagodaTester.onto_dir + "uobm/univ-bench-dl.owl",
45 PagodaTester.onto_dir + "uobm/data/uobm1.ttl",
46 PagodaTester.onto_dir + "uobm/queries/standard.sparql"
47 };
48 PagodaTester.main(args);
49 AllTests.copy("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/uobm1/pagoda");
50 }
51
52
53 public void uobm1_conj() {
54 String[] args = new String[] {
55 PagodaTester.onto_dir + "uobm/univ-bench-dl.owl",
56 PagodaTester.onto_dir + "uobm/data/uobm1.ttl",
57 PagodaTester.onto_dir + "uobm/queries/standard_pellet.sparql"
58 };
59 PagodaTester.main(args);
60 AllTests.copy("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/uobm1/pagoda_conj");
61 }
62
63
64 public void uobm1_rolledUp() {
65 String[] args = new String[] {
66 "/home/yzhou/backup/20141212/univ-bench-dl-queries.owl",
67 PagodaTester.onto_dir + "uobm/data/uobm1.ttl",
68 PagodaTester.onto_dir + "uobm/queries/atomic_uobm.sparql"
69 };
70 PagodaTester.main(args);
71// AllTests.copy("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/uobm1/pagoda_rolledUp");
72 }
73
74
75 public void fly() {
76 String[] args = new String[] {
77 PagodaTester.onto_dir + "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl",
78 null,
79 PagodaTester.onto_dir + "fly/queries/fly_pellet.sparql"
80 };
81 PagodaTester.main(args);
82// AllTests.copy("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/fly/pagoda");
83 }
84
85 @Test
86 public void fly_conj() {
87 String[] args = new String[] {
88 PagodaTester.onto_dir + "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl",
89 null,
90 PagodaTester.onto_dir + "fly/queries/fly_pellet.sparql"
91 };
92 PagodaTester.main(args);
93 AllTests.copy("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/fly/pagoda_conj");
94 }
95
96
97 public void fly_rolledUp() {
98 PagodaTester.main(new String[] {
99// PagodaTester.onto_dir + "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl",
100 PagodaTester.onto_dir + "fly/fly-all-in-one_rolledUp.owl",
101 null,
102 PagodaTester.onto_dir + "fly/queries/fly_atomic.sparql"
103 });
104// AllTests.copy("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/fly/pagoda_rolledUp");
105 }
106
107 public void dbpedia() {
108 PagodaTester.main(
109 PagodaTester.onto_dir + "dbpedia/integratedOntology-all-in-one-minus-datatype.owl",
110 PagodaTester.onto_dir + "dbpedia/data/dbpedia-minus-datatype-new.ttl",
111 PagodaTester.onto_dir + "dbpedia/queries/atomic_ground.sparql"
112 , "dbpedia.ans"
113 );
114
115// AllTests.copy("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/dbpedia/pagoda");
116 }
117
118 public void npd() {
119 PagodaTester.main(
120 PagodaTester.onto_dir + "npd/npd-all-minus-datatype.owl",
121 PagodaTester.onto_dir + "npd/data/npd-data-dump-minus-datatype-new.ttl",
122 PagodaTester.onto_dir + "npd/queries/atomic_ground.sparql"
123 , "npd.ans"
124 );
125
126// AllTests.copy("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/npd/pagoda");
127 }
128
129 public void reactome() {
130 PagodaTester.main(
131 PagodaTester.onto_dir + "bio2rdf/reactome/biopax-level3-processed.owl",
132 PagodaTester.onto_dir + "bio2rdf/reactome/graph sampling/reactome_sample_10.ttl",
133// null,
134// PagodaTester.onto_dir + "bio2rdf/reactome/queries/atomic_ground.sparql"
135 PagodaTester.onto_dir + "bio2rdf/reactome/queries/example.sparql"
136 , "pagoda_reactome.ans"
137 );
138 AllTests.copy("log4j.log", "output/jair/pagoda_reactome.example");
139
140// AllTests.copy("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/reactome/pagoda_10p");
141 }
142
143 public void chembl() {
144 PagodaTester.main(
145 PagodaTester.onto_dir + "bio2rdf/chembl/cco-noDPR.ttl",
146 PagodaTester.onto_dir + "bio2rdf/chembl/graph sampling/sample_1.nt",
147// PagodaTester.onto_dir + "bio2rdf/chembl/queries/atomic_ground.sparql"
148 PagodaTester.onto_dir + "bio2rdf/chembl/queries/example.sparql"
149 , "pagoda_chembl.ans"
150 );
151 AllTests.copy("log4j.log", "output/jair/pagoda_chembl.example");
152// AllTests.copy("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/chembl/pagoda_1p");
153 }
154
155 public void uniprot() {
156 PagodaTester.main(
157 PagodaTester.onto_dir + "bio2rdf/uniprot/core-sat-processed.owl",
158 PagodaTester.onto_dir + "bio2rdf/uniprot/graph sampling/sample_1.nt",
159// null,
160// PagodaTester.onto_dir + "bio2rdf/uniprot/queries/atomic_ground.sparql"
161 PagodaTester.onto_dir + "bio2rdf/uniprot/queries/example.sparql"
162 , "pagoda_uniprot.ans"
163 );
164 AllTests.copy("log4j.log", "output/jair/pagoda_uniprot.example");
165// AllTests.copy("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/uniprot/pagoda_1p");
166 }
167
168
169 public static void main(String... args) {
170 new JAIR_PAGOdA().fly();
171 }
172
173}
diff --git a/test/uk/ac/ox/cs/pagoda/junit/JAIR_Scalability.java b/test/uk/ac/ox/cs/pagoda/junit/JAIR_Scalability.java
new file mode 100644
index 0000000..5bd3134
--- /dev/null
+++ b/test/uk/ac/ox/cs/pagoda/junit/JAIR_Scalability.java
@@ -0,0 +1,85 @@
1package uk.ac.ox.cs.pagoda.junit;
2
3import org.junit.Test;
4
5import uk.ac.ox.cs.pagoda.tester.PagodaTester;
6
7public class JAIR_Scalability {
8
9 private static final String date = "_0123";
10
11 @Test
12 public void reactome() {
13 testReactome(10, false);
14 }
15
16 @Test
17 public void chembl() {
18 testChEMBL(1, false);
19 }
20
21 @Test
22 public void uniprot() {
23 testUniProt(1, false);
24 }
25
26 public void testReactome(int percentage, boolean save) {
27 String[] args = new String[] {
28 PagodaTester.onto_dir + "bio2rdf/reactome/biopax-level3-processed.owl",
29 PagodaTester.onto_dir + "bio2rdf/reactome/graph sampling/simplifed_sample_" + percentage + ".ttl",
30 PagodaTester.onto_dir + "bio2rdf/reactome/queries/test.sparql"
31 , "reactome.ans"
32 };
33 if (percentage == 10)
34 args[1] = args[1].replace("simplifed", "reactome");
35
36 PagodaTester.main(args);
37 if (save)
38 AllTests.copy("log4j.log", "/home/yzhou/java-workspace/test-share/results_new/reactome/pagoda_" + percentage + "p" + date);
39 }
40
41 public void testChEMBL(int percentage, boolean save) {
42 String[] args = new String[] {
43 PagodaTester.onto_dir + "bio2rdf/chembl/cco-noDPR.ttl",
44 PagodaTester.onto_dir + "bio2rdf/chembl/sample_" + percentage + ".nt",
45// PagodaTester.onto_dir + "bio2rdf/chembl/queries/atomic_ground.sparql"
46 PagodaTester.onto_dir + "bio2rdf/chembl/queries/test.sparql"
47 , "chembl.ans"
48 };
49 if (percentage == 1 || percentage == 10 || percentage == 50)
50 args[1] = args[1].replace("chembl", "chembl/graph sampling");
51 else
52 if (percentage == 100)
53 args[1] = "/home/yzhou/RDFData/ChEMBL/facts/ChEMBL.ttl";
54
55 PagodaTester.main(args);
56 if (save)
57 AllTests.copy("log4j.log", "/home/yzhou/java-workspace/test-share/results_new/chembl/pagoda_" + percentage + "p" + date);
58 }
59
60 public void testUniProt(int percentage, boolean save) {
61 String[] args = new String[] {
62 PagodaTester.onto_dir + "bio2rdf/uniprot/core-sat-processed.owl",
63 PagodaTester.onto_dir + "bio2rdf/uniprot/sample_" + percentage + ".nt",
64// PagodaTester.onto_dir + "bio2rdf/uniprot/queries/atomic_ground.sparql"
65 PagodaTester.onto_dir + "bio2rdf/uniprot/queries/test.sparql"
66 , "uniprot.ans"
67 };
68
69 if (percentage == 1 || percentage == 10 || percentage == 50)
70 args[1] = args[1].replace("uniprot", "uniprot/graph sampling");
71 else
72 if (percentage == 100)
73 args[1] = "/home/yzhou/krr-nas-share/Yujiao/ontologies/bio2rdf/uniprot/data/uniprot_cleaned.nt";
74
75 PagodaTester.main(args);
76 if (save)
77 AllTests.copy("log4j.log", "/home/yzhou/java-workspace/test-share/results_new/uniprot/pagoda_" + percentage + "p" + date);
78 }
79
80 public static void main(String... args) {
81 PagodaTester.ShellMode = true;
82 new JAIR_Scalability().testUniProt(50, false);
83 }
84
85}
diff --git a/test/uk/ac/ox/cs/pagoda/junit/LightEvaluation.java b/test/uk/ac/ox/cs/pagoda/junit/LightEvaluation.java
new file mode 100644
index 0000000..1ddca15
--- /dev/null
+++ b/test/uk/ac/ox/cs/pagoda/junit/LightEvaluation.java
@@ -0,0 +1,59 @@
1package uk.ac.ox.cs.pagoda.junit;
2
3import org.junit.Test;
4import uk.ac.ox.cs.pagoda.tester.PagodaTester;
5
6public class LightEvaluation {
7
8 @Test
9 public void uobm1() {
10 int number = 1;
11 PagodaTester.main(
12 PagodaTester.onto_dir + "uobm/univ-bench-dl.owl",
13 PagodaTester.onto_dir + "uobm/data/uobm" + number + ".ttl",
14 PagodaTester.onto_dir + "uobm/queries/standard.sparql"
15 );
16 AllTests.copy("log4j.log", "output/jair/uobm1.out");
17 }
18
19 @Test
20 public void lubm100() {
21 int number = 100;
22 PagodaTester.main(
23 PagodaTester.onto_dir + "lubm/univ-bench.owl",
24 PagodaTester.onto_dir + "lubm/data/lubm" + number + ".ttl",
25 PagodaTester.onto_dir + "lubm/queries/test.sparql"
26 );
27 AllTests.copy("log4j.log", "results-backup/current/lubm100.out");
28 }
29
30 @Test
31 public void fly() {
32 PagodaTester.main(
33 PagodaTester.onto_dir + "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl",
34 PagodaTester.onto_dir + "fly/queries/fly.sparql"
35 );
36 AllTests.copy("log4j.log", "results-backup/current/fly.out");
37 }
38
39 @Test
40 public void dbpedia() {
41 PagodaTester.main(
42 PagodaTester.onto_dir + "dbpedia/integratedOntology-all-in-one-minus-datatype.owl",
43 PagodaTester.onto_dir + "dbpedia/data/dbpedia-minus-datatype-new.ttl",
44 PagodaTester.onto_dir + "dbpedia/atomic.sparql"
45 );
46 AllTests.copy("log4j.log", "results-backup/current/dbpedia.out");
47 }
48
49 @Test
50 public void npdWithoutDataType() {
51 PagodaTester.main(
52 PagodaTester.onto_dir + "npd/npd-all-minus-datatype.owl",
53 PagodaTester.onto_dir + "npd/data/npd-data-dump-minus-datatype-new.ttl",
54 PagodaTester.onto_dir + "npd/queries/atomic.sparql"
55 );
56 AllTests.copy("log4j.log", "results-backup/current/npd_minus.out");
57 }
58
59}
diff --git a/test/uk/ac/ox/cs/pagoda/junit/PagodaDBPedia.java b/test/uk/ac/ox/cs/pagoda/junit/PagodaDBPedia.java
new file mode 100644
index 0000000..37ffb44
--- /dev/null
+++ b/test/uk/ac/ox/cs/pagoda/junit/PagodaDBPedia.java
@@ -0,0 +1,27 @@
1package uk.ac.ox.cs.pagoda.junit;
2
3import static org.junit.Assert.fail;
4
5import org.junit.Test;
6
7import uk.ac.ox.cs.pagoda.tester.PagodaTester;
8import uk.ac.ox.cs.pagoda.tester.Statistics;
9
10public class PagodaDBPedia {
11
12 @Test
13 public void test() {
14 PagodaTester.main(
15 PagodaTester.onto_dir + "dbpedia/integratedOntology-all-in-one-minus-datatype.owl",
16 PagodaTester.onto_dir + "dbpedia/data/dbpedia-minus-datatype-new.ttl",
17 PagodaTester.onto_dir + "dbpedia/atomic.sparql"
18 );
19
20 Statistics stat = new Statistics("output/log4j.log");
21 String diff = stat.diff("results-backup/benchmark/dbpedia.out");
22 AllTests.copy("output/log4j.log", "results-backup/current/dbpedia.out");
23 if (!diff.isEmpty())
24 fail(diff);
25 }
26
27}
diff --git a/test/uk/ac/ox/cs/pagoda/junit/PagodaELU.java b/test/uk/ac/ox/cs/pagoda/junit/PagodaELU.java
new file mode 100644
index 0000000..d999a6e
--- /dev/null
+++ b/test/uk/ac/ox/cs/pagoda/junit/PagodaELU.java
@@ -0,0 +1,18 @@
1package uk.ac.ox.cs.pagoda.junit;
2
3import org.junit.Test;
4import uk.ac.ox.cs.pagoda.tester.PagodaTester;
5
6public class PagodaELU {
7
8 @Test void test() {
9 int number = 1;
10 PagodaTester.main(
11 PagodaTester.onto_dir + "uobm/univ-bench-dl.owl",
12 PagodaTester.onto_dir + "uobm/data/uobm" + number + ".ttl",
13 PagodaTester.onto_dir + "uobm/queries/standard.sparql"
14 );
15 }
16
17
18}
diff --git a/test/uk/ac/ox/cs/pagoda/junit/PagodaFLY.java b/test/uk/ac/ox/cs/pagoda/junit/PagodaFLY.java
new file mode 100644
index 0000000..4631837
--- /dev/null
+++ b/test/uk/ac/ox/cs/pagoda/junit/PagodaFLY.java
@@ -0,0 +1,24 @@
1package uk.ac.ox.cs.pagoda.junit;
2
3import org.junit.Test;
4
5import uk.ac.ox.cs.pagoda.tester.PagodaTester;
6
7public class PagodaFLY {
8
9 @Test
10 public void test() {
11 PagodaTester.main(
12 PagodaTester.onto_dir + "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl",
13 PagodaTester.onto_dir + "fly/queries/fly_pellet.sparql"
14 );
15
16// Statistics stat = new Statistics("output/log4j.log");
17// String diff = stat.diff("results-backup/benchmark/fly.out");
18// AllTests.copy("output/log4j.log", "results-backup/current/fly.out");
19// if (!diff.isEmpty())
20// fail(diff);
21 }
22
23
24}
diff --git a/test/uk/ac/ox/cs/pagoda/junit/PagodaLUBM.java b/test/uk/ac/ox/cs/pagoda/junit/PagodaLUBM.java
new file mode 100644
index 0000000..f8fef0e
--- /dev/null
+++ b/test/uk/ac/ox/cs/pagoda/junit/PagodaLUBM.java
@@ -0,0 +1,38 @@
1package uk.ac.ox.cs.pagoda.junit;
2
3import static org.junit.Assert.*;
4
5import org.junit.Test;
6
7import uk.ac.ox.cs.pagoda.tester.PagodaTester;
8import uk.ac.ox.cs.pagoda.tester.Statistics;
9
10public class PagodaLUBM {
11
12 public void test_all(int number) {
13 PagodaTester.main(
14 PagodaTester.onto_dir + "lubm/univ-bench.owl",
15 PagodaTester.onto_dir + "lubm/data/lubm" + number + ".ttl",
16 PagodaTester.onto_dir + "lubm/queries/test_all_pagoda.sparql"
17 );
18
19 AllTests.copy("log4j.log", "output/jair/lubm" + number + ".out");
20 }
21
22 @Test
23 public void test1() { test_all(1); }
24
25 public void test() {
26 int number = 100;
27 test_all(number);
28 }
29
30 public void check(int number) {
31 Statistics stat = new Statistics("output/log4j.log");
32 String diff = stat.diff("results-backup/benchmark/lubm" + number + ".out");
33 AllTests.copy("output/log4j.log", "results-backup/current/lubm" + number + ".out");
34 if (!diff.isEmpty())
35 fail(diff);
36 }
37
38}
diff --git a/test/uk/ac/ox/cs/pagoda/junit/PagodaNPD.java b/test/uk/ac/ox/cs/pagoda/junit/PagodaNPD.java
new file mode 100644
index 0000000..96edbb4
--- /dev/null
+++ b/test/uk/ac/ox/cs/pagoda/junit/PagodaNPD.java
@@ -0,0 +1,42 @@
1package uk.ac.ox.cs.pagoda.junit;
2
3import static org.junit.Assert.fail;
4
5import org.junit.Test;
6
7import uk.ac.ox.cs.pagoda.tester.PagodaTester;
8import uk.ac.ox.cs.pagoda.tester.Statistics;
9
10public class PagodaNPD {
11
12 @Test
13 public void testNPDwithoutDataType() {
14 PagodaTester.main(
15 PagodaTester.onto_dir + "npd/npd-all-minus-datatype.owl",
16 PagodaTester.onto_dir + "npd/data/npd-data-dump-minus-datatype-new.ttl",
17 PagodaTester.onto_dir + "npd/queries/atomic.sparql"
18 );
19
20 Statistics stat = new Statistics("output/log4j.log");
21 String diff = stat.diff("results-backup/benchmark/npd_minus.out");
22 AllTests.copy("output/log4j.log", "results-backup/current/npd_minus.out");
23 if (!diff.isEmpty())
24 fail(diff);
25 }
26
27 @Test
28 public void testNPD() {
29 PagodaTester.main(
30 PagodaTester.onto_dir + "npd/npd-all.owl",
31 PagodaTester.onto_dir + "npd/data/npd-data-dump-processed.ttl",
32 PagodaTester.onto_dir + "npd/queries/atomic.sparql"
33 );
34
35 Statistics stat = new Statistics("output/log4j.log");
36 String diff = stat.diff("results-backup/benchmark/npd.out");
37 AllTests.copy("output/log4j.log", "results-backup/current/npd.out");
38 if (!diff.isEmpty())
39 fail(diff);
40 }
41
42}
diff --git a/test/uk/ac/ox/cs/pagoda/junit/PagodaNPD_bench.java b/test/uk/ac/ox/cs/pagoda/junit/PagodaNPD_bench.java
new file mode 100644
index 0000000..df1a57d
--- /dev/null
+++ b/test/uk/ac/ox/cs/pagoda/junit/PagodaNPD_bench.java
@@ -0,0 +1,27 @@
1package uk.ac.ox.cs.pagoda.junit;
2
3import static org.junit.Assert.fail;
4
5import org.junit.Test;
6
7import uk.ac.ox.cs.pagoda.tester.PagodaTester;
8import uk.ac.ox.cs.pagoda.tester.Statistics;
9
10public class PagodaNPD_bench {
11
12 @Test
13 public void test() {
14 PagodaTester.main(
15 PagodaTester.onto_dir + "npd-benchmark/npd-v2-ql_a.owl",
16 PagodaTester.onto_dir + "npd-benchmark/npd-v2-ql_a.ttl",
17 PagodaTester.onto_dir + "npd-benchmark/queries/all.sparql"
18 );
19
20 Statistics stat = new Statistics("output/log4j.log");
21 String diff = stat.diff("results-backup/benchmark/npd-bench.out");
22 AllTests.copy("output/log4j.log", "results-backup/current/npd-bench.out");
23 if (!diff.isEmpty())
24 fail(diff);
25 }
26
27}
diff --git a/test/uk/ac/ox/cs/pagoda/junit/PagodaRLU.java b/test/uk/ac/ox/cs/pagoda/junit/PagodaRLU.java
new file mode 100644
index 0000000..5d93302
--- /dev/null
+++ b/test/uk/ac/ox/cs/pagoda/junit/PagodaRLU.java
@@ -0,0 +1,18 @@
1package uk.ac.ox.cs.pagoda.junit;
2
3import org.junit.Test;
4import uk.ac.ox.cs.pagoda.tester.PagodaTester;
5
6public class PagodaRLU {
7
8 @Test
9 public void testRL() {
10 int number = 1;
11 PagodaTester.main(
12 PagodaTester.onto_dir + "uobm/univ-bench-dl.owl",
13 PagodaTester.onto_dir + "uobm/data/uobm" + number + ".ttl",
14 PagodaTester.onto_dir + "uobm/queries/standard.sparql"
15 );
16 }
17
18}
diff --git a/test/uk/ac/ox/cs/pagoda/junit/PagodaUOBM.java b/test/uk/ac/ox/cs/pagoda/junit/PagodaUOBM.java
new file mode 100644
index 0000000..5b56c6d
--- /dev/null
+++ b/test/uk/ac/ox/cs/pagoda/junit/PagodaUOBM.java
@@ -0,0 +1,48 @@
1package uk.ac.ox.cs.pagoda.junit;
2
3import org.junit.Test;
4
5import uk.ac.ox.cs.pagoda.tester.PagodaTester;
6import uk.ac.ox.cs.pagoda.tester.Statistics;
7
8public class PagodaUOBM {
9
10 public void test_all(int number ) {
11 PagodaTester.main(
12 PagodaTester.onto_dir + "uobm/univ-bench-dl.owl",
13 PagodaTester.onto_dir + "uobm/data/uobm" + number + ".ttl",
14 PagodaTester.onto_dir + "uobm/queries/standard_all_pagoda.sparql"
15// PagodaTester.onto_dir + "uobm/queries/standard_group3_all_less.sparql;" +
16// PagodaTester.onto_dir + "uobm/queries/G3.sparql;" +
17// PagodaTester.onto_dir + "uobm/queries/last.sparql"
18 );
19
20 AllTests.copy("log4j.log", "output/jair/newuobm/uobm" + number + ".out");
21 }
22
23 public void test_upToSum(int number) {
24 PagodaTester.main(
25 PagodaTester.onto_dir + "uobm/univ-bench-dl.owl",
26 PagodaTester.onto_dir + "uobm/data/uobm" + number + ".ttl",
27 PagodaTester.onto_dir + "uobm/queries/standard_group3_all.sparql"
28 );
29
30// AllTests.copy("log4j.log", "output/jair/uobm" + number + ".out");
31 }
32
33 @Test
34 public void test1() { test_all(1); }
35
36 public void test500() { test_upToSum(500); }
37
38 public static void main(String... args) {
39 new PagodaUOBM().test_all(1);
40 }
41
42 public void check() {
43 Statistics stat = new Statistics("results-backup/current/uobm1.out");
44 String diff = stat.diff("results-backup/benchmark/uobm1.out");
45 System.out.println(diff);
46 }
47
48}
diff --git a/test/uk/ac/ox/cs/pagoda/summary/SummaryTester.java b/test/uk/ac/ox/cs/pagoda/summary/SummaryTester.java
new file mode 100644
index 0000000..18b6090
--- /dev/null
+++ b/test/uk/ac/ox/cs/pagoda/summary/SummaryTester.java
@@ -0,0 +1,139 @@
1package uk.ac.ox.cs.pagoda.summary;
2
3import java.io.File;
4import java.io.FileNotFoundException;
5import java.io.FileOutputStream;
6import java.io.IOException;
7import java.util.Scanner;
8
9import org.semanticweb.HermiT.Reasoner;
10import org.semanticweb.owlapi.model.AxiomType;
11import org.semanticweb.owlapi.model.IRI;
12import org.semanticweb.owlapi.model.OWLClassExpression;
13import org.semanticweb.owlapi.model.OWLDataFactory;
14import org.semanticweb.owlapi.model.OWLOntology;
15import org.semanticweb.owlapi.model.OWLOntologyCreationException;
16import org.semanticweb.owlapi.model.OWLOntologyStorageException;
17
18import uk.ac.ox.cs.pagoda.hermit.DLClauseHelper;
19import uk.ac.ox.cs.pagoda.owl.OWLHelper;
20import uk.ac.ox.cs.pagoda.owl.QueryRoller;
21import uk.ac.ox.cs.pagoda.query.QueryManager;
22import uk.ac.ox.cs.pagoda.query.QueryRecord;
23import uk.ac.ox.cs.pagoda.summary.Summary;
24
25public class SummaryTester {
26
27 static String FILE_BREAK = System.getProperty("file.separator");
28 static String LINE_BREAK = System.getProperty("line.separator");
29
30 public static void main(String[] args) throws Exception {
31// String arg = "ontologies/claros/all-in-one-manually.owl";
32// String arg = "ontologies/claros/Claros.owl ontologies/claros/data";
33 String arg = "../uobmGenerator/univ-bench-dl.owl " +
34 "../uobmGenerator/uobm1 " + //"a " +
35 "ontologies/uobm/queries/uobm_standard_less.sparql";
36
37 testSummarisedUpperBound(arg.split("\\ "));
38 }
39
40 /**
41 * args[0] ontology file location
42 * args[1] data directory
43 * args[2] sparql query file location
44 *
45 * @param args
46 * @throws OWLOntologyCreationException
47 * @throws FileNotFoundException
48 * @throws OWLOntologyStorageException
49 */
50 public static void testSummarisedUpperBound(String[] args) throws OWLOntologyCreationException, FileNotFoundException, OWLOntologyStorageException {
51 OWLOntology onto = OWLHelper.loadOntology(args[0]);
52 try {
53 onto = OWLHelper.getImportedOntology(onto, args[1]);
54 } catch (IOException e) {
55 e.printStackTrace();
56 }
57
58 Summary sum = testSummary(onto);
59 System.out.println("Summarisation Done.");
60
61 System.out.println(args[2]);
62 Scanner scanner = new Scanner(new File(args[2]));
63 OWLOntology summary = sum.getSummary();
64 OWLDataFactory factory = summary.getOWLOntologyManager().getOWLDataFactory();
65 QueryRoller r = new QueryRoller(factory);
66 OWLClassExpression summarisedQueryExp;
67 Reasoner reasoner = new Reasoner(summary);
68 QueryManager queryManager = new QueryManager();
69 int upperBoundCounter, queryID = 0;
70 StringBuilder queryText = new StringBuilder();
71 String[] vars;
72
73 for (String line; ; ) {
74 queryText.setLength(0);
75 while (scanner.hasNextLine() && (line = scanner.nextLine()) != null && !line.startsWith("^[query"));
76 if (!scanner.hasNextLine()) break;
77
78 while (scanner.hasNextLine() && (line = scanner.nextLine()) != null && !line.isEmpty())
79 queryText.append(line).append(LINE_BREAK);
80 if (!scanner.hasNextLine()) break;
81
82 System.out.println("------------ starting computing for Query " + ++queryID + "------------");
83
84 System.out.println(queryText);
85
86 QueryRecord record = queryManager.create(queryText.toString(), queryID);
87 vars = record.getAnswerVariables();
88 if (vars.length > 1) {
89 System.out.println("The query cannot be processed by HermiT ... More than one answer variable");
90 continue;
91 }
92
93 summarisedQueryExp = r.rollUp(DLClauseHelper.getQuery(sum.getSummary(record), null), vars[0]);
94
95 upperBoundCounter = 0;
96 for (String representative: sum.getRepresentatives())
97 if (reasoner.isEntailed(factory.getOWLClassAssertionAxiom(summarisedQueryExp, factory.getOWLNamedIndividual(IRI.create(representative))))) {
98 upperBoundCounter += sum.getGroup(representative).size();
99 }
100
101 System.out.println("There are " + upperBoundCounter + " individual(s) in the upper bound computed by summary.");
102 }
103 scanner.close();
104 }
105
106 public static Summary testSummary(OWLOntology ontology) throws OWLOntologyCreationException, FileNotFoundException {
107 Summary sum = new Summary(ontology);
108
109 System.out.println("original ontology data: ");
110 outputStatistics(ontology);
111
112 OWLOntology summary = sum.getSummary();
113
114 System.out.println("summarised ontology data: ");
115 outputStatistics(summary);
116
117 try {
118 FileOutputStream out = new FileOutputStream("summary.owl");
119 summary.getOWLOntologyManager().saveOntology(summary, out);
120 out.close();
121 } catch (OWLOntologyStorageException e) {
122 e.printStackTrace();
123 } catch (IOException e) {
124 // TODO Auto-generated catch block
125 e.printStackTrace();
126 }
127
128 return sum;
129 }
130
131 private static void outputStatistics(OWLOntology onto) {
132 System.out.println("TBox: " + onto.getTBoxAxioms(true).size() +
133 "\tRBox: " + onto.getRBoxAxioms(true).size() +
134 "\tABox: " + onto.getABoxAxioms(true).size());
135 System.out.println("Class Assertions: " + onto.getAxiomCount(AxiomType.CLASS_ASSERTION, true) +
136 "\tObject Property Assertions: " + onto.getAxiomCount(AxiomType.OBJECT_PROPERTY_ASSERTION, true));
137 }
138
139}
diff --git a/test/uk/ac/ox/cs/pagoda/tester/ORETester.java b/test/uk/ac/ox/cs/pagoda/tester/ORETester.java
new file mode 100644
index 0000000..1092d6f
--- /dev/null
+++ b/test/uk/ac/ox/cs/pagoda/tester/ORETester.java
@@ -0,0 +1,29 @@
1package uk.ac.ox.cs.pagoda.tester;
2
3import org.semanticweb.owlapi.model.OWLOntology;
4
5import uk.ac.ox.cs.pagoda.owl.OWLHelper;
6import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner;
7
8public class ORETester {
9
10 public static void main(String... args) {
11// args = new String[] { "/home/yzhou/krr-nas-share/Yujiao/ontologies/ORE2014/DL/00a1118a-5420-46f0-b4b2-a2585165b28a_ePizza.owl" };
12// args = new String[] { "/home/yzhou/krr-nas-share/Yujiao/ontologies/ORE2014/DL/77de15c6-cc39-4960-a38a-e35e487d52b0_owl%2Fcoma" };
13// args = new String[] { "/home/yzhou/krr-nas-share/Yujiao/ontologies/ORE2014/DL/wine_nodatatype.owl" };
14
15// args = new String[] { "/home/yzhou/krr-nas-share/Yujiao/ontologies/ORE2014/EL/b7700fe1-103b-4b32-a21c-f6604a763ba5_t-cell.owl" };
16 args = new String[] { "/home/yzhou/krr-nas-share/Yujiao/ontologies/ORE2014/EL/baa29363-f93c-4285-827e-0e2380c82efc_cations.n3" };
17
18
19 OWLOntology ontology = OWLHelper.loadOntology(args[0]);
20 QueryReasoner pagoda = QueryReasoner.getInstance(ontology);
21 System.out.println(pagoda);
22 pagoda.loadOntology(ontology);
23 if (pagoda.preprocess())
24 System.out.println("The ontology is consistent!");
25 else
26 System.out.println("The ontology is inconsistent!");
27 }
28
29}
diff --git a/test/uk/ac/ox/cs/pagoda/tester/OWLTester.java b/test/uk/ac/ox/cs/pagoda/tester/OWLTester.java
new file mode 100644
index 0000000..5bc1a9b
--- /dev/null
+++ b/test/uk/ac/ox/cs/pagoda/tester/OWLTester.java
@@ -0,0 +1,29 @@
1package uk.ac.ox.cs.pagoda.tester;
2
3import org.semanticweb.owlapi.model.OWLOntology;
4import org.semanticweb.owlapi.model.OWLOntologyCreationException;
5import org.semanticweb.owlapi.model.OWLOntologyManager;
6
7import uk.ac.ox.cs.pagoda.owl.OWLHelper;
8
9public class OWLTester {
10
11 public static void main(String[] args) throws OWLOntologyCreationException {
12// OWLOntology onto = OWLHelper.loadOntology("dbpedia_imported.owl");
13 OWLOntology onto = OWLHelper.loadOntology("reactome_imported.owl");
14 OWLOntologyManager manager = onto.getOWLOntologyManager();
15// OWLOntology data = manager.loadOntology(IRI.create("file:/media/krr-nas-share/Yujiao/ontologies/bio2rdf/reactome/graph\ sampling/sample_1_new.ttl"));
16// System.out.println("data: " + data.getAxiomCount() + " " + data.getABoxAxioms(true).size());
17 for (OWLOntology t: manager.getOntologies()) {
18 System.out.println(t.getOntologyID());
19 System.out.println(t.getAxiomCount() + " " + onto.getABoxAxioms(true).size());
20 }
21 System.out.println("In closure: " + onto.getImportsClosure().size());
22 for (OWLOntology t: onto.getImportsClosure())
23 System.out.println(t.getOntologyID());
24
25 System.out.println(onto.getAxiomCount() + " " + onto.getABoxAxioms(true).size());
26 }
27
28}
29
diff --git a/test/uk/ac/ox/cs/pagoda/tester/PagodaTester.java b/test/uk/ac/ox/cs/pagoda/tester/PagodaTester.java
new file mode 100644
index 0000000..e040c18
--- /dev/null
+++ b/test/uk/ac/ox/cs/pagoda/tester/PagodaTester.java
@@ -0,0 +1,336 @@
1package uk.ac.ox.cs.pagoda.tester;
2
3import java.io.File;
4import java.io.FileNotFoundException;
5import java.io.IOException;
6import java.util.Scanner;
7
8import org.semanticweb.owlapi.model.OWLOntology;
9
10import uk.ac.ox.cs.pagoda.owl.OWLHelper;
11import uk.ac.ox.cs.pagoda.query.AnswerTuple;
12import uk.ac.ox.cs.pagoda.query.AnswerTuples;
13import uk.ac.ox.cs.pagoda.reasoner.*;
14import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner.Type;
15import uk.ac.ox.cs.pagoda.util.Timer;
16import uk.ac.ox.cs.pagoda.util.Utility;
17
18public class PagodaTester {
19
20// public static final String onto_dir = "/media/RDFData/yzhou/";
21// public static final String onto_dir = "/users/yzhou/ontologies/";
22// public static final String onto_dir = "/home/scratch/yzhou/ontologies/";
23 public static final String onto_dir = "/home/yzhou/krr-nas-share/Yujiao/ontologies/";
24
25 public static final String fly = onto_dir + "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl";
26 public static final String fly_query = onto_dir + "fly/queries/fly.sparql";
27
28 public static final String test_tbox = onto_dir + "smallExampleFromAna/dummy.owl";
29 public static final String test_abox = onto_dir + "smallExampleFromAna/initialABox.ttl";
30 public static final String test_query = onto_dir + "smallExampleFromAna/queries.dlog";
31
32 public static final int lubm_number = 1;
33 public static final String lubm_tbox = onto_dir + "lubm/univ-bench.owl";
34 public static final String lubm_abox = onto_dir + "lubm/data/lubm" + lubm_number + ".ttl";
35 public static final String lubm_abox_copy = onto_dir + "lubm/data/lubm" + lubm_number + " (copy).ttl";
36 public static final String lubm_query = onto_dir + "lubm/queries/test.sparql";
37 public static final String lubm_query6 = onto_dir + "lubm/queries/test_q6.sparql";
38 public static final String lubm_query20 = onto_dir + "lubm/queries/test_q16.sparql";
39
40 public static final int uobm_number = 1;
41 public static final String uobm_tbox = onto_dir + "uobm/univ-bench-dl.owl";
42 public static final String uobm_abox = onto_dir + "uobm/data/uobm" + uobm_number + ".ttl";
43 public static final String uobm_query = onto_dir + "uobm/queries/standard.sparql";
44 public static final String uobm_query_temp = onto_dir + "uobm/queries/temp.sparql";
45 public static final String uobm_query2 = onto_dir + "uobm/queries/standard_q2.sparql";
46 public static final String uobm_query9 = onto_dir + "uobm/queries/standard_q9.sparql";
47 public static final String uobm_query11 = onto_dir + "uobm/queries/standard_q11.sparql";
48 public static final String uobm_query12 = onto_dir + "uobm/queries/standard_q12.sparql";
49 public static final String uobm_query14 = onto_dir + "uobm/queries/standard_q14.sparql";
50 public static final String uobm_query15 = onto_dir + "uobm/queries/standard_q15.sparql";
51 public static final String uobm_query_multi = onto_dir + "uobm/queries/standard_multi.sparql";
52 public static final String uobm_generated_query1 = onto_dir + "uobm/queries/generated_q1.sparql";
53 public static final String uobm_query_group3 = onto_dir + "uobm/queries/standard_group3.sparql";
54
55 public static final String npd_tbox = onto_dir + "npd/npd-all-minus-datatype.owl";
56 // "npd/npd-all.owl";
57 // "npd-all-minus-datatype.owl";
58 public static final String npd_abox = onto_dir + "npd/data/npd-data-dump-minus-datatype-new.ttl";
59 // "npd/data/npd-data-dump-processed.ttl";
60 // "npd-data-dump-minus-datatype-old.ttl";
61 public static final String npd_query = onto_dir + "npd/queries/atomic.sparql";
62
63 public static final String npd_bench_tbox = onto_dir + "npd-benchmark/npd-v2-ql_a.owl"; // npd-all-minus-datatype.owl";
64 public static final String npd_bench_abox = onto_dir + "npd-benchmark/npd-v2-ql_a.ttl"; // npd-data-dump-minus-datatype-old.ttl";
65 public static final String npd_bench_query = onto_dir + "npd-benchmark/queries/all.sparql";
66
67 public static final String dbpedia_tbox = onto_dir + "dbpedia/integratedOntology-all-in-one-minus-datatype.owl";
68 public static final String dbpedia_abox = onto_dir + "dbpedia/data/dbpedia-minus-datatype-new.ttl";
69 public static final String dbpedia_query = onto_dir + "dbpedia/queries/atomic_ground.sparql";
70 public static final String dbpedia_query274 = onto_dir + "dbpedia/atomic_q274.sparql";
71
72 public static final String dbpedia_latest_tbox = onto_dir + "dbpedia/dbpedia_2014.owl";
73 public static final String travel_tbox = onto_dir + "dbpedia/travel.owl";
74 public static final String dbpedia_tbox_simple = onto_dir + "dbpedia/dbpedia_simple.owl";
75
76 public static final String bioModels_tbox = onto_dir + "biomodels/biomodels-21.owl";
77 public static final String bioModels_abox = onto_dir + "biomodels/data_processed_1.ttl";
78 public static final String bioModels_queries = onto_dir + "biomodels/queries/queries.sparql";
79
80 public static final String chembl_tbox = onto_dir + "bio2rdf/chembl/cco-processed-noDPR-noDPD.ttl";
81 public static final String chembl_abox = onto_dir + "bio2rdf/chembl/graph sampling old/sample_100.nt";
82 public static final String chembl_queries = onto_dir + "bio2rdf/chembl/queries/problematic.sparql"; //"bio2rdf/chembl/queries/atomic_one_filtered.sparql"; //
83
84 public static final String reactome_tbox = onto_dir + "bio2rdf/reactome/biopax-level3-processed.owl";
85 public static final String reactome_abox = onto_dir + "bio2rdf/reactome/graph sampling old/sample.ttl"; //data/data.ttl"; //graph sampling old/reactome_sample_10.ttl"; //
86 public static final String reactome_queries = onto_dir +"bio2rdf/reactome/queries/atomic.sparql";
87
88 public static final String uniprot_tbox = onto_dir + "bio2rdf/uniprot/core-processed.owl";
89 public static final String uniprot_abox = onto_dir + "bio2rdf/uniprot/graph sampling/sample_1.nt";
90 public static final String uniprot_queries = onto_dir + "bio2rdf/uniprot/queries/atomic_one.sparql";
91
92 public static final String atlas_tbox = onto_dir + "bio2rdf/atlas/gxaterms.owl";
93 public static final String atlas_abox = onto_dir + "bio2rdf/atlas/graph sampling/sample_1.nt";
94 public static final String atlas_queries = onto_dir + "bio2rdf/atlas/queries/atomic_one.sparql";
95
96 public static boolean ShellMode = false;
97
98 public static void main(String... args) {
99 if (args.length == 0) {
100// args = new String[] {test_tbox, test_abox, test_query};
101// args = new String[] {lubm_tbox, lubm_abox, lubm_query.replace(".sparql", "_all_pagoda.sparql")};
102// args = new String[] {uobm_tbox, uobm_abox, uobm_query.replace(".sparql", "_all_pagoda.sparql")};
103// args = new String[] {fly, "null", fly_query.replace(".sparql", "_pellet.sparql") };
104// args = new String[] {dbpedia_tbox, dbpedia_abox, dbpedia_query};
105// args = new String[] {travel_tbox, null, dbpedia_query274};
106// args = new String[] {fly, null, fly_query};
107// args = new String[] {npd_tbox, npd_abox, npd_query};
108// args = new String[] {npd_bench_tbox, npd_bench_abox, npd_bench_query};
109// args = new String[] {"../SemFacet/WebContent/WEB-INF/data/dbpedia.owl", "../SemFacet/WebContent/WEB-INF/data/dbpediaA.nt", null};
110// args = new String[] {"../SemFacet/WebContent/WEB-INF/data/isg.owl", "../SemFacet/WebContent/WEB-INF/data/isg.nt", null};
111 args = new String[] {"..\\core\\WebContent\\WEB-INF\\data\\fly.owl", "..\\core\\WebContent\\WEB-INF\\data\\fly-data.nt", null};
112// args = new String[] {bioModels_tbox, bioModels_abox, bioModels_queries};
113// args = new String[] {chembl_tbox, chembl_abox, chembl_queries};
114// args = new String[] {reactome_tbox, reactome_abox, reactome_queries};
115// args = new String[] {reactome_tbox, "/users/yzhou/temp/reactome_debug.ttl", onto_dir +"bio2rdf/reactome/queries/atomic_one_q65.sparql"};
116// args = new String[] {uniprot_tbox.replace(".owl", "-noDis.owl"), "/users/yzhou/temp/uniprot_debug/sample_1_string.nt", uniprot_queries};
117// args = new String[] {uniprot_tbox.replace(".owl", "-noDis.owl"), uniprot_abox, uniprot_queries};
118// args = new String[] {atlas_tbox, atlas_abox, atlas_queries};
119// args = new String[] {onto_dir + "test/unsatisfiable.owl", null, onto_dir + "test/unsatisfiable_queries.sparql"};
120// args = new String[] {onto_dir + "test/jair-example.owl", null, onto_dir + "test/jair-example_query.sparql"};
121// args[2] = args[2].replace(".sparql", "_all_pagoda.sparql");
122// args[2] = args[2].replace(".sparql", "_pellet.sparql");
123 }
124
125 int ontoIndex = 0, dataIndex = 1, queryIndex = 2;
126
127 if (args.length > dataIndex && args[dataIndex] != null && args[dataIndex].endsWith(".sparql")) {
128 String[] inputArgs = args;
129 args = new String[inputArgs.length + 1];
130 for (int i = 0; i < dataIndex; ++i)
131 args[i] = inputArgs[i];
132 args[dataIndex] = null;
133 args[queryIndex] = inputArgs[dataIndex];
134 for (int i = dataIndex + 1; i < inputArgs.length; ++i)
135 args[i + 1] = inputArgs[i];
136 }
137
138 StringBuilder info = new StringBuilder();
139 info.append("System started with \n");
140 for (int i = 0; i < args.length; ++i)
141 info.append("Arg " + (i + 1) + ": " + args[i] + "\n");
142 Utility.logInfo(info);
143
144// Utility.redirectCurrentOut("temp.out");
145
146 OWLOntology ontology = OWLHelper.loadOntology(args[ontoIndex]);
147
148 QueryReasoner pagoda = QueryReasoner.getInstance(Type.Full, ontology, true, true);
149// QueryReasoner pagoda = QueryReasoner.getInstance(Type.ELHOU, ontology, true, true);
150
151// QueryReasoner pagoda = QueryReasoner.getInstanceForSemFacet(ontology);
152// QueryReasoner pagoda = QueryReasoner.getHermiTReasoner(false);
153
154// PagodaTester tester = new PagodaTester(pagoda);
155 String ansFile = args.length > 3 ? args[3] : null;
156 try {
157 Timer t = new Timer();
158 pagoda.loadOntology(ontology);
159 pagoda.importData(args[dataIndex]);
160 if (!pagoda.preprocess())
161 return;
162 Utility.logInfo("Preprocessing Done in " + t.duration() + " seconds.");
163// tester.printPredicatesWithGap();
164// tester.testSemFacetQueries();
165// tester.testSomeFlyQueries();
166// tester.testISGQueries();
167// tester.testReactomeQueries();
168 if (args[queryIndex] != null)
169 for (String queryFile: args[queryIndex].split(";"))
170 pagoda.evaluate(pagoda.getQueryManager().collectQueryRecords(queryFile), ansFile);
171
172 if (ShellMode)
173 try {
174 evaluateConsoleQuery(pagoda);
175 } catch (IOException e) {
176 e.printStackTrace();
177 }
178 } finally {
179 pagoda.dispose();
180 }
181
182 Utility.closeCurrentOut();
183
184 if (ShellMode) System.exit(0);
185 }
186
187// private void printPredicatesWithGap() {
188// for (String p: ((MyQueryReasoner) pagoda).getPredicatesWithGap()) {
189// System.out.println(p);
190// }
191// }
192
193 private static void evaluateConsoleQuery(QueryReasoner pagoda) throws IOException {
194 int ending = (int) '$', symbol;
195 while (true) {
196 Utility.logInfo("Input your query ending with $");
197 StringBuilder queryBuilder = new StringBuilder();
198 while ((symbol = System.in.read()) != ending) {
199 queryBuilder.append((char) symbol);
200 }
201 System.in.read();
202 if (queryBuilder.length() == 0) return ;
203 pagoda.evaluate_shell(queryBuilder.toString());
204 }
205 }
206
207 void testReactomeQueries() {
208 evaluate("select ?x where { ?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.biopax.org/release/biopax-level3.owl#DnaReference> . }");
209 evaluate("select ?y ?z where { <http://identifiers.org/ensembl/ENSG00000157557> ?y ?z . }");
210 evaluate("select ?y where { <http://identifiers.org/ensembl/ENSG00000157557> <http://www.biopax.org/release/biopax-level3.owl#name> ?y . }", true);
211
212 }
213
214 void testSemFacetQueries() {
215// try {
216// BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("query.line")));
217// for (String line; (line = reader.readLine()) != null && !line.isEmpty(); )
218// evaluate(line, true);
219// reader.close();
220// } catch (FileNotFoundException e) {
221// e.printStackTrace();
222// } catch (IOException e) {
223// e.printStackTrace();
224// }
225 evaluate("select ?x ?z where { ?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?z }", true);
226 evaluate("select distinct ?y where { ?x ?y ?z }", true);
227 evaluate("select distinct ?z where { ?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?z }", true);
228 evaluate("select ?y ?z where { <http://www.reactome.org/biopax/46/49633#Protein3885> ?y ?z .}", true);
229 }
230
231 void testISGQueries() {
232 evaluate("select ?z where {<http://cs.ox.ac.uk/Evgeny_Kharlamov> <http://cs.ox.ac.uk/lat> ?z .}", false);
233 evaluate("select ?x where {?x <http://cs.ox.ac.uk/type> <http://cs.ox.ac.uk/person> .}", false);
234 }
235
236 void testSomeTravelQueries() {
237 evaluate("select ?y ?z where {<http://www.owl-ontologies.com/travel.owl#BlueMountains> ?y ?z. }", true);
238 evaluate("select ?x where {?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.owl-ontologies.com/travel.owl#RetireeDestination>. }");
239 evaluate("select ?x where {?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.owl-ontologies.com/travel.owl#BackpackersDestination>. }");
240 }
241
242 void testSomeFlyQueries() {
243 evaluate("select ?x where { ?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://purl.obolibrary.org/obo/FBbt_00005106> . }", false);
244
245 evaluate("select DISTINCT ?z where { ?x <http://purl.obolibrary.org/obo/FBbt#develops_from> ?any . ?any <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?z . ?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://purl.obolibrary.org/obo/FBbt_00067123> . } ", true);
246
247 evaluate("Select ?x where { ?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> "
248 + "<http://purl.obolibrary.org/obo/FBbt_00067123>. ?x "
249 + "<http://purl.obolibrary.org/obo/RO_0002131> ?any . ?any "
250 + "<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> "
251 + "<http://purl.obolibrary.org/obo/FBbt_00005140> . }", true);
252
253 evaluate("Select ?x where {?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> "
254 + "<http://purl.obolibrary.org/obo/FBbt_00067363> . ?x "
255 + "<http://purl.obolibrary.org/obo/RO_0002131> ?any . ?any "
256 + "<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> "
257 + "<http://purl.obolibrary.org/obo/FBbt_00005140> . }", true);
258
259// evaluate("Select ?x where { "
260// + "?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://purl.obolibrary.org/obo/FBbt_00003660>. "
261// + "?x <http://purl.obolibrary.org/obo/FBbt#develops_from> ?any . "
262// + "?any <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://purl.obolibrary.org/obo/FBbt_00001446> . }", true);
263
264 evaluate("select DISTINCT ?z where { ?x <http://purl.obolibrary.org/obo/RO_0002110> ?any . "
265 + "?any <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?z . "
266 + "?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://purl.obolibrary.org/obo/FBbt_00007016> . } ", true);
267
268 evaluate("Select * where {"
269 + "<http://www.virtualflybrain.org/ontologies/individuals/VFB_00100607> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://purl.obolibrary.org/obo/FBbt_00007364>. "
270 + "<http://www.virtualflybrain.org/ontologies/individuals/VFB_00100607> <http://www.w3.org/2002/07/owl#sameAs> ?z }", true);
271
272 evaluate("SELECT DISTINCT ?x ?z WHERE {?x <http://www.w3.org/2002/07/owl#sameAs> ?z}", true);
273 evaluate("SELECT DISTINCT ?x ?z WHERE {?x <http://purl.obolibrary.org/obo/BFO_0000051> ?z}", true);
274
275 evaluate("select DISTINCT ?y where { ?x ?y ?z . "
276 + "?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://purl.obolibrary.org/obo/FBbt_00007364> }", true);
277
278 evaluateQueriesFromFile("/users/yzhou/Downloads/logs(1).log");
279 evaluateQueriesFromFile("/users/yzhou/Downloads/logs.log");
280
281 evaluate("SELECT DISTINCT ?x ?z WHERE {?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?z}", true);
282 evaluate("SELECT DISTINCT ?x ?z WHERE {?x <http://xmlns.com/foaf/0.1/depicts> ?z}", true);
283
284 evaluate("select ?x ?z where { ?x <http://www.w3.org/2002/07/owl#sameAs> ?z } ", true);
285 evaluate("select ?x ?z where { ?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?z } ", true);
286 }
287
288 public void evaluateQueriesFromFile(String fileName) {
289 Scanner scanner = null;
290 try {
291 scanner = new Scanner(new File(fileName));
292 String line;
293 while (scanner.hasNextLine()) {
294 line = scanner.nextLine();
295 if (line.startsWith("select"))
296 evaluate(line, true);
297 }
298 } catch (FileNotFoundException e) {
299 e.printStackTrace();
300 } finally {
301 if (scanner != null)
302 scanner.close();
303 }
304 }
305
306 QueryReasoner pagoda;
307
308 public PagodaTester(QueryReasoner reasoner) {
309 pagoda = reasoner;
310 }
311
312 Timer timer = new Timer();
313
314 private void evaluate(String query) {
315 evaluate(query, false);
316 }
317
318 private void evaluate(String query, boolean tag) {
319 timer.reset();
320 AnswerTuples tuples = pagoda.evaluate(query, tag);
321 int arity = tuples.getArity();
322 int count = 0;
323 for (AnswerTuple tuple; tuples.isValid(); tuples.moveNext()) {
324 tuple = tuples.getTuple();
325 for (int i = 0; i < arity; ++i)
326 tuple.getGroundTerm(i).toString();
327// System.out.print(tuple.getGroundTerm(i).toString() + "\t");
328// System.out.println();
329 ++count;
330 }
331 tuples.dispose();
332 Utility.logInfo("The number of answers for this SemFacet query: " + count);
333 Utility.logInfo("Total time for this SemFacet query: " + timer.duration());
334 }
335
336}
diff --git a/test/uk/ac/ox/cs/pagoda/tester/Statistics.java b/test/uk/ac/ox/cs/pagoda/tester/Statistics.java
new file mode 100644
index 0000000..71f1726
--- /dev/null
+++ b/test/uk/ac/ox/cs/pagoda/tester/Statistics.java
@@ -0,0 +1,59 @@
1package uk.ac.ox.cs.pagoda.tester;
2
3import java.io.File;
4import java.io.FileNotFoundException;
5import java.util.Iterator;
6import java.util.LinkedList;
7import java.util.Scanner;
8
9public class Statistics {
10
11 double satCheckTime;
12 double preprocessTime;
13 LinkedList<Integer> number = new LinkedList<Integer>();
14 LinkedList<Double> time = new LinkedList<Double>();
15
16 public Statistics(String file) {
17 Scanner scanner = null;
18 try {
19 scanner = new Scanner(new File(file));
20 for (String line; scanner.hasNextLine(); ) {
21 line = scanner.nextLine();
22 if (line.contains("time for satisfiability checking"))
23 satCheckTime = Double.parseDouble(line.substring(line.indexOf(": ") + 2));
24 else if (line.contains("Preprocessing Done in"))
25 preprocessTime = Double.parseDouble(line.substring(line.indexOf("in ") + 3, line.indexOf(" second")));
26 else if (line.contains("The number of answer tuples:"))
27 number.add(Integer.parseInt(line.substring(line.indexOf(": ") + 2)));
28 else if (line.contains("Total time to answer this query:"))
29 time.add(Double.parseDouble(line.substring(line.indexOf(": ") + 2)));
30 }
31 } catch (FileNotFoundException e) {
32 e.printStackTrace();
33 } finally {
34 if (scanner != null)
35 scanner.close();
36 }
37 }
38
39 public String diff(String other) {
40 return diff(new Statistics(other));
41 }
42
43 public String diff(Statistics other) {
44 if (other.number.size() != number.size())
45 return "The number of query is different! " + this.number.size() + " v.s. " + other.number.size();
46 int i = 0;
47 Iterator<Integer> iter1 = number.iterator(), iter2 = other.number.iterator();
48 StringBuilder diff = new StringBuilder();
49 int a, b;
50 while (iter1.hasNext()) {
51 ++i;
52 if ((a = iter1.next()) != (b = iter2.next())) {
53 diff.append("Query ").append(i).append(": ").append(a).append(", reference ").append(b).append("\n");
54 }
55 }
56 return diff.toString();
57 }
58
59}