Examples of CTNode


Examples of com.clearnlp.constituent.CTNode

 
  /** Fixes illegal PROs. */
  private void fixIllegalPROs(PBInstance instance)
  {
    CTTree tree = instance.getTree();
    CTNode node;
   
    for (PBArg arg : instance.getArgs())
    {
      if (arg.isLabel(PBLib.PB_REL))  continue;
     
      for (PBLoc loc : arg.getLocs())
      {
        if (loc.terminalId > instance.predId)
        {
          node = tree.getNode(loc);
         
          if (node.isEmptyCategoryRec() && node.hasFTag(CTLibEn.FTAG_SBJ) && node.getParent().isPTag(CTLibEn.PTAG_S))
            loc.height++;
        }
      }
    }
  }
View Full Code Here

Examples of com.clearnlp.constituent.CTNode

   * PRE: {@link PBInstance#sortArgs()} is called.
   */
  private void getLinks(PBInstance instance)
  {
    CTTree tree = instance.getTree();
    CTNode node, link;
    List<PBArg> lLinks = new ArrayList<PBArg>();
    PBLoc loc; int i;
   
    for (PBArg arg : instance.getArgs())
    {
      if (arg.label.startsWith("LINK"))
        lLinks.add(arg);
     
      for (i=arg.getLocSize()-1; i>0; i--)
      {
        loc  = arg.getLoc(i);
        node = tree.getNode(loc);
       
        if (node.pTag.startsWith("WH"))
        {
          link = CTLibEn.getComplementizer(node);

          if (link.getAntecedent() == null)
          {
            link.setAntecedent(tree.getNode(arg.getLoc(i-1)));
            break;
          }
        }
        else if (CTLibEn.isComplementizer(node))
        {
          if (node.getAntecedent() == null)
          {
            node.setAntecedent(tree.getNode(arg.getLoc(i-1)));
            break;
          }
        }
        else if (node.isEmptyCategoryRec() && loc.isType("*"))
        {
          link = node.getFirstTerminal();
         
          if (link.getAntecedent() == null)
            link.setAntecedent(tree.getNode(arg.getLoc(i-1)));
        }
      }
View Full Code Here

Examples of com.clearnlp.constituent.CTNode

   */
  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(), ";"));
            }
          }
View Full Code Here

Examples of com.clearnlp.constituent.CTNode

  }
 
  /** Called by {@link PBLibEn#normalizeLinks(CTTree, PBArg, int)}. */
  private CTNode getCoIndexedWHNode(CTNode node)
  {
    CTNode parent = node.getParent();
   
    while (parent != null)
    {
      if (!parent.pTag.startsWith("WH"))
        break;
     
      if (parent.coIndex != -1)
        return parent;
     
      parent = parent.getParent();
    }
   
    return null;
  }
View Full Code Here

Examples of com.clearnlp.constituent.CTNode

  }
 
  private void addLinks(PBInstance instance)
  {
    CTTree tree = instance.getTree();
    CTNode node, comp, ante = null;
    String label;
    List<PBArg> lAdd = new ArrayList<PBArg>();
    PBArg nArg;
   
    for (PBArg arg : instance.getArgs())
    {
      for (PBLoc loc : arg.getLocs())
      {
        node  = tree.getNode(loc);
        label = null;
       
        if (node.pTag.startsWith("WH"))
        {
          if ((comp = CTLibEn.getComplementizer(node)) != null && (ante = comp.getAntecedent()) != null)
            label = PBLib.PB_LINK_SLC;
        }
        else if (node.isEmptyCategory())
        {
          if ((ante = node.getAntecedent()) != null)
          {
            if (node.form.equals(CTLibEn.EC_NULL))
              label = PBLib.PB_LINK_PSV;
            else if (node.form.equals(CTLibEn.EC_PRO))
              label = PBLib.PB_LINK_PRO;
          }
        }
       
        if (label != null)
        {
          nArg = new PBArg();
          nArg.label = label;
          nArg.addLoc(new PBLoc(ante.getPBLoc(), ""));
          nArg.addLoc(new PBLoc(node.getPBLoc(), "*"));
         
          lAdd.add(nArg);
        }
      }
    }
 
View Full Code Here

Examples of com.clearnlp.constituent.CTNode

  }
 
  private void raiseEmptyArguments(PBInstance instance)
  {
    CTTree tree = instance.getTree();
    CTNode node, parent;
    int i, size;
    PBLoc loc;
   
    for (PBArg arg : instance.getArgs())
    {
      if (arg.isLabel(PBLib.PB_REL))  continue;
      size = arg.getLocSize();
     
      for (i=0; i<size; i++)
      {
        loc  = arg.getLoc(i);
        node = tree.getNode(loc);
        parent = node.getParent();
       
        if (parent != null && !parent.isPTag(CTLib.PTAG_TOP) && parent.getChildrenSize() == 1)
          node = parent;
       
        loc.set(node.getPBLoc(), loc.type);
      }
    }
  }
View Full Code Here

Examples of com.clearnlp.constituent.CTNode

  }
 
  private PBArg getArgDSP(PBInstance instance)
  {
    CTTree tree = instance.getTree();
    CTNode pred = tree.getTerminal(instance.predId);
    Pair<CTNode,CTNode> pair = getESMPair(pred);
    if (pair == nullreturn null;
   
    Pair<PBArg,IntOpenHashSet> max = new Pair<PBArg,IntOpenHashSet>(null, new IntOpenHashSet());
    IntOpenHashSet set;
    CTNode prn = pair.o1;
    CTNode esm = pair.o2;
   
    for (PBArg arg : instance.getArgs())
    {
      if (!PBLib.isNumberedArgument(arg) || arg.isLabel(PBLib.PB_ARG0))
        continue;
     
      set = arg.getTerminalIdSet(tree);
     
      if (set.contains(esm.getTerminalId()))
      {
        max.set(arg, set);
        break;
      }
     
      if (arg.hasType(",") && max.o2.size() < set.size())
        max.set(arg, set);
    }
   
    if (max.o1 == nullreturn null;
    CTNode dsp = esm.getAntecedent();
    if (dsp == nulldsp = prn.getNearestAncestor("+S.*");
   
    if (dsp != null)
    {
      PBArg arg = new PBArg();
      arg.addLoc(dsp.getPBLoc());
      arg.label = max.o1.label+"-"+PBLib.PB_DSP;
      instance.removeArgs(max.o1.label);
     
      return arg;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.