Package opennlp.tools.util
Class BaseToolFactory
java.lang.Object
opennlp.tools.util.BaseToolFactory
- Direct Known Subclasses:
ChunkerFactory
,DoccatFactory
,LanguageDetectorFactory
,LemmatizerFactory
,POSTaggerFactory
,SentenceDetectorFactory
,TokenizerFactory
,TokenNameFinderFactory
Base class for all tool
factories
.
Extensions of this class should:
- implement an empty constructor,
- implement a constructor that takes the
ArtifactProvider
}, - override
createArtifactMap()
andcreateArtifactSerializersMap()
methods if necessary.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic BaseToolFactory
create
(Class<? extends BaseToolFactory> factoryClass, ArtifactProvider artifactProvider) Instantiates aBaseToolFactory
via a givensubclassName
.static BaseToolFactory
create
(String subclassName, ArtifactProvider artifactProvider) Instantiates aBaseToolFactory
via a givensubclassName
.A model's implementation should call this constructor that creates a model programmatically.Creates aMap
with pairs of keys andArtifactSerializer
.abstract void
Validates the parsed artifacts.
-
Constructor Details
-
BaseToolFactory
public BaseToolFactory()All subclasses should have an empty constructor
-
-
Method Details
-
createArtifactSerializersMap
Creates aMap
with pairs of keys andArtifactSerializer
. The models implementation should call this method fromBaseModel#createArtifactSerializersMap
.The base implementation will return a
HashMap
that should be populated by subclasses. -
createArtifactMap
A model's implementation should call this constructor that creates a model programmatically.The base implementation will return a
HashMap
that should be populated by subclasses.- Returns:
- Retrieves a
Map
with pairs of keys and objects.
-
createManifestEntries
- Returns:
- Retrieves the manifest entries to be added to the model manifest.
-
validateArtifactMap
Validates the parsed artifacts.Note: Subclasses should generally invoke
super.validateArtifactMap
at the beginning of this method.- Throws:
InvalidFormatException
- Thrown if validation found invalid states.
-
create
public static BaseToolFactory create(String subclassName, ArtifactProvider artifactProvider) throws InvalidFormatException Instantiates aBaseToolFactory
via a givensubclassName
.- Parameters:
subclassName
- The class name used for instantiation. TheExtensionLoader
mechanism is applied to load the requestedsubclassName
.artifactProvider
- TheArtifactProvider
to be used.- Returns:
- A valid
BaseToolFactory
instance. - Throws:
InvalidFormatException
- Thrown if theExtensionLoader
mechanism failed to create the factory associated withsubclassName
.
-
create
public static BaseToolFactory create(Class<? extends BaseToolFactory> factoryClass, ArtifactProvider artifactProvider) throws InvalidFormatException Instantiates aBaseToolFactory
via a givensubclassName
.- Parameters:
factoryClass
- The class used for instantiation. The no-arg constructor of that class will be used to create and init the resulting object.artifactProvider
- TheArtifactProvider
to be used.- Returns:
- A valid
BaseToolFactory
instance. - Throws:
InvalidFormatException
- Thrown if theExtensionLoader
mechanism failed to create the factory associated withsubclassName
.
-