aboutsummaryrefslogtreecommitdiff
path: root/test/uk/ac/ox/cs/pagoda
diff options
context:
space:
mode:
authorRncLsn <rnc.lsn@gmail.com>2015-05-28 17:11:35 +0100
committerRncLsn <rnc.lsn@gmail.com>2015-05-28 17:11:35 +0100
commitde3749532d060f26c966a81c03f9a5d846c33d06 (patch)
tree6cc5ba2837dc3c167b100f5e8be4e8c16da7be98 /test/uk/ac/ox/cs/pagoda
parent4298cdef8e551325cd16b4e24ae6699c44b60751 (diff)
downloadACQuA-de3749532d060f26c966a81c03f9a5d846c33d06.tar.gz
ACQuA-de3749532d060f26c966a81c03f9a5d846c33d06.zip
Merged updates from upstream.
Diffstat (limited to 'test/uk/ac/ox/cs/pagoda')
-rw-r--r--test/uk/ac/ox/cs/pagoda/junit/ClauseTester.java (renamed from test/uk/ac/ox/cs/pagoda/global_tests/ClauseTester.java)41
-rw-r--r--test/uk/ac/ox/cs/pagoda/junit/TestGapMappedToLower.java68
2 files changed, 101 insertions, 8 deletions
diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/ClauseTester.java b/test/uk/ac/ox/cs/pagoda/junit/ClauseTester.java
index abd0741..ad4b2de 100644
--- a/test/uk/ac/ox/cs/pagoda/global_tests/ClauseTester.java
+++ b/test/uk/ac/ox/cs/pagoda/junit/ClauseTester.java
@@ -1,16 +1,41 @@
1package uk.ac.ox.cs.pagoda.global_tests; 1package uk.ac.ox.cs.pagoda.junit;
2 2
3import org.junit.Test;
3import org.semanticweb.HermiT.model.*; 4import org.semanticweb.HermiT.model.*;
4import org.semanticweb.owlapi.apibinding.OWLManager; 5import org.semanticweb.owlapi.apibinding.OWLManager;
5import org.semanticweb.owlapi.model.OWLOntology; 6import org.semanticweb.owlapi.model.OWLOntology;
6import org.semanticweb.owlapi.model.OWLOntologyManager; 7import org.semanticweb.owlapi.model.OWLOntologyManager;
7import org.testng.Assert;
8import org.testng.annotations.Test;
9import uk.ac.ox.cs.pagoda.approx.Clause; 8import uk.ac.ox.cs.pagoda.approx.Clause;
10import uk.ac.ox.cs.pagoda.approx.Clausifier; 9import uk.ac.ox.cs.pagoda.approx.Clausifier;
11 10
11import static org.junit.Assert.fail;
12
12public class ClauseTester { 13public class ClauseTester {
13 14
15 public void test_clause(Atom[] headAtoms, Atom[] bodyAtoms) {
16 OWLOntologyManager m = OWLManager.createOWLOntologyManager();
17 OWLOntology emptyOntology = null;
18 try {
19 emptyOntology = m.createOntology();
20 } catch(Exception e) {
21 e.printStackTrace();
22 fail("failed to create a new ontology");
23 }
24 Clause c = new Clause(Clausifier.getInstance(emptyOntology), DLClause.create(headAtoms, bodyAtoms));
25 System.out.println(c.toString());
26 }
27
28 @Test
29 public void test_nominal() {
30 Variable x = Variable.create("X");
31 AtomicRole r = AtomicRole.create("r");
32 Individual o = Individual.create("o");
33 Atom[] bodyAtoms = new Atom[]{Atom.create(r, x, o)};
34 AtomicConcept A = AtomicConcept.create("A");
35 Atom[] headAtoms = new Atom[]{Atom.create(A, x)};
36 test_clause(headAtoms, bodyAtoms);
37 }
38
14 @Test 39 @Test
15 public void test_simple() { 40 public void test_simple() {
16 Variable x = Variable.create("X"), y1 = Variable.create("y1"), y2 = Variable.create("y2"); 41 Variable x = Variable.create("X"), y1 = Variable.create("y1"), y2 = Variable.create("y2");
@@ -32,7 +57,7 @@ public class ClauseTester {
32 emptyOntology = m.createOntology(); 57 emptyOntology = m.createOntology();
33 } catch (Exception e) { 58 } catch (Exception e) {
34 e.printStackTrace(); 59 e.printStackTrace();
35 Assert.fail("failed to create a new ontology"); 60 fail("failed to create a new ontology");
36 } 61 }
37 Clause c = new Clause(Clausifier.getInstance(emptyOntology), DLClause.create(headAtoms, bodyAtoms)); 62 Clause c = new Clause(Clausifier.getInstance(emptyOntology), DLClause.create(headAtoms, bodyAtoms));
38 System.out.println(c.toString()); 63 System.out.println(c.toString());
@@ -62,7 +87,7 @@ public class ClauseTester {
62 emptyOntology = m.createOntology(); 87 emptyOntology = m.createOntology();
63 } catch (Exception e) { 88 } catch (Exception e) {
64 e.printStackTrace(); 89 e.printStackTrace();
65 Assert.fail("failed to create a new ontology"); 90 fail("failed to create a new ontology");
66 } 91 }
67 Clause c = new Clause(Clausifier.getInstance(emptyOntology), DLClause.create(headAtoms, bodyAtoms)); 92 Clause c = new Clause(Clausifier.getInstance(emptyOntology), DLClause.create(headAtoms, bodyAtoms));
68 System.out.println(c.toString()); 93 System.out.println(c.toString());
@@ -89,7 +114,7 @@ public class ClauseTester {
89 emptyOntology = m.createOntology(); 114 emptyOntology = m.createOntology();
90 } catch (Exception e) { 115 } catch (Exception e) {
91 e.printStackTrace(); 116 e.printStackTrace();
92 Assert.fail("failed to create a new ontology"); 117 fail("failed to create a new ontology");
93 } 118 }
94 Clause c = new Clause(Clausifier.getInstance(emptyOntology), DLClause.create(headAtoms, bodyAtoms)); 119 Clause c = new Clause(Clausifier.getInstance(emptyOntology), DLClause.create(headAtoms, bodyAtoms));
95 System.out.println(c.toString()); 120 System.out.println(c.toString());
@@ -119,7 +144,7 @@ public class ClauseTester {
119 emptyOntology = m.createOntology(); 144 emptyOntology = m.createOntology();
120 } catch (Exception e) { 145 } catch (Exception e) {
121 e.printStackTrace(); 146 e.printStackTrace();
122 Assert.fail("failed to create a new ontology"); 147 fail("failed to create a new ontology");
123 } 148 }
124 Clause c = new Clause(Clausifier.getInstance(emptyOntology), DLClause.create(headAtoms, bodyAtoms)); 149 Clause c = new Clause(Clausifier.getInstance(emptyOntology), DLClause.create(headAtoms, bodyAtoms));
125 System.out.println(c.toString()); 150 System.out.println(c.toString());
@@ -149,7 +174,7 @@ public class ClauseTester {
149 emptyOntology = m.createOntology(); 174 emptyOntology = m.createOntology();
150 } catch (Exception e) { 175 } catch (Exception e) {
151 e.printStackTrace(); 176 e.printStackTrace();
152 Assert.fail("failed to create a new ontology"); 177 fail("failed to create a new ontology");
153 } 178 }
154 Clause c = new Clause(Clausifier.getInstance(emptyOntology), DLClause.create(headAtoms, bodyAtoms)); 179 Clause c = new Clause(Clausifier.getInstance(emptyOntology), DLClause.create(headAtoms, bodyAtoms));
155 System.out.println(c.toString()); 180 System.out.println(c.toString());
diff --git a/test/uk/ac/ox/cs/pagoda/junit/TestGapMappedToLower.java b/test/uk/ac/ox/cs/pagoda/junit/TestGapMappedToLower.java
new file mode 100644
index 0000000..8fae16c
--- /dev/null
+++ b/test/uk/ac/ox/cs/pagoda/junit/TestGapMappedToLower.java
@@ -0,0 +1,68 @@
1package uk.ac.ox.cs.pagoda.junit;
2
3import junit.framework.Assert;
4import org.junit.Test;
5import org.semanticweb.owlapi.apibinding.OWLManager;
6import org.semanticweb.owlapi.model.*;
7import uk.ac.ox.cs.pagoda.query.AnswerTuple;
8import uk.ac.ox.cs.pagoda.query.AnswerTuples;
9import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner;
10import uk.ac.ox.cs.pagoda.util.Namespace;
11
12public class TestGapMappedToLower {
13
14 public static final String ns = "http://example.org/test#%s";
15
16 public IRI getEntityIRI(String name) {
17 return IRI.create(String.format(ns, name));
18 }
19
20 @Test
21 public void test() throws OWLOntologyCreationException {
22 OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
23 OWLDataFactory factory = manager.getOWLDataFactory();
24 OWLOntology ontology = manager.createOntology();
25 OWLClass A = factory.getOWLClass(getEntityIRI("A"));
26 manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(A));
27 OWLClass B = factory.getOWLClass(getEntityIRI("B"));
28 manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(B));
29 OWLClass C = factory.getOWLClass(getEntityIRI("C"));
30 manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(C));
31 OWLClass A1 = factory.getOWLClass(getEntityIRI("A1"));
32 manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(A1));
33 OWLClass A2 = factory.getOWLClass(getEntityIRI("A2"));
34 manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(A2));
35 OWLNamedIndividual a = factory.getOWLNamedIndividual(getEntityIRI("a"));
36 OWLNamedIndividual b = factory.getOWLNamedIndividual(getEntityIRI("b"));
37 OWLNamedIndividual c = factory.getOWLNamedIndividual(getEntityIRI("c"));
38 OWLObjectProperty r = factory.getOWLObjectProperty(IRI.create(String.format(ns, "r")));
39 manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(r));
40
41 manager.addAxiom(ontology, factory.getOWLClassAssertionAxiom(A, a)); // A(a)
42 manager.addAxiom(ontology, factory.getOWLClassAssertionAxiom(B, b)); // B(b)
43 manager.addAxiom(ontology, factory.getOWLClassAssertionAxiom(C, c)); // C(c)
44 manager.addAxiom(ontology, factory.getOWLObjectPropertyAssertionAxiom(r, a, b)); // r(a,b)
45 manager.addAxiom(ontology, factory.getOWLObjectPropertyAssertionAxiom(r, a, c)); // r(a,c)
46 manager.addAxiom(ontology, factory.getOWLSubClassOfAxiom(A, factory.getOWLObjectUnionOf(A1, A2))); // A \sqsubseteq A1 \sqcup A2
47 manager.addAxiom(ontology, factory.getOWLSubClassOfAxiom(A1, factory.getOWLObjectMaxCardinality(1, r))); // A1 \sqsubseteq \leq 1 r.\top
48 manager.addAxiom(ontology, factory.getOWLSubClassOfAxiom(A2, factory.getOWLObjectMaxCardinality(1, r))); // A2 \sqsubseteq \leq 1 r.\top
49
50 QueryReasoner pagoda = QueryReasoner.getInstance(ontology);
51 pagoda.loadOntology(ontology);
52 if(pagoda.preprocess()) {
53 String sparql = "select ?x where { "
54 + "?x <" + r.toStringID() + "> ?y . "
55 + "?y " + Namespace.RDF_TYPE_QUOTED + " <" + B.toStringID() + "> . "
56 + "?y " + Namespace.RDF_TYPE_QUOTED + " <" + C.toStringID() + "> . } ";
57 AnswerTuples rs = pagoda.evaluate(sparql);
58 int count = 0;
59 for(AnswerTuple ans; rs.isValid(); rs.moveNext()) {
60 ans = rs.getTuple();
61 System.out.println(ans.getGroundTerm(0));
62 ++count;
63 }
64 Assert.assertEquals(1, count);
65 }
66 }
67
68}