use of fr.lirmm.graphik.graal.io.owl.OWL2Parser in project graal by graphik-team.
the class OWL2ParserTest method subClassOfAxiom.
// /////////////////////////////////////////////////////////////////////////
// Axioms
// /////////////////////////////////////////////////////////////////////////
@Test
public void subClassOfAxiom() throws OWL2ParserException {
OWL2Parser parser = new OWL2Parser(PREFIXES + ":A rdf:type owl:Class . " + ":B rdf:type owl:Class . " + ":A 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 body = bodyIt.next();
Atom head = headIt.next();
Assert.assertTrue(!body.getTerm(0).isConstant());
Assert.assertTrue(body.getTerm(0).equals(head.getTerm(0)));
Assert.assertEquals(A, body.getPredicate());
Assert.assertEquals(B, head.getPredicate());
Assert.assertFalse(bodyIt.hasNext());
Assert.assertFalse(headIt.hasNext());
}
}
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 unionOfUnionOfUnion.
@Test
public void unionOfUnionOfUnion() 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:unionOf ( :ClassA [ owl:unionOf ( :ClassB [ 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);
}
use of fr.lirmm.graphik.graal.io.owl.OWL2Parser in project graal by graphik-team.
the class OWL2ParserTest method objectExactCardinality0.
@Test
public void objectExactCardinality0() 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:qualifiedCardinality 0 ] . ");
int nbRules = 0;
while (parser.hasNext()) {
if (parser.next() instanceof Rule)
++nbRules;
}
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 objectInverseOf.
// /////////////////////////////////////////////////////////////////////////
// OTHERS
// /////////////////////////////////////////////////////////////////////////
@Test
public void objectInverseOf() throws OWL2ParserException {
OWL2Parser parser = new OWL2Parser(PREFIXES + ":p rdf:type owl:ObjectProperty . " + ":q rdf:type owl:ObjectProperty . " + ":p rdfs:subPropertyOf [owl:inverseOf :q] .");
int nbRules = 0;
while (parser.hasNext()) {
Object o = parser.next();
if (o instanceof Rule) {
++nbRules;
Rule r = (Rule) o;
Atom subProperty = (Atom) r.getBody().iterator().next();
Atom property = (Atom) r.getHead().iterator().next();
Assert.assertEquals(P, subProperty.getPredicate());
Assert.assertEquals(Q, property.getPredicate());
Assert.assertEquals(subProperty.getTerm(0), property.getTerm(1));
Assert.assertEquals(subProperty.getTerm(1), property.getTerm(0));
}
}
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 illegalAllValuesFromMaskedInIntersection.
@Test
public void illegalAllValuesFromMaskedInIntersection() throws OWL2ParserException {
OWL2Parser parser = new OWL2Parser(PREFIXES + " :A a owl:Class. " + ":B a owl:Class. :C a owl:Class. " + ":p a owl:ObjectProperty. " + "[owl:intersectionOf ( :A [rdf:type owl:Restriction; " + " owl:onProperty :p ; " + " owl:allValuesFrom :B] ) ] rdfs:subClassOf :C .");
int nbAssertion = 0;
while (parser.hasNext()) {
Object o = parser.next();
if (!(o instanceof Prefix)) {
++nbAssertion;
}
}
parser.close();
Assert.assertEquals("Number of assertions found:", 0, nbAssertion);
}
Aggregations