Package org.apache.uima.fit.pipeline
Class JCasIterator
java.lang.Object
org.apache.uima.fit.pipeline.JCasIterator
A class implementing iteration over a the documents of a collection. Each element in the Iterable
is a JCas containing a single document. The documents have been loaded by the CollectionReader
and processed by the AnalysisEngine (if any).
-
Constructor Summary
ConstructorDescriptionJCasIterator
(CollectionReaderDescription aReader, AnalysisEngineDescription... aEngines) Iterate over the documents loaded by the given reader, running the analysis engines on each one before yielding them.JCasIterator
(CollectionReader aReader, AnalysisEngine... aEngines) Iterate over the documents loaded by the CollectionReader, running the AnalysisEngine on each one before yielding them.JCasIterator
(CollectionReader aReader, TypeSystemDescription aTypeSystemDescription) Iterate over the documents loaded by the CollectionReader.JCasIterator
(ResourceManager aResMgr, CollectionReaderDescription aReader, AnalysisEngineDescription... aEngines) Iterate over the documents loaded by the given reader, running the analysis engines on each one before yielding them.JCasIterator
(ResourceManager aResMgr, CollectionReader aReader, AnalysisEngine... aEngines) Iterate over the documents loaded by the CollectionReader, running the AnalysisEngine on each one before yielding them. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Notify analysis engines that the collection process is complete.void
destroy()
Close and destroy all components.sboolean
hasNext()
boolean
Get whethercollectionProcessComplete()
is automatically called.boolean
Get whetherdestroy()
is automatically called.next()
void
remove()
void
setSelfComplete
(boolean aSelfComplete) Send acollectionProcessComplete()
call to analysis engines when the reader has no further CASes to produce.void
setSelfDestroy
(boolean aSelfDestroy) Send a destroy call to analysis engines when the reader has no further CASes to produce or if an error occurs.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
JCasIterator
public JCasIterator(CollectionReaderDescription aReader, AnalysisEngineDescription... aEngines) throws CASException, ResourceInitializationException Iterate over the documents loaded by the given reader, running the analysis engines on each one before yielding them. By default, components DO get life-cycle events, such as collectionProcessComplete or destroy when this constructor is used.- Parameters:
aReader
- The CollectionReader for loading documents.aEngines
- The AnalysisEngines for processing documents.- Throws:
ResourceInitializationException
- if a failure occurs during initialization of the componentsCASException
- if the JCas could not be initialized
-
JCasIterator
public JCasIterator(ResourceManager aResMgr, CollectionReaderDescription aReader, AnalysisEngineDescription... aEngines) throws CASException, ResourceInitializationException Iterate over the documents loaded by the given reader, running the analysis engines on each one before yielding them. By default, components DO get life-cycle events, such as collectionProcessComplete or destroy when this constructor is used.- Parameters:
aResMgr
- TheResourceManager
used to create the components and the JCas. If this parameter isnull
thenResourceManagerFactory.newResourceManager()
will be used to obtain a resource manager. If a new resource manager was internally created, it is destroyed at the end of the pipeline (ifisSelfDestroy()
).aReader
- The CollectionReader for loading documents.aEngines
- The AnalysisEngines for processing documents.- Throws:
ResourceInitializationException
- if a failure occurs during initialization of the componentsCASException
- if the JCas could not be initialized
-
JCasIterator
public JCasIterator(CollectionReader aReader, AnalysisEngine... aEngines) throws CASException, ResourceInitializationException Iterate over the documents loaded by the CollectionReader, running the AnalysisEngine on each one before yielding them. By default, components do NOT get life-cycle events, such as collectionProcessComplete or destroy when this constructor is used.- Parameters:
aReader
- The CollectionReader for loading documents.aEngines
- The AnalysisEngines for processing documents.- Throws:
ResourceInitializationException
- if a failure occurs during initialization of the componentsCASException
- if the JCas could not be initialized
-
JCasIterator
public JCasIterator(CollectionReader aReader, TypeSystemDescription aTypeSystemDescription) throws CASException, ResourceInitializationException Iterate over the documents loaded by the CollectionReader. (Uses an JCasAnnotatorAdapter to create the document JCas.) By default, components do NOT get life-cycle events, such as collectionProcessComplete or destroy when this constructor is used.- Parameters:
aReader
- The CollectionReader for loading documents.aTypeSystemDescription
- a type system description- Throws:
ResourceInitializationException
- if a failure occurs during initialization of the componentsCASException
- if the JCas could not be initialized
-
JCasIterator
public JCasIterator(ResourceManager aResMgr, CollectionReader aReader, AnalysisEngine... aEngines) throws CASException, ResourceInitializationException Iterate over the documents loaded by the CollectionReader, running the AnalysisEngine on each one before yielding them. By default, components do NOT get life-cycle events, such as collectionProcessComplete or destroy when this constructor is used.- Parameters:
aResMgr
- TheResourceManager
used to create the JCas. Should be the one also used by the CollectionReader and the AnalysisEngines. If this parameter isnull
thenResourceManagerFactory.newResourceManager()
will be used to obtain a resource manager. If a new resource manager was internally created, it is destroyed at the end of the pipeline (ifisSelfDestroy()
).aReader
- The CollectionReader for loading documents.aEngines
- The AnalysisEngines for processing documents.- Throws:
ResourceInitializationException
- if a failure occurs during initialization of the componentsCASException
- if the JCas could not be initialized
-
-
Method Details
-
hasNext
public boolean hasNext() -
next
-
remove
public void remove() -
collectionProcessComplete
Notify analysis engines that the collection process is complete.- Throws:
AnalysisEngineProcessException
- if there was a problem completing the process
-
destroy
public void destroy()Close and destroy all components.s -
isSelfComplete
public boolean isSelfComplete()Get whethercollectionProcessComplete()
is automatically called.- Returns:
- whether
collectionProcessComplete()
is automatically called.
-
setSelfComplete
public void setSelfComplete(boolean aSelfComplete) Send acollectionProcessComplete()
call to analysis engines when the reader has no further CASes to produce.- Parameters:
aSelfComplete
- whether to enable the automatic call tocollectionProcessComplete()
-
isSelfDestroy
public boolean isSelfDestroy()Get whetherdestroy()
is automatically called.- Returns:
- whether
destroy()
is automatically called.
-
setSelfDestroy
public void setSelfDestroy(boolean aSelfDestroy) Send a destroy call to analysis engines when the reader has no further CASes to produce or if an error occurs.- Parameters:
aSelfDestroy
- whether to enable the automatic call toResource.destroy()
-