use of fr.lirmm.graphik.graal.io.owl.OWL2Parser in project graal by graphik-team.
the class OWL2ParserTest method equivalentClassAxiom.
@Test
public void equivalentClassAxiom() throws OWL2ParserException {
OWL2Parser parser = new OWL2Parser(PREFIXES + ":A rdf:type owl:Class . " + ":B rdf:type owl:Class . " + ":A owl:equivalentClass :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.assertTrue(A.equals(body.getPredicate()) || B.equals(body.getPredicate()));
Assert.assertTrue(A.equals(head.getPredicate()) || B.equals(head.getPredicate()));
Assert.assertFalse(bodyIt.hasNext());
Assert.assertFalse(headIt.hasNext());
}
}
parser.close();
Assert.assertEquals("Number of assertions found:", 2, nbRules);
}
use of fr.lirmm.graphik.graal.io.owl.OWL2Parser in project graal by graphik-team.
the class OWL2ParserTest method intersectionOfIntersectionOfIntersection.
@Test
public void intersectionOfIntersectionOfIntersection() throws OWL2ParserException {
OWL2Parser parser = new OWL2Parser(PREFIXES + " :A a owl:Class. " + ":B a owl:Class. " + ":C a owl:Class. " + ":D a owl:Class. " + ":E a owl:Class. " + "[owl:intersectionOf ( :B [owl:intersectionOf (:C " + "[owl:intersectionOf( :D :E ) ] )] )]" + " rdfs:subClassOf :A .");
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 assertionObjectProperty.
@Test
public void assertionObjectProperty() throws OWL2ParserException {
OWL2Parser parser = new OWL2Parser(PREFIXES + ":p rdf:type owl:ObjectProperty . " + ":i1 :p :i2 ." + "");
boolean found = false;
while (parser.hasNext()) {
Object o = parser.next();
if (!(o instanceof Prefix)) {
InMemoryAtomSet atomset = (InMemoryAtomSet) o;
Atom a = atomset.iterator().next();
Assert.assertEquals(P, a.getPredicate());
Iterator<Term> it = a.iterator();
Assert.assertEquals(I1, it.next());
Assert.assertEquals(I2, it.next());
found = true;
}
}
parser.close();
Assert.assertTrue("Number of assertions found:", found);
}
use of fr.lirmm.graphik.graal.io.owl.OWL2Parser in project graal by graphik-team.
the class OWL2ParserTest method objectSomeValuesFrom.
@Test
public void objectSomeValuesFrom() throws OWL2ParserException {
OWL2Parser parser = new OWL2Parser(PREFIXES + ":A rdf:type owl:Class . " + ":B rdf:type owl:Class . " + ":p rdf:type owl:ObjectProperty . " + " [rdf:type owl:Restriction ; owl:onProperty :p ;" + " owl:someValuesFrom :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 body1 = bodyIt.next();
Atom body2 = bodyIt.next();
Atom head = headIt.next();
Assert.assertFalse(bodyIt.hasNext());
Assert.assertFalse(headIt.hasNext());
Assert.assertTrue(A.equals(body1.getPredicate()) || A.equals(body2.getPredicate()));
Assert.assertTrue(P.equals(body1.getPredicate()) || P.equals(body2.getPredicate()));
Assert.assertTrue(A.equals(body1.getPredicate()) || P.equals(body1.getPredicate()));
Assert.assertTrue(A.equals(body2.getPredicate()) || P.equals(body2.getPredicate()));
Assert.assertEquals(B, head.getPredicate());
}
}
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 objectMaxCardinality1WithInverseOf.
@Test
public void objectMaxCardinality1WithInverseOf() throws OWL2ParserException {
OWL2Parser parser = new OWL2Parser(PREFIXES + ":A a owl:Class. " + ":p a owl:ObjectProperty. " + ":A rdfs:subClassOf [ rdf:type owl:Restriction ; " + " owl:onProperty [owl:inverseOf :p] ; " + " owl:maxCardinality 1 ]. ");
int nbRules = 0;
while (parser.hasNext()) {
if (parser.next() instanceof Rule)
++nbRules;
}
parser.close();
Assert.assertEquals("Number of assertions found:", 1, nbRules);
}
Aggregations