Package edu.stanford.nlp.trees

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


    // TODO: I don't have an explanation for this, it was just stated
    // in Zhang & Clark 2009
    if (state.stack.size() > 0) {
      Tree top = state.stack.peek();
      // Temporary node, eg part of a binarized sequence
      if (top.label().value().startsWith("@") && top.children().length == 2 &&
          ShiftReduceUtils.getBinarySide(top) == BinaryTransition.Side.RIGHT) {
        return false;
      }
    }
View Full Code Here


          maxDepth = nodeDepth;
          if(node.isPhrasal() && stack.size() + 1 > maxBreadth) maxBreadth = stack.size() + 1;
        }

        if(node.isPhrasal()) {
          ocs.addPhrasalBranch(node.value(), node.children().length);
        } else if(node.isPreTerminal())
          ocs.posTags.incrementCount(node.value());
        else if(node.isLeaf()) {
          ocs.words.incrementCount(node.value());
          if(addToVocab) trainVocab.add(node.value());
View Full Code Here

          ocs.posTags.incrementCount(node.value());
        else if(node.isLeaf()) {
          ocs.words.incrementCount(node.value());
          if(addToVocab) trainVocab.add(node.value());
        }
        for(Tree kid : node.children())
          stack.push(new Pair<Integer,Tree>(nodeDepth + 1, kid));
      }
    }

    return new Pair<Integer,Integer>(maxDepth,maxBreadth);
View Full Code Here

          if (node==root) {
            return;
          }
          Tree parent = matcher.getParent(node);
          int i = parent.objectIndexOf(node);
          while (i == parent.children().length-1 && parent != root) {
            node = parent;
            parent = matcher.getParent(parent);
            i = parent.objectIndexOf(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

      return false;
    }
    if (top.label().value().startsWith("@") && !label.equals(top.label().value().substring(1))) {
      return false;
    }
    if (top.children().length == 1) {
      Tree child = top.children()[0];
      if (child.children().length == 1) {
        Tree grandChild = child.children()[0];
        if (grandChild.children().length == 1) {
          // Three consecutive unary trees.  Not legal to keep adding unaries.
View Full Code Here

    if (top.label().value().startsWith("@") && !label.equals(top.label().value().substring(1))) {
      return false;
    }
    if (top.children().length == 1) {
      Tree child = top.children()[0];
      if (child.children().length == 1) {
        Tree grandChild = child.children()[0];
        if (grandChild.children().length == 1) {
          // Three consecutive unary trees.  Not legal to keep adding unaries.
          // TODO: do preterminals count in that equation?
          return false;
View Full Code Here

    }
    if (top.children().length == 1) {
      Tree child = top.children()[0];
      if (child.children().length == 1) {
        Tree grandChild = child.children()[0];
        if (grandChild.children().length == 1) {
          // Three consecutive unary trees.  Not legal to keep adding unaries.
          // TODO: do preterminals count in that equation?
          return false;
        }
      }
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.