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