Search in sources :

Example 11 with DefaultNegativeConstraint

use of fr.lirmm.graphik.graal.core.DefaultNegativeConstraint in project graal by graphik-team.

the class OWL2ParserTest method disjointClassAxiom.

@Test
public void disjointClassAxiom() throws OWL2ParserException {
    OWL2Parser parser = new OWL2Parser(PREFIXES + ":A rdf:type owl:Class . " + ":B rdf:type owl:Class . " + ":C rdf:type owl:Class . " + " _:x rdf:type owl:AllDisjointClasses ; " + " owl:members ( :A :B :C ) . ");
    int nbNegativeConstraint = 0;
    while (parser.hasNext()) {
        Object o = parser.next();
        if (o instanceof DefaultNegativeConstraint) {
            ++nbNegativeConstraint;
            DefaultNegativeConstraint r = (DefaultNegativeConstraint) o;
            CloseableIteratorWithoutException<Atom> bodyIt = r.getBody().iterator();
            Assert.assertTrue(bodyIt.hasNext());
            Atom body1 = bodyIt.next();
            Assert.assertTrue(bodyIt.hasNext());
            Atom body2 = bodyIt.next();
            Assert.assertFalse(bodyIt.hasNext());
            Assert.assertTrue(!body1.getTerm(0).isConstant());
            Assert.assertTrue(body1.getTerm(0).equals(body2.getTerm(0)));
            Assert.assertTrue(A.equals(body1.getPredicate()) || B.equals(body1.getPredicate()) || C.equals(body1.getPredicate()));
            Assert.assertTrue(A.equals(body2.getPredicate()) || B.equals(body2.getPredicate()) || C.equals(body2.getPredicate()));
        }
    }
    parser.close();
    Assert.assertEquals("Number of assertions found:", 3, nbNegativeConstraint);
}
Also used : OWL2Parser(fr.lirmm.graphik.graal.io.owl.OWL2Parser) DefaultNegativeConstraint(fr.lirmm.graphik.graal.core.DefaultNegativeConstraint) DefaultNegativeConstraint(fr.lirmm.graphik.graal.core.DefaultNegativeConstraint) Atom(fr.lirmm.graphik.graal.api.core.Atom) Test(org.junit.Test)

Example 12 with DefaultNegativeConstraint

use of fr.lirmm.graphik.graal.core.DefaultNegativeConstraint in project graal by graphik-team.

the class OWL2ParserTest method objectComplementOf.

// /////////////////////////////////////////////////////////////////////////
// SUPER CLASS EXPRESSION
// /////////////////////////////////////////////////////////////////////////
@Test
public void objectComplementOf() throws OWL2ParserException {
    OWL2Parser parser = new OWL2Parser(PREFIXES + ":A rdf:type owl:Class . " + ":B rdf:type owl:Class . " + ":A rdfs:subClassOf [ owl:complementOf :B ]. ");
    int nbRules = 0;
    while (parser.hasNext()) {
        Object o = parser.next();
        if (o instanceof DefaultNegativeConstraint) {
            ++nbRules;
            DefaultNegativeConstraint r = (DefaultNegativeConstraint) o;
            CloseableIteratorWithoutException<Atom> bodyIt = r.getBody().iterator();
            Assert.assertTrue(bodyIt.hasNext());
            Atom body1 = bodyIt.next();
            Assert.assertTrue(bodyIt.hasNext());
            Atom body2 = bodyIt.next();
            Assert.assertFalse(bodyIt.hasNext());
            Assert.assertTrue(!body1.getTerm(0).isConstant());
            Assert.assertTrue(body1.getTerm(0).equals(body2.getTerm(0)));
            Assert.assertTrue(A.equals(body1.getPredicate()) || B.equals(body1.getPredicate()));
            Assert.assertTrue(A.equals(body2.getPredicate()) || B.equals(body2.getPredicate()));
        }
    }
    parser.close();
    Assert.assertEquals("Number of assertions found:", 1, nbRules);
}
Also used : OWL2Parser(fr.lirmm.graphik.graal.io.owl.OWL2Parser) DefaultNegativeConstraint(fr.lirmm.graphik.graal.core.DefaultNegativeConstraint) DefaultNegativeConstraint(fr.lirmm.graphik.graal.core.DefaultNegativeConstraint) Atom(fr.lirmm.graphik.graal.api.core.Atom) Test(org.junit.Test)

Aggregations

DefaultNegativeConstraint (fr.lirmm.graphik.graal.core.DefaultNegativeConstraint)12 OWL2Parser (fr.lirmm.graphik.graal.io.owl.OWL2Parser)6 Test (org.junit.Test)6 Atom (fr.lirmm.graphik.graal.api.core.Atom)5 InMemoryAtomSet (fr.lirmm.graphik.graal.api.core.InMemoryAtomSet)5 Term (fr.lirmm.graphik.graal.api.core.Term)4 Rule (fr.lirmm.graphik.graal.api.core.Rule)2 LinkedListAtomSet (fr.lirmm.graphik.graal.core.atomset.LinkedListAtomSet)2 Variable (fr.lirmm.graphik.graal.api.core.Variable)1 ParseError (fr.lirmm.graphik.graal.api.io.ParseError)1 DefaultAtom (fr.lirmm.graphik.graal.core.DefaultAtom)1 OWL2ParserException (fr.lirmm.graphik.graal.io.owl.OWL2ParserException)1 CloseableIteratorWithoutException (fr.lirmm.graphik.util.stream.CloseableIteratorWithoutException)1 IteratorException (fr.lirmm.graphik.util.stream.IteratorException)1 LinkedList (java.util.LinkedList)1 OWLIndividual (org.semanticweb.owlapi.model.OWLIndividual)1 OWLPropertyExpression (org.semanticweb.owlapi.model.OWLPropertyExpression)1 SWRLRule (org.semanticweb.owlapi.model.SWRLRule)1