org.annotation.wordfreak.annotator
Class Annotator

java.lang.Object
  extended byorg.annotation.wordfreak.annotator.Annotator
All Implemented Interfaces:
java.awt.event.ActionListener, AnnotatedFileListener, java.util.EventListener, Plugin
Direct Known Subclasses:
DocumentProcessor, RegExAnnotator

public abstract class Annotator
extends java.lang.Object
implements Plugin, java.awt.event.ActionListener, AnnotatedFileListener

This is the top level class for automatic annotators or taggers. It primarily provides routines to collect data which is sent to methods of classes extending this class and implementing or overriding it methods.


Field Summary
protected  AnnotationFilter annotationFilter
          The filter that should be used during annotation so as to only change existing annotations which meet the filter criteria.
protected  java.lang.String dataDirectory
          Directory where models that this annotator might require would be found.
static java.lang.String DEFAULT_ANNOTATOR_NAME
           
protected  java.util.List files
          List of AnnotationFile objects currently loaded.
protected  GuiListener guiListener
          This variable is assigned a value when this annotator is attached to a gui.
protected  java.util.List listeners
          List of AnnotatorListener objects to be notified of annotator changes.
protected  boolean loaded
          Indicates whether or not the the annotator is ready to be run.
protected  double progress
          Double between 0 and 100 indicating progress in annotation.
protected  AnnotationFilter trainingFilter
          The filter that should be used during training so as to only use existing annotations which meet the filter criteria for training.
 
Constructor Summary
Annotator(java.lang.String type)
           
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent evt)
           
 void addAnnotatorListener(AnnotatorListener annotatorListener)
          Registers the specified annotator listener for notification from this annotator.
 void annotate()
          Creates a progress bar and then annotates all the loaded files with this annotator.
 void annotatedFile(AnnotationFile f)
          Selects annotations from f required for annotator.
abstract  void annotating()
          Applies the appropiate annotation actions to each loaded annotation file.
 void closeAnnotatedFile(AnnotationFile f)
          Notifies the listener that the specified file was closed.
protected  void done()
          This method is called by the annotator when annotating is complete.
 java.lang.String getDataDirectory()
          Returns the current directory used for storing data needed by the annotator.
protected  void hideWaitDialog(javax.swing.JDialog dialog)
          Hides the wait-for-tagger-to-load dialog.
abstract  boolean loadAnnotator()
          Loads the annotator.
 boolean loaded()
          Returns whether the annotator is ready to be run.
 void removeAnnotatorListener(AnnotatorListener annotatorListener)
          Un-registers the specified annotator listener from notification from this annotator.
 void setAnnotationFilter(AnnotationFilter af)
           
 void setDataDirectory(java.lang.String dir)
          Designates the directory used for storing data needed by the annotator.
 void setGuiListener(GuiListener gl)
           
protected  void setProgress(double progress)
          Explicitly sets the amount of progress that the annotator has made.
 void setTrainingFilter(AnnotationFilter af)
           
protected  javax.swing.JDialog showWaitDialog()
          Displays waiting-for-tagger-to-load dialog.
 java.lang.String[] sortedOutcomes(Annotation a)
          Returns a sorted version of the possible outcomes.
 boolean supportsTraining()
          Specifies whether or not this annotator suports training.
 void train(java.lang.String[] paths)
          Trains the annotator on the files in paths.
protected  void training(java.lang.String[] paths)
           
protected  void updateProgress(double additionalProgress)
          Indicates that the specified amount of additional progress has been made.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ANNOTATOR_NAME

public static final java.lang.String DEFAULT_ANNOTATOR_NAME
See Also:
Constant Field Values

guiListener

protected GuiListener guiListener
This variable is assigned a value when this annotator is attached to a gui. It's non-null value is typically used to determine if users should be notified of lengthy task.


progress

protected double progress
Double between 0 and 100 indicating progress in annotation.


loaded

protected boolean loaded
Indicates whether or not the the annotator is ready to be run.


dataDirectory

protected java.lang.String dataDirectory
Directory where models that this annotator might require would be found. The exact semantics of this variable is left to the descresion of the implementor.


annotationFilter

protected AnnotationFilter annotationFilter
The filter that should be used during annotation so as to only change existing annotations which meet the filter criteria. How best to use this filter is left to the descretion of the annotators implementor.


trainingFilter

protected AnnotationFilter trainingFilter
The filter that should be used during training so as to only use existing annotations which meet the filter criteria for training. How best to use this filter is left to the descretion of the annotators implementor.


files

protected java.util.List files
List of AnnotationFile objects currently loaded.


listeners

protected java.util.List listeners
List of AnnotatorListener objects to be notified of annotator changes.

Constructor Detail

Annotator

public Annotator(java.lang.String type)
Method Detail

addAnnotatorListener

public void addAnnotatorListener(AnnotatorListener annotatorListener)
Registers the specified annotator listener for notification from this annotator.

Parameters:
annotatorListener - The listener to be registered for notification.

removeAnnotatorListener

public void removeAnnotatorListener(AnnotatorListener annotatorListener)
Un-registers the specified annotator listener from notification from this annotator.

Parameters:
annotatorListener - The listener to be un-registered from notification.

supportsTraining

public boolean supportsTraining()
Specifies whether or not this annotator suports training.

Returns:
true if this annotator supports training, false otherwise.

annotate

public void annotate()
Creates a progress bar and then annotates all the loaded files with this annotator. Annotation is done by calling the annotating method, followed by the done method.


updateProgress

protected void updateProgress(double additionalProgress)
Indicates that the specified amount of additional progress has been made.

Parameters:
additionalProgress - The addition progress that an annotator has made.

setProgress

protected void setProgress(double progress)
Explicitly sets the amount of progress that the annotator has made. Use updateProgress when possible.

Parameters:
progress - The amount of progress that the annotaotr has made.
See Also:
updateProgress(double)

done

protected void done()
This method is called by the annotator when annotating is complete.


annotating

public abstract void annotating()
Applies the appropiate annotation actions to each loaded annotation file. progressInt should be updated to indicate annotation progress.


train

public void train(java.lang.String[] paths)
Trains the annotator on the files in paths.


training

protected void training(java.lang.String[] paths)

loadAnnotator

public abstract boolean loadAnnotator()
Loads the annotator.


loaded

public boolean loaded()
Returns whether the annotator is ready to be run.

Returns:
true when this annotator can be run, false otherwise.

getDataDirectory

public java.lang.String getDataDirectory()
Returns the current directory used for storing data needed by the annotator.


showWaitDialog

protected javax.swing.JDialog showWaitDialog()
Displays waiting-for-tagger-to-load dialog.

Returns:
the dialog window created. This need to be passed to the hideWaitDialog method.

hideWaitDialog

protected void hideWaitDialog(javax.swing.JDialog dialog)
Hides the wait-for-tagger-to-load dialog.

Parameters:
dialog - The dialog to be hidden. This was returned by showWaitDialog.

setDataDirectory

public void setDataDirectory(java.lang.String dir)
Designates the directory used for storing data needed by the annotator.


sortedOutcomes

public java.lang.String[] sortedOutcomes(Annotation a)
Returns a sorted version of the possible outcomes. Presumably the most likely outcomes are placed first which can help the annotator if a large number of outcomes is to be considered.

Returns:
a sorted array of outcomes with the most likly outcome in position 0.

annotatedFile

public void annotatedFile(AnnotationFile f)
Selects annotations from f required for annotator. This may include annotations needed for the generation of sorted outcomes. @see #sortedOutComes() sortedOutcomes

Specified by:
annotatedFile in interface AnnotatedFileListener
Parameters:
f - The file which was opened.

closeAnnotatedFile

public void closeAnnotatedFile(AnnotationFile f)
Description copied from interface: AnnotatedFileListener
Notifies the listener that the specified file was closed.

Specified by:
closeAnnotatedFile in interface AnnotatedFileListener
Parameters:
f - The file which was closed.

setGuiListener

public void setGuiListener(GuiListener gl)

setAnnotationFilter

public void setAnnotationFilter(AnnotationFilter af)

setTrainingFilter

public void setTrainingFilter(AnnotationFilter af)

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent evt)
Specified by:
actionPerformed in interface java.awt.event.ActionListener


Copyright © 2004 Thomas Morton and Jeremy LaCivita. All Rights Reserved.