use of fr.lirmm.graphik.graal.io.owl.OWL2Parser in project graal by graphik-team.
the class OWL2ParserTest method unionOfUnion.
@Test
public void unionOfUnion() 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 . " + "[ owl:unionOf ( :ClassA [ owl:unionOf ( :ClassB :ClassC ) ] ) ] rdfs:subClassOf :ClassD. ");
int nbRules = 0;
while (parser.hasNext()) {
Object o = parser.next();
if (o instanceof Rule) {
++nbRules;
}
}
parser.close();
Assert.assertEquals("Number of assertions found:", 3, nbRules);
}
use of fr.lirmm.graphik.graal.io.owl.OWL2Parser in project graal by graphik-team.
the class OWL2ParserTest method asymetricObjectPropertyOf.
@Test
public void asymetricObjectPropertyOf() {
// ! :- q(X, Y), q(X, Y).
try {
OWL2Parser parser = new OWL2Parser(PREFIXES + ":p rdf:type owl:AsymmetricProperty . ");
int nbRules = 0;
while (parser.hasNext()) {
Object o = parser.next();
if (o instanceof Rule) {
++nbRules;
Rule r = (Rule) o;
CloseableIteratorWithoutException<Atom> it = r.getBody().iterator();
Atom a1 = (Atom) it.next();
Atom a2 = (Atom) it.next();
Assert.assertFalse(it.hasNext());
Assert.assertEquals(P, a1.getPredicate());
Assert.assertEquals(P, a2.getPredicate());
Assert.assertEquals(a1.getTerm(0), a2.getTerm(1));
Assert.assertEquals(a1.getTerm(1), a2.getTerm(0));
}
}
parser.close();
Assert.assertEquals("Number of assertions found:", 1, nbRules);
} catch (Exception e) {
Assert.assertFalse(e.getMessage(), true);
}
}
use of fr.lirmm.graphik.graal.io.owl.OWL2Parser in project graal by graphik-team.
the class OWL2ParserTest method objectUnionOf.
// /////////////////////////////////////////////////////////////////////////
// SUB CLASS EXPRESSION
// /////////////////////////////////////////////////////////////////////////
@Test
public void objectUnionOf() throws OWL2ParserException {
OWL2Parser parser = new OWL2Parser(PREFIXES + ":A rdf:type owl:Class . " + ":B rdf:type owl:Class . " + ":C rdf:type owl:Class . " + ":D rdf:type owl:Class . " + "[ owl:unionOf ( :B :C :D ) ] 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.assertTrue(!body.getTerm(0).isConstant());
Assert.assertTrue(body.getTerm(0).equals(head.getTerm(0)));
Assert.assertEquals(A, head.getPredicate());
Assert.assertTrue(B.equals(body.getPredicate()) || C.equals(body.getPredicate()) || D.equals(body.getPredicate()));
Assert.assertFalse(bodyIt.hasNext());
Assert.assertFalse(headIt.hasNext());
}
}
parser.close();
Assert.assertEquals("Number of assertions found:", 3, nbRules);
}
use of fr.lirmm.graphik.graal.io.owl.OWL2Parser in project graal by graphik-team.
the class OWL2ParserTest method illegalAllValuesFromMaskedInUnion.
@Test
public void illegalAllValuesFromMaskedInUnion() throws OWL2ParserException {
OWL2Parser parser = new OWL2Parser(PREFIXES + " :A a owl:Class. " + ":B a owl:Class. :C a owl:Class. " + ":p a owl:ObjectProperty. " + "[owl:unionOf ( :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:", 1, nbAssertion);
}
use of fr.lirmm.graphik.graal.io.owl.OWL2Parser in project graal by graphik-team.
the class OWL2ParserTest method dataSomeValuesFrom.
@Test
public void dataSomeValuesFrom() throws OWL2ParserException {
// p(X,Y) D(Y) :- A(X).
OWL2Parser parser = new OWL2Parser(PREFIXES + ":A a owl:Class. " + ":D a rdfs:Datatype. " + ":p rdf:type owl:DatatypeProperty . " + ":A rdfs:subClassOf [a owl:Restriction; owl:onProperty :p; owl:someValuesFrom :D].");
int nbAssertions = 0;
while (parser.hasNext()) {
Object o = parser.next();
if (!(o instanceof Prefix)) {
Assert.assertTrue(o instanceof Rule);
++nbAssertions;
}
}
parser.close();
Assert.assertEquals("Number of assertions found:", 1, nbAssertions);
}
Aggregations