Package edu.stanford.nlp.ling

Examples of edu.stanford.nlp.ling.Label


      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;
        }

        String lv1 = lab1.value();
        String lv2 = lab2.value();
        if (lv1 == null && lv2 == null) {
          return true;
        }
        if (lv1  != null && lv2 != null) {
          return lab1.value().equals(lab2.value());
        }
      }
    }
    return false;
  }
View Full Code Here


   * @return the integer hashCode
   */
  @Override
  public int hashCode() {
    int hash = (start() << 16) | end();
    Label lab = label();
    return (lab == null || lab.value() == null) ? hash : hash ^ lab.value().hashCode();
  }
View Full Code Here

   * 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

   *
   * @param tree The tree node
   * @return The vector (distributed representation) of the given tree
   */
  public static SimpleMatrix getNodeVector(Tree tree) {
    Label label = tree.label();
    if (!(label instanceof CoreLabel)) {
      throw new IllegalArgumentException("CoreLabels required to get the attached node vector");
    }
    return ((CoreLabel) label).get(NodeVector.class);
  }
View Full Code Here

      return SimpleMatrix.class;
    }
  }

  public static SimpleMatrix getPredictions(Tree tree) {
    Label label = tree.label();
    if (!(label instanceof CoreLabel)) {
      throw new IllegalArgumentException("CoreLabels required to get the attached predictions");
    }
    return ((CoreLabel) label).get(Predictions.class);
  }
View Full Code Here

      return Integer.class;
    }
  }

  public static int getPredictedClass(Tree tree) {
    Label label = tree.label();
    if (!(label instanceof CoreLabel)) {
      throw new IllegalArgumentException("CoreLabels required to get the attached predicted class");
    }
    return ((CoreLabel) label).get(PredictedClass.class);
  }
View Full Code Here

      return Integer.class;
    }
  }

  public static int getGoldClass(Tree tree) {
    Label label = tree.label();
    if (!(label instanceof CoreLabel)) {
      throw new IllegalArgumentException("CoreLabels required to get the attached gold class");
    }
    return ((CoreLabel) label).get(GoldClass.class);
  }
View Full Code Here

    }
    return ((CoreLabel) label).get(GoldClass.class);
  }

  public static void setGoldClass(Tree tree, int goldClass) {
    Label label = tree.label();
    if (!(label instanceof CoreLabel)) {
      throw new IllegalArgumentException("CoreLabels required to set the attached gold class");
    }
    ((CoreLabel) label).set(GoldClass.class, goldClass);
  }
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.