Package edu.stanford.nlp.trees

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


      Tree parent = parents.get(enclosingS0)// cannot be root
      while (spansEqual(parent, enclosingS0)) { // in case we had missed unary transitions
        enclosingS0 = parent;
        parent = parents.get(parent);
      }
      if (parent.children()[0] == enclosingS0) { // S0 is the left child of the correct tree
        return new OracleTransition(new ShiftTransition(), false, false, false);
      }
      // was the second (right) child.  there must be something else on the stack...
      Tree S1 = state.stack.pop().peek();
      Tree enclosingS1 = getEnclosingTree(S1, parents, leaves);
View Full Code Here


    if (!spansEqual(S0, enclosingS0)) {
      return null;
    }

    Tree parent = parents.get(enclosingS0);
    if (parent == null || parent.children().length != 1) {
      return null;
    }

    // TODO: should we allow @ here?  Handle @ in some other way?
    String value = S0.value();
View Full Code Here

      while (true) {
        enclosingS0 = parent;
        parent = parents.get(enclosingS0);
        if (enclosingS0.value().equals(value)) {
          // We found the current stack top in the unary sequence ...
          if (parent == null || parent.children().length > 1) {
            // ... however, it was the root or the top of the unary sequence
            return null;
          } else {
            // ... not root or top of unary sequence, so create unary transitions based on this top
            break;
View Full Code Here

          // We went to the root without finding a match.
          // Treat the root as the unary transition to be made
          // TODO: correct logic?
          parent = enclosingS0;
          break;
        } else if (parent.children().length > 1) {
          // We went off the top of the unary chain without finding a match.
          // Transition to the top of the unary chain without any subnodes
          parent = enclosingS0;
          break;
        }
View Full Code Here

    }


    if (compoundUnaries) {
      List<String> labels = Generics.newArrayList();
      while (parent != null && parent.children().length == 1) {
        labels.add(parent.value());
        parent = parents.get(parent);
      }
      Collections.reverse(labels);
      return new OracleTransition(new CompoundUnaryTransition(labels, false), false, false, false);
View Full Code Here

        newChildren.add(preTerms.getFirst());
        preTerms.removeFirst();
      }
      Tree newChild = transformNode(child, tf);
      LinkedList<Tree> temp = new LinkedList<Tree>();
      if (newChild.children().length > 0) {
        newChildren.add(newChild);
      }
      while (!preTerms.isEmpty() && isPunc(preTerms.getLast())) {
        temp.addFirst(preTerms.getLast());
        preTerms.removeLast();
View Full Code Here

        System.err.println("Excising...original tree:");
        tree.pennPrint(System.err);
        System.err.println("top: " + topNode + "\nbottom:" + bottomNode);
      }
      if (topNode == tree) {
        if (bottomNode.children().length == 1) {
          return bottomNode.children()[0];
        } else {
          return null;
        }
      }
View Full Code Here

        tree.pennPrint(System.err);
        System.err.println("top: " + topNode + "\nbottom:" + bottomNode);
      }
      if (topNode == tree) {
        if (bottomNode.children().length == 1) {
          return bottomNode.children()[0];
        } else {
          return null;
        }
      }
      Tree parent = topNode.parent(tree);
View Full Code Here

        }
        return t.treeFactory().newTreeNode(label, Arrays.asList(transformedChildren));
      }
      Tree tree = t;
      List<String> conjoinedList = new ArrayList<String>();
      while (tree.children().length == 1 && !tree.isPrePreTerminal()) {
        String nodeString = tree.label().value();
        if (!nodeString.startsWith("@")) {
          conjoinedList.add(nodeString);
        }
        tree = tree.children()[0];
View Full Code Here

      while (tree.children().length == 1 && !tree.isPrePreTerminal()) {
        String nodeString = tree.label().value();
        if (!nodeString.startsWith("@")) {
          conjoinedList.add(nodeString);
        }
        tree = tree.children()[0];
      }
      String nodeString = tree.label().value();
      if (!nodeString.startsWith("@")) {
        conjoinedList.add(nodeString);
      }
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.