diff options
| author | Federico Igne <federico.igne@cs.ox.ac.uk> | 2022-05-10 18:17:06 +0100 |
|---|---|---|
| committer | Federico Igne <federico.igne@cs.ox.ac.uk> | 2022-05-11 12:34:47 +0100 |
| commit | 17bd9beaf7f358a44e5bf36a5855fe6727d506dc (patch) | |
| tree | 47e9310a0cff869d9ec017dcb2c81876407782c8 /src/test/java/uk/ac/ox/cs/jrdfox | |
| parent | 8651164cd632a5db310b457ce32d4fbc97bdc41c (diff) | |
| download | ACQuA-17bd9beaf7f358a44e5bf36a5855fe6727d506dc.tar.gz ACQuA-17bd9beaf7f358a44e5bf36a5855fe6727d506dc.zip | |
[pagoda] Move project to Scala
This commit includes a few changes:
- The repository still uses Maven to manage dependency but it is now a
Scala project.
- The code has been ported from OWLAPI 3.4.10 to 5.1.20
- A proof of concept program using both RSAComb and PAGOdA has been
added.
Diffstat (limited to 'src/test/java/uk/ac/ox/cs/jrdfox')
| -rw-r--r-- | src/test/java/uk/ac/ox/cs/jrdfox/Tester.java | 195 |
1 files changed, 195 insertions, 0 deletions
diff --git a/src/test/java/uk/ac/ox/cs/jrdfox/Tester.java b/src/test/java/uk/ac/ox/cs/jrdfox/Tester.java new file mode 100644 index 0000000..94f5401 --- /dev/null +++ b/src/test/java/uk/ac/ox/cs/jrdfox/Tester.java | |||
| @@ -0,0 +1,195 @@ | |||
| 1 | package uk.ac.ox.cs.jrdfox; | ||
| 2 | |||
| 3 | import java.io.File; | ||
| 4 | |||
| 5 | import org.semanticweb.owlapi.model.OWLOntology; | ||
| 6 | |||
| 7 | import uk.ac.ox.cs.JRDFox.JRDFStoreException; | ||
| 8 | import uk.ac.ox.cs.JRDFox.Prefixes; | ||
| 9 | import uk.ac.ox.cs.JRDFox.store.DataStore; | ||
| 10 | import uk.ac.ox.cs.JRDFox.store.DataStore.UpdateType; | ||
| 11 | import uk.ac.ox.cs.JRDFox.store.Parameters; | ||
| 12 | import uk.ac.ox.cs.JRDFox.store.TripleStatus; | ||
| 13 | import uk.ac.ox.cs.JRDFox.store.TupleIterator; | ||
| 14 | import uk.ac.ox.cs.JRDFox.store.DataStore.StoreType; | ||
| 15 | import uk.ac.ox.cs.pagoda.owl.OWLHelper; | ||
| 16 | import uk.ac.ox.cs.pagoda.reasoner.light.RDFoxQueryEngine; | ||
| 17 | import uk.ac.ox.cs.pagoda.util.Namespace; | ||
| 18 | import uk.ac.ox.cs.pagoda.util.Timer; | ||
| 19 | |||
| 20 | public class Tester { | ||
| 21 | |||
| 22 | public static void main(String[] args) throws JRDFStoreException { | ||
| 23 | Tester tester = new Tester(); | ||
| 24 | tester.testCrash(); | ||
| 25 | } | ||
| 26 | |||
| 27 | private void evaluate_againstIDs(String queryText) throws JRDFStoreException { | ||
| 28 | int number = 0; | ||
| 29 | Timer t = new Timer(); | ||
| 30 | TupleIterator iter = null; | ||
| 31 | try { | ||
| 32 | iter = store.compileQuery(queryText, prefixes, parameters, TripleStatus.TUPLE_STATUS_IDB.union(TripleStatus.TUPLE_STATUS_EDB), TripleStatus.TUPLE_STATUS_IDB); | ||
| 33 | for (long multi = iter.open(); multi != 0; multi = iter.getNext()) | ||
| 34 | ++number; | ||
| 35 | } finally { | ||
| 36 | if (iter != null) iter.dispose(); | ||
| 37 | } | ||
| 38 | System.out.println(number); | ||
| 39 | System.out.println(t.duration()); | ||
| 40 | |||
| 41 | } | ||
| 42 | |||
| 43 | DataStore store; | ||
| 44 | Prefixes prefixes = new Prefixes(); | ||
| 45 | Parameters parameters; | ||
| 46 | |||
| 47 | public Tester() { | ||
| 48 | try { | ||
| 49 | store = new DataStore(StoreType.NarrowParallelHead); | ||
| 50 | store.setNumberOfThreads(RDFoxQueryEngine.matNoOfThreads); | ||
| 51 | store.initialize(); | ||
| 52 | System.out.println("data store created."); | ||
| 53 | } catch (JRDFStoreException e) { | ||
| 54 | e.printStackTrace(); | ||
| 55 | } | ||
| 56 | parameters = new Parameters(); | ||
| 57 | parameters.m_allAnswersInRoot = true; | ||
| 58 | parameters.m_useBushy = true; | ||
| 59 | } | ||
| 60 | |||
| 61 | public Tester(String path) { | ||
| 62 | try { | ||
| 63 | store = new DataStore(new File(path)); | ||
| 64 | } catch (JRDFStoreException e) { | ||
| 65 | e.printStackTrace(); | ||
| 66 | } | ||
| 67 | parameters = new Parameters(); | ||
| 68 | // parameters.m_allAnswersInRoot = true; | ||
| 69 | // parameters.m_useBushy = true; | ||
| 70 | } | ||
| 71 | |||
| 72 | public void applyReasoning(boolean incremental) { | ||
| 73 | Timer t = new Timer(); | ||
| 74 | try { | ||
| 75 | store.applyReasoning(incremental); | ||
| 76 | } catch (JRDFStoreException e) { | ||
| 77 | e.printStackTrace(); | ||
| 78 | } | ||
| 79 | System.out.println("reasoning done: " + t.duration()); | ||
| 80 | } | ||
| 81 | |||
| 82 | public void dispose() { | ||
| 83 | store.dispose(); | ||
| 84 | } | ||
| 85 | |||
| 86 | public void testCrash() throws JRDFStoreException { | ||
| 87 | // DataStore lowerStore = new DataStore(StoreType.NarrowParallelHead); | ||
| 88 | // lowerStore.setNumberOfThreads(RDFoxQueryEngine.matNoOfThreads); | ||
| 89 | // lowerStore.initialize(); | ||
| 90 | // System.out.println("lower data store created."); | ||
| 91 | OWLOntology ontology = OWLHelper.loadOntology("data/fly/fly_anatomy_XP_with_GJ_FC_individuals.owl"); | ||
| 92 | System.out.println("ontology loaded ... " + ontology.getAxiomCount()); | ||
| 93 | |||
| 94 | store.importTurtleFile(new File("testcase/fly.ttl")); | ||
| 95 | System.out.println("data loaded. " + store.getTriplesCount()); | ||
| 96 | |||
| 97 | store.importRules(new File[] {new File("testcase/lower.dlog")}); | ||
| 98 | System.out.println("rules loaded. " + store.getTriplesCount()); | ||
| 99 | |||
| 100 | store.applyReasoning(); | ||
| 101 | System.out.println("materialised. " + store.getTriplesCount()); | ||
| 102 | |||
| 103 | store.clearRulesAndMakeFactsExplicit(); | ||
| 104 | |||
| 105 | store.importRules(new File[] {new File("testcase/multi.dlog")}); | ||
| 106 | System.out.println("rules loaded. " + store.getTriplesCount()); | ||
| 107 | |||
| 108 | store.applyReasoning(); | ||
| 109 | System.out.println("materialised. " + store.getTriplesCount()); | ||
| 110 | |||
| 111 | store.makeFactsExplicit(); | ||
| 112 | |||
| 113 | store.importTurtleFiles(new File[] {new File("testcase/first.ttl")}, UpdateType.ScheduleForAddition); | ||
| 114 | System.out.println("first data loaded. " + store.getTriplesCount()); | ||
| 115 | |||
| 116 | store.applyReasoning(true); | ||
| 117 | System.out.println("incremental reasoning done. " + store.getTriplesCount()); | ||
| 118 | |||
| 119 | store.clearRulesAndMakeFactsExplicit(); | ||
| 120 | |||
| 121 | store.importTurtleFiles(new File[] {new File("testcase/second.ttl")}, UpdateType.ScheduleForAddition); | ||
| 122 | store.importRules(new File[] {new File("testcase/tracking.dlog")}, UpdateType.ScheduleForAddition); | ||
| 123 | store.applyReasoning(true); | ||
| 124 | System.out.println("incremental reasoning done. " + store.getTriplesCount()); | ||
| 125 | |||
| 126 | evaluate_againstIDs("select distinct ?z where { ?x <" + Namespace.RDF_TYPE + "> ?z . }"); | ||
| 127 | System.out.println("done."); | ||
| 128 | // tester.applyReasoning(true); | ||
| 129 | // tester.evaluate_againstIDs("select distinct ?z where { ?x <" + Namespace.RDF_TYPE + "> ?z . }"); | ||
| 130 | // System.out.println("done."); | ||
| 131 | |||
| 132 | store.dispose(); | ||
| 133 | // lowerStore.dispose(); | ||
| 134 | } | ||
| 135 | |||
| 136 | public void test() throws JRDFStoreException { | ||
| 137 | evaluate("PREFIX benchmark: <http://semantics.crl.ibm.com/univ-bench-dl.owl#> " | ||
| 138 | + "SELECT distinct ?x WHERE { " | ||
| 139 | + "?x a benchmark:Person . " | ||
| 140 | + "?x benchmark:like ?y . " | ||
| 141 | + "?z a benchmark:Chair . " | ||
| 142 | + "?z benchmark:isHeadOf <http://www.Department0.University0.edu> . " | ||
| 143 | + "?z benchmark:like ?y . " | ||
| 144 | + "?x a <http://www.cs.ox.ac.uk/PAGOdA/auxiliary#Original> . " | ||
| 145 | + "?z a <http://www.cs.ox.ac.uk/PAGOdA/auxiliary#Original> . " | ||
| 146 | + "?y a <http://www.cs.ox.ac.uk/PAGOdA/auxiliary#Original> }"); | ||
| 147 | |||
| 148 | evaluate("PREFIX benchmark: <http://semantics.crl.ibm.com/univ-bench-dl.owl#> " | ||
| 149 | + "SELECT distinct ?x WHERE { " | ||
| 150 | + "?x a benchmark:Person . " | ||
| 151 | + "?x benchmark:like ?y . " | ||
| 152 | + "?z a benchmark:Chair . " | ||
| 153 | + "?z benchmark:isHeadOf <http://www.Department0.University0.edu> . " | ||
| 154 | + "?z benchmark:like ?y . " | ||
| 155 | + "?z a <http://www.cs.ox.ac.uk/PAGOdA/auxiliary#Original> . " | ||
| 156 | + "?y a <http://www.cs.ox.ac.uk/PAGOdA/auxiliary#Original> ." | ||
| 157 | + "?x a <http://www.cs.ox.ac.uk/PAGOdA/auxiliary#Original> }"); | ||
| 158 | |||
| 159 | evaluate("PREFIX benchmark: <http://semantics.crl.ibm.com/univ-bench-dl.owl#> " | ||
| 160 | + "SELECT distinct ?x WHERE { " | ||
| 161 | + "?x a benchmark:Person . " | ||
| 162 | + "?x benchmark:like ?y . " | ||
| 163 | + "?z a benchmark:Chair . " | ||
| 164 | + "?z benchmark:isHeadOf <http://www.Department0.University0.edu> . " | ||
| 165 | + "?z benchmark:like ?y . " | ||
| 166 | + "?y a <http://www.cs.ox.ac.uk/PAGOdA/auxiliary#Original> . " | ||
| 167 | + "?x a <http://www.cs.ox.ac.uk/PAGOdA/auxiliary#Original> . " | ||
| 168 | + "?z a <http://www.cs.ox.ac.uk/PAGOdA/auxiliary#Original> }"); | ||
| 169 | |||
| 170 | evaluate("PREFIX benchmark: <http://semantics.crl.ibm.com/univ-bench-dl.owl#> " | ||
| 171 | + "SELECT distinct ?x WHERE { " | ||
| 172 | + "?x a benchmark:Person . " | ||
| 173 | + "?x benchmark:like ?y . " | ||
| 174 | + "?z a benchmark:Chair . " | ||
| 175 | + "?z benchmark:isHeadOf <http://www.Department0.University0.edu> . " | ||
| 176 | + "?z benchmark:like ?y . " | ||
| 177 | + "?y a <http://www.cs.ox.ac.uk/PAGOdA/auxiliary#Original> }"); | ||
| 178 | } | ||
| 179 | |||
| 180 | public void evaluate(String query) throws JRDFStoreException { | ||
| 181 | int number = 0; | ||
| 182 | Timer t = new Timer(); | ||
| 183 | TupleIterator iter = null; | ||
| 184 | try { | ||
| 185 | iter = store.compileQuery(query, prefixes, parameters); | ||
| 186 | for (long multi = iter.open(); multi != 0; multi = iter.getNext()) | ||
| 187 | ++number; | ||
| 188 | } finally { | ||
| 189 | if (iter != null) iter.dispose(); | ||
| 190 | } | ||
| 191 | System.out.println(number); | ||
| 192 | System.out.println(t.duration()); | ||
| 193 | } | ||
| 194 | |||
| 195 | } | ||
