edu.stanford.nlp.pipeline
Class AnnotatorPool

java.lang.Object
  extended by edu.stanford.nlp.pipeline.AnnotatorPool

public class AnnotatorPool
extends java.lang.Object

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.

Author:
bethard

Constructor Summary
AnnotatorPool()
          Create an empty AnnotatorPool.
 
Method Summary
 Annotator get(java.lang.String name)
          Retrieve an Annotator from the pool.
 boolean register(java.lang.String name, AnnotatorFactory factory)
          Register an Annotator that can be created by the pool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnnotatorPool

public AnnotatorPool()
Create an empty AnnotatorPool.

Method Detail

register

public boolean register(java.lang.String name,
                        AnnotatorFactory factory)
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.

Parameters:
name - The name to be associated with the Annotator.
factory - A factory that creates an instance of the desired Annotator.
Returns:
true if a new annotator was created; false if we reuse an existing one

get

public Annotator get(java.lang.String name)
Retrieve an Annotator from the pool. If the named Annotator has not yet been requested, it will be created. Otherwise, the existing instance of the Annotator will be returned.

Parameters:
name - The annotator to retrieve from the pool
Returns:
The annotator
Throws:
java.lang.IllegalArgumentException - If the annotator cannot be created


Stanford NLP Group