diff options
| author | RncLsn <rnc.lsn@gmail.com> | 2015-05-28 17:24:00 +0100 |
|---|---|---|
| committer | RncLsn <rnc.lsn@gmail.com> | 2015-05-28 17:24:00 +0100 |
| commit | 1055e67727b1aca80ae7ffaceabce3aacb00b6d2 (patch) | |
| tree | 71632dfc0fdf596d0286a4912245cacedfd2b534 /test/uk/ac/ox/cs/pagoda/junit/TestGapMappedToLower.java | |
| parent | de3749532d060f26c966a81c03f9a5d846c33d06 (diff) | |
| parent | 4f98cb7df7f2921808d825cdcd82f95a0899640e (diff) | |
| download | ACQuA-1055e67727b1aca80ae7ffaceabce3aacb00b6d2.tar.gz ACQuA-1055e67727b1aca80ae7ffaceabce3aacb00b6d2.zip | |
Merge branch 'upstream' into Query-dependent-skolemisation
Conflicts:
src/uk/ac/ox/cs/pagoda/approx/RLPlusOntology.java
src/uk/ac/ox/cs/pagoda/endomorph/plan/OpenEndMultiThreadPlan.java
src/uk/ac/ox/cs/pagoda/endomorph/plan/OpenEndPlan.java
src/uk/ac/ox/cs/pagoda/query/GapByStore4ID.java
src/uk/ac/ox/cs/pagoda/query/GapByStore4ID2.java
src/uk/ac/ox/cs/pagoda/reasoner/MyQueryReasoner.java
src/uk/ac/ox/cs/pagoda/reasoner/light/BasicQueryEngine.java
src/uk/ac/ox/cs/pagoda/tracking/TrackingRuleEncoderWithGap.java
src/uk/ac/ox/cs/pagoda/util/Utility.java
test/uk/ac/ox/cs/pagoda/junit/ClauseTester.java
test/uk/ac/ox/cs/pagoda/junit/TestGapMappedToLower.java
Diffstat (limited to 'test/uk/ac/ox/cs/pagoda/junit/TestGapMappedToLower.java')
| -rw-r--r-- | test/uk/ac/ox/cs/pagoda/junit/TestGapMappedToLower.java | 113 |
1 files changed, 61 insertions, 52 deletions
diff --git a/test/uk/ac/ox/cs/pagoda/junit/TestGapMappedToLower.java b/test/uk/ac/ox/cs/pagoda/junit/TestGapMappedToLower.java index 8fae16c..3e385e5 100644 --- a/test/uk/ac/ox/cs/pagoda/junit/TestGapMappedToLower.java +++ b/test/uk/ac/ox/cs/pagoda/junit/TestGapMappedToLower.java | |||
| @@ -1,9 +1,18 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.junit; | 1 | package uk.ac.ox.cs.pagoda.junit; |
| 2 | 2 | ||
| 3 | import junit.framework.Assert; | 3 | import junit.framework.Assert; |
| 4 | |||
| 4 | import org.junit.Test; | 5 | import org.junit.Test; |
| 5 | import org.semanticweb.owlapi.apibinding.OWLManager; | 6 | import org.semanticweb.owlapi.apibinding.OWLManager; |
| 6 | import org.semanticweb.owlapi.model.*; | 7 | import org.semanticweb.owlapi.model.IRI; |
| 8 | import org.semanticweb.owlapi.model.OWLClass; | ||
| 9 | import org.semanticweb.owlapi.model.OWLDataFactory; | ||
| 10 | import org.semanticweb.owlapi.model.OWLNamedIndividual; | ||
| 11 | import org.semanticweb.owlapi.model.OWLObjectProperty; | ||
| 12 | import org.semanticweb.owlapi.model.OWLOntology; | ||
| 13 | import org.semanticweb.owlapi.model.OWLOntologyCreationException; | ||
| 14 | import org.semanticweb.owlapi.model.OWLOntologyManager; | ||
| 15 | |||
| 7 | import uk.ac.ox.cs.pagoda.query.AnswerTuple; | 16 | import uk.ac.ox.cs.pagoda.query.AnswerTuple; |
| 8 | import uk.ac.ox.cs.pagoda.query.AnswerTuples; | 17 | import uk.ac.ox.cs.pagoda.query.AnswerTuples; |
| 9 | import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner; | 18 | import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner; |
| @@ -11,58 +20,58 @@ import uk.ac.ox.cs.pagoda.util.Namespace; | |||
| 11 | 20 | ||
| 12 | public class TestGapMappedToLower { | 21 | public class TestGapMappedToLower { |
| 13 | 22 | ||
| 14 | public static final String ns = "http://example.org/test#%s"; | 23 | public static final String ns = "http://example.org/test#%s"; |
| 15 | 24 | ||
| 16 | public IRI getEntityIRI(String name) { | 25 | public IRI getEntityIRI(String name) { |
| 17 | return IRI.create(String.format(ns, name)); | 26 | return IRI.create(String.format(ns, name)); |
| 18 | } | 27 | } |
| 19 | 28 | ||
| 20 | @Test | 29 | @Test |
| 21 | public void test() throws OWLOntologyCreationException { | 30 | public void test() throws OWLOntologyCreationException { |
| 22 | OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); | 31 | OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); |
| 23 | OWLDataFactory factory = manager.getOWLDataFactory(); | 32 | OWLDataFactory factory = manager.getOWLDataFactory(); |
| 24 | OWLOntology ontology = manager.createOntology(); | 33 | OWLOntology ontology = manager.createOntology(); |
| 25 | OWLClass A = factory.getOWLClass(getEntityIRI("A")); | 34 | OWLClass A = factory.getOWLClass(getEntityIRI("A")); |
| 26 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(A)); | 35 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(A)); |
| 27 | OWLClass B = factory.getOWLClass(getEntityIRI("B")); | 36 | OWLClass B = factory.getOWLClass(getEntityIRI("B")); |
| 28 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(B)); | 37 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(B)); |
| 29 | OWLClass C = factory.getOWLClass(getEntityIRI("C")); | 38 | OWLClass C = factory.getOWLClass(getEntityIRI("C")); |
| 30 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(C)); | 39 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(C)); |
| 31 | OWLClass A1 = factory.getOWLClass(getEntityIRI("A1")); | 40 | OWLClass A1 = factory.getOWLClass(getEntityIRI("A1")); |
| 32 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(A1)); | 41 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(A1)); |
| 33 | OWLClass A2 = factory.getOWLClass(getEntityIRI("A2")); | 42 | OWLClass A2 = factory.getOWLClass(getEntityIRI("A2")); |
| 34 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(A2)); | 43 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(A2)); |
| 35 | OWLNamedIndividual a = factory.getOWLNamedIndividual(getEntityIRI("a")); | 44 | OWLNamedIndividual a = factory.getOWLNamedIndividual(getEntityIRI("a")); |
| 36 | OWLNamedIndividual b = factory.getOWLNamedIndividual(getEntityIRI("b")); | 45 | OWLNamedIndividual b = factory.getOWLNamedIndividual(getEntityIRI("b")); |
| 37 | OWLNamedIndividual c = factory.getOWLNamedIndividual(getEntityIRI("c")); | 46 | OWLNamedIndividual c = factory.getOWLNamedIndividual(getEntityIRI("c")); |
| 38 | OWLObjectProperty r = factory.getOWLObjectProperty(IRI.create(String.format(ns, "r"))); | 47 | OWLObjectProperty r = factory.getOWLObjectProperty(IRI.create(String.format(ns, "r"))); |
| 39 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(r)); | 48 | manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(r)); |
| 40 | 49 | ||
| 41 | manager.addAxiom(ontology, factory.getOWLClassAssertionAxiom(A, a)); // A(a) | 50 | manager.addAxiom(ontology, factory.getOWLClassAssertionAxiom(A, a)); // A(a) |
| 42 | manager.addAxiom(ontology, factory.getOWLClassAssertionAxiom(B, b)); // B(b) | 51 | manager.addAxiom(ontology, factory.getOWLClassAssertionAxiom(B, b)); // B(b) |
| 43 | manager.addAxiom(ontology, factory.getOWLClassAssertionAxiom(C, c)); // C(c) | 52 | manager.addAxiom(ontology, factory.getOWLClassAssertionAxiom(C, c)); // C(c) |
| 44 | manager.addAxiom(ontology, factory.getOWLObjectPropertyAssertionAxiom(r, a, b)); // r(a,b) | 53 | manager.addAxiom(ontology, factory.getOWLObjectPropertyAssertionAxiom(r, a, b)); // r(a,b) |
| 45 | manager.addAxiom(ontology, factory.getOWLObjectPropertyAssertionAxiom(r, a, c)); // r(a,c) | 54 | 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 | 55 | 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 | 56 | 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 | 57 | manager.addAxiom(ontology, factory.getOWLSubClassOfAxiom(A2, factory.getOWLObjectMaxCardinality(1, r))); // A2 \sqsubseteq \leq 1 r.\top |
| 49 | 58 | ||
| 50 | QueryReasoner pagoda = QueryReasoner.getInstance(ontology); | 59 | QueryReasoner pagoda = QueryReasoner.getInstance(ontology); |
| 51 | pagoda.loadOntology(ontology); | 60 | pagoda.loadOntology(ontology); |
| 52 | if(pagoda.preprocess()) { | 61 | if (pagoda.preprocess()) { |
| 53 | String sparql = "select ?x where { " | 62 | String sparql = "select ?x where { " |
| 54 | + "?x <" + r.toStringID() + "> ?y . " | 63 | + "?x <" + r.toStringID() + "> ?y . " |
| 55 | + "?y " + Namespace.RDF_TYPE_QUOTED + " <" + B.toStringID() + "> . " | 64 | + "?y " + Namespace.RDF_TYPE_QUOTED + " <" + B.toStringID() + "> . " |
| 56 | + "?y " + Namespace.RDF_TYPE_QUOTED + " <" + C.toStringID() + "> . } "; | 65 | + "?y " + Namespace.RDF_TYPE_QUOTED + " <" + C.toStringID() + "> . } "; |
| 57 | AnswerTuples rs = pagoda.evaluate(sparql); | 66 | AnswerTuples rs = pagoda.evaluate(sparql); |
| 58 | int count = 0; | 67 | int count = 0; |
| 59 | for(AnswerTuple ans; rs.isValid(); rs.moveNext()) { | 68 | for (AnswerTuple ans; rs.isValid(); rs.moveNext()) { |
| 60 | ans = rs.getTuple(); | 69 | ans = rs.getTuple(); |
| 61 | System.out.println(ans.getGroundTerm(0)); | 70 | System.out.println(ans.getGroundTerm(0)); |
| 62 | ++count; | 71 | ++count; |
| 63 | } | 72 | } |
| 64 | Assert.assertEquals(1, count); | 73 | Assert.assertEquals(1, count); |
| 65 | } | 74 | } |
| 66 | } | 75 | } |
| 67 | 76 | ||
| 68 | } | 77 | } |
