public interface AnalysisComponent
Typically, developers do not implement this interface directly. There are several abstract classes that you can inherit from depending on the function that your component performs and which CAS interface it uses:
JCasAnnotator_ImplBase
: Uses JCas interfaceCasAnnotator_ImplBase
: Uses CASinterface
CasConsumer_ImplBase
: Receives an input CAS but does not
update it. May update a data structure based on information in the CASes it receives.JCasMultiplier_ImplBase
: Uses JCas interfaceCasMultiplier_ImplBase
: Uses CAS interfaceCollectionReader_ImplBase
: A special type of
CasMultiplier that, for historical reasons, does not take an input CAS.The framework interacts with AnalysisComponents as follows:
process(AbstractCas)
method with an
input CAS.hasNext()
method, which should
return true
if the AnalysisComponent intends to produce new output CASes, or
false
if the AnalysisComponent will not produce new output CASes.true
, the framework will then call the
next()
method.next
method, can create a new CAS by calling
UimaContext.getEmptyCas(Class)
(or instead, one of the helper methods in the ImplBase
class that it extended). It then populates the empty CAS and returns it.hasNext()
returns
false.process
is called until the time when hasNext
returns false, the AnalysisComponent "owns" the CAS that was passed to process
.
The AnalysisComponent is permitted to make changes to this CAS. Once hasNext
returns false, the AnalysisComponent releases control of the initial CAS. This means that the
AnalysisComponent must finish all updates to the initial CAS prior to returning false from
hasNext
.
However, if the process
method is called a second time, before hasNext
has returned
false, this is a signal to the AnalysisComponent to cancel all processing of the previous CAS and begin
processing the new CAS instead.
Modifier and Type | Method and Description |
---|---|
void |
batchProcessComplete()
Completes the processing of a batch of CASes.
|
void |
collectionProcessComplete()
Notifies this AnalysisComponent that processing of an entire collection has been completed.
|
void |
destroy()
Frees all resources held by this AnalysisComponent.
|
int |
getCasInstancesRequired()
Returns the maximum number of CAS instances that this AnalysisComponent expects to use at the
same time.
|
Class<? extends AbstractCas> |
getRequiredCasInterface()
Returns the specific CAS interface that this AnalysisComponent requires the framework to pass
to its
process(AbstractCas) method. |
boolean |
hasNext()
Asks if this AnalysisComponent has another CAS to output.
|
void |
initialize(UimaContext aContext)
Performs any startup tasks required by this component.
|
AbstractCas |
next()
Gets the next output CAS.
|
void |
process(AbstractCas aCAS)
Inputs a CAS to the AnalysisComponent.
|
void |
reconfigure()
Alerts this AnalysisComponent that the values of its configuration parameters or external
resources have changed.
|
void |
setResultSpecification(ResultSpecification aResultSpec)
Sets the ResultSpecification that this AnalysisComponent should use.
|
void initialize(UimaContext aContext) throws ResourceInitializationException
The framework supplies this AnalysisComponent with a reference to the UimaContext
that
it will use, for example to access configuration settings or resources. This AnalysisComponent
should store a reference to its the UimaContext
for later use.
aContext
- Provides access to services and resources managed by the framework. This includes
configuration parameters, logging, and access to external resources.ResourceInitializationException
- if this AnalysisComponent cannot initialize successfully.void reconfigure() throws ResourceInitializationException, ResourceConfigurationException
UimaContext
and take appropriate action to reconfigure itself.
In the abstract base classes provided by the framework, this is generally implemented by
calling destroy
followed by initialize
and
typeSystemChanged
. If a more efficient implementation is needed, you can
override that implementation.
ResourceConfigurationException
- if the configuration specified for this component is invalid.ResourceInitializationException
- if this component fails to reinitialize itself based on the new configuration.void batchProcessComplete() throws AnalysisEngineProcessException
batchProcessComplete
is to give this AnalysisComponent the change to flush
information from memory to persistent storage. In the event of an error, this allows the
processing to be restarted from the end of the last completed batch.
If this component's descriptor declares that it is recoverable
, then this
component is required to be restartable from the end of the last completed batch.
AnalysisEngineProcessException
- if this component encounters a problem in flushing its state to persistent storagevoid collectionProcessComplete() throws AnalysisEngineProcessException
AnalysisEngineProcessException
- if this component encounters a problem in its end-of-collection processingvoid destroy()
void process(AbstractCas aCAS) throws AnalysisEngineProcessException
hasNext()
is called and returns false or until process
is called again
(see class description).aCAS
- A CAS that this AnalysisComponent should process. The framework will ensure that aCAS
implements the specific CAS interface specified by the
getRequiredCasInterface()
method.AnalysisEngineProcessException
- if a problem occurs during processingboolean hasNext() throws AnalysisEngineProcessException
next()
should retrieve the next output CAS. When this method returns false,
the AnalysisComponent gives up control of the initial CAS that was passed to its
process(AbstractCas)
method.AnalysisEngineProcessException
- if a problem occurs during processingAbstractCas next() throws AnalysisEngineProcessException
hasNext()
and checking that it returns true.
The AnalysisComponent can obtain a new CAS by calling UimaContext.getEmptyCas(Class)
(or instead, one of the helper methods in the ImplBase class that it extended).
AnalysisEngineProcessException
- if a problem occurs during processingClass<? extends AbstractCas> getRequiredCasInterface()
process(AbstractCas)
method.AbstractCas
.int getCasInstancesRequired()
void setResultSpecification(ResultSpecification aResultSpec)
aResultSpec
- the ResultSpecification for this Analysis Component to use.Copyright © 2006–2017 The Apache Software Foundation. All rights reserved.