edu.upenn.cis.spinal
Class AbstractWalker

java.lang.Object
  extended by edu.upenn.cis.spinal.AbstractWalker
Direct Known Subclasses:
EchoWalker, GraphvizWalker

public abstract class AbstractWalker
extends Object

Inherit from this abstract class to create standalone command-line applications that operate on a file containing an LTAG-spinal annotated sentence or sentences. See the other XYZWalker classes in this packages for examples. All inherited classes should include the following method:

 
 public static void main(String argv[]) {
      new XYZWalker().process(argv);
 }
 

Author:
Lucas Champollion

Field Summary
protected  String[] args
          Contains the arguments that have been passed to process(String[]).
protected  boolean terminate
          Indicates whether terminate() has been called.
 
Constructor Summary
AbstractWalker()
           
 
Method Summary
abstract  void forEachSentence(Sentence t)
          Implementations of this method should specify what the class should do on reading in a sentence (a derivation tree) from the file.
protected  String[] getArgs()
          Returns the string array of arguments that has been passed to process(String[]).
protected abstract  void init()
          Implementations of this method should specify what (if anything) the class should do before attempting to read in a file.
protected abstract  void printUsage()
          Implementations of this method should print out a short string to stdout describing the function of the class.
protected  void process(String[] args)
          This method calls init(), then opens a file in LTAG-spinal format using the first element of the args array as the filename, and reads in elementary trees from that file.
protected  void terminate()
          Call this method from within forEachSentence(Sentence) to instruct process(String[]) to skip any remaining sentences.
protected abstract  void wrapUp()
          Implementations of this method should specify what (if anything) the class should do upon reading all sentences from the file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

args

protected String[] args
Contains the arguments that have been passed to process(String[]).


terminate

protected boolean terminate
Indicates whether terminate() has been called.

Constructor Detail

AbstractWalker

public AbstractWalker()
Method Detail

getArgs

protected String[] getArgs()
Returns the string array of arguments that has been passed to process(String[]).

Returns:
the arguments

terminate

protected void terminate()
Call this method from within forEachSentence(Sentence) to instruct process(String[]) to skip any remaining sentences. process(String[]) will still call wrapUp() even after this method is invoked.


process

protected void process(String[] args)
This method calls init(), then opens a file in LTAG-spinal format using the first element of the args array as the filename, and reads in elementary trees from that file. On each of these trees, it calls forEachSentence(Sentence). When terminate() is called or the end of the file is reached, the method calls wrapUp().

Parameters:
args - an array of arguments. The first of them is used as a filename to indicate the location of the file containing LTAG-spinal annotation.

init

protected abstract void init()
Implementations of this method should specify what (if anything) the class should do before attempting to read in a file.


forEachSentence

public abstract void forEachSentence(Sentence t)
Implementations of this method should specify what the class should do on reading in a sentence (a derivation tree) from the file.

Parameters:
t - the current Sentence object

wrapUp

protected abstract void wrapUp()
Implementations of this method should specify what (if anything) the class should do upon reading all sentences from the file. The process(String[]) method also calls this if terminate() has been invoked.


printUsage

protected abstract void printUsage()
Implementations of this method should print out a short string to stdout describing the function of the class. This method is automatically called by process(String[]) when no command-line argument is passed.