use of fr.lirmm.graphik.graal.api.core.Rule in project graal by graphik-team.
the class OWL2ParserTest method objectPropertyDomain.
@Test
public void objectPropertyDomain() {
// C(Y) :- p(X, Y).
try {
OWL2Parser parser = new OWL2Parser(PREFIXES + ":p rdf:type owl:ObjectProperty . " + ":A rdf:type owl:Class . " + ":p rdfs:domain :A .");
boolean found = false;
while (parser.hasNext()) {
Object o = parser.next();
if (!(o instanceof Prefix)) {
Rule r = (Rule) o;
Atom property = (Atom) r.getBody().iterator().next();
Assert.assertEquals(P, property.getPredicate());
Atom classs = (Atom) r.getHead().iterator().next();
Assert.assertEquals(A, classs.getPredicate());
Assert.assertEquals(property.getTerm(0), classs.getTerm(0));
found = true;
}
}
parser.close();
Assert.assertTrue("Number of assertions found:", found);
} catch (Exception e) {
Assert.assertFalse(e.getMessage(), true);
}
}
use of fr.lirmm.graphik.graal.api.core.Rule in project graal by graphik-team.
the class OWL2ParserTest method symetricObjectPropertyOf.
@Test
public void symetricObjectPropertyOf() {
// p(X, Y) :- p(Y, X).
try {
OWL2Parser parser = new OWL2Parser(PREFIXES + ":p rdf:type owl:SymmetricProperty . ");
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 b = (Atom) it.next();
Assert.assertFalse(it.hasNext());
it = r.getHead().iterator();
Atom h = (Atom) it.next();
Assert.assertFalse(it.hasNext());
Assert.assertEquals(P, b.getPredicate());
Assert.assertEquals(P, h.getPredicate());
Assert.assertNotEquals(b.getTerm(0), b.getTerm(1));
Assert.assertEquals(b.getTerm(0), h.getTerm(1));
Assert.assertEquals(b.getTerm(1), h.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.api.core.Rule 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.api.core.Rule in project graal by graphik-team.
the class OWL2ParserTest method objectExactCardinality1.
@Test
public void objectExactCardinality1() 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 1 ] . ");
int nbRules = 0;
while (parser.hasNext()) {
if (parser.next() instanceof Rule)
++nbRules;
}
parser.close();
Assert.assertEquals("Number of assertions found:", 2, nbRules);
}
use of fr.lirmm.graphik.graal.api.core.Rule in project graal by graphik-team.
the class OWL2ParserTest method dataRangeOneOf.
@Test
public void dataRangeOneOf() throws OWL2ParserException {
// D(Y) :- p(X, Y).
OWL2Parser parser = new OWL2Parser(PREFIXES + ":p rdf:type owl:DatatypeProperty . " + ":p rdfs:range [a rdfs:Datatype; owl:complementOf [a rdfs:Datatype; owl:oneOf ( :i1 :i2 :i3 ) ]] .");
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:", 3, nbAssertions);
}
Aggregations