aboutsummaryrefslogtreecommitdiff
path: root/test/uk/ac/ox/cs/data/AtomicQueryGenerator.java
diff options
context:
space:
mode:
Diffstat (limited to 'test/uk/ac/ox/cs/data/AtomicQueryGenerator.java')
-rw-r--r--test/uk/ac/ox/cs/data/AtomicQueryGenerator.java86
1 files changed, 0 insertions, 86 deletions
diff --git a/test/uk/ac/ox/cs/data/AtomicQueryGenerator.java b/test/uk/ac/ox/cs/data/AtomicQueryGenerator.java
deleted file mode 100644
index d271e87..0000000
--- a/test/uk/ac/ox/cs/data/AtomicQueryGenerator.java
+++ /dev/null
@@ -1,86 +0,0 @@
1package uk.ac.ox.cs.data;
2
3import org.semanticweb.owlapi.model.OWLClass;
4import org.semanticweb.owlapi.model.OWLDataFactory;
5import org.semanticweb.owlapi.model.OWLObjectProperty;
6import org.semanticweb.owlapi.model.OWLOntology;
7import org.semanticweb.owlapi.model.OWLOntologyManager;
8
9import uk.ac.ox.cs.pagoda.owl.OWLHelper;
10import uk.ac.ox.cs.pagoda.tester.PagodaTester;
11import uk.ac.ox.cs.pagoda.util.Utility;
12
13public class AtomicQueryGenerator {
14
15 public static final String template = //"^[query@ID]" + Utility.LINE_SEPARATOR +
16 "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>" + Utility.LINE_SEPARATOR +
17 "SELECT ?X" + Utility.LINE_SEPARATOR +
18 "WHERE {" + Utility.LINE_SEPARATOR +
19 "?X rdf:type <@CLASS>" + Utility.LINE_SEPARATOR +
20 "}";
21
22 public static String outputFile = "output/atomic_fly.sparql";
23
24 public static void main(String[] args) throws Exception {
25 if (args.length == 0) {
26// args = new String[] { "/home/yzhou/backup/20141212/univ-bench-dl-queries.owl"};
27 args = new String[] { PagodaTester.onto_dir + "fly/fly-all-in-one_rolledUp.owl"};
28// args = new String[] { PagodaTester.onto_dir + "dbpedia/integratedOntology-all-in-one-minus-datatype.owl" };
29// args = new String[] { PagodaTester.onto_dir + "npd/npd-all-minus-datatype.owl" };
30// args = new String[] { PagodaTester.onto_dir + "bio2rdf/chembl/cco-noDPR.ttl" };
31// args = new String[] { PagodaTester.onto_dir + "bio2rdf/reactome/biopax-level3-processed.owl" };
32// args = new String[] { PagodaTester.onto_dir + "bio2rdf/uniprot/core-processed-noDis.owl" };
33 }
34
35// OWLOntology ontology = OWLHelper.getMergedOntology(args[0], null);
36// OWLHelper.correctDataTypeRangeAxioms(ontology);
37 OWLOntology ontology = OWLHelper.loadOntology(args[0]);
38
39 OWLOntologyManager manager = ontology.getOWLOntologyManager();
40 OWLDataFactory factory = manager.getOWLDataFactory();
41// manager.saveOntology(ontology, new FileOutputStream(args[0].replace(".owl", "_owlapi.owl")));
42
43 if (outputFile != null)
44 Utility.redirectCurrentOut(outputFile);
45
46 int queryID = 0;
47 for (OWLClass cls: ontology.getClassesInSignature(true)) {
48 if (cls.equals(factory.getOWLThing()) || cls.equals(factory.getOWLNothing()))
49 continue;
50 if (!cls.toStringID().contains("Query")) continue;
51 System.out.println("^[Query" + ++queryID + "]");
52 System.out.println(template.replace("@CLASS", cls.toStringID()));
53 System.out.println();
54 }
55
56 for (OWLOntology onto: ontology.getImportsClosure())
57 for (OWLObjectProperty prop: onto.getObjectPropertiesInSignature()) {
58// if (!prop.toStringID().contains("Query")) continue;
59 System.out.println("^[Query" + ++queryID + "]");
60 System.out.println("SELECT ?X ?Y");
61 System.out.println("WHERE {");
62 System.out.println("?X <" + prop.toStringID() + "> ?Y .");
63 System.out.println("}");
64 System.out.println();
65 }
66
67 String[] answerVars = new String[] {"?X", "?Y"};
68
69 for (OWLOntology onto: ontology.getImportsClosure())
70 for (OWLObjectProperty prop: onto.getObjectPropertiesInSignature()) {
71// if (!prop.toStringID().contains("Query")) continue;
72 for (int i = 0; i < answerVars.length; ++i) {
73 System.out.println("^[Query" + ++queryID + "]");
74 System.out.println("SELECT " + answerVars[i]);
75 System.out.println("WHERE {");
76 System.out.println("?X <" + prop.toStringID() + "> ?Y .");
77 System.out.println("}");
78 System.out.println();
79 }
80 }
81
82 if (outputFile != null)
83 Utility.closeCurrentOut();
84 }
85
86}