Package opennlp.tools.namefind
Class TokenNameFinderFactory
java.lang.Object
opennlp.tools.util.BaseToolFactory
opennlp.tools.namefind.TokenNameFinderFactory
The factory that provides
TokenNameFinder
default implementations and
resources. That only works if that's the central class used for training/runtime.-
Constructor Summary
ConstructorDescriptionInitializes aTokenNameFinderFactory
that provides the default implementation of the resources.TokenNameFinderFactory
(byte[] featureGeneratorBytes, Map<String, Object> resources, SequenceCodec<String> seqCodec) Initializes aTokenNameFinderFactory
instance via given parameters. -
Method Summary
Modifier and TypeMethodDescriptionstatic TokenNameFinderFactory
create
(String subclassName, byte[] featureGeneratorBytes, Map<String, Object> resources, SequenceCodec<String> seqCodec) Initializes aTokenNameFinderFactory
instance via given parameters.Creates and configures a newNameContextGenerator
in a default combination.Creates theAdaptiveFeatureGenerator
.static SequenceCodec<String>
instantiateSequenceCodec
(String sequenceCodecImplName) Initializes aSequenceCodec
instance via given parameters.void
Validates the parsed artifacts.Methods inherited from class opennlp.tools.util.BaseToolFactory
create, create, createArtifactMap, createArtifactSerializersMap, createManifestEntries
-
Constructor Details
-
TokenNameFinderFactory
public TokenNameFinderFactory()Initializes aTokenNameFinderFactory
that provides the default implementation of the resources.BioCodec
will be used as defaultSequenceCodec
. -
TokenNameFinderFactory
public TokenNameFinderFactory(byte[] featureGeneratorBytes, Map<String, Object> resources, SequenceCodec<String> seqCodec) Initializes aTokenNameFinderFactory
instance via given parameters.- Parameters:
featureGeneratorBytes
- Thebyte[]
representing the feature generator descriptor.resources
- Additional resources in a mapping.seqCodec
- TheSequenceCodec
to use.
-
-
Method Details
-
create
public static TokenNameFinderFactory create(String subclassName, byte[] featureGeneratorBytes, Map<String, Object> resources, SequenceCodec<String> seqCodec) throws InvalidFormatExceptionInitializes aTokenNameFinderFactory
instance via given parameters.- Parameters:
subclassName
- The class name used for instantiation. Ifnull
, an instance ofTokenNameFinderFactory
will be returned per default. Otherwise, theExtensionLoader
mechanism is applied to load the requestedsubclassName
.featureGeneratorBytes
- Thebyte[]
representing the feature generator descriptor.resources
- Additional resources in a mapping.seqCodec
- TheSequenceCodec
to use.- Returns:
- A valid
TokenNameFinderFactory
instance. - Throws:
InvalidFormatException
- Thrown if theExtensionLoader
mechanism failed to create the factory associated withsubclassName
.
-
validateArtifactMap
Description copied from class:BaseToolFactory
Validates the parsed artifacts.Note: Subclasses should generally invoke
super.validateArtifactMap
at the beginning of this method.- Specified by:
validateArtifactMap
in classBaseToolFactory
- Throws:
InvalidFormatException
- Thrown if validation found invalid states.
-
createSequenceCodec
- Returns:
- Initializes and returns a
SequenceCodec
via its class name configured in a manifest. If that initialization fails (e.g., if no matching class could be loaded for the configured class name at runtime), the currently loaded (default)SequenceCodec
is returned. - See Also:
-
createContextGenerator
Creates and configures a newNameContextGenerator
in a default combination.- Returns:
- A
NameContextGenerator
instance. - See Also:
-
createFeatureGenerators
Creates theAdaptiveFeatureGenerator
. Usually this is a set of generators contained inAggregatedFeatureGenerator
.Note: The generators are created on every call to this method.
- Returns:
- The
AdaptiveFeatureGenerator
ornull
if there is no descriptor in the model. - Throws:
TokenNameFinderModel.FeatureGeneratorCreationError
- Thrown if configuration errors occurred.IllegalStateException
- Thrown if inconsistencies occurred during creation.
-
instantiateSequenceCodec
public static SequenceCodec<String> instantiateSequenceCodec(String sequenceCodecImplName) throws InvalidFormatException Initializes aSequenceCodec
instance via given parameters.- Parameters:
sequenceCodecImplName
- The class name used for instantiation. Ifnull
, an instance ofBioCodec
will be returned per default. Otherwise, theExtensionLoader
mechanism is applied to load the requestedsubclassName
.- Returns:
- A valid
SequenceCodec
instance. - Throws:
InvalidFormatException
- Thrown if theExtensionLoader
mechanism failed to create the codec associated withsequenceCodecImplName
.- See Also:
-