diff options
Diffstat (limited to 'test/uk/ac/ox/cs/pagoda/global_tests/TestGapMappedToLower.java')
| -rw-r--r-- | test/uk/ac/ox/cs/pagoda/global_tests/TestGapMappedToLower.java | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/TestGapMappedToLower.java b/test/uk/ac/ox/cs/pagoda/global_tests/TestGapMappedToLower.java deleted file mode 100644 index 4b1ec6d..0000000 --- a/test/uk/ac/ox/cs/pagoda/global_tests/TestGapMappedToLower.java +++ /dev/null | |||
| @@ -1,68 +0,0 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.global_tests; | ||
| 2 | |||
| 3 | import junit.framework.Assert; | ||
| 4 | import org.semanticweb.owlapi.apibinding.OWLManager; | ||
| 5 | import org.semanticweb.owlapi.model.*; | ||
| 6 | import org.testng.annotations.Test; | ||
| 7 | import uk.ac.ox.cs.pagoda.query.AnswerTuple; | ||
| 8 | import uk.ac.ox.cs.pagoda.query.AnswerTuples; | ||
| 9 | import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner; | ||
| 10 | import uk.ac.ox.cs.pagoda.util.Namespace; | ||
| 11 | |||
| 12 | public 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 | } | ||
