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

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

package edu.stanford.nlp.trees;

import edu.stanford.nlp.ling.Label;

import java.util.List;

/**
 * A TreeFactory acts as a factory for creating objects of
 * class Tree, or some descendant class.
 * Methods implementing this interface may assume that the List
 * of children passed to them is a list that actually contains trees, but
 * this can't be enforced in Java without polymorphic types.
 * The methods with a String argument do not guarantee
 * that the tree label() will be a String -- the TreeFactory may
 * convert it into some other type.
 *
 * @author Christopher Manning
 * @version 2000/12/20
 */
public interface TreeFactory {

  /**
   * Create a new tree leaf node, where the label is formed from
   * the String passed in.
   *
   * @param word The word that will go into the tree label.
   * @return The new leaf
   */
  public Tree newLeaf(String word);


  /**
   * Create a new tree non-leaf node, where the label is formed from
   * the String passed in.
   *
   * @param parent   The string that will go into the parent tree label.
   * @param children The list of daughters of this tree.  The children
   *                 may be a (possibly empty) List of children or
   *                 null
   * @return The new interior tree node
   */
  public Tree newTreeNode(String parent, List children);


  /**
   * Create a new tree leaf node, with the given label.
   *
   * @param label The label for the leaf node
   * @return The new leaf
   */
  public Tree newLeaf(Label label);


  /**
   * Create a new tree non-leaf node, with the given label.
   *
   * @param label    The label for the parent tree node.
   * @param children The list of daughters of this tree.  The children
   *                 may be a (possibly empty) List of children or
   *                 null
   * @return The new interior tree node
   */
  public Tree newTreeNode(Label label, List children);

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy