All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.stanford.nlp.ling.CategoryWordTagFactory Maven / Gradle / Ivy

Go to download

Stanford CoreNLP provides a set of natural language analysis tools which can take raw English language text input and give the base forms of words, their parts of speech, whether they are names of companies, people, etc., normalize dates, times, and numeric quantities, mark up the structure of sentences in terms of phrases and word dependencies, and indicate which noun phrases refer to the same entities. It provides the foundational building blocks for higher level text understanding applications.

There is a newer version: 4.5.7
Show newest version
package edu.stanford.nlp.ling;


/**
 * A CategoryWordTagFactory is a factory that makes
 * a Label which is a CategoryWordTag triplet.
 *
 * @author Christopher Manning
 */
public class CategoryWordTagFactory implements LabelFactory {

  /**
   * Make a new label with this String as the "name".
   *
   * @param labelStr The string to use as a label
   * @return The newly created Label
   */
  public Label newLabel(String labelStr) {
    return new CategoryWordTag(labelStr);
  }

  /**
   * Make a new label with this String as the value.
   * This implementation ignores the options
   *
   * @param labelStr The String that will be used for balue
   * @param options  This argument is ignored
   * @return The newly created Label
   */
  public Label newLabel(String labelStr, int options) {
    return new CategoryWordTag(labelStr);
  }

  /**
   * Make a new label with this String as the "name".
   *
   * @param labelStr The string to use as a label
   * @return The newly created Label
   */
  public Label newLabelFromString(String labelStr) {
    CategoryWordTag cwt = new CategoryWordTag();
    cwt.setFromString(labelStr);
    return cwt;
  }

  /**
   * Create a new CategoryWordTag label, where the label is formed from
   * the various String objects passed in.
   *
   * @param word     The word part of the label
   * @param tag      The tag part of the label
   * @param category The category part of the label
   * @return The newly created Label
   */
  public Label newLabel(String word, String tag, String category) {
    // System.out.println("Making new CWT label: " + category + " | " +
    //		   word + " | " + tag);
    return new CategoryWordTag(category, word, tag);
  }

  /**
   * Create a new CategoryWordTag Label, where the label is
   * formed from
   * the Label object passed in.  Depending on what fields
   * each label has, other things will be null.
   *
   * @param oldLabel The Label that the new label is being created from
   * @return a new label of a particular type
   */
  public Label newLabel(Label oldLabel) {
    return new CategoryWordTag(oldLabel);
  }

}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy