Search in sources :

Example 31 with Prefix

use of fr.lirmm.graphik.util.Prefix in project graal by graphik-team.

the class OWL2ParserTest method dataPropertyRangeAxiom.

@Test
public void dataPropertyRangeAxiom() throws OWL2ParserException {
    // D(Y) :- p(X, Y).
    OWL2Parser parser = new OWL2Parser(PREFIXES + ":p rdf:type owl:DatatypeProperty . " + ":D rdf:type rdfs:Datatype ." + ":p rdfs:range :D .");
    boolean found = false;
    while (parser.hasNext()) {
        Object o = parser.next();
        if (!(o instanceof Prefix)) {
            Assert.assertTrue(o instanceof Rule);
            Rule r = (Rule) o;
            Atom property = (Atom) r.getBody().iterator().next();
            Assert.assertEquals(P, property.getPredicate());
            Atom classs = (Atom) r.getHead().iterator().next();
            Assert.assertEquals(D, classs.getPredicate());
            Assert.assertEquals(property.getTerm(1), classs.getTerm(0));
            found = true;
        }
    }
    parser.close();
    Assert.assertTrue("Number of assertions found:", found);
}
Also used : OWL2Parser(fr.lirmm.graphik.graal.io.owl.OWL2Parser) Prefix(fr.lirmm.graphik.util.Prefix) Rule(fr.lirmm.graphik.graal.api.core.Rule) Atom(fr.lirmm.graphik.graal.api.core.Atom) Test(org.junit.Test)

Example 32 with Prefix

use of fr.lirmm.graphik.util.Prefix in project graal by graphik-team.

the class OWL2ParserTest method intersectionOfIntersectionOfIntersection.

@Test
public void intersectionOfIntersectionOfIntersection() throws OWL2ParserException {
    OWL2Parser parser = new OWL2Parser(PREFIXES + " :A a owl:Class. " + ":B a owl:Class. " + ":C a owl:Class. " + ":D a owl:Class. " + ":E a owl:Class. " + "[owl:intersectionOf ( :B [owl:intersectionOf (:C " + "[owl:intersectionOf( :D :E ) ] )] )]" + " rdfs:subClassOf :A .");
    int nbAssertion = 0;
    while (parser.hasNext()) {
        Object o = parser.next();
        if (!(o instanceof Prefix)) {
            ++nbAssertion;
        }
    }
    parser.close();
    Assert.assertEquals("Number of assertions found:", 1, nbAssertion);
}
Also used : OWL2Parser(fr.lirmm.graphik.graal.io.owl.OWL2Parser) Prefix(fr.lirmm.graphik.util.Prefix) DefaultNegativeConstraint(fr.lirmm.graphik.graal.core.DefaultNegativeConstraint) Test(org.junit.Test)

Example 33 with Prefix

use of fr.lirmm.graphik.util.Prefix in project graal by graphik-team.

the class OWL2ParserTest method assertionObjectProperty.

@Test
public void assertionObjectProperty() throws OWL2ParserException {
    OWL2Parser parser = new OWL2Parser(PREFIXES + ":p rdf:type owl:ObjectProperty . " + ":i1 :p :i2 ." + "");
    boolean found = false;
    while (parser.hasNext()) {
        Object o = parser.next();
        if (!(o instanceof Prefix)) {
            InMemoryAtomSet atomset = (InMemoryAtomSet) o;
            Atom a = atomset.iterator().next();
            Assert.assertEquals(P, a.getPredicate());
            Iterator<Term> it = a.iterator();
            Assert.assertEquals(I1, it.next());
            Assert.assertEquals(I2, it.next());
            found = true;
        }
    }
    parser.close();
    Assert.assertTrue("Number of assertions found:", found);
}
Also used : OWL2Parser(fr.lirmm.graphik.graal.io.owl.OWL2Parser) InMemoryAtomSet(fr.lirmm.graphik.graal.api.core.InMemoryAtomSet) Prefix(fr.lirmm.graphik.util.Prefix) Term(fr.lirmm.graphik.graal.api.core.Term) Atom(fr.lirmm.graphik.graal.api.core.Atom) Test(org.junit.Test)

Aggregations

Prefix (fr.lirmm.graphik.util.Prefix)33 Test (org.junit.Test)27 OWL2Parser (fr.lirmm.graphik.graal.io.owl.OWL2Parser)23 DefaultNegativeConstraint (fr.lirmm.graphik.graal.core.DefaultNegativeConstraint)17 Rule (fr.lirmm.graphik.graal.api.core.Rule)14 Atom (fr.lirmm.graphik.graal.api.core.Atom)6 Term (fr.lirmm.graphik.graal.api.core.Term)3 Map (java.util.Map)3 Query (com.hp.hpl.jena.query.Query)2 InMemoryAtomSet (fr.lirmm.graphik.graal.api.core.InMemoryAtomSet)2 Predicate (fr.lirmm.graphik.graal.api.core.Predicate)2 DefaultAtom (fr.lirmm.graphik.graal.core.DefaultAtom)2 OWL2ParserException (fr.lirmm.graphik.graal.io.owl.OWL2ParserException)2 DefaultURI (fr.lirmm.graphik.util.DefaultURI)2 CloseableIteratorWithoutException (fr.lirmm.graphik.util.stream.CloseableIteratorWithoutException)2 IteratorException (fr.lirmm.graphik.util.stream.IteratorException)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 Triple (com.hp.hpl.jena.graph.Triple)1 QueryParseException (com.hp.hpl.jena.query.QueryParseException)1 Template (com.hp.hpl.jena.sparql.syntax.Template)1