private void normalizeLinks(PBInstance instance)
{
List<PBLoc> lDel = new ArrayList<PBLoc>();
CTTree tree = instance.getTree();
CTNode curr, node, ante;
PBLoc cLoc; int i;
List<CTNode> list;
CTNode pred = tree.getTerminal(instance.predId);
for (PBArg arg : instance.getArgs())
{
if (arg.isLabel(PBLib.PB_REL)) continue;
lDel.clear();
for (i=0; i<arg.getLocSize(); i++) // size() gets changed dynamically
{
cLoc = arg.getLoc(i);
curr = tree.getNode(cLoc);
if (CTLibEn.isComplementizer(curr))
{
if ((ante = curr.getAntecedent()) != null)
arg.addLoc(new PBLoc(ante.getPBLoc(), "*"));
if ((node = getCoIndexedWHNode(curr)) != null)
cLoc.set(node.getPBLoc(), "*");
}
else if (curr.pTag.startsWith("WH"))
{
if ((node = CTLibEn.getComplementizer(curr)) != null && (ante = node.getAntecedent()) != null)
arg.addLoc(new PBLoc(ante.getPBLoc(), "*"));
}
else if (curr.isEmptyCategoryRec()) // *T*, *
{
cLoc.height = 0;
node = tree.getTerminal(cLoc.terminalId);
if ((ante = node.getAntecedent()) != null)
arg.addLoc(new PBLoc(ante.getPBLoc(), "*"));
}
else if (!(list = curr.getIncludedEmptyCategory("\\*(ICH|RNR)\\*.*")).isEmpty())
{
for (CTNode ec : list)
{
lDel.add(new PBLoc(ec.getPBLoc(), ""));
if ((ante = ec.getAntecedent()) != null)
{
if (ante.isDescendantOf(curr) || pred.isDescendantOf(ante))
lDel.add(new PBLoc(ante.getPBLoc(), ""));
else
arg.addLoc(new PBLoc(ante.getPBLoc(), ";"));
}
}
}
else if (curr.isPTag(CTLibEn.PTAG_S) && (node = curr.getFirstChild("-"+CTLibEn.FTAG_SBJ)) != null && node.isEmptyCategoryRec() && curr.containsTags(CTLibEn.PTAG_VP))
{
node = node.getFirstTerminal();
if (CTLibEn.RE_NULL.matcher(node.form).find() && (ante = node.getAntecedent()) != null && ante.hasFTag(CTLibEn.FTAG_SBJ) && !ante.isEmptyCategoryRec() && !existsLoc(instance, ante.getPBLoc()))
arg.addLoc(new PBLoc(ante.getPBLoc(), "*"));
}
}
// removes errorneous arguments
for (PBLoc rLoc : lDel)