use of fr.lirmm.graphik.graal.api.core.Rule in project graal by graphik-team.
the class OWL2ParserTest method hasKeyWithUnion.
@Test
public void hasKeyWithUnion() throws OWL2ParserException {
OWL2Parser parser = new OWL2Parser(PREFIXES + ":A a owl:Class . " + ":B a owl:Class . " + ":p a owl:ObjectProperty . " + ":q a owl:DatatypeProperty . " + "[owl:unionOf( :A :B [owl:oneOf (:i1)] ) ] owl:hasKey (:p :q) .");
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:", 6, nbAssertions);
}
use of fr.lirmm.graphik.graal.api.core.Rule in project graal by graphik-team.
the class OWL2ParserTest method dataRangeComplementOf.
@Test
public void dataRangeComplementOf() throws OWL2ParserException {
// D(Y) :- p(X, Y).
OWL2Parser parser = new OWL2Parser(PREFIXES + ":p rdf:type owl:DatatypeProperty . " + ":D rdf:type rdfs:Datatype ." + ":E rdf:type rdfs:Datatype." + ":p rdfs:range [owl:complementOf [owl:intersectionOf ( :D :E ) ]] .");
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);
}
use of fr.lirmm.graphik.graal.api.core.Rule 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.api.core.Rule in project graal by graphik-team.
the class OWL2ParserTest method inverseFunctionalObjectProperty.
@Test
public void inverseFunctionalObjectProperty() {
// Y = Z :- p(Y, X), p(Z, X).
try {
OWL2Parser parser = new OWL2Parser(PREFIXES + ":p rdf:type owl:InverseFunctionalProperty . ");
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 b1 = it.next();
Atom b2 = it.next();
Assert.assertFalse(it.hasNext());
it = r.getHead().iterator();
Atom h = it.next();
Assert.assertFalse(it.hasNext());
Assert.assertEquals(P, b1.getPredicate());
Assert.assertEquals(P, b2.getPredicate());
Assert.assertEquals(Predicate.EQUALITY, h.getPredicate());
Assert.assertEquals(b1.getTerm(1), b2.getTerm(1));
Assert.assertTrue(b1.getTerm(0).equals(h.getTerm(0)) || b1.getTerm(0).equals(h.getTerm(1)));
Assert.assertTrue(b2.getTerm(0).equals(h.getTerm(0)) || b2.getTerm(0).equals(h.getTerm(1)));
}
}
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 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);
}
Aggregations