use of fr.lirmm.graphik.graal.core.DefaultNegativeConstraint in project graal by graphik-team.
the class OWL2ParserTest method complexClassAssertion.
@Test
public void complexClassAssertion() throws OWL2ParserException {
OWL2Parser parser = new OWL2Parser(PREFIXES + ":A rdf:type owl:Class . " + ":B rdf:type owl:Class . " + ":i1 a [owl:intersectionOf ( :A [owl:complementOf :B] ) ] ." + "");
int nbFacts = 0;
int nbConstraint = 0;
while (parser.hasNext()) {
Object o = parser.next();
if ((o instanceof InMemoryAtomSet)) {
++nbFacts;
CloseableIteratorWithoutException<Atom> it = ((InMemoryAtomSet) o).iterator();
Assert.assertTrue(it.hasNext());
Atom a = it.next();
Assert.assertEquals(A, a.getPredicate());
Assert.assertEquals(I1, a.getTerm(0));
}
if ((o instanceof DefaultNegativeConstraint)) {
++nbConstraint;
CloseableIteratorWithoutException<Atom> it = ((DefaultNegativeConstraint) o).getBody().iterator();
Assert.assertTrue(it.hasNext());
Atom a = it.next();
Assert.assertEquals(B, a.getPredicate());
Assert.assertEquals(I1, a.getTerm(0));
}
}
parser.close();
Assert.assertEquals("Number of assertions found:", 1, nbFacts);
Assert.assertEquals("Number of assertions found:", 1, nbConstraint);
}
use of fr.lirmm.graphik.graal.core.DefaultNegativeConstraint in project graal by graphik-team.
the class OWL2ParserTest method objectMaxCardinality0.
@Test
public void objectMaxCardinality0() throws OWL2ParserException {
OWL2Parser parser = new OWL2Parser(PREFIXES + ":A rdf:type owl:Class . " + ":B rdf:type owl:Class . " + ":p rdf:type owl:ObjectProperty . " + " :A rdfs:subClassOf [ rdf:type owl:Restriction ; " + " owl:onProperty :p ; " + " owl:onClass :B ; " + " owl:maxCardinality 0 ] . ");
int nbRules = 0;
while (parser.hasNext()) {
Object o = parser.next();
if (o instanceof DefaultNegativeConstraint) {
++nbRules;
}
}
parser.close();
Assert.assertEquals("Number of assertions found:", 1, nbRules);
}
use of fr.lirmm.graphik.graal.core.DefaultNegativeConstraint in project graal by graphik-team.
the class OWL2ParserTest method dataMaxCardinality0.
@Test
public void dataMaxCardinality0() throws OWL2ParserException {
OWL2Parser parser = new OWL2Parser(PREFIXES + ":A rdf:type owl:Class . " + ":B rdf:type owl:Datatype . " + ":p rdf:type owl:DatatypeProperty . " + " :A rdfs:subClassOf [ rdf:type owl:Restriction ; " + " owl:onProperty :p ; " + " owl:onDataRange :B ; " + " owl:maxCardinality 0 ] . ");
int nbRules = 0;
while (parser.hasNext()) {
Object o = parser.next();
if (o instanceof DefaultNegativeConstraint) {
++nbRules;
}
}
parser.close();
Assert.assertEquals("Number of assertions found:", 1, nbRules);
}
use of fr.lirmm.graphik.graal.core.DefaultNegativeConstraint in project graal by graphik-team.
the class OWLAxiomParser method visit.
@Override
public Iterable<? extends Object> visit(OWLAsymmetricObjectPropertyAxiom arg) {
InMemoryAtomSet atomset = arg.getProperty().accept(propertyVisitorXY);
atomset.addAll(arg.getProperty().accept(propertyVisitorYX));
return Collections.singleton(new DefaultNegativeConstraint(atomset));
}
use of fr.lirmm.graphik.graal.core.DefaultNegativeConstraint in project graal by graphik-team.
the class OWL2ParserTest method irreflexiveObjectPropertyOf.
@Test
public void irreflexiveObjectPropertyOf() {
// ! :- p(X,X) .
try {
OWL2Parser parser = new OWL2Parser(PREFIXES + ":p rdf:type owl:IrreflexiveProperty . ");
int nbRules = 0;
while (parser.hasNext()) {
Object o = parser.next();
if (o instanceof DefaultNegativeConstraint) {
++nbRules;
Rule r = (Rule) o;
CloseableIteratorWithoutException<Atom> it = r.getBody().iterator();
Atom b = it.next();
Assert.assertFalse(it.hasNext());
Assert.assertEquals(P, b.getPredicate());
Assert.assertEquals(b.getTerm(0), b.getTerm(1));
}
}
parser.close();
Assert.assertEquals("Number of assertions found:", 1, nbRules);
} catch (Exception e) {
Assert.assertFalse(e.getMessage(), true);
}
}
Aggregations