Textractor API textractor-720 (20091120123250)

textractor.chain
Class AbstractSentenceTransformer

java.lang.Object
  extended by textractor.sentence.AbstractSentenceProcessor
      extended by textractor.chain.AbstractSentenceTransformer
All Implemented Interfaces:
Callable<Boolean>, EventListener, Chain, Command, SentenceProcessingCompleteListener, SentenceProcessor, SentenceTransformer, TextractorProcessor
Direct Known Subclasses:
AbnerSentenceTransformer, Filter, RandomArticleSampler, SentenceCapitalizer, SentenceCountFilter, TitleExtractor

public abstract class AbstractSentenceTransformer
extends AbstractSentenceProcessor
implements Chain, SentenceTransformer, SentenceProcessingCompleteListener, Callable<Boolean>

Base class for Chain implementations that contain one or more SentenceProcessor commands.


Field Summary
protected  List<Command> commands
          The list of Commands configured for this Chain, in the order in which they may delegate processing to the remainder of the Chain.
protected  boolean frozen
          Flag indicating whether the configuration of our commands list has been frozen by a call to the execute() method.
protected  boolean productionCompleted
          Indicates the producer is done and there will be no more to consume.
 
Fields inherited from interface org.apache.commons.chain.Command
CONTINUE_PROCESSING, PROCESSING_COMPLETE
 
Constructor Summary
AbstractSentenceTransformer()
          Create a new Chain.
AbstractSentenceTransformer(Collection<Command> commands)
          Construct a Chain configured with the specified Commands.
AbstractSentenceTransformer(Command command)
          Construct a Chain configured with the specified Command.
AbstractSentenceTransformer(Command[] commands)
          Construct a Chain configured with the specified Commands.
 
Method Summary
 void addCommand(Command command)
          See the Chain JavaDoc.
 Boolean call()
           
 boolean execute(Context context)
          See the Chain JavaDoc.
 int getOutputQueueSize()
          Get the size of the sentence transformation queue.
 boolean okToComplete()
          Indicate that all processing is complete and it's ok to terminate.
 void processingComplete(SentenceProcessingCompleteEvent event)
          This method gets called when a sentence processing is complete.
 void setOutputQueueSize(int size)
          Set the size of the sentence transformation queue.
 
Methods inherited from class textractor.sentence.AbstractSentenceProcessor
addSentenceProcessedListener, addSentenceProcessingCompleteListener, fireSentenceProcessedEvent, fireSentenceProcessingCompleteEvent, removeSentenceProcessedListener, removeSentenceProcessingCompleteListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface textractor.sentence.SentenceTransformer
transform
 
Methods inherited from interface textractor.sentence.SentenceProcessor
addSentenceProcessedListener, addSentenceProcessingCompleteListener, getNumberOfArticlesProcessed, getNumberOfSentencesProcessed, removeSentenceProcessedListener, removeSentenceProcessingCompleteListener
 

Field Detail

productionCompleted

protected boolean productionCompleted
Indicates the producer is done and there will be no more to consume.


commands

protected final List<Command> commands
The list of Commands configured for this Chain, in the order in which they may delegate processing to the remainder of the Chain.


frozen

protected boolean frozen
Flag indicating whether the configuration of our commands list has been frozen by a call to the execute() method.

Constructor Detail

AbstractSentenceTransformer

public AbstractSentenceTransformer()
Create a new Chain.


AbstractSentenceTransformer

public AbstractSentenceTransformer(Command command)
Construct a Chain configured with the specified Command.

Parameters:
command - The Command to be configured
Throws:
IllegalArgumentException - if command is null

AbstractSentenceTransformer

public AbstractSentenceTransformer(Command[] commands)
Construct a Chain configured with the specified Commands.

Parameters:
commands - The Commands to be configured
Throws:
IllegalArgumentException - if commands, or one of the individual Command elements, is null

AbstractSentenceTransformer

public AbstractSentenceTransformer(Collection<Command> commands)
Construct a Chain configured with the specified Commands.

Parameters:
commands - The Commands to be configured
Throws:
IllegalArgumentException - if commands, or one of the individual Command elements, is null
Method Detail

addCommand

public final void addCommand(Command command)
See the Chain JavaDoc.

Specified by:
addCommand in interface Chain
Parameters:
command - The Command to be added
Throws:
IllegalArgumentException - if command is null
IllegalStateException - if no further configuration is allowed

execute

public final boolean execute(Context context)
                      throws Exception
See the Chain JavaDoc.

Specified by:
execute in interface Chain
Specified by:
execute in interface Command
Parameters:
context - The Context to be processed by this Chain
Returns:
true if the processing of this Context has been completed, or false if the processing of this Context should be delegated to a subsequent Command in an enclosing Chain
Throws:
Exception - if there is a problem executing the Chain.
IllegalArgumentException - if context is null

call

public final Boolean call()
                   throws Exception
Specified by:
call in interface Callable<Boolean>
Throws:
Exception

processingComplete

public void processingComplete(SentenceProcessingCompleteEvent event)
This method gets called when a sentence processing is complete.

Specified by:
processingComplete in interface SentenceProcessingCompleteListener
Parameters:
event - A SentenceProcessingCompleteEvent object describing the event source.

okToComplete

public boolean okToComplete()
Indicate that all processing is complete and it's ok to terminate. If false is returned the consumer thread will terminate without firing a SentenceProcessingCompleteEvent. Be aware of this and send the event if you override the default behavior.

Returns:
true if it's ok to complete.

getOutputQueueSize

public int getOutputQueueSize()
Get the size of the sentence transformation queue.

Returns:
The size of the queue.

setOutputQueueSize

public void setOutputQueueSize(int size)
Set the size of the sentence transformation queue.

Parameters:
size - The size of the queue.

Textractor API textractor-720 (20091120123250)

Copyright © 2003-2008 Institute for Computational Biomedicine, All Rights Reserved.