use of fr.lirmm.graphik.graal.api.core.InMemoryAtomSet in project graal by graphik-team.
the class OWLAxiomParser method visit.
// /////////////////////////////////////////////////////////////////////////
// HasKey
// /////////////////////////////////////////////////////////////////////////
@Override
public Iterable<? extends Object> visit(OWLHasKeyAxiom arg) {
// =(Y, Z) :- C(Y), C(Z), p1(Y, X1), p1(Z, X1), ..., pn(Y, Xn), pn(Z,
// Xn).
Collection<Rule> rules = GraalUtils.<Rule>createCollection();
freeVarGen.setIndex(2);
InMemoryAtomSet head = GraalUtils.createAtomSet(DefaultAtomFactory.instance().create(equalityPredicate, glueVarX, glueVarY));
OWLClassExpression classExpression = OWLAPIUtils.classExpressionDisjunctiveNormalForm(arg.getClassExpression());
for (Pair<OWLClassExpression, OWLClassExpression> pair : MathUtils.selfCartesianProduct(OWLAPIUtils.getObjectUnionOperands(classExpression))) {
InMemoryAtomSet body = pair.getLeft().accept(classVisitorX);
body.addAll(pair.getRight().accept(classVisitorY));
for (OWLObjectPropertyExpression pe : arg.getObjectPropertyExpressions()) {
Term var = freeVarGen.getFreshSymbol();
body.addAll(pe.accept(new OWLPropertyExpressionVisitorImpl(glueVarX, var)));
body.addAll(pe.accept(new OWLPropertyExpressionVisitorImpl(glueVarY, var)));
}
for (OWLDataPropertyExpression pe : arg.getDataPropertyExpressions()) {
Term var = freeVarGen.getFreshSymbol();
body.add(DefaultAtomFactory.instance().create(GraalUtils.createPredicate(pe), glueVarX, var));
body.add(DefaultAtomFactory.instance().create(GraalUtils.createPredicate(pe), glueVarY, var));
}
rules.add(DefaultRuleFactory.instance().create(body, head));
}
return rules;
}
use of fr.lirmm.graphik.graal.api.core.InMemoryAtomSet in project graal by graphik-team.
the class OWLAxiomParser method visit.
@Override
public Iterable<? extends Object> visit(OWLSymmetricObjectPropertyAxiom arg) {
InMemoryAtomSet body = arg.getProperty().accept(propertyVisitorXY);
InMemoryAtomSet head = arg.getProperty().accept(propertyVisitorYX);
return Collections.singleton(DefaultRuleFactory.instance().create(body, head));
}
use of fr.lirmm.graphik.graal.api.core.InMemoryAtomSet in project graal by graphik-team.
the class OWLAxiomParser method visit.
@Override
public Iterable<? extends Object> visit(OWLNegativeObjectPropertyAssertionAxiom arg) {
freeVarGen.setIndex(0);
Term a = GraalUtils.createTerm(arg.getSubject());
Term b = GraalUtils.createTerm(arg.getObject());
InMemoryAtomSet atomset = arg.getProperty().accept(new OWLPropertyExpressionVisitorImpl(a, b));
return Collections.singleton(new DefaultNegativeConstraint(atomset));
}
use of fr.lirmm.graphik.graal.api.core.InMemoryAtomSet in project graal by graphik-team.
the class OWLAxiomParser method visit.
@Override
public Iterable<? extends Object> visit(OWLTransitiveObjectPropertyAxiom arg) {
InMemoryAtomSet body = arg.getProperty().accept(propertyVisitorXY);
body.addAll(arg.getProperty().accept(propertyVisitorYZ));
InMemoryAtomSet head = arg.getProperty().accept(propertyVisitorXZ);
return Collections.singleton(DefaultRuleFactory.instance().create(body, head));
}
use of fr.lirmm.graphik.graal.api.core.InMemoryAtomSet in project graal by graphik-team.
the class OWLAxiomParser method disjointPropertiesAxiom.
private Iterable<? extends Object> disjointPropertiesAxiom(Iterable<? extends OWLPropertyExpression> properties) {
Collection<Rule> rules = GraalUtils.<Rule>createCollection();
InMemoryAtomSet a, a1, a2;
Iterator<? extends OWLPropertyExpression> it1, it2;
it1 = properties.iterator();
while (it1.hasNext()) {
OWLPropertyExpression propExpr = (OWLPropertyExpression) it1.next();
a1 = propExpr.accept(propertyVisitorXY);
it1.remove();
it2 = properties.iterator();
while (it2.hasNext()) {
OWLPropertyExpression next = (OWLPropertyExpression) it2.next();
a2 = next.accept(propertyVisitorXY);
a = GraalUtils.createAtomSet();
a.addAll(a1);
a.addAll(a2);
rules.add(new DefaultNegativeConstraint(a));
}
}
return rules;
}
Aggregations