use of fr.lirmm.graphik.graal.api.core.Rule in project graal by graphik-team.
the class OWL2ParserTest method functionalObjectProperty.
@Test
public void functionalObjectProperty() {
// Y = Z :- p(X, Y), p(X, Z).
try {
OWL2Parser parser = new OWL2Parser(PREFIXES + ":p rdf:type owl:ObjectProperty ; rdf:type owl:FunctionalProperty . ");
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(0), b2.getTerm(0));
Assert.assertTrue(b1.getTerm(1).equals(h.getTerm(0)) || b1.getTerm(1).equals(h.getTerm(1)));
Assert.assertTrue(b2.getTerm(1).equals(h.getTerm(0)) || b2.getTerm(1).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 example6.
@Test
public void example6() 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 . " + ":p rdf:type owl:ObjectProperty . " + ":q rdf:type owl:ObjectProperty . " + ":r rdf:type owl:ObjectProperty . " + "[owl:unionOf (" + " [owl:oneOf ( :i )] " + " [rdf:type owl:Restriction ;" + " owl:onProperty :p ;" + " owl:someValuesFrom :A]" + " )] " + " rdfs:subClassOf " + "[owl:intersectionOf ( " + " [rdf:type owl:Restriction ;" + " owl:onProperty :q ;" + " owl:someValuesFrom :B]" + " [owl:complementOf :C ] " + " [rdf:type owl:Restriction ;" + " owl:onProperty :r ;" + " owl:allValuesFrom :D]" + " )] . ");
int nbRules = 0;
while (parser.hasNext()) {
Object o = parser.next();
if (o instanceof Rule || o instanceof AtomSet) {
++nbRules;
}
}
parser.close();
Assert.assertEquals("Number of assertions found:", 6, nbRules);
}
use of fr.lirmm.graphik.graal.api.core.Rule in project graal by graphik-team.
the class OWL2ParserTest method dataRangeIntersection.
@Test
public void dataRangeIntersection() 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: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:", 2, nbAssertions);
}
use of fr.lirmm.graphik.graal.api.core.Rule in project graal by graphik-team.
the class OWL2ParserTest method dataMaxCardinality1.
@Test
public void dataMaxCardinality1() throws OWL2ParserException {
OWL2Parser parser = new OWL2Parser(PREFIXES + ":A rdf:type owl:Class . " + ":B rdf:type owl:Datatype . " + ":p rdf:type owl:DatatypeProperty . " + " :A rdfs:subClassOf [ rdf:type owl:Restriction ; " + " owl:onProperty :p ; " + " owl:onDataRange :B ; " + " owl:maxCardinality 1 ] . ");
int nbRules = 0;
while (parser.hasNext()) {
Object o = parser.next();
if (o instanceof Rule) {
++nbRules;
}
}
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 dataAllValuesFrom.
@Test
public void dataAllValuesFrom() throws OWL2ParserException {
// D(Y) :- p(X,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:allValuesFrom :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