Class PearAnalysisEngineWrapper
- All Implemented Interfaces:
AnalysisEngine
,TextAnalysisEngine
,CasObjectProcessor
,CasProcessor
,ConfigurableResource
,Resource
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
inner class StringPair -
Field Summary
Fields inherited from class org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase
LOG_RESOURCE_BUNDLE, PARAM_VERIFICATION_MODE
Fields inherited from interface org.apache.uima.analysis_engine.AnalysisEngine
MDC_ANNOTATOR_CONTEXT_NAME, MDC_ANNOTATOR_IMPL_NAME, MDC_CAS_ID, MDC_ROOT_CONTEXT_ID, PARAM_CONFIG_PARAM_SETTINGS, PARAM_MBEAN_NAME_PREFIX, PARAM_MBEAN_SERVER, PARAM_NUM_SIMULTANEOUS_REQUESTS, PARAM_RESOURCE_MANAGER, PARAM_THROTTLE_EXCESSIVE_ANNOTATOR_LOGGING, PARAM_TIMEOUT_PERIOD
Fields inherited from interface org.apache.uima.resource.Resource
PARAM_AGGREGATE_SOFA_MAPPINGS, PARAM_CONFIG_MANAGER, PARAM_CONFIG_PARAM_SETTINGS, PARAM_EXTERNAL_OVERRIDE_SETTINGS, PARAM_PERFORMANCE_TUNING_SETTINGS, PARAM_RESOURCE_MANAGER, PARAM_UIMA_CONTEXT
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Notifies this AnalysisEngine that processing of a batch has completed.void
batchProcessComplete
(ProcessTrace trace) Completes the processing of a batch.protected void
Modify an existing ProcessTrace object by adding events that represent the last excecution of this AnalysisEngine.void
Notifies this AnalysisEngine that processing of an entire collection has completed.void
Completes the processing of an entire collection.A factory method used to create an instance ofResultSpecification
for use with this AnalysisEngine.createResultSpecification
(TypeSystem typeSystem) A factory method used to create an instance ofResultSpecification
for use with this AnalysisEngine.void
destroy()
Releases all resources held by thisResource
.protected void
protected void
protected void
protected void
protected void
protected void
Gets the metadata that describes thisAnalysisEngine
.protected String
protected Object
Gets the metadata that describes thisResource
.Gets the performance tuning settings in effect for this Analysis Engine.Gets the metadata that describes thisCasProcesor
.Gets the UIMA Context for this Resource.Gets the Administrative interface to the UIMA Context.boolean
initialize
(ResourceSpecifier aSpecifier, Map<String, Object> aAdditionalParams) Initializes thisResource
from aResourceSpecifier
.protected boolean
Gets whether the Process Trace (which collects performance stats for this AnalysisEngine) is enabled.newCAS()
Creates a new Common Analysis System appropriate for this Analysis Engine.processAndOutputNewCASes
(CAS aCAS) Processes a CAS, possibly producing multiple CASes as a result.void
Instructs this Resource to re-read its configuration parameter settings.protected void
setMetaData
(ResourceMetaData aMetaData) Sets theResourceMetaData
object associated with thisResource
.protected void
setPerformanceTuningSettings
(Properties aSettings) Sets the performance tuning settings in effect for this Analysis Engine.void
setResultSpecification
(ResultSpecification resultSpec) Sets the list of output types and features that the application wants this AnalysisEngine to produce.void
typeSystemInit
(TypeSystem typeSystem) From the CAS Processor interface.Methods inherited from class org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase
buildProcessTraceFromMBeanStats, callInitializeMethod, callProcessMethod, finalize, getCurrentConfigParameterSettings, getFeatureNamesForType, getManagementInterface, getMBean, isReadOnly, isStateless, newJCas, normalizeIsoLangCodes, process, process, process, process, process, process, process, processAndOutputNewCASes, processCas, processCas, resetResultSpecificationToDefault
Methods inherited from class org.apache.uima.resource.ConfigurableResource_ImplBase
getConfigParameterValue, getConfigParameterValue, setConfigParameterValue, setConfigParameterValue
Methods inherited from class org.apache.uima.resource.Resource_ImplBase
getCasManager, getLogger, getRelativePathResolver, getResourceManager, loadUserClass, loadUserClassOrThrow, setContextHolder, setContextHolderX, setLogger, withContextHolder
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.uima.analysis_engine.AnalysisEngine
getLogger, getResourceManager, setLogger
Methods inherited from interface org.apache.uima.resource.ConfigurableResource
getConfigParameterValue, getConfigParameterValue, setConfigParameterValue, setConfigParameterValue
-
Constructor Details
-
PearAnalysisEngineWrapper
public PearAnalysisEngineWrapper()
-
-
Method Details
-
initialize
public boolean initialize(ResourceSpecifier aSpecifier, Map<String, Object> aAdditionalParams) throws ResourceInitializationExceptionDescription copied from interface:Resource
Initializes thisResource
from aResourceSpecifier
. Applications do not need to call this method. It is called automatically by theResourceFactory
and cannot be called a second time.- Specified by:
initialize
in interfaceAnalysisEngine
- Specified by:
initialize
in interfaceResource
- Overrides:
initialize
in classAnalysisEngineImplBase
- Parameters:
aSpecifier
- specifies how to create a resource or locate an existing resource service.aAdditionalParams
- a Map containing additional parameters. May benull
if there are no parameters. Each class that implements this interface can decide what additional parameters it supports.- Returns:
- true if and only if initialization completed successfully. Returns false if the given
ResourceSpecifier
is not of an appropriate type for this Resource. If theResourceSpecifier
is of an appropriate type but is invalid or if some other failure occurs, an exception should be thrown. - Throws:
ResourceInitializationException
- if a failure occurs during initialization.- See Also:
-
getAnalysisEngineMetaData
Description copied from interface:AnalysisEngine
Gets the metadata that describes thisAnalysisEngine
. This is just a convenience method that callsResource.getMetaData()
and casts the result to aAnalysisEngineMetaData
.- Specified by:
getAnalysisEngineMetaData
in interfaceAnalysisEngine
- Overrides:
getAnalysisEngineMetaData
in classAnalysisEngineImplBase
- Returns:
- an object containing all metadata for this AnalysisEngine
-
getMetaData
Description copied from interface:Resource
Gets the metadata that describes thisResource
.- Specified by:
getMetaData
in interfaceResource
- Overrides:
getMetaData
in classResource_ImplBase
- Returns:
- an object containing all metadata for this resource.
-
batchProcessComplete
Description copied from interface:AnalysisEngine
Notifies this AnalysisEngine that processing of a batch has completed. It is up to the caller to determine the size of a batch. Components (particularly CAS Consumers) inside this Analysis Engine may respond to this event, for example by writing data to the disk.- Specified by:
batchProcessComplete
in interfaceAnalysisEngine
- Overrides:
batchProcessComplete
in classAnalysisEngineImplBase
- Throws:
AnalysisEngineProcessException
- if an exception occurs during processing
-
collectionProcessComplete
Description copied from interface:AnalysisEngine
Notifies this AnalysisEngine that processing of an entire collection has completed. It is up to the caller to determine when this has occurred. Components (particularly CAS Consumers) inside this Analysis Engine may respond to this event, for example by writing data to the disk.If this AnalysisEngine is an aggregate, this method will call the collectionProcessComplete method of all components of that aggregate. If the aggregate descriptor declares a
fixedFlow
orcapabilityLanguageFlow
, then the components' collectionProcessComplete methods will be called in the order specified by that flow element. Once all components in the flow have been called, any components not declared in the flow will be called, in arbitrary order. If there is nofixedFlow
orcapabilityLanguageFlow
, then all components in the aggregate will be called in arbitrary order.- Specified by:
collectionProcessComplete
in interfaceAnalysisEngine
- Overrides:
collectionProcessComplete
in classAnalysisEngineImplBase
- Throws:
AnalysisEngineProcessException
- if an exception occurs during processing
-
processAndOutputNewCASes
Description copied from interface:AnalysisEngine
Processes a CAS, possibly producing multiple CASes as a result. The application uses theCasIterator
interface to step through the output CASes.If this Analysis Engine does not produce output CASes, then the
CasIterator
will return no elements. You can check if an AnalysisEngine is capable of producing output CASes by checking theOperationalProperties.getOutputsNewCASes()
operational property (getAnalysisEngineMetaData().getOperationalProperties().getOutputsNewCASes()
).Once this method is called, the AnalysisEngine "owns"
aCAS
until such time as theCasIterator.hasNext()
method returns false. That is, the caller should not attempt to modify or access the input CAS until it has read all of the elements from the CasIterator. If the caller wants to abort the processing before having read all of the output CASes, it may callCasIterator.release()
, which will stop further processing from occurring, and ownership ofaCAS
will revert to the caller.- Specified by:
processAndOutputNewCASes
in interfaceAnalysisEngine
- Overrides:
processAndOutputNewCASes
in classAnalysisEngineImplBase
- Parameters:
aCAS
- the CAS to be processed- Returns:
- an object for iterating through any output CASes
- Throws:
AnalysisEngineProcessException
- if a failure occurs during processing
-
destroy
public void destroy()Description copied from interface:Resource
Releases all resources held by thisResource
.- Specified by:
destroy
in interfaceResource
- Overrides:
destroy
in classResource_ImplBase
- See Also:
-
reconfigure
Description copied from interface:ConfigurableResource
Instructs this Resource to re-read its configuration parameter settings.- Specified by:
reconfigure
in interfaceAnalysisEngine
- Specified by:
reconfigure
in interfaceConfigurableResource
- Overrides:
reconfigure
in classConfigurableResource_ImplBase
- Throws:
ResourceConfigurationException
- if the configuration is not valid- See Also:
-
buildProcessTraceFromMBeanStats
Description copied from class:AnalysisEngineImplBase
Modify an existing ProcessTrace object by adding events that represent the last excecution of this AnalysisEngine. This is used so that we can return a ProcessTrace object from each process() call for backwards compatibility with version 1.x.- Overrides:
buildProcessTraceFromMBeanStats
in classAnalysisEngineImplBase
- Parameters:
trace
- -
-
enterBatchProcessComplete
protected void enterBatchProcessComplete()- Overrides:
enterBatchProcessComplete
in classAnalysisEngineImplBase
-
enterCollectionProcessComplete
protected void enterCollectionProcessComplete()- Overrides:
enterCollectionProcessComplete
in classAnalysisEngineImplBase
-
enterProcess
protected void enterProcess()- Overrides:
enterProcess
in classAnalysisEngineImplBase
-
exitBatchProcessComplete
protected void exitBatchProcessComplete()- Overrides:
exitBatchProcessComplete
in classAnalysisEngineImplBase
-
exitCollectionProcessComplete
protected void exitCollectionProcessComplete()- Overrides:
exitCollectionProcessComplete
in classAnalysisEngineImplBase
-
exitProcess
protected void exitProcess()- Overrides:
exitProcess
in classAnalysisEngineImplBase
-
getMBeanNamePrefix
- Overrides:
getMBeanNamePrefix
in classAnalysisEngineImplBase
-
getMBeanServer
- Overrides:
getMBeanServer
in classAnalysisEngineImplBase
-
getPerformanceTuningSettings
Description copied from class:AnalysisEngineImplBase
Gets the performance tuning settings in effect for this Analysis Engine.- Specified by:
getPerformanceTuningSettings
in interfaceAnalysisEngine
- Overrides:
getPerformanceTuningSettings
in classAnalysisEngineImplBase
- Returns:
- performance tuning settings
-
isProcessTraceEnabled
protected boolean isProcessTraceEnabled()Description copied from class:AnalysisEngineImplBase
Gets whether the Process Trace (which collects performance stats for this AnalysisEngine) is enabled. This is controlled through the PerformanceTuningSettings passed to the initialize() method.- Overrides:
isProcessTraceEnabled
in classAnalysisEngineImplBase
- Returns:
- true if the ProcessTrace is enabled, false if not.
-
setPerformanceTuningSettings
Description copied from class:AnalysisEngineImplBase
Sets the performance tuning settings in effect for this Analysis Engine. This should be set from the initialize() method if the defaults are to be overriden.- Overrides:
setPerformanceTuningSettings
in classAnalysisEngineImplBase
- Parameters:
aSettings
- performance tuning settings
-
getUimaContext
Description copied from interface:Resource
Gets the UIMA Context for this Resource. This can be used to access external resources or facilities such as the Logger.- Specified by:
getUimaContext
in interfaceResource
- Overrides:
getUimaContext
in classResource_ImplBase
- Returns:
- the UimaContext for use by this Resource
-
getUimaContextAdmin
Description copied from interface:Resource
Gets the Administrative interface to the UIMA Context. This can be used by deployment wrappers to modify the UimaContext (for example, by setting the Session object).- Specified by:
getUimaContextAdmin
in interfaceResource
- Overrides:
getUimaContextAdmin
in classResource_ImplBase
- Returns:
- the Admin interface to this Resource's UimaContext.
-
setMetaData
Description copied from class:Resource_ImplBase
Sets theResourceMetaData
object associated with thisResource
. Any previously existing metadata will be replaced.Resource subclasses should call this method during initialization in order to set the metadata before any calls to
Resource_ImplBase.getMetaData()
are made.- Overrides:
setMetaData
in classAnalysisEngineImplBase
- Parameters:
aMetaData
- metadata to assign to thisResource
-
setResultSpecification
Description copied from interface:AnalysisEngine
Sets the list of output types and features that the application wants this AnalysisEngine to produce. This is only a guideline. Annotators may use this information to avoid doing unnecessary work, but they are not required to do so.- Specified by:
setResultSpecification
in interfaceAnalysisEngine
- Overrides:
setResultSpecification
in classAnalysisEngineImplBase
- Parameters:
resultSpec
- specifies the list of output types and features that the application is interested in.
-
batchProcessComplete
Description copied from interface:CasProcessor
Completes the processing of a batch. A collection may be divided into one or more batches - it is up to the CollectionProcessingManager or the application to determine the number and size of batches.- Specified by:
batchProcessComplete
in interfaceCasProcessor
- Overrides:
batchProcessComplete
in classAnalysisEngineImplBase
- Parameters:
trace
- an object that records information, such as timing, about this method's execution.- Throws:
ResourceProcessException
- if an exception occurs during processingIOException
- if an I/O failure occurs
-
collectionProcessComplete
public void collectionProcessComplete(ProcessTrace trace) throws ResourceProcessException, IOException Description copied from interface:CasProcessor
Completes the processing of an entire collection.- Specified by:
collectionProcessComplete
in interfaceCasProcessor
- Overrides:
collectionProcessComplete
in classAnalysisEngineImplBase
- Parameters:
trace
- an object that records information, such as timing, about this method's execution.- Throws:
ResourceProcessException
- if an exception occurs during processingIOException
- if an I/O failure occurs
-
createResultSpecification
Description copied from interface:AnalysisEngine
A factory method used to create an instance of
ResultSpecification
for use with this AnalysisEngine. Applications use this method to constructResultSpecification
s to pass to this AnalysisEngine'sAnalysisEngine.setResultSpecification(ResultSpecification)
method.See also
AnalysisEngine.createResultSpecification(TypeSystem)
which should be used if the type system associated with this result specification is known at this point in time.- Specified by:
createResultSpecification
in interfaceAnalysisEngine
- Overrides:
createResultSpecification
in classAnalysisEngineImplBase
- Returns:
- a new instance of
ResultSpecification
-
createResultSpecification
Description copied from interface:AnalysisEngine
A factory method used to create an instance ofResultSpecification
for use with this AnalysisEngine. Applications use this method to constructResultSpecification
s to pass to this AnalysisEngine'sAnalysisEngine.setResultSpecification(ResultSpecification)
method.- Specified by:
createResultSpecification
in interfaceAnalysisEngine
- Overrides:
createResultSpecification
in classAnalysisEngineImplBase
- Parameters:
typeSystem
- the type system- Returns:
- a new instance of
ResultSpecification
-
getProcessingResourceMetaData
Description copied from interface:CasProcessor
Gets the metadata that describes thisCasProcesor
.- Specified by:
getProcessingResourceMetaData
in interfaceCasProcessor
- Overrides:
getProcessingResourceMetaData
in classAnalysisEngineImplBase
- Returns:
- an object containing all metadata for this CasProcessor
-
newCAS
Description copied from interface:AnalysisEngine
Creates a new Common Analysis System appropriate for this Analysis Engine. An application can pre-populate this CAS, then pass it to theAnalysisEngine.process(CAS)
method. Then, when the process method returns, the CAS will contain the results of the analysis.Important: CAS creation is expensive, so if at all possible an application should reuse CASes. When a CAS instance is no longer being used, call its
CAS.reset()
method, which will remove all prior analysis information, and then reuse that same CAS instance for another call toAnalysisEngine.process(CAS)
.Note that the CAS allows multiple subjects of analysis (e.g. documents) and defines a separate "view" for each of them. If your application wants to work with a single subject of analysis, call the method
CAS.getCurrentView()
and operate on the returned view.- Specified by:
newCAS
in interfaceAnalysisEngine
- Overrides:
newCAS
in classAnalysisEngineImplBase
- Returns:
- a new
CAS
appropriate for this AnalysisEngine. - Throws:
ResourceInitializationException
- if a CAS could not be created because this AnalysisEngine's CAS metadata (type system, type priorities, or FS indexes) are invalid. Ideally this would be checked at AnalysisEngine initialization time, and it will likely be moved in the future.
-
typeSystemInit
Description copied from class:AnalysisEngineImplBase
From the CAS Processor interface. Called by the CPM if the CAS type system changes - this does not need to do anything since the annotators' typeSystemInit methods are automatically called prior to processing whenever it is necessary.- Specified by:
typeSystemInit
in interfaceCasObjectProcessor
- Overrides:
typeSystemInit
in classAnalysisEngineImplBase
- Parameters:
typeSystem
- the type system to use- Throws:
ResourceInitializationException
- if the type system is not compatible with this Cas Consumer- See Also:
-
getCachedResourceManagers
public static Map<ResourceManager,Map<PearAnalysisEngineWrapper.StringPair, getCachedResourceManagers()ResourceManager>>
-