edu.stanford.nlp.trees
Class TreeReader

java.lang.Object
  |
  +--edu.stanford.nlp.trees.TreeReader

public final class TreeReader
extends Object

A TreeReader adds functionality to another Reader by reading in Trees, or some descendant class. Like other standard classes, this class does not provide buffering, so for high performance, a typical invocation of TreeReader would be something like: TreeReader tr = new TreeReader(new BufferedReader(new FileReader(file)), myTreeFactory);


Constructor Summary
TreeReader(Reader in)
          Read parse trees from a Reader.
TreeReader(Reader in, TreeFactory tf)
          Read parse trees from a Reader
TreeReader(Reader in, TreeFactory tf, TreeNormalizer tn)
          Read parse trees from a Reader
TreeReader(Reader in, TreeFactory tf, TreeNormalizer tn, StreamTokenizer st)
          Read parse trees from a stream
 
Method Summary
 void close()
          Close the Reader behind this TreeReader
static void main(String[] args)
          Loads treebank data from first argument and prints it.
 Tree readTree()
          Returns a single tree, which is in standard Penn Treebank format, with or without an additional set of parens around it (an unnamed ROOT node).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeReader

public TreeReader(Reader in)
Read parse trees from a Reader. For the defaulted arguments, you get a SimpleTreeFactory, no TreeNormalizer, and a PennTreebankStreamTokenizer.

Parameters:
in - the Reader

TreeReader

public TreeReader(Reader in,
                  TreeFactory tf)
Read parse trees from a Reader

Parameters:
in - the Reader
tf - TreeFactory -- factory to create some kind of Tree

TreeReader

public TreeReader(Reader in,
                  TreeFactory tf,
                  TreeNormalizer tn)
Read parse trees from a Reader

Parameters:
in - input stream
tf - TreeFactory -- factory to create some kind of Tree
tn - the method of normalizing trees

TreeReader

public TreeReader(Reader in,
                  TreeFactory tf,
                  TreeNormalizer tn,
                  StreamTokenizer st)
Read parse trees from a stream

Parameters:
in - input stream
tf - TreeFactory -- factory to create some kind of Tree
tn - the method of normalizing trees
st - StreamTokenizer that divides up InputStream
Method Detail

readTree

public Tree readTree()
              throws IOException
Returns a single tree, which is in standard Penn Treebank format, with or without an additional set of parens around it (an unnamed ROOT node). Returns null at end of file.

IOException

close

public void close()
           throws IOException
Close the Reader behind this TreeReader

IOException

main

public static void main(String[] args)
Loads treebank data from first argument and prints it.

Parameters:
args - array of command-line arguments


Stanford NLP Group