public abstract class Annotator extends Object
TextAnnotation
. Supports lazy initialization.
IMPORTANT FOR DERIVED CLASSES: if you initialize fields at declaration rather than in the constructor,
those assignments take place AFTER the super.constructor has run -- so e.g. you cannot
use a Logger you declare in this way to log messages in the initialize() method that
is called by the Annotator class constructor.Modifier and Type | Field and Description |
---|---|
protected ResourceManager |
config
stores configuration for lazy initialization.
|
protected boolean |
isInitialized |
protected String[] |
requiredViews |
protected String |
viewName |
Constructor and Description |
---|
Annotator(String viewName,
String[] requiredViews)
set the name of the View this Annotator creates, and the list of prerequisite Views that this
Annotator requires as input
|
Annotator(String viewName,
String[] requiredViews,
boolean isLazilyInitialized)
explicitly declare whether lazy initialization should be used
|
Annotator(String viewName,
String[] requiredViews,
boolean isLazilyInitialized,
ResourceManager config)
some annotators have complex initialization, so will have to pass a ResourceManager to be on
hand for their initialization if non-lazy initialization is desired.
|
Annotator(String viewName,
String[] requiredViews,
ResourceManager rm)
If lazy initialization is desired, set the property
AnnotatorConfigurator.IS_LAZILY_INITIALIZED in the ResourceManager argument |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
addView(TextAnnotation ta)
create and add the view named by getViewName() to the TextAnnotation argument.
|
void |
doInitialize()
If you want lazy initialization, this method must load the component models/resources,
Default implementation just sets the relevant field to 'true'.
|
String[] |
getRequiredViews()
Can be used internally by
BasicAnnotatorService to check for pre-requisites before
calling any single (external) Annotator . |
Set<String> |
getTagValues()
Return possible tag values that the annotator can produce.
|
View |
getView(TextAnnotation ta)
Add the view named by getViewName() to the TextAnnotation argument, and return the View
|
String |
getViewName()
return the name of the View created by this Annotator
|
abstract void |
initialize(ResourceManager rm)
Derived classes use this to load memory- or time-consuming resources.
|
boolean |
isInitialized()
Indicates whether or not all models/resources have been loaded.
|
boolean |
isSentenceLevel() |
protected String viewName
protected String[] requiredViews
protected boolean isInitialized
protected ResourceManager config
public Annotator(String viewName, String[] requiredViews)
viewName
- The name of the View this annotator will populate. This will be used to
access the created view from the TextAnnotation holding it.requiredViews
- The views that must be populated for this new view to be created.public Annotator(String viewName, String[] requiredViews, boolean isLazilyInitialized)
viewName
- The name of the View this annotator will populate. This will be used to
access the created view from the TextAnnotation holding it.requiredViews
- The views that must be populated for this new view to be created.isLazilyInitialized
- if 'true', defers the initialization of the derived class until
getView() is called.public Annotator(String viewName, String[] requiredViews, ResourceManager rm)
AnnotatorConfigurator.IS_LAZILY_INITIALIZED
in the ResourceManager argumentviewName
- The name of the View this annotator will populate. This will be used to
access the created view from the TextAnnotation holding it.requiredViews
- The views that must be populated for this new view to be created.rm
- configuration parameters. lazy initialization is set to 'false' by default.public Annotator(String viewName, String[] requiredViews, boolean isLazilyInitialized, ResourceManager config)
viewName
- The name of the View this annotator will populate. This will be used to
access the created view from the TextAnnotation holding it.requiredViews
- The views that must be populated for this new view to be created.isLazilyInitialized
- if 'true', defers the initialization of the derived class until
getView() is called.config
- these properties are stored for use by derived class, esp. in
initialize()public abstract void initialize(ResourceManager rm)
rm
- configuration parameterspublic final void doInitialize()
public boolean isInitialized()
protected abstract void addView(TextAnnotation ta) throws AnnotatorException
ta
- the TextAnnotation to modify.AnnotatorException
public String getViewName()
public final View getView(TextAnnotation ta) throws AnnotatorException
ta
- AnnotatorException
public String[] getRequiredViews()
BasicAnnotatorService
to check for pre-requisites before
calling any single (external) Annotator
.ViewNames
required by
this ViewGeneratorpublic Set<String> getTagValues()
public boolean isSentenceLevel()
Copyright © 2017. All rights reserved.