public abstract class LeoBaseAnnotator extends org.apache.uima.analysis_component.JCasAnnotator_ImplBase implements LeoAnnotator
Modifier and Type | Field and Description |
---|---|
protected String[] |
excludeTypesFilter
Optional, only process a CAS if it does not include instances of one of the types in this list.
|
protected String[] |
includeTypesFilter
Optional, only process CAS if it includes instances of one of the types in the list.
|
protected String[] |
inputTypes
The types of annotations to use as "anchors" or to be processed.
|
protected static org.apache.log4j.Logger |
logger
Logger object for messaging.
|
protected String |
name
Optional, Name of the annotator to be set in the descriptor.
|
protected long |
numberOfCASesProcessed
Counter for the number of CASes this annotator has processed.
|
protected long |
numberOfFilteredCASesProcessed
Counter for the number of CASes that made it past the filter for processing.
|
protected int |
numInstances
Number of replication instances for this annotator.
|
protected String |
outputType
The output type that will be created for each matching window.
|
protected LeoTypeSystemDescription |
typeSystemDescription
Type system for this annotator, defaults to an empty type system.
|
Constructor and Description |
---|
LeoBaseAnnotator()
Default constructor for initialization by the UIMA Framework.
|
LeoBaseAnnotator(String outputType,
String... inputTypes)
Constructor setting the initial values for the inputTypes and outputType parameters.
|
Modifier and Type | Method and Description |
---|---|
<T extends LeoBaseAnnotator> |
addLeoTypeSystemDescription(LeoTypeSystemDescription typeSystemDescription)
Add the type system provided to the type system of the annotator.
|
protected org.apache.uima.jcas.tcas.Annotation |
addOutputAnnotation(String outputType,
org.apache.uima.jcas.JCas cas,
int begin,
int end)
Create an output annotation, and add it to the cas.
|
protected org.apache.uima.jcas.tcas.Annotation |
addOutputAnnotation(String outputType,
org.apache.uima.jcas.JCas cas,
int begin,
int end,
Map<String,Object> featureNameValues)
Create an output annotation, and add it to the cas.
|
abstract void |
annotate(org.apache.uima.jcas.JCas aJCas)
This method is called by the LeoBaseAnnotator process method if the CAS meets the filter requirements and either
has not input types defined or else contains one or more instances of the input types.
|
void |
collectionProcessComplete() |
protected boolean |
containsAnnotationInList(org.apache.uima.jcas.JCas jCas,
String[] typeList,
boolean isEmpty)
Checks the CAS for instances of the annotation types in the list.
|
protected org.apache.uima.cas.FSIterator<org.apache.uima.jcas.tcas.Annotation> |
getAnnotationListForType(org.apache.uima.jcas.JCas aJCas,
String type)
Given a cas and type, return all of the annotations in the cas for that type.
|
LeoDelegate |
getDescriptor()
Generate a descriptor from this annotator object.
|
String[] |
getExcludeTypesFilter()
Get the exclude types list.
|
String[] |
getIncludeTypesFilter()
Return the types filter array of type names.
|
String[] |
getInputTypes()
Get the input types list this annotator will use.
|
LeoAEDescriptor |
getLeoAEDescriptor()
Generate a descriptor from this annotator object.
|
LeoTypeSystemDescription |
getLeoTypeSystemDescription()
Return the type system description for this annotator.
|
String |
getName()
Get the name of this annotator.
|
long |
getNumberOfCASesProcessed()
Get the number of CASes this annotator has processed.
|
long |
getNumberOfFilteredCASesProcessed()
Get the number of CASes that were processed once getting through the filter.
|
int |
getNumInstances()
Number of instances of this annotator in the pipeline.
|
String |
getOutputType()
Get the output type name this annotator will use.
|
InputStream |
getResourceAsInputStream(String resourcePath)
Gets a resource as an input stream.
|
String |
getResourceFileAsString(String resourcePath)
Note: Resource paths are specified via file: and classpath: to determine
if the resource should be looked up in the file system or in the
classpath.
|
protected boolean |
hasFilteredAnnotation(org.apache.uima.jcas.JCas jCas)
If includeTypesFilter is not set then return true.
|
protected boolean |
hasInputTypesAnnotation(org.apache.uima.jcas.JCas jCas)
If the input types list is empty or one or more of the types are found in the CAS then return true, return false
otherwise.
|
void |
initialize(org.apache.uima.UimaContext aContext)
Initialize this annotator.
|
void |
process(org.apache.uima.jcas.JCas aJCas)
Called once by the UIMA Framework for each document being analyzed (each
CAS instance).
|
<T extends LeoBaseAnnotator> |
resetNumberOfCASesProcessed()
Set the number of CASes this annotator has processed.
|
<T extends LeoBaseAnnotator> |
resetNumberOfFilteredCASesProcessed()
Reset the number of filtered CASes processed.
|
<T extends LeoBaseAnnotator> |
setExcludeTypesFilter(String... excludeTypesFilterNames)
Set the list of exclude types.
|
<T extends LeoBaseAnnotator> |
setIncludeTypesFilter(String... includeTypesFilterNames)
Set one or more types to filter on.
|
<T extends LeoBaseAnnotator> |
setInputTypes(String... inputTypes)
Set the input types list.
|
<T extends LeoBaseAnnotator> |
setLeoTypeSystemDescription(LeoTypeSystemDescription typeSystemDescription)
Set the type system for this annotator.
|
<T extends LeoBaseAnnotator> |
setName(String name)
Set the name of this annotator.
|
<T extends LeoBaseAnnotator> |
setNumInstances(int numInstances)
Set the number of instances of this annotator in the pipeline.
|
<T extends LeoBaseAnnotator> |
setOutputType(String outputType)
Set the output type name.
|
getRequiredCasInterface, process
getCasInstancesRequired, hasNext, next
protected static org.apache.log4j.Logger logger
@LeoConfigurationParameter protected String[] inputTypes
@LeoConfigurationParameter protected String outputType
protected long numberOfCASesProcessed
protected long numberOfFilteredCASesProcessed
protected int numInstances
protected String name
protected LeoTypeSystemDescription typeSystemDescription
@LeoConfigurationParameter protected String[] includeTypesFilter
@LeoConfigurationParameter protected String[] excludeTypesFilter
public LeoBaseAnnotator()
public LeoBaseAnnotator(String outputType, String... inputTypes)
outputType
- Annotation type to be used as output for this annotatorinputTypes
- One or more annotation types on which processing will occurpublic String[] getInputTypes()
public <T extends LeoBaseAnnotator> T setInputTypes(String... inputTypes)
inputTypes
- input types listpublic String getOutputType()
public <T extends LeoBaseAnnotator> T setOutputType(String outputType)
outputType
- output type namepublic int getNumInstances()
public <T extends LeoBaseAnnotator> T setNumInstances(int numInstances)
T
- delegate object reference for extending classes to support the builder pattern.numInstances
- Number of replication instances for this annotator in the pipelinepublic String getName()
public <T extends LeoBaseAnnotator> T setName(String name)
T
- delegate object reference for extending classes to support the builder pattern.name
- String representation of the annotator name to setpublic String[] getIncludeTypesFilter()
public <T extends LeoBaseAnnotator> T setIncludeTypesFilter(String... includeTypesFilterNames)
includeTypesFilterNames
- One or more type names to filter onpublic String[] getExcludeTypesFilter()
public <T extends LeoBaseAnnotator> T setExcludeTypesFilter(String... excludeTypesFilterNames)
excludeTypesFilterNames
- one or more type names to excludepublic void initialize(org.apache.uima.UimaContext aContext) throws org.apache.uima.resource.ResourceInitializationException
initialize
in interface org.apache.uima.analysis_component.AnalysisComponent
initialize
in class org.apache.uima.analysis_component.AnalysisComponent_ImplBase
aContext
- the UimaContext to initialize with.org.apache.uima.resource.ResourceInitializationException
AnalysisComponent_ImplBase.initialize(org.apache.uima.UimaContext)
public InputStream getResourceAsInputStream(String resourcePath) throws IOException
resourcePath
- the path to the resource to get the inputstream for.IOException
- if the input stream for the resource throws an exception.protected org.apache.uima.cas.FSIterator<org.apache.uima.jcas.tcas.Annotation> getAnnotationListForType(org.apache.uima.jcas.JCas aJCas, String type)
aJCas
- the casetype
- the type to get, ie gov.va.vinci.Tokenprotected org.apache.uima.jcas.tcas.Annotation addOutputAnnotation(String outputType, org.apache.uima.jcas.JCas cas, int begin, int end) throws org.apache.uima.analysis_engine.AnalysisEngineProcessException
outputType
- The classname of the type. ie- gov.va.vinci.Tokencas
- The cas to add the output annotation to.begin
- the start index of the annotationend
- the end index of the annotationorg.apache.uima.analysis_engine.AnalysisEngineProcessException
- If any exception occurs when getting and instantiating the
output annotation type, this exception is thrown with the real exception inside of it. (analysisEngineProcessException.getCause());protected org.apache.uima.jcas.tcas.Annotation addOutputAnnotation(String outputType, org.apache.uima.jcas.JCas cas, int begin, int end, Map<String,Object> featureNameValues) throws org.apache.uima.analysis_engine.AnalysisEngineProcessException
outputType
- The classname of the type. ie- gov.va.vinci.Tokencas
- The cas to add the output annotation to.begin
- the start index of the annotationend
- the end index of the annotationfeatureNameValues
- a map of feature names and associated values to set on the annotation.org.apache.uima.analysis_engine.AnalysisEngineProcessException
- If any exception occurs when getting and instantiating the
output annotation type, this exception is thrown with the real exception inside of it. (analysisEngineProcessException.getCause());public String getResourceFileAsString(String resourcePath) throws IOException
resourcePath
- the path to the resource to getIOException
- if the input stream for the resource throws an exception.public long getNumberOfCASesProcessed()
public <T extends LeoBaseAnnotator> T resetNumberOfCASesProcessed()
public long getNumberOfFilteredCASesProcessed()
public <T extends LeoBaseAnnotator> T resetNumberOfFilteredCASesProcessed()
public final void process(org.apache.uima.jcas.JCas aJCas) throws org.apache.uima.analysis_engine.AnalysisEngineProcessException
process
in class org.apache.uima.analysis_component.JCasAnnotator_ImplBase
aJCas
- the CAS to processorg.apache.uima.analysis_engine.AnalysisEngineProcessException
- if an exception occurs during processing.JCasAnnotator_ImplBase.process(org.apache.uima.jcas.JCas)
public abstract void annotate(org.apache.uima.jcas.JCas aJCas) throws org.apache.uima.analysis_engine.AnalysisEngineProcessException
aJCas
- CAS for processingorg.apache.uima.analysis_engine.AnalysisEngineProcessException
- if there is an error processing the CASpublic void collectionProcessComplete() throws org.apache.uima.analysis_engine.AnalysisEngineProcessException
collectionProcessComplete
in interface org.apache.uima.analysis_component.AnalysisComponent
collectionProcessComplete
in class org.apache.uima.analysis_component.AnalysisComponent_ImplBase
org.apache.uima.analysis_engine.AnalysisEngineProcessException
protected boolean hasFilteredAnnotation(org.apache.uima.jcas.JCas jCas) throws org.apache.uima.analysis_engine.AnalysisEngineProcessException
jCas
- CAS to check for filtered typesorg.apache.uima.analysis_engine.AnalysisEngineProcessException
- if one of the type names in the tyepsFilter is not found in the type systemprotected boolean hasInputTypesAnnotation(org.apache.uima.jcas.JCas jCas) throws org.apache.uima.analysis_engine.AnalysisEngineProcessException
jCas
- CAS to checkorg.apache.uima.analysis_engine.AnalysisEngineProcessException
- If one of the type names in the inputTypes list is not found in the type systemprotected boolean containsAnnotationInList(org.apache.uima.jcas.JCas jCas, String[] typeList, boolean isEmpty) throws org.apache.uima.analysis_engine.AnalysisEngineProcessException
jCas
- CAS to checktypeList
- list of types to check forisEmpty
- if this list is empty then return the value of this boolean flagorg.apache.uima.analysis_engine.AnalysisEngineProcessException
- If one of the types is not in the type system of the CASpublic LeoDelegate getDescriptor() throws Exception
getDescriptor
in interface LeoAnnotator
Exception
- if there is an error getting the descriptorpublic LeoAEDescriptor getLeoAEDescriptor() throws Exception
Exception
- if there is an error getting the descriptorpublic LeoTypeSystemDescription getLeoTypeSystemDescription()
typeSystemDescription
to set a default type system description unique to that annotator.public <T extends LeoBaseAnnotator> T addLeoTypeSystemDescription(LeoTypeSystemDescription typeSystemDescription)
T
- delegate object reference for extending classes to support the builder pattern.typeSystemDescription
- LeoTypeSystemDescription to add.public <T extends LeoBaseAnnotator> T setLeoTypeSystemDescription(LeoTypeSystemDescription typeSystemDescription)
T
- delegate object reference for extending classes to support the builder pattern.typeSystemDescription
- LeoTypeSystemDescription to use.Copyright © 2018 Department of Veterans Affairs. All Rights Reserved.