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

edu.stanford.nlp.trees.PennTreeReaderFactory 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.trees;

import java.io.Reader;

/** Vends {@link PennTreeReader} objects.
 *
 *  @author Roger Levy ([email protected])
 */
public class PennTreeReaderFactory implements TreeReaderFactory {

  private final TreeFactory tf;
  private final TreeNormalizer tn;

  /**
   * Default constructor; uses a {@link LabeledScoredTreeFactory},
   * with StringLabels, a {@link PennTreebankTokenizer},
   * and a {@link TreeNormalizer}.
   */
  public PennTreeReaderFactory() {
    this(new LabeledScoredTreeFactory());
  }

  /**
   * Specify your own {@link TreeFactory};
   * uses a {@link PennTreebankTokenizer}, and a {@link TreeNormalizer}.
   *
   * @param tf The TreeFactory to use in building Tree objects to return.
   */
  public PennTreeReaderFactory(TreeFactory tf) {
    this(tf, new TreeNormalizer());
  }


  /**
   * Specify your own {@link TreeNormalizer};
   * uses a {@link PennTreebankTokenizer}, and a {@link LabeledScoredTreeFactory}.
   *
   * @param tn The TreeNormalizer to use in building Tree objects to return.
   */
  public PennTreeReaderFactory(TreeNormalizer tn) {
    this(new LabeledScoredTreeFactory(), tn);
  }


  /**
   * Specify your own {@link TreeFactory};
   * uses a {@link PennTreebankTokenizer}, and a {@link TreeNormalizer}.
   *
   * @param tf The TreeFactory to use in building Tree objects to return.
   * @param tn The TreeNormalizer to use
   */
  public PennTreeReaderFactory(TreeFactory tf, TreeNormalizer tn) {
    this.tf = tf;
    this.tn = tn;
  }


  @Override
  public TreeReader newTreeReader(Reader in) {
    return new PennTreeReader(in, tf, tn, new PennTreebankTokenizer(in));
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy