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);
}
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);
}
Aggregations