use of fr.lirmm.graphik.graal.io.owl.OWL2Parser 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.io.owl.OWL2Parser in project graal by graphik-team.
the class OWL2ParserTest method objectMaxCardinality1.
@Test
public void objectMaxCardinality1() 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:maxCardinality 1 ] . ");
int nbRules = 0;
while (parser.hasNext()) {
if (parser.next() instanceof Rule)
++nbRules;
}
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 objectPropertyRange.
// /////////////////////////////////////////////////////////////////////////
//
// /////////////////////////////////////////////////////////////////////////
@Test
public void objectPropertyRange() {
// C(Y) :- p(X, Y).
try {
OWL2Parser parser = new OWL2Parser(PREFIXES + ":p rdf:type owl:ObjectProperty . " + ":A rdf:type owl:Class . " + ":p rdfs:range :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(1), 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.io.owl.OWL2Parser in project graal by graphik-team.
the class OWL2ParserTest method dataPropertyDomainAxiom.
@Test
public void dataPropertyDomainAxiom() throws OWL2ParserException {
// C(X) :- p(X, Y).
OWL2Parser parser = new OWL2Parser(PREFIXES + ":p rdf:type owl:DatatypeProperty . " + ":C rdf:type owl:Class ." + ":p rdfs:domain :C .");
boolean found = false;
while (parser.hasNext()) {
Object o = parser.next();
if (!(o instanceof Prefix)) {
Assert.assertTrue(o instanceof Rule);
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(C, classs.getPredicate());
Assert.assertEquals(property.getTerm(0), classs.getTerm(0));
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 assertionWithExistential.
@Test
public void assertionWithExistential() throws OWL2ParserException {
try {
OWL2Parser parser = new OWL2Parser(PREFIXES + ":A rdf:type owl:Class . " + ":p rdf:type owl:ObjectProperty . " + ":i1 :p [a :A] ." + "");
int nbFacts = 0;
int nbAtoms = 0;
while (parser.hasNext()) {
Object o = parser.next();
if (o instanceof InMemoryAtomSet) {
++nbFacts;
CloseableIterator<Atom> it = ((AtomSet) o).iterator();
while (it.hasNext()) {
it.next();
++nbAtoms;
}
}
}
parser.close();
Assert.assertEquals("Number of facts found:", 1, nbFacts);
Assert.assertEquals("Number of atoms found:", 2, nbAtoms);
} catch (Throwable e) {
Assert.fail("An exception was found: " + e);
}
}
Aggregations