Package edu.stanford.nlp.trees

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


    // 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


    Tree tagNode = state.sentence.get(state.tokenPosition);
    if (!tagNode.isPreTerminal()) {
      throw new AssertionError("Only expected preterminal nodes");
    }
    Tree wordNode = tagNode.children()[0];
    String word = wordNode.label().value();
    return new State(state.stack.push(tagNode), state.transitions.push(this), state.separators, state.sentence, state.tokenPosition + 1, state.score + scoreDelta, false);
  }

  @Override
  public boolean equals(Object o) {
View Full Code Here

       if (theHead != null) {
         break;
       }
     }
     if (DEBUG) {
       System.err.println("  Chose " + theHead.label());
     }
     return theHead;
   }

}
View Full Code Here

  private void addFoundPair(Tree np1, Tree np2, Tree t,
      Set<Pair<Integer, Integer>> foundPairs) {
    Tree head1 = np1.headTerminal(headFinder);
    Tree head2 = np2.headTerminal(headFinder);
    int h1 = ((CoreMap) head1.label()).get(CoreAnnotations.IndexAnnotation.class) - 1;
    int h2 = ((CoreMap) head2.label()).get(CoreAnnotations.IndexAnnotation.class) - 1;
    Pair<Integer, Integer> p = new Pair<Integer, Integer>(h1, h2);
    foundPairs.add(p);
  }

  private static final TregexPattern appositionPattern = TregexPattern.compile("NP=m1 < (NP=m2 $.. (/,/ $.. NP=m3))");
View Full Code Here

    if (sameSentence) {
      Tree tree = m1.contextParseTree;
      Tree current = m1.mentionSubTree;
      current = current.parent(tree);
      while (current != null) {
        if (current.label().value().startsWith("S")) {
          for (Mention m : l) {
            if (!sorted.contains(m) && current.dominates(m.mentionSubTree)) {
              sorted.add(m);
            }
          }
View Full Code Here

      subtrees[i].label().setValue(Integer.toString(classLabel));
    }

    for (int i = 0; i < sentence.size(); ++i) {
      Tree leaf = subtrees[i].children()[0];
      leaf.label().setValue(escaper.escapeString(leaf.label().value()));
    }

    for (int i = 0; i < tregexPatterns.length; ++i) {
      root = Tsurgeon.processPattern(tregexPatterns[i], tsurgeonPatterns[i], root);
    }
View Full Code Here

      subtrees[i].label().setValue(Integer.toString(classLabel));
    }

    for (int i = 0; i < sentence.size(); ++i) {
      Tree leaf = subtrees[i].children()[0];
      leaf.label().setValue(escaper.escapeString(leaf.label().value()));
    }

    for (int i = 0; i < tregexPatterns.length; ++i) {
      root = Tsurgeon.processPattern(tregexPatterns[i], tsurgeonPatterns[i], root);
    }
View Full Code Here

    }
    List<Tree> newChildren = new ArrayList<Tree>();
    Tree[] children = tree.children();
    for (Tree child : children) {
      Tree newChild = flatten(child);
      if (!newChild.isPreTerminal() && newChild.label().toString().equals(tree.label().toString())) {
        newChildren.addAll(newChild.getChildrenAsList());
      } else {
        newChildren.add(newChild);
      }
    }
View Full Code Here

      t = getTreeFromXML(sentRoot);

      if(t != null) {
        t = treeNormalizer.normalizeWholeTree(t, treeFactory);

        if(t.label() instanceof CoreLabel)
          ((CoreLabel) t.label()).set(CoreAnnotations.SentenceIDAnnotation.class,
                                      Integer.toString(thisSentenceId));
      }
    }
    return t;
View Full Code Here

      if(t != null) {
        t = treeNormalizer.normalizeWholeTree(t, treeFactory);

        if(t.label() instanceof CoreLabel)
          ((CoreLabel) t.label()).set(CoreAnnotations.SentenceIDAnnotation.class,
                                      Integer.toString(thisSentenceId));
      }
    }
    return t;
  }
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.