se.lth.cs.nlp.nlputils.pstree
Class PSTree

java.lang.Object
  extended by se.lth.cs.nlp.nlputils.pstree.PSTree

public class PSTree
extends Object

A phrase structure tree.

Author:
Richard Johansson (richard@cs.lth.se)

Field Summary
 ArrayList<Node> heads
          The heads.
 ArrayList<Node> nodes
          The nodes.
 ArrayList<TokenNode> tokens
          The tokens.
 Node topnode
          The top node.
 
Constructor Summary
PSTree()
           
 
Method Summary
static PSTree collinsTree(String line)
          Creates a parse tree from a string containing a tree in Collins' format, that is a phrase structure tree with heads.
 int countEndPunc(Node n)
          Returns the number of punctuation tokens that the node n ends with.
static PSTree pennTree(String line)
          Creates a parse tree from a string containing a tree in the Penn Treebank format.
static PSTree pennTreeWithLemmas(String line)
          Creates a parse tree from a string containing a tree in the Penn Treebank format with lemmas.
 String tabbedOutput()
          Returns an indented string representing this tree.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

topnode

public Node topnode
The top node.


tokens

public ArrayList<TokenNode> tokens
The tokens.


heads

public ArrayList<Node> heads
The heads.


nodes

public ArrayList<Node> nodes
The nodes.

Constructor Detail

PSTree

PSTree()
Method Detail

collinsTree

public static PSTree collinsTree(String line)
Creates a parse tree from a string containing a tree in Collins' format, that is a phrase structure tree with heads.

Parameters:
line - the string.
Returns:
the constructed tree.

pennTree

public static PSTree pennTree(String line)
Creates a parse tree from a string containing a tree in the Penn Treebank format. Uses Collins' head finder to find the heads.

Parameters:
line - the string.
Returns:
the constructed tree.

pennTreeWithLemmas

public static PSTree pennTreeWithLemmas(String line)
Creates a parse tree from a string containing a tree in the Penn Treebank format with lemmas. Uses Collins' head finder to find the heads.

Parameters:
line - the string.
Returns:
the constructed tree.

toString

public String toString()
Overrides:
toString in class Object

countEndPunc

public int countEndPunc(Node n)
Returns the number of punctuation tokens that the node n ends with.

Parameters:
n - the node.
Returns:
the number of punctuation tokens.

tabbedOutput

public String tabbedOutput()
Returns an indented string representing this tree.

Returns:
the indented string.