Package edu.stanford.nlp.ling

Examples of edu.stanford.nlp.ling.Label


   * Return the value of the label (or null if none).
   *
   * @return String the value for the label
   */
  public String value() {
    Label lab = label();
    if (lab == null) {
      return null;
    }
    return lab.value();
  }
View Full Code Here


   * Set the value for the label (if one is stored).
   *
   * @param value The value for the label
   */
  public void setValue(String value) {
    Label lab = label();
    if (lab != null) {
      lab.setValue(value);
    }
  }
View Full Code Here

   *
   * @param labelStr the String that translates into the content of the
   *                 label
   */
  public void setFromString(String labelStr) {
    Label lab = label();
    if (lab != null) {
      lab.setFromString(labelStr);
    }
  }
View Full Code Here

       */
      private static final long serialVersionUID = -7250433816896327901L;

      public boolean accept(Tree t) {
        Tree[] kids = t.children();
        Label l = t.label();
        // The special Switchboard non-terminals clause.
        // Note that it deletes IP which other Treebanks might use!
        if ("RS".equals(t.label().value()) || "RM".equals(t.label().value()) || "IP".equals(t.label().value()) || "CODE".equals(t.label().value())) {
          return false;
        }
        if ((l != null) && l.value() != null && (l.value().equals("-NONE-")) && !t.isLeaf() && kids.length == 1 && kids[0].isLeaf()) {
          // Delete empty/trace nodes (ones marked '-NONE-')
          return false;
        }
        return true;
      }
View Full Code Here

    for (Tree subtree : treeCopy) {
      if (subtree.depth() < 2) {
        continue;
      }
      String categoryLabel = subtree.label().toString();
      Label label = subtree.label();
      label.setFromString(categoryLabel+"-t1");
    }
    return treeCopy;
  }
View Full Code Here

    for (Tree subtree : treeCopy) {
      if (subtree.depth() < 1) {
        continue;
      }
      String categoryLabel = subtree.label().toString();
      Label label = subtree.label();
      label.setFromString(categoryLabel+"-t2");
    }
    return treeCopy;
  }
View Full Code Here

    for (Tree subtree : treeCopy) {
      if (subtree.depth() < 2) {
        continue;
      }
      String categoryLabel = subtree.label().toString();
      Label label = subtree.label();
      label.setFromString(categoryLabel+"-t3");
    }
    return treeCopy;
  }
View Full Code Here

   *
   * @return The hash code
   */
  @Override
  public int hashCode() {
    Label l = label();
    int hc = (l == null) ? 1 : l.hashCode();
    Tree[] kids = children();
    for (int i = 0; i < kids.length; i++) {
      l = kids[i].label();
      int hc2 = (l == null) ? i : l.hashCode();
      hc ^= (hc2 << i);
    }
    return hc;
  }
View Full Code Here

        if (nodes == null) {
          nodes = StringUtils.getShortClassName(st);
        } else if ( ! nodes.equals(StringUtils.getShortClassName(st))) {
          nodes = "mixed";
        }
        Label lab = st.label();
        if (phraseLabels == null) {
          if (lab == null) {
            phraseLabels = "null";
          } else {
            phraseLabels = StringUtils.getShortClassName(lab);
          }
        } else if ( ! phraseLabels.equals(StringUtils.getShortClassName(lab))) {
          phraseLabels = "mixed";
        }
      } else if (st.isPreTerminal()) {
        if (nodes == null) {
          nodes = StringUtils.getShortClassName(st);
        } else if ( ! nodes.equals(StringUtils.getShortClassName(st))) {
          nodes = "mixed";
        }
        Label lab = st.label();
        if (tagLabels == null) {
          if (lab == null) {
            tagLabels = "null";
          } else {
            tagLabels = StringUtils.getShortClassName(lab);
          }
        } else if ( ! tagLabels.equals(StringUtils.getShortClassName(lab))) {
          tagLabels = "mixed";
        }
      } else if (st.isLeaf()) {
        if (leaves == null) {
          leaves = StringUtils.getShortClassName(st);
        } else if ( ! leaves.equals(StringUtils.getShortClassName(st))) {
          leaves = "mixed";
        }
        Label lab = st.label();
        if (leafLabels == null) {
          if (lab == null) {
            leafLabels = "null";
          } else {
            leafLabels = StringUtils.getShortClassName(lab);
View Full Code Here

   * @param pw     The PrintWriter to print the tree to
   * @param printScores Whether to print the scores (log probs) of tree nodes
   */
  private void indentedListPrint(String indent, String pad, PrintWriter pw, boolean printScores) {
    StringBuilder sb = new StringBuilder(indent);
    Label label = label();
    if (label != null) {
      sb.append(label.toString());
    }
    if (printScores) {
      sb.append("  ");
      sb.append(score());
    }
View Full Code Here

TOP

Related Classes of edu.stanford.nlp.ling.Label

Copyright © 2018 www.massapicom. 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.