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

edu.stanford.nlp.trees.TreeGraphNodeFactory Maven / Gradle / Ivy

Go to download

Stanford Parser processes raw text in English, Chinese, German, Arabic, and French, and extracts constituency parse trees.

There is a newer version: 3.9.2
Show newest version
package edu.stanford.nlp.trees;

import edu.stanford.nlp.ling.Label;
import edu.stanford.nlp.ling.LabelFactory;
import edu.stanford.nlp.ling.CoreLabel;

import java.util.List;


/**
 * A TreeGraphNodeFactory acts as a factory for creating
 * nodes in a {@link TreeGraph TreeGraph}.  Unless
 * another {@link LabelFactory LabelFactory} is
 * supplied, it will use a CoreLabelFactory
 * by default.
 *
 * @author Bill MacCartney
 */
public class TreeGraphNodeFactory implements TreeFactory {

  private LabelFactory mlf;

  /**
   * Make a TreeFactory that produces
   * TreeGraphNodes.  The labels are of class
   * CoreLabel.
   */
  public TreeGraphNodeFactory() {
    this(CoreLabel.factory());
  }

  public TreeGraphNodeFactory(LabelFactory mlf) {
    this.mlf = mlf;
  }

  // docs inherited
  public Tree newLeaf(final String word) {
    return newLeaf(mlf.newLabel(word));
  }

  // docs inherited
  public Tree newLeaf(Label label) {
    return new TreeGraphNode(label);
  }

  // docs inherited
  public Tree newTreeNode(final String parent, final List children) {
    return newTreeNode(mlf.newLabel(parent), children);
  }

  // docs inherited
  public Tree newTreeNode(Label parentLabel, List children) {
    return new TreeGraphNode(parentLabel, children);
  }

}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy