candidateHeads = negHeads;
} else {
candidateHeads = posHeads;
}
AtomicSentence nearAtom = nearLiteral.getAtomicSentence();
String nearestKey = nearAtom.getSymbolicName();
List<Chain> farParents = candidateHeads.get(nearestKey);
if (null != farParents) {
Chain farParent = farParents.get(farParentIndex);
standardizeApart(farParent);
Literal farLiteral = farParent.getHead();
AtomicSentence farAtom = farLiteral.getAtomicSentence();
Map<Variable, Term> subst = unifier.unify(nearAtom, farAtom);
// If I was able to unify with one
// of the far heads
if (null != subst) {
// Want to always apply reduction uniformly
Chain topChain = farParent;
Literal botLit = nearLiteral;
Chain botChain = nearParent;
// Need to apply subst to all of the
// literals in the reduction
List<Literal> reduction = new ArrayList<Literal>();
for (Literal l : topChain.getTail()) {
AtomicSentence atom = (AtomicSentence) substVisitor.subst(
subst, l.getAtomicSentence());
reduction.add(l.newInstance(atom));
}
reduction.add(new ReducedLiteral((AtomicSentence) substVisitor
.subst(subst, botLit.getAtomicSentence()), botLit
.isNegativeLiteral()));
for (Literal l : botChain.getTail()) {
AtomicSentence atom = (AtomicSentence) substVisitor.subst(
subst, l.getAtomicSentence());
reduction.add(l.newInstance(atom));
}
nnpc = new Chain(reduction);