Examples of CTNode


Examples of com.clearnlp.constituent.CTNode

  }
 
  // KAIST
  private String getSpecialLabel(CTNode C)
  {
    CTNode d = C.c2d.getDependencyHead();
   
    if (CTLibKaist.isPunctuation(C) || CTLibKaist.isPunctuation(d))
      return DEPLibKr.DEP_PUNCT;
   
    if (CTLibKaist.isOnlyEJX(C, DELIM_PLUS))
View Full Code Here

Examples of com.clearnlp.constituent.CTNode

  /** Adds dependency heads. */
  private void addDEPHeads(DEPTree dTree, CTTree cTree)
  {
    int currId, headId, size = dTree.size(), rootCount = 0;
    DEPNode dNode;
    CTNode cNode;
    String label;
   
    for (currId=1; currId<size; currId++)
    {
      dNode  = dTree.get(currId);
View Full Code Here

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

Examples of com.clearnlp.constituent.CTNode

  {
    if (instances == nullreturn;
    initPBArgs(cTree.getRoot());
    int    predTokenId;
    String label;
    CTNode cNode;
   
    for (PBInstance instance : instances)
    {
      if (isPBSkip(instance, cTree))  continue;
      predTokenId = cTree.getTerminal(instance.predId).getTokenId() + 1;
     
      for (PBArg arg : instance.getArgs())
      {
        if (arg.label.startsWith(PBLib.PB_LINK))
          continue;
       
        if (arg.label.endsWith("UNDEF"))
          continue;
       
        label = arg.isLabel(PBLib.PB_REL) ? PBLib.PB_C_V : "A"+arg.label.substring(3);
       
        for (PBLoc loc : arg.getLocs())
        {
          if (arg.isLabel(PBLib.PB_REL) && loc.terminalId == instance.predId)
            continue;
         
          cNode = cTree.getNode(loc);
         
          if (!cNode.isEmptyCategoryRec())
            cNode.pbArgs.add(new StringIntPair(label, predTokenId));
        }
      }
    }
  }
View Full Code Here

Examples of com.clearnlp.constituent.CTNode

    return null;
  }
 
  private Pair<CTNode,CTNode> getESMPair(CTNode pred)
  {
    CTNode s = pred.getNearestAncestor("+S.*");
   
    if (s != null && s.getParent().isPTag(CTLibEn.PTAG_PRN))
    {
      CTNode next = pred.getNextSibling("+S|SBAR");
     
      if (next != null)
      {
        CTNode ec = getESM(next);
        if (ec != nullreturn new Pair<CTNode,CTNode>(s.getParent(), ec);
      }
    }
   
    return null;
View Full Code Here

Examples of com.clearnlp.constituent.CTNode

      return getESMAux(node);
    else if (node.isPTag(CTLibEn.PTAG_SBAR))
    {
      if (node.getChildrenSize() == 2)
      {
        CTNode fst = node.getChild(0);
        CTNode snd = node.getChild(1);
       
        if (fst.isEmptyCategory() && fst.form.equals(CTLibEn.EC_ZERO))
          return getESMAux(snd);
      }
    }
View Full Code Here

Examples of com.clearnlp.constituent.CTNode

 
  private CTNode getESMAux(CTNode node)
  {
    if (node.isEmptyCategoryRec())
    {
      CTNode ec = node.getFirstTerminal();
     
      if (ec != null && (ec.form.startsWith(CTLibEn.EC_TRACE) || ec.form.startsWith(CTLibEn.EC_ESM)))
        return ec;
    }
   
View Full Code Here

Examples of com.clearnlp.constituent.CTNode

    String[] tmp = P_UNDER.split(loc);
    int treeId = Integer.parseInt(tmp[0]);
    int terminalId = Integer.parseInt(tmp[1]);
    CTTree tree = trees.get(treeId);
    List<CTNode> terminals = tree.getTerminals();
    CTNode node = tree.getTerminal(terminalId);
   
    if (isFirst)
    {
      int size = terminals.size();
     
      while (node.isEmptyCategory())
      {
        if (terminalId+1 < size)
          node = terminals.get(++terminalId);
        else
          return null;
     
    }
    else
    {
      while (node.isEmptyCategory())
      {
        if (terminalId-1 >= 0)
          node = terminals.get(--terminalId);
        else
          return null;
      }
    }
   
    return new IntIntPair(treeId, node.getTokenId());
  }
View Full Code Here

Examples of com.clearnlp.constituent.CTNode

  private void joinConcatenations(PBInstance instance)
  {
    SortedIntArrayList ids = new SortedIntArrayList();
    CTTree tree = instance.getTree();
    int terminalId, height;
    CTNode node, parent;
    List<PBLoc> lNew;
   
    for (PBArg arg : instance.getArgs())
    {
      if (arg.isLabel(PBLib.PB_REL))  continue;
      ids.clear();
     
      for (PBLoc loc : arg.getLocs())
      {
        if (!loc.isType("") && !loc.isType(","))  return;
        if (loc.height > 0)              return;
        ids.add(loc.terminalId);
      }
     
      lNew = new ArrayList<PBLoc>();
     
      while (!ids.isEmpty())
      {
        terminalId = ids.get(0);
        height     = 0;
        node       = tree.getNode(terminalId, height);
       
        while ((parent = node.getParent()) != null && !parent.isPTag(CTLib.PTAG_TOP) && UTHppc.isSubset(ids, parent.getSubTerminalIdSet()))
        {
          node = parent;
          height++;
        }
       
        lNew.add(new PBLoc(terminalId, height, ","));
        ids.removeAll(node.getSubTerminalIdSet());
      }
     
      if (lNew.size() < arg.getLocSize())
      {
        lNew.get(0).type = "";
View Full Code Here

Examples of com.clearnlp.constituent.CTNode

  private void fixCyclicLocs(PBInstance instance)
  {
    CTTree  tree  = instance.getTree();
    int    predId = instance.predId;
    boolean isCyc = false;
    CTNode  node, tmp;
   
    StringBuilder build = new StringBuilder();
    build.append(ERR_CYCLIC);
   
    for (PBArg arg : instance.getArgs())
    {
      if (arg.isLabel(PBLib.PB_REL))  continue;
     
      for (PBLoc loc : arg.getLocs())
      {
        if ((node = tree.getNode(loc)).getSubTerminalIdSet().contains(predId))
        {
          if (arg.isLabel(PBLib.PB_ARGM_MOD))
            loc.height = 0;
          else if (arg.isLabel(PBLib.PB_LINK_SLC) && node.isPTag(CTLibEn.PTAG_SBAR) && (tmp = node.getFirstChild("+WH.*")) != null)
            loc.set(tmp.getPBLoc(), loc.type);
          else if (node.isPTag(CTLibEn.PTAG_NP) && (tmp = node.getChild(0)).isPTag(CTLibEn.PTAG_NP) && !tmp.getSubTerminalIdSet().contains(predId))
            loc.height--;
          else
          {
            build.append(":");
            build.append(arg.label);
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.