aboutsummaryrefslogtreecommitdiff
path: root/test/uk/ac/ox/cs/pagoda/junit/ClauseTester.java
diff options
context:
space:
mode:
Diffstat (limited to 'test/uk/ac/ox/cs/pagoda/junit/ClauseTester.java')
-rw-r--r--test/uk/ac/ox/cs/pagoda/junit/ClauseTester.java183
1 files changed, 183 insertions, 0 deletions
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..ad4b2de
--- /dev/null
+++ b/test/uk/ac/ox/cs/pagoda/junit/ClauseTester.java
@@ -0,0 +1,183 @@
1package uk.ac.ox.cs.pagoda.junit;
2
3import org.junit.Test;
4import org.semanticweb.HermiT.model.*;
5import org.semanticweb.owlapi.apibinding.OWLManager;
6import org.semanticweb.owlapi.model.OWLOntology;
7import org.semanticweb.owlapi.model.OWLOntologyManager;
8import uk.ac.ox.cs.pagoda.approx.Clause;
9import uk.ac.ox.cs.pagoda.approx.Clausifier;
10
11import static org.junit.Assert.fail;
12
13public class ClauseTester {
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
39 @Test
40 public void test_simple() {
41 Variable x = Variable.create("X"), y1 = Variable.create("y1"), y2 = Variable.create("y2");
42 AtomicConcept A = AtomicConcept.create("A");
43 AtomicRole r = AtomicRole.create("r");
44 Atom[] bodyAtoms = new Atom[] {
45 Atom.create(A, x),
46 Atom.create(r, x, y1),
47 Atom.create(r, x, y2)
48 };
49
50 Atom[] headAtoms = new Atom[] {
51 Atom.create(Equality.INSTANCE, y1, y2)
52 };
53
54 OWLOntologyManager m = OWLManager.createOWLOntologyManager();
55 OWLOntology emptyOntology = null;
56 try {
57 emptyOntology = m.createOntology();
58 } catch (Exception e) {
59 e.printStackTrace();
60 fail("failed to create a new ontology");
61 }
62 Clause c = new Clause(Clausifier.getInstance(emptyOntology), DLClause.create(headAtoms, bodyAtoms));
63 System.out.println(c.toString());
64 }
65
66 @Test
67 public void test_more() {
68 Variable x = Variable.create("X"), y1 = Variable.create("y1"), y2 = Variable.create("y2"), y3 = Variable.create("y3");
69 AtomicConcept A = AtomicConcept.create("A");
70 AtomicRole r = AtomicRole.create("r");
71 Atom[] bodyAtoms = new Atom[] {
72 Atom.create(A, x),
73 Atom.create(r, x, y1),
74 Atom.create(r, x, y2),
75 Atom.create(r, x, y3),
76 };
77
78 Atom[] headAtoms = new Atom[] {
79 Atom.create(Equality.INSTANCE, y1, y2),
80 Atom.create(Equality.INSTANCE, y1, y3),
81 Atom.create(Equality.INSTANCE, y2, y3)
82 };
83
84 OWLOntologyManager m = OWLManager.createOWLOntologyManager();
85 OWLOntology emptyOntology = null;
86 try {
87 emptyOntology = m.createOntology();
88 } catch (Exception e) {
89 e.printStackTrace();
90 fail("failed to create a new ontology");
91 }
92 Clause c = new Clause(Clausifier.getInstance(emptyOntology), DLClause.create(headAtoms, bodyAtoms));
93 System.out.println(c.toString());
94 }
95
96 @Test
97 public void test_inverse() {
98 Variable x = Variable.create("X"), y1 = Variable.create("y1"), y2 = Variable.create("y2");
99 AtomicConcept A = AtomicConcept.create("A");
100 AtomicRole r = AtomicRole.create("r");
101 Atom[] bodyAtoms = new Atom[] {
102 Atom.create(A, x),
103 Atom.create(r, y1, x),
104 Atom.create(r, y2, x)
105 };
106
107 Atom[] headAtoms = new Atom[] {
108 Atom.create(Equality.INSTANCE, y1, y2)
109 };
110
111 OWLOntologyManager m = OWLManager.createOWLOntologyManager();
112 OWLOntology emptyOntology = null;
113 try {
114 emptyOntology = m.createOntology();
115 } catch (Exception e) {
116 e.printStackTrace();
117 fail("failed to create a new ontology");
118 }
119 Clause c = new Clause(Clausifier.getInstance(emptyOntology), DLClause.create(headAtoms, bodyAtoms));
120 System.out.println(c.toString());
121 }
122
123 @Test
124 public void test_fillter() {
125 Variable x = Variable.create("X"), y1 = Variable.create("y1"), y2 = Variable.create("y2");
126 AtomicConcept A = AtomicConcept.create("A");
127 AtomicConcept B = AtomicConcept.create("B");
128 AtomicRole r = AtomicRole.create("r");
129 Atom[] bodyAtoms = new Atom[] {
130 Atom.create(A, x),
131 Atom.create(r, y1, x),
132 Atom.create(r, y2, x),
133 Atom.create(B, y1),
134 Atom.create(B, y2)
135 };
136
137 Atom[] headAtoms = new Atom[] {
138 Atom.create(Equality.INSTANCE, y1, y2)
139 };
140
141 OWLOntologyManager m = OWLManager.createOWLOntologyManager();
142 OWLOntology emptyOntology = null;
143 try {
144 emptyOntology = m.createOntology();
145 } catch (Exception e) {
146 e.printStackTrace();
147 fail("failed to create a new ontology");
148 }
149 Clause c = new Clause(Clausifier.getInstance(emptyOntology), DLClause.create(headAtoms, bodyAtoms));
150 System.out.println(c.toString());
151 }
152
153 @Test
154 public void test_negFillter() {
155 Variable x = Variable.create("X"), y1 = Variable.create("y1"), y2 = Variable.create("y2");
156 AtomicConcept A = AtomicConcept.create("A");
157 AtomicConcept B = AtomicConcept.create("B");
158 AtomicRole r = AtomicRole.create("r");
159 Atom[] bodyAtoms = new Atom[] {
160 Atom.create(A, x),
161 Atom.create(r, y1, x),
162 Atom.create(r, y2, x)
163 };
164
165 Atom[] headAtoms = new Atom[] {
166 Atom.create(Equality.INSTANCE, y1, y2),
167 Atom.create(B, y1),
168 Atom.create(B, y2)
169 };
170
171 OWLOntologyManager m = OWLManager.createOWLOntologyManager();
172 OWLOntology emptyOntology = null;
173 try {
174 emptyOntology = m.createOntology();
175 } catch (Exception e) {
176 e.printStackTrace();
177 fail("failed to create a new ontology");
178 }
179 Clause c = new Clause(Clausifier.getInstance(emptyOntology), DLClause.create(headAtoms, bodyAtoms));
180 System.out.println(c.toString());
181 }
182
183}