}
static public void relinkRelativeClause(SRLTree sTree)
{
DEPNode pred = sTree.getPredicate();
DEPArc ref = null;
DEPNode dep, arg;
for (DEPArc arc : pred.getDependents())
{
dep = arc.getNode();
if (dep.containsSHead(pred, P_ARG_REF))
{
ref = arc;
break;
}
}
for (SRLArc sArc : sTree.getArguments())
{
arg = sArc.getNode();
for (DEPArc dArc : arg.getDependents())
{
dep = dArc.getNode();
if (dep == pred || pred.isDescendentOf(dep))
{
arg.removeDependent(dArc);
dep.setHead(arg.getHead(), arg.getLabel());
if (ref != null) // && ref.isLabel(SRLLib.S_PREFIX_REFERENT+arg.getLabel())
{
DEPNode rDep = ref.getNode();
DEPArc rHead = rDep.getSHead(pred);
DEPArc whose = rDep.getAnyDescendentArcByPOS(CTLibEn.POS_WPS);
if (whose != null)
{
DEPNode tmp = whose.getNode();
arg.setHead(tmp.getHead(), tmp.getLabel());
arg.id = tmp.id;
whose.setNode(arg);
rHead.setLabel(sArc.getLabel());
arg.removeSHead(pred);
tmp = arg.getLastNode();
tmp.form = LGLibEn.getPossessiveForm(tmp.form);
}
else if (ref.isLabel(DEPLibEn.DEP_PREP))
{
DEPArc tmp = new DEPArc(arg, DEPLibEn.DEP_POBJ);
arg.setHead(rDep, tmp.getLabel());
arg.id = rDep.id + 1;
rDep.clearDependents();
rDep.addDependent(tmp);
rHead.setLabel(sArc.getLabel());
arg.removeSHead(pred);
}
else if (ref.isLabel(DEPLibEn.P_SBJ))
{
arg.setHead(pred, ref.getLabel());
arg.id = rDep.id;
ref.setNode(arg);
rHead.setLabel(sArc.getLabel());
}
else
{
DEPArc tmp = new DEPArc(arg, ref.getLabel());
arg.setHead(pred, tmp.getLabel());
arg.id = pred.id + 1;
if (ref.isLabel(DEPLibEn.P_OBJ) || ref.isLabel(DEPLibEn.DEP_ATTR))
pred.addDependentRightNextToSelf(tmp);
else
pred.addDependent(tmp);
pred.removeDependent(ref);
}
}
else
{
DEPArc tmp = new DEPArc(arg, DEPLibEn.DEP_DEP);
arg.setHead(pred, tmp.getLabel());
arg.id = pred.id + 1;
if (sArc.isLabel(PBLib.P_ARGN))
pred.addDependentRightNextToSelf(tmp);
else