Package edu.stanford.nlp.trees

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


        if(mention.mentionSubTree==null) {
          // mentionSubTree = highest NP that has the same head
          Tree headTree = tree.getLeaves().get(mention.headIndex);
          if (headTree == null) { throw new RuntimeException("Missing head tree for a mention!"); }
          Tree t = headTree;
          while ((t = t.parent(tree)) != null) {
            if (t.headTerminal(headFinder) == headTree && t.value().equals("NP")) {
              mention.mentionSubTree = t;
            } else if(mention.mentionSubTree != null){
              break;
            }
View Full Code Here


  private static List<Mention> sortMentionsForPronoun(List<Mention> l, Mention m1, boolean sameSentence) {
    List<Mention> sorted = new ArrayList<Mention>();
    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

            if (!sorted.contains(m) && current.dominates(m.mentionSubTree)) {
              sorted.add(m);
            }
          }
        }
        current = current.parent(tree);
      }
      if (SieveCoreferenceSystem.logger.isLoggable(Level.FINEST)) {
        if (l.size()!=sorted.size()) {
          SieveCoreferenceSystem.logger.finest("sorting failed!!! -> parser error?? \tmentionID: "+m1.mentionID+" " + m1.spanToString());
          sorted = l;
View Full Code Here

        newIndex = Integer.parseInt(m.group(1))-1;
        parent = relativeNode;
        if(relation.charAt(1)=='-') // backwards.
          newIndex = parent.children().length - newIndex;
      } else {
        parent = relativeNode.parent(tree);
        if (parent == null) {
          throw new RuntimeException("Error: looking for a non-existent parent in tree " + tree + " for \"" + toString() + "\"");
        }
        int index = parent.objectIndexOf(relativeNode);
        if (relation.equals("$+")) {
View Full Code Here

          }
          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;
          if (i+1 < parent.children().length) {
            followingNode = parent.children()[i+1];
View Full Code Here

          }
          Tree parent = node.parent(root);
          int i = parent.indexOf(node);
          while (i == 0 && parent != root) {
            node = parent;
            parent = parent.parent(root);
            i = parent.indexOf(node);
          }
          Tree precedingNode;
          if (i > 0) {
            precedingNode = parent.children()[i-1];
View Full Code Here

      newIndex = Integer.parseInt(m.group(1))-1;
      parent = relativeNode;
      if(relation.charAt(1)=='-') // backwards.
        newIndex = parent.children().length - newIndex;
    } else {
      parent = relativeNode.parent(t);
      if (parent == null) {
        throw new RuntimeException("Error: looking for a non-existent parent in tree " + t + " for \"" + toString() + "\"");
      }
      int index = parent.indexOf(relativeNode);
      if (relation.equals("$+")) {
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.