public class AnnotatorPool
An object for keeping track of Annotators. Typical use is to allow multiple
pipelines to share any Annotators in common.
For example, if multiple pipelines exist, and they both need a
ParserAnnotator, it would be bad to load two such Annotators into memory.
Instead, an AnnotatorPool will only create one Annotator and allow both
pipelines to share it.
A global singleton annotator pool, so that we can cache globally on a JVM instance.
Create an empty AnnotatorPool.
public boolean register(java.lang.String name,
Register an Annotator that can be created by the pool.
Note that factories are used here so that many possible annotators can
be defined within the AnnotatorPool, but an Annotator is only created
when one is actually needed.
name - The name to be associated with the Annotator.
props - The properties we are using to create the annotator
annotator - A factory that creates an instance of the desired Annotator.
This should be an instance of Lazy.cache(Supplier), if we want
the annotator pool to behave as a cache (i.e., evict old annotators
when the GC requires it).
true if a new annotator was created; false if we reuse an existing one
public void clear()
Clear this pool, and unmount all the annotators mounted on it.