use of fr.lirmm.graphik.graal.io.owl.OWL2Parser in project graal by graphik-team.
the class OWL2ParserTest method dataMinCardinality1.
@Test
public void dataMinCardinality1() throws OWL2ParserException {
OWL2Parser parser = new OWL2Parser(PREFIXES + ":D rdf:type rdfs:Datatype . " + ":B rdf:type owl:Class . " + ":p rdf:type owl:DatatypeProperty . " + " [ rdf:type owl:Restriction ; " + " owl:onProperty :p ; " + " owl:onDataRange :D ; " + " owl:minCardinality 1 ] " + " " + " rdfs:subClassOf :B . ");
int nbRules = 0;
while (parser.hasNext()) {
Object o = parser.next();
if (o instanceof Rule) {
++nbRules;
Rule r = (Rule) o;
CloseableIteratorWithoutException<Atom> bodyIt = r.getBody().iterator();
CloseableIteratorWithoutException<Atom> headIt = r.getHead().iterator();
Assert.assertTrue(bodyIt.hasNext());
Assert.assertTrue(headIt.hasNext());
Atom body1 = bodyIt.next();
Atom body2 = bodyIt.next();
Atom head = headIt.next();
Assert.assertFalse(bodyIt.hasNext());
Assert.assertFalse(headIt.hasNext());
Assert.assertTrue(D.equals(body1.getPredicate()) || D.equals(body2.getPredicate()));
Assert.assertTrue(P.equals(body1.getPredicate()) || P.equals(body2.getPredicate()));
Assert.assertTrue(D.equals(body1.getPredicate()) || P.equals(body1.getPredicate()));
Assert.assertTrue(D.equals(body2.getPredicate()) || P.equals(body2.getPredicate()));
Assert.assertEquals(B, head.getPredicate());
}
}
parser.close();
Assert.assertEquals("Number of assertions found:", 1, nbRules);
}
use of fr.lirmm.graphik.graal.io.owl.OWL2Parser in project graal by graphik-team.
the class OWL2ParserTest method objectHasValue.
@Test
public void objectHasValue() throws OWL2ParserException {
OWL2Parser parser = new OWL2Parser(PREFIXES + ":A rdf:type owl:Class . " + ":p rdf:type owl:ObjectProperty . " + " [rdf:type owl:Restriction ; owl:onProperty :p ;" + " owl:hasValue :i1]" + " rdfs:subClassOf :A . ");
int nbRules = 0;
while (parser.hasNext()) {
Object o = parser.next();
if (o instanceof Rule) {
++nbRules;
Rule r = (Rule) o;
CloseableIteratorWithoutException<Atom> bodyIt = r.getBody().iterator();
CloseableIteratorWithoutException<Atom> headIt = r.getHead().iterator();
Assert.assertTrue(bodyIt.hasNext());
Assert.assertTrue(headIt.hasNext());
Atom body = bodyIt.next();
Atom head = headIt.next();
Assert.assertFalse(bodyIt.hasNext());
Assert.assertFalse(headIt.hasNext());
Assert.assertEquals(P, body.getPredicate());
Assert.assertEquals(A, head.getPredicate());
Assert.assertTrue(!body.getTerm(0).isConstant());
Assert.assertEquals(body.getTerm(0), head.getTerm(0));
Assert.assertEquals(I1, body.getTerm(1));
}
}
parser.close();
Assert.assertEquals("Number of assertions found:", 1, nbRules);
}
use of fr.lirmm.graphik.graal.io.owl.OWL2Parser in project graal by graphik-team.
the class OWL2ParserTest method intersectionOfObjectOneOfAndUnionOf.
@Test
public void intersectionOfObjectOneOfAndUnionOf() throws OWL2ParserException {
OWL2Parser parser = new OWL2Parser(PREFIXES + ":ClassA rdf:type owl:Class . " + ":ClassB rdf:type owl:Class . " + ":ClassC rdf:type owl:Class . " + ":ClassD rdf:type owl:Class . " + ":ClassE rdf:type owl:Class . " + "[ owl:intersectionOf ( [ owl:oneOf ( :i1 :i2 ) ] [ owl:unionOf ( :ClassC :ClassD ) ] ) ] rdfs:subClassOf :ClassE. ");
int nbRules = 0;
while (parser.hasNext()) {
Object o = parser.next();
if (o instanceof Rule) {
++nbRules;
}
}
parser.close();
Assert.assertEquals("Number of assertions found:", 4, nbRules);
}
Aggregations