use of fr.lirmm.graphik.graal.api.core.ConjunctiveQueryWithNegatedParts in project graal by graphik-team.
the class RestrictedChaseRuleApplier method apply.
// /////////////////////////////////////////////////////////////////////////
// PUBLIC METHODS
// /////////////////////////////////////////////////////////////////////////
@Override
public boolean apply(Rule rule, T atomSet) throws RuleApplicationException {
try {
boolean res = false;
ConjunctiveQueryWithNegatedParts query = new RuleWrapper2ConjunctiveQueryWithNegatedParts(rule);
CloseableIterator<Substitution> results;
results = SmartHomomorphism.instance().execute(query, atomSet);
while (results.hasNext()) {
res = true;
Substitution proj = results.next();
// replace variables by fresh symbol
for (Variable t : rule.getExistentials()) {
proj.put(t, atomSet.getFreshSymbolGenerator().getFreshSymbol());
}
CloseableIteratorWithoutException<Atom> it = proj.createImageOf(rule.getHead()).iterator();
while (it.hasNext()) {
atomSet.add(it.next());
}
}
return res;
} catch (HomomorphismException e) {
throw new RuleApplicationException("", e);
} catch (AtomSetException e) {
throw new RuleApplicationException("", e);
} catch (IteratorException e) {
throw new RuleApplicationException("", e);
}
}
use of fr.lirmm.graphik.graal.api.core.ConjunctiveQueryWithNegatedParts in project graal by graphik-team.
the class RestrictedChaseRuleApplier method delegatedApply.
@Override
public CloseableIterator<Atom> delegatedApply(Rule rule, T atomSet) throws RuleApplicationException {
try {
ConjunctiveQueryWithNegatedParts query = new RuleWrapper2ConjunctiveQueryWithNegatedParts(rule);
CloseableIterator<Substitution> results = SmartHomomorphism.instance().execute(query, atomSet);
return new RuleApplierIterator(results, rule, atomSet);
} catch (HomomorphismException e) {
throw new RuleApplicationException("", e);
}
}
Aggregations