Class CollectionReaderAdapter
- All Implemented Interfaces:
AnalysisComponent
-
Constructor Summary
ConstructorDescriptionCollectionReaderAdapter
(CollectionReader aCollectionReader, AnalysisEngineMetaData aMetaData) Create a new annotator adapter. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Completes the processing of a batch of CASes.void
void
Notifies this AnalysisComponent that processing of an entire collection has been completed.void
destroy()
Frees all resources held by this AnalysisComponent.int
Returns the maximum number of CAS instances that this AnalysisComponent expects to use at the same time.Class
<? extends AbstractCas> 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.next()
Gets the next output CAS.void
next
(AbstractCas aEmptyCas) void
process
(AbstractCas aCAS) Inputs a CAS to the AnalysisComponent.void
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.
-
Constructor Details
-
CollectionReaderAdapter
public CollectionReaderAdapter(CollectionReader aCollectionReader, AnalysisEngineMetaData aMetaData) Create a new annotator adapter.- Parameters:
aCollectionReader
- the CollectionReader instanceaMetaData
- metadata for the annotator. Needed to compute ResultSpecification.
-
-
Method Details
-
initialize
Description copied from interface:AnalysisComponent
Performs any startup tasks required by this component. The framework calls this method only once, just after the AnalysisComponent has been instantiated.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 theUimaContext
for later use.- Specified by:
initialize
in interfaceAnalysisComponent
- Parameters:
aContext
- Provides access to services and resources managed by the framework. This includes configuration parameters, logging, and access to external resources.- Throws:
ResourceInitializationException
- if this AnalysisComponent cannot initialize successfully.
-
checkTypeSystemChange
- Throws:
AnalysisEngineProcessException
-
process
Description copied from interface:AnalysisComponent
Inputs a CAS to the AnalysisComponent. The AnalysisComponent "owns" this CAS until such time asAnalysisComponent.hasNext()
is called and returns false or untilprocess
is called again (see class description).- Specified by:
process
in interfaceAnalysisComponent
- Parameters:
aCAS
- A CAS that this AnalysisComponent should process. The framework will ensure that aCAS implements the specific CAS interface specified by theAnalysisComponent.getRequiredCasInterface()
method.- Throws:
AnalysisEngineProcessException
- if a problem occurs during processing
-
batchProcessComplete
Description copied from interface:AnalysisComponent
Completes the processing of a batch of CASes. The size of a batch is determined based on configuration provided by the application that is using this component. The purpose ofbatchProcessComplete
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.- Specified by:
batchProcessComplete
in interfaceAnalysisComponent
- Throws:
AnalysisEngineProcessException
- if this component encounters a problem in flushing its state to persistent storage
-
collectionProcessComplete
Description copied from interface:AnalysisComponent
Notifies this AnalysisComponent that processing of an entire collection has been completed. In this method, this component should finish writing any output relating to the current collection.- Specified by:
collectionProcessComplete
in interfaceAnalysisComponent
- Throws:
AnalysisEngineProcessException
- if this component encounters a problem in its end-of-collection processing
-
destroy
public void destroy()Description copied from interface:AnalysisComponent
Frees all resources held by this AnalysisComponent. The framework calls this method only once, when it is finished using this component.- Specified by:
destroy
in interfaceAnalysisComponent
-
reconfigure
Description copied from interface:AnalysisComponent
Alerts this AnalysisComponent that the values of its configuration parameters or external resources have changed. This AnalysisComponent should re-read its configuration from theUimaContext
and take appropriate action to reconfigure itself.In the abstract base classes provided by the framework, this is generally implemented by calling
destroy
followed byinitialize
andtypeSystemChanged
. If a more efficient implementation is needed, you can override that implementation.- Specified by:
reconfigure
in interfaceAnalysisComponent
- Throws:
ResourceInitializationException
- if this component fails to reinitialize itself based on the new configuration.ResourceConfigurationException
- if the configuration specified for this component is invalid.
-
hasNext
Description copied from interface:AnalysisComponent
Asks if this AnalysisComponent has another CAS to output. If this method returns true, then a call toAnalysisComponent.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 itsAnalysisComponent.process(AbstractCas)
method.- Specified by:
hasNext
in interfaceAnalysisComponent
- Returns:
- true if this AnalysisComponent has another CAS to output, false if not.
- Throws:
AnalysisEngineProcessException
- if a problem occurs during processing
-
next
Description copied from interface:AnalysisComponent
Gets the next output CAS. The framework will only call this method after first callingAnalysisComponent.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).- Specified by:
next
in interfaceAnalysisComponent
- Returns:
- the next output CAS.
- Throws:
AnalysisEngineProcessException
- if a problem occurs during processing
-
next
- Throws:
AnalysisEngineProcessException
-
getRequiredCasInterface
Get the CAS interface required by this annotator.- Specified by:
getRequiredCasInterface
in interfaceAnalysisComponent
- Returns:
- the CAS interface required by this annotator
-
getCasInstancesRequired
public int getCasInstancesRequired()Description copied from interface:AnalysisComponent
Returns the maximum number of CAS instances that this AnalysisComponent expects to use at the same time. This only applies to CasMultipliers. Most CasMultipliers will only need one CAS at a time. Only if there is a clear need should this be overridden to return something greater than 1.- Specified by:
getCasInstancesRequired
in interfaceAnalysisComponent
- Returns:
- the number of CAS instances required by this AnalysisComponent.
-
setResultSpecification
Description copied from interface:AnalysisComponent
Sets the ResultSpecification that this AnalysisComponent should use. The ResultSpecification is a set of types and features that this AnalysisComponent is asked to produce. An Analysis Component may (but is not required to) optimize its processing by omitting the generation of any types or features that are not part of the ResultSpecification.- Specified by:
setResultSpecification
in interfaceAnalysisComponent
- Parameters:
aResultSpec
- the ResultSpecification for this Analysis Component to use.
-