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