use of fr.lirmm.graphik.graal.api.core.unifier.DependencyChecker in project graal by graphik-team.
the class UnifierIterator method extendUnifier.
private Collection<Substitution> extendUnifier(Rule rule, Queue<Atom> atomset, Atom pieceElement, Unifier unifier) {
atomset.remove(pieceElement);
unifier.queryPiece.add(pieceElement);
Collection<Substitution> unifierCollection = new LinkedList<Substitution>();
Set<Variable> frontierVars = rule.getFrontier();
Set<Variable> existentialVars = rule.getExistentials();
CloseableIteratorWithoutException<Atom> it = rule.getHead().iterator();
while (it.hasNext()) {
Atom atom = it.next();
Substitution u = unifier(unifier.s, pieceElement, atom, frontierVars, existentialVars);
if (u != null) {
unifier = new Unifier(unifier);
unifier.ruleHeadPiece.add(atom);
unifier.s = u;
// look if there exist other element for the current piece
Atom nextPieceElement = getNextPieceElementIfExist(u, atomset, existentialVars);
if (nextPieceElement == null) {
boolean check = true;
for (DependencyChecker c : this.checkers) {
check &= c.isValidDependency(this.source, this.target, unifier.s);
}
if (check) {
unifierCollection.add(unifier.s);
}
} else {
unifierCollection.addAll(extendUnifier(rule, new LinkedList<Atom>(atomset), nextPieceElement, unifier));
}
}
}
return unifierCollection;
}
Aggregations