Pep 0.4 API Documentation

edu.osu.ling.pep
Class ParseTree

java.lang.Object
  extended by edu.osu.ling.pep.ParseTree

public class ParseTree
extends Object

A parse tree that represents the derivation of a string based on the rules in a Grammar. Parse trees recursively contain other parse trees, so they can be iterated through to find the entire derivation of a category. A parse tree can also be traversed upward by calling getParent() for each successive parse tree until it returns null.

Parse trees are essentially partial views of a Chart from a given Edge or Category. They represent the completed categories at a given string index and origin position. The special Category.START category is not included in a parse tree at the root (only categories that are actually specified in the corresponding grammar are represented).

Since:
0.2
Version:
$LastChangedRevision: 1806 $
Author:
Scott Martin
See Also:
Parse.getParseTreesFor(Category, int, int)

Constructor Summary
ParseTree(Category node, ParseTree parent)
          Creates a new parse tree with the specified category and parent parse tree.
ParseTree(Category node, ParseTree parent, ParseTree[] children)
          Creates a new parse tree with the specified category, parent, and child trees.
 
Method Summary
 boolean equals(Object obj)
          Tests whether this parse tree is equal to another by comparing its node, parent, and child parse trees.
 ParseTree[] getChildren()
          Gets the child parse trees of this parse tree, retaining their linear ordering.
 Category getNode()
          Gets the node category of this parse tree.
 ParseTree getParent()
          Gets the parent parse tree, if any.
 int hashCode()
          Computes a hash code for this parse tree based on its underlying edge and child parse trees.
static ParseTree newParseTree(Edge edge)
          Creates a parse tree based on the specified edge that is the root of the resulting parse tree.
static ParseTree newParseTree(Edge edge, ParseTree parent)
          Creates a new parse tree based on the specified edge and parent tree.
 String toString()
          Gets a string representation of this parse tree.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ParseTree

public ParseTree(Category node,
                 ParseTree parent)
Creates a new parse tree with the specified category and parent parse tree.

See Also:
ParseTree(Category, ParseTree, ParseTree[])

ParseTree

public ParseTree(Category node,
                 ParseTree parent,
                 ParseTree[] children)
Creates a new parse tree with the specified category, parent, and child trees.

Parameters:
node - The category of the node of this parse tree.
parent - This parse tree's parent tree, or null if this parse tree is the root node.
children - The list of children of this parse tree, in their linear order.
Method Detail

equals

public boolean equals(Object obj)
Tests whether this parse tree is equal to another by comparing its node, parent, and child parse trees.

Overrides:
equals in class Object

getChildren

public ParseTree[] getChildren()
Gets the child parse trees of this parse tree, retaining their linear ordering.

Returns:
For a subtree NP -> Det N, returns an array that contains parse trees whose node is Det, N in that order, or null if this parse tree has no children.
Since:
0.4

getNode

public Category getNode()
Gets the node category of this parse tree.

Returns:
NP for a subtree NP -> Det N.

getParent

public ParseTree getParent()
Gets the parent parse tree, if any.

Returns:
A parse tree containing (for example) S -> NP VP if this parse tree's node is NP and is one of the children of S. If this parse tree is the root node in a series of parse trees, returns null.

hashCode

public int hashCode()
Computes a hash code for this parse tree based on its underlying edge and child parse trees.

Overrides:
hashCode in class Object

newParseTree

public static ParseTree newParseTree(Edge edge)
Creates a parse tree based on the specified edge that is the root of the resulting parse tree.

Parameters:
edge - The edge that is to be at the root of the parse tree.
Returns:
The result of calling newParseTree(Edge, ParseTree) with null as the argument for the parent parse tree.
Since:
0.4
See Also:
newParseTree(Edge, ParseTree)

newParseTree

public static ParseTree newParseTree(Edge edge,
                                     ParseTree parent)
Creates a new parse tree based on the specified edge and parent tree.

Parameters:
edge - The edge to use to create a parse tree. For a parse tree that is the root, this should be null.
parent - The parent tree of the new parse tree.
Returns:
A new parse tree whose node is the specified edge's dotted rule's left side and whose children are based on the bases of the specified edge.

toString

public String toString()
Gets a string representation of this parse tree.

Overrides:
toString in class Object
Returns:
For the string "the boy left", possibly something like:
[S[NP[Det[the]][N[boy]]][VP[left]]]
(The actual string would depend on the grammar rules in effect for the parse).

Pep: Pep is an Earley parser

Pep API Documentation, Copyright © 2007 Scott Martin

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the overview file.