use of fr.lirmm.graphik.graal.api.core.Atom in project graal by graphik-team.
the class OWLPropertyExpressionVisitorImpl method visit.
@Override
public InMemoryAtomSet visit(OWLObjectInverseOf property) {
Predicate p = GraalUtils.createPredicate(property.getInverse());
Atom a = DefaultAtomFactory.instance().create(p, glueVariable2, glueVariable1);
return GraalUtils.createAtomSet(a);
}
use of fr.lirmm.graphik.graal.api.core.Atom in project graal by graphik-team.
the class OWLPropertyExpressionVisitorImpl method visit.
@Override
public InMemoryAtomSet visit(OWLDataProperty property) {
Predicate p = GraalUtils.createPredicate(property);
Atom a = DefaultAtomFactory.instance().create(p, glueVariable1, glueVariable2);
return GraalUtils.createAtomSet(a);
}
use of fr.lirmm.graphik.graal.api.core.Atom in project graal by graphik-team.
the class OWL2ParserTest method classAssertion.
// /////////////////////////////////////////////////////////////////////////
// ASSERTIONS
// /////////////////////////////////////////////////////////////////////////
@Test
public void classAssertion() throws OWL2ParserException {
OWL2Parser parser = new OWL2Parser(PREFIXES + ":A rdf:type owl:Class . " + ":i1 a :A ." + "");
int nbFacts = 0;
while (parser.hasNext()) {
Object o = parser.next();
if ((o instanceof InMemoryAtomSet)) {
++nbFacts;
CloseableIteratorWithoutException<Atom> it = ((InMemoryAtomSet) o).iterator();
Assert.assertTrue(it.hasNext());
Atom a = it.next();
Assert.assertEquals(A, a.getPredicate());
Assert.assertEquals(I1, a.getTerm(0));
}
}
parser.close();
Assert.assertEquals("Number of assertions found:", 1, nbFacts);
}
use of fr.lirmm.graphik.graal.api.core.Atom in project graal by graphik-team.
the class OWL2ParserTest method equivalentProperty.
@Test
public void equivalentProperty() {
// q(X, Y) <-> p(X, Y).
try {
OWL2Parser parser = new OWL2Parser(PREFIXES + ":p rdf:type owl:ObjectProperty . " + ":q rdf:type owl:ObjectProperty . " + ":p owl:equivalentProperty :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.assertTrue(Q.equals(property.getPredicate()) || P.equals(property.getPredicate()));
Assert.assertTrue(Q.equals(subProperty.getPredicate()) || P.equals(subProperty.getPredicate()));
Assert.assertEquals(property.getTerm(0), subProperty.getTerm(0));
Assert.assertEquals(property.getTerm(1), subProperty.getTerm(1));
}
}
parser.close();
Assert.assertEquals("Number of assertions found:", 2, nbRules);
} catch (Exception e) {
Assert.assertFalse(e.getMessage(), true);
}
}
use of fr.lirmm.graphik.graal.api.core.Atom in project graal by graphik-team.
the class RuleMLWriter method writeAtomSet.
protected void writeAtomSet(CloseableIterator<Atom> it) throws IOException {
while (it.hasNext()) {
Atom a = it.next();
this.writeAtom(a);
}
it.close();
}
Aggregations