Package com.clearnlp.constituent

Examples of com.clearnlp.constituent.CTNode


  void printTreesForCKY(String[] args)
  {
    CTReader reader = new CTReader(UTInput.createBufferedFileReader(args[0]));
    PrintStream fout = UTOutput.createPrintBufferedFileStream(args[1]);
    CTTree tree;
    CTNode root;
    int count;
   
    while ((tree = reader.nextTree()) != null)
    {
      root = tree.getRoot();
     
      if (root.getChildrenSize() == 1)
      {
        count = stripPunct(tree);
       
        if (root.getChildrenSize() > 0 && tree.getTokens().size()-count >= 4 && !containsEmptyCategories(tree) && isCKYTree(root.getChild(0)))
          fout.println(tree+"\n");
      }
    }
   
    reader.close();
View Full Code Here


  void printTreesForCKY(String[] args)
  {
    CTReader reader = new CTReader(UTInput.createBufferedFileReader(args[0]));
    PrintStream fout = UTOutput.createPrintBufferedFileStream(args[1]);
    CTTree tree;
    CTNode root;
    int count;
   
    while ((tree = reader.nextTree()) != null)
    {
      root = tree.getRoot();
     
      if (root.getChildrenSize() == 1)
      {
        count = stripPunct(tree);
       
        if (root.getChildrenSize() > 0 && tree.getTokens().size()-count >= 4 && !containsEmptyCategories(tree) && isCKYTree(root.getChild(0)))
          fout.println(tree+"\n");
      }
    }
   
    reader.close();
View Full Code Here

  }
 
  /** Called by {@link EnglishC2DConverter#mapEmtpyCategories(CTTree)}. */
  private void mapPRO(CTTree cTree, CTNode ec)
  {
    CTNode np = ec.getParent();
    CTNode vp = np.getParent().getFirstChainedDescendant(CTLibEn.PTAG_VP);
   
    if (vp == null)                // small clauses
      relocatePRD(np, ec);
    else
    {
      CTNode ante;
     
      if ((ante = ec.getAntecedent()) != null && ante.pTag.startsWith("WH"))  // relative clauses
      {
        if (cTree.getCoIndexedEmptyCategories(ante.coIndex).size() == 1)
          mapTrace(cTree, ec);
View Full Code Here

  }
 
  /** Called by {@link EnglishC2DConverter#mapEmtpyCategories(CTTree)}. */
  private void mapTrace(CTTree cTree, CTNode ec)
  {
    CTNode ante = ec.getAntecedent();
   
    if (ante == null || ec.isDescendantOf(ante))
      removeCTNode(ec);
    else if (ante.hasFTag(CTLibEn.FTAG_TPC))
    {
      if (!ante.hasFTag(CTLibEn.FTAG_SBJ))
      {
        CTNode parent = ec.getParent();
        parent.removeChild(ec);
        replaceEC(parent, ante);
      }
      else
        removeCTNode(ec);
    }
    else  // relative clauses
    {
      CTNode parent = ante.getHighestChainedAncestor(CTLibEn.PTAG_SBAR);
      if (parent != null)    parent.addFTag(DEPLibEn.DEP_RCMOD);
      replaceEC(ec, ante);
    }
  }
View Full Code Here

  }
 
  /** Called by {@link EnglishC2DConverter#mapEmtpyCategories(CTTree)}. */
  private void mapNull(CTTree cTree, CTNode ec)
  {
    CTNode np = ec.getParent();
   
    if (np.hasFTag(CTLibEn.FTAG_SBJ))
    {
      // small clauses
      if (np.getNextSibling(CTLibEn.PTAG_VP) == null)
        relocatePRD(np, ec);
      else
        addXSubject(ec, m_xsbj);
    }
  }
View Full Code Here

  }
 
  /** Called by {@link EnglishC2DConverter#mapEmtpyCategories(CTTree)}. */
  private void mapICH(CTTree cTree, CTNode ec)
  {
    CTNode parent = ec.getParent();
    CTNode ante   = ec.getAntecedent();
   
    if (ec.form.startsWith(CTLibEn.EC_ICH) && parent.getPrevSibling("+WH.*") != null)
      removeCTNode(ec);
    else if (ante == null || ec.isDescendantOf(ante))
      removeCTNode(ec);
    else
    {
      List<CTNode> list = cTree.getCoIndexedEmptyCategories(ante.coIndex);
      boolean isRNR = ec.form.startsWith(CTLibEn.EC_RNR);
      int i, size = list.size();
      CTNode node;
     
      Deque<CTNode> dq = isRNR ? new ArrayDeque<CTNode>() : null;
     
      if (ec.getTerminalId() < ante.getFirstTerminal().getTerminalId())
      {   
        for (i=0; i<size-1; i++)
        {
          node = list.get(i);
          if (isRNRdq.addLast(node.getParent().getParent());
          removeCTNode(node);
        }
       
        ec = list.get(size-1);
      }
      else
      {
        for (i=size-1; i>0; i--)
        {
          node = list.get(i);
          if (isRNRdq.addFirst(node.getParent().getParent());
          removeCTNode(node);
        }
       
        ec = list.get(0);
      }
View Full Code Here

  }
 
  /** Called by {@link EnglishC2DConverter#mapPRO(CTTree, CTNode)} and {@link EnglishC2DConverter#mapNull(CTTree, CTNode)}. */
  private void relocatePRD(CTNode np, CTNode ec)
  {
    CTNode s   = np.getParent();
    CTNode prd = s.getFirstChild("-"+CTLibEn.FTAG_PRD);
    Set<String> fTags = s.getFTags();
   
    if (prd != null && (fTags.isEmpty() || fTags.contains(CTLibEn.FTAG_CLR)))
    {
      fTags.clear();
View Full Code Here

   * @param ec empty subject.
   * @param map key: antecedent, value: list of clauses containing empty subjects.
   */
  private void addXSubject(CTNode ec, Map<CTNode, Deque<CTNode>> map)
  {
    CTNode ante = ec.getAntecedent();
   
    while (ante != null && ante.isEmptyCategoryRec() && !ante.pTag.startsWith("WH"))
      ante = ante.getFirstTerminal().getAntecedent();
   
    if (ante != null)
    {
      CTNode s = ec.getNearestAncestor(CTLibEn.PTAG_S);
     
      if (s != null)
      {
        Deque<CTNode> dq = map.get(ante);
        if (dq == nulldq = new ArrayDeque<CTNode>();
View Full Code Here

    }
  }
 
  private void removeCTNode(CTNode node)
  {
    CTNode parent = node.getParent();
 
    if (parent != null)
    {
      parent.removeChild(node);
     
      if (parent.getChildrenSize() == 0)
        removeCTNode(parent);     
    }
  }
View Full Code Here

   
    findHyphens(curr);
    findHeadsApposition(curr);
    findHeadsSmallClause(curr);

    CTNode head = getHead(rule, curr.getChildren(), SIZE_HEAD_FLAGS);
    if (head.c2d.getLabel() != nullhead.c2d.setLabel(null);
    curr.c2d = new C2DInfo(head);
  }
View Full Code Here

TOP

Related Classes of com.clearnlp.constituent.CTNode

Copyright © 2018 www.massapicom. 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.