public class AnnotatorAdapter extends Object implements AnalysisComponent
Constructor and Description |
---|
AnnotatorAdapter(BaseAnnotator aAnnotator,
AnalysisEngineMetaData aMetaData,
Map<String,Object> aAdditionalParams)
Create a new annotator adapter.
|
Modifier and Type | Method and Description |
---|---|
void |
batchProcessComplete()
Completes the processing of a batch of CASes.
|
void |
checkTypeSystemChange(AbstractCas aCAS)
Checks it the type system of the given CAS is different from the last type system this
component was operating on.
|
void |
collectionProcessComplete()
Notifies this AnalysisComponent that processing of an entire collection has been completed.
|
void |
destroy()
Frees all resources held by this AnalysisComponent.
|
protected BaseAnnotator |
getAnnotator() |
int |
getCasInstancesRequired()
Returns the maximum number of CAS instances that this AnalysisComponent expects to use at the
same time.
|
Class<? extends AbstractCas> |
getRequiredCasInterface()
Get the CAS interface required by this annotator.
|
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.
|
public AnnotatorAdapter(BaseAnnotator aAnnotator, AnalysisEngineMetaData aMetaData, Map<String,Object> aAdditionalParams) throws ResourceInitializationException
aAnnotator
- the annotator instanceaMetaData
- metadata for the annotator. Needed to compute ResultSpecification.aAdditionalParams
- parameters passed to AE's initialize method. Used to allow containing Aggregate to
influence ResultSpecification, for backwards compatibility with CapabilityLanguageFlow.ResourceInitializationException
- if the component is sofa-awarepublic void initialize(UimaContext aContext) throws ResourceInitializationException
AnalysisComponent
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.
initialize
in interface AnalysisComponent
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.public void setResultSpecification(ResultSpecification aResultSpec)
AnalysisComponent
setResultSpecification
in interface AnalysisComponent
aResultSpec
- the ResultSpecification for this Analysis Component to use.public void process(AbstractCas aCAS) throws AnalysisEngineProcessException
AnalysisComponent
AnalysisComponent.hasNext()
is called and returns false or until process
is called again
(see class description).process
in interface AnalysisComponent
aCAS
- A CAS that this AnalysisComponent should process. The framework will ensure that aCAS
implements the specific CAS interface specified by the
AnalysisComponent.getRequiredCasInterface()
method.AnalysisEngineProcessException
- if a problem occurs during processingpublic void checkTypeSystemChange(AbstractCas aCAS) throws AnalysisEngineProcessException
AnalysisEngineProcessException
public void batchProcessComplete() throws AnalysisEngineProcessException
AnalysisComponent
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.
batchProcessComplete
in interface AnalysisComponent
AnalysisEngineProcessException
- if this component encounters a problem in flushing its state to persistent storagepublic void collectionProcessComplete() throws AnalysisEngineProcessException
AnalysisComponent
collectionProcessComplete
in interface AnalysisComponent
AnalysisEngineProcessException
- if this component encounters a problem in its end-of-collection processingpublic void destroy()
AnalysisComponent
destroy
in interface AnalysisComponent
public void reconfigure() throws ResourceConfigurationException, ResourceInitializationException
AnalysisComponent
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.
reconfigure
in interface AnalysisComponent
ResourceConfigurationException
- if the configuration specified for this component is invalid.ResourceInitializationException
- if this component fails to reinitialize itself based on the new configuration.public boolean hasNext() throws AnalysisEngineProcessException
AnalysisComponent
AnalysisComponent.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
AnalysisComponent.process(AbstractCas)
method.hasNext
in interface AnalysisComponent
AnalysisEngineProcessException
- if a problem occurs during processingpublic AbstractCas next() throws AnalysisEngineProcessException
AnalysisComponent
AnalysisComponent.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).
next
in interface AnalysisComponent
AnalysisEngineProcessException
- if a problem occurs during processingpublic Class<? extends AbstractCas> getRequiredCasInterface()
getRequiredCasInterface
in interface AnalysisComponent
public int getCasInstancesRequired()
AnalysisComponent
getCasInstancesRequired
in interface AnalysisComponent
protected BaseAnnotator getAnnotator()
Copyright © 2006–2014 The Apache Software Foundation. All rights reserved.