Package edu.stanford.nlp.trees

Examples of edu.stanford.nlp.trees.Tree.children()


      } else if (conjoinedList.size() == 1) {
        conjoinedLabels = conjoinedList.iterator().next();
      } else {
        return transformTree(t.children()[0]);
      }
      children = tree.children();
      Label label = t.label().labelFactory().newLabel(conjoinedLabels);
      Tree[] transformedChildren = new Tree[children.length];
      for (int childIndex = 0; childIndex < children.length; childIndex++) {
        Tree child = children[childIndex];
        transformedChildren[childIndex] = transformTree(child);
View Full Code Here


      if(mwCounter == null)
        throw new RuntimeException("Cannot enable POSSequence features without POS sequence map. Use option -frenchMWMap.");

      Tree t = m.getMatch();
      StringBuilder sb = new StringBuilder();
      for(Tree kid : t.children()) {
        if( ! kid.isPreTerminal())
          throw new RuntimeException("Not POS sequence for tree: " + t.toString());
        String tag = doBasicCat ? tlp.basicCategory(kid.value()) : kid.value();
        sb.append(tag).append(" ");
      }
View Full Code Here

      // other children are kept in an outer list, with the new node
      // added at the appropriate location.
      List<Tree> children = Generics.newArrayList();
      List<Tree> innerChildren = Generics.newArrayList();
      boolean insideSpan = false;
      for (Tree child : parent.children()) {
        if (child == startChild || child == endChild) {
          if (!insideSpan && startChild != endChild) {
            insideSpan = true;
            innerChildren.add(child);
          } else {
View Full Code Here

  @Override
  public Tree normalizeWholeTree(Tree tree, TreeFactory tf) {
    Tree newTree = tree.prune(chineseEmptyFilter, tf).spliceOut(aOverAFilter);

    // Report non-unary initial rewrites & fix 'obvious ones'
    Tree[] kids = newTree.children();
    if (kids.length > 1) {
    /* -------------- don't do this as probably shouldn't for test set (and doesn't help anyway)
      if (kids.length == 2 &&
          "PU".equals(kids[kids.length - 1].value()) &&
          kids[0].isPhrasal()) {
View Full Code Here

          if (node==root) {
            return;
          }
          Tree parent = node.parent(root);
          int i = parent.indexOf(node);
          while (i == parent.children().length-1 && parent != root) {
            node = parent;
            parent = parent.parent(root);
            i = parent.indexOf(node);
          }
          Tree followingNode;
View Full Code Here

            }
            if (pathMatchesNode(followingNode)) {
              initializeHelper(stack, followingNode, root);
            }
            if (! followingNode.isLeaf()) {
              followingNode = followingNode.children()[0];
            } else {
              followingNode = null;
            }
          }
        }
View Full Code Here

            }
            if (pathMatchesNode(precedingNode)) {
              initializeHelper(stack, precedingNode, root);
            }
            if (! precedingNode.isLeaf()) {
              precedingNode = precedingNode.children()[0];
            } else {
              precedingNode = null;
            }
          }
        }
View Full Code Here

  private static Tree pruneHelper(Tree root, Tree nodeToPrune) {
    if(nodeToPrune==root)
      return null;
    Tree parent = nodeToPrune.parent(root);
    parent.removeChild(Trees.objectEqualityIndexOf(parent,nodeToPrune));
    if(parent.children().length==0)
      return pruneHelper(root,parent);
    return root;
  }
}
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.