Class BaseToolFactory
java.lang.Object
opennlp.tools.util.BaseToolFactory
- Direct Known Subclasses:
ChunkerFactory, DoccatFactory, LanguageDetectorFactory, LemmatizerFactory, POSTaggerFactory, SentenceDetectorFactory, SentimentFactory, 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic BaseToolFactorycreate(Class<? extends BaseToolFactory> factoryClass, opennlp.tools.util.model.ArtifactProvider artifactProvider) Instantiates aBaseToolFactoryvia a givensubclassName.static BaseToolFactoryInstantiates aBaseToolFactoryvia a givensubclassName.A model's implementation should call this constructor that creates a model programmatically.Creates aMapwith pairs of keys andArtifactSerializer.abstract voidValidates the parsed artifacts.
-
Constructor Details
-
BaseToolFactory
public BaseToolFactory()All subclasses should have an empty constructor
-
-
Method Details
-
createArtifactSerializersMap
-
createArtifactMap
-
createManifestEntries
-
validateArtifactMap
public abstract void validateArtifactMap() throws opennlp.tools.util.InvalidFormatExceptionValidates the parsed artifacts.Note: Subclasses should generally invoke
super.validateArtifactMapat the beginning of this method.- Throws:
opennlp.tools.util.InvalidFormatException- Thrown if validation found invalid states.
-
create
public static BaseToolFactory create(String subclassName, opennlp.tools.util.model.ArtifactProvider artifactProvider) throws opennlp.tools.util.InvalidFormatException Instantiates aBaseToolFactoryvia a givensubclassName.- Parameters:
subclassName- The class name used for instantiation. TheExtensionLoadermechanism is applied to load the requestedsubclassName.artifactProvider- TheArtifactProviderto be used.- Returns:
- A valid
BaseToolFactoryinstance. - Throws:
opennlp.tools.util.InvalidFormatException- Thrown if theExtensionLoadermechanism failed to create the factory associated withsubclassName.
-
create
public static BaseToolFactory create(Class<? extends BaseToolFactory> factoryClass, opennlp.tools.util.model.ArtifactProvider artifactProvider) throws opennlp.tools.util.InvalidFormatException Instantiates aBaseToolFactoryvia 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- TheArtifactProviderto be used.- Returns:
- A valid
BaseToolFactoryinstance. - Throws:
opennlp.tools.util.InvalidFormatException- Thrown if theExtensionLoadermechanism failed to create the factory associated withsubclassName.
-