diff options
Diffstat (limited to 'test/uk/ac/ox/cs/pagoda/tester/PagodaTester.java')
| -rw-r--r-- | test/uk/ac/ox/cs/pagoda/tester/PagodaTester.java | 336 |
1 files changed, 336 insertions, 0 deletions
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 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.tester; | ||
| 2 | |||
| 3 | import java.io.File; | ||
| 4 | import java.io.FileNotFoundException; | ||
| 5 | import java.io.IOException; | ||
| 6 | import java.util.Scanner; | ||
| 7 | |||
| 8 | import org.semanticweb.owlapi.model.OWLOntology; | ||
| 9 | |||
| 10 | import uk.ac.ox.cs.pagoda.owl.OWLHelper; | ||
| 11 | import uk.ac.ox.cs.pagoda.query.AnswerTuple; | ||
| 12 | import uk.ac.ox.cs.pagoda.query.AnswerTuples; | ||
| 13 | import uk.ac.ox.cs.pagoda.reasoner.*; | ||
| 14 | import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner.Type; | ||
| 15 | import uk.ac.ox.cs.pagoda.util.Timer; | ||
| 16 | import uk.ac.ox.cs.pagoda.util.Utility; | ||
| 17 | |||
| 18 | public 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 | } | ||
