Package edu.stanford.nlp.ling

Examples of edu.stanford.nlp.ling.Label


  }

  protected TreeFactory tf = new LabeledScoredTreeFactory();

  public Tree transformTree(Tree tree) {
    Label l = tree.label();
    if (tree.isLeaf()) {
      return tf.newLeaf(l);
    }
    String s = l.value();
    s = tlpp.treebankLanguagePack().basicCategory(s);
    if (deletePunct) {
      // this is broken as it's not the right thing to do when there
      // is any tag ambiguity -- and there is for ' (POS/'').  Sentences
      // can then have more or less words.  It's also unnecessary for EVALB,
View Full Code Here


    private static final long serialVersionUID = 8914098359495987617L;

    /** Doesn't accept nodes that only cover an empty. */
    public boolean test(Tree t) {
      Tree[] kids = t.children();
      Label l = t.label();
      if ((l != null) && l.value() != null && // there appears to be a mistake in CTB3 where the label "-NONE-1" is used once
              // presumably it should be "-NONE-" and be spliced out here.
              (l.value().matches("-NONE-.*")) && !t.isLeaf() && kids.length == 1 && kids[0].isLeaf()) {
        // Delete empty/trace nodes (ones marked '-NONE-')
        if ( ! l.value().equals("-NONE-")) {
          EncodingPrintWriter.err.println("Deleting errant node " + l.value() + " as if -NONE-: " + t, ChineseTreebankLanguagePack.ENCODING);
        }
        return false;
      }
      return true;
    }
View Full Code Here

    public boolean accept(Dependency<Label, Label, Object> d) {
      if (d == null) {
        return false;
      }
      Label lab = d.dependent();
      if (lab == null) {
        return false;
      }
      return npf.accept(lab.value());
    }
View Full Code Here

      if (d == null) return false;

      TreeGraphNode s = d.dep();
      if (s == null) return false;

      Label l = s.label();
      if (l == null) return false;

      return npf.accept(l.value());
    }
View Full Code Here

  private boolean hasVerbalAuxiliary(Tree[] kids, HashSet<String> verbalSet) {

    for (Tree kid : kids) {

      Label kidLabel = kid.label();

      String cat = tlp.basicCategory(kidLabel.value());
      String word = null;
      if (kidLabel instanceof HasWord) {
        word = ((HasWord) kidLabel).word();
      }
      if (word == null) {
        Label htl = kid.headTerminal(this).label();
        if (htl instanceof HasWord) {
          word = ((HasWord) htl).word();
        }
        if (word == null) {
          word = htl.value();
        }
      }

      String tag = null;
      if (kidLabel instanceof HasTag) {
View Full Code Here

    private static final long serialVersionUID = 8914098359495987617L;

    /** Doesn't accept nodes that only cover an empty. */
    public boolean accept(Tree t) {
      Tree[] kids = t.children();
      Label l = t.label();
      // Delete (return false for) empty/trace nodes (ones marked '-NONE-')
      return ! ((l != null) && "-NONE-".equals(l.value()) && !t.isLeaf() && kids.length == 1 && kids[0].isLeaf());
    }
View Full Code Here

          numNonPhrasal++;
        }
        starts.incrementCount(t2.value());
      }
      for (Tree subtree : t) {
        Label lab = subtree.label();
        if (lab == null || lab.value() == null || "".equals(lab.value())) {
          if (numNullLabel == 0) {
            nullLabelEg = subtree;
          }
          numNullLabel++;
          if (lab == null) {
            subtree.setLabel(new StringLabel(""));
          } else if (lab.value() == null) {
            subtree.label().setValue("");
          }
        }
        if (subtree.isLeaf()) {
          numWords++;
View Full Code Here

   * @return The full string representation.
   */
  @Override
  public String toString() {
    StringBuffer sb;
    Label lab = label();
    if (lab != null) {
      sb = new StringBuffer(lab.toString());
    } else {
      sb = new StringBuffer();
    }
    sb.append("(").append(start()).append(",").append(end()).append(")");
    return sb.toString();
View Full Code Here

      Constituent c = (Constituent) obj;
      // System.out.println("Comparing " + this + " to " + c + "\n  " +
      //  "start: " + (start() == c.start()) + " end: " +
      //  (end() == c.end()) + " score: " + (score() == c.score()));
      if ((start() == c.start()) && (end() == c.end())) {
        Label lab1 = label();
        Label lab2 = c.label();
        if (lab1 == null) {
          return lab2 == null;
        }
        return lab1.equals(lab2);
      }
View Full Code Here

   * @return the integer hashCode
   */
  @Override
  public int hashCode() {
    int hash = (start() << 16) | end();
    Label lab = label();
    return lab == null ? hash : hash ^ lab.hashCode();
  }
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.