Package opennlp.tools.namefind
Class TokenNameFinderFactory
- java.lang.Object
-
- opennlp.tools.util.BaseToolFactory
-
- opennlp.tools.namefind.TokenNameFinderFactory
-
public class TokenNameFinderFactory extends BaseToolFactory
The factory that providesTokenNameFinder
default implementations and resources. That only works if that's the central class used for training/runtime.
-
-
Constructor Summary
Constructors Constructor Description TokenNameFinderFactory()
Initializes 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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static TokenNameFinderFactory
create(String subclassName, byte[] featureGeneratorBytes, Map<String,Object> resources, SequenceCodec<String> seqCodec)
Initializes aTokenNameFinderFactory
instance via given parameters.NameContextGenerator
createContextGenerator()
Creates and configures a newNameContextGenerator
in a default combination.AdaptiveFeatureGenerator
createFeatureGenerators()
Creates theAdaptiveFeatureGenerator
.SequenceCodec<String>
createSequenceCodec()
static SequenceCodec<String>
instantiateSequenceCodec(String sequenceCodecImplName)
Initializes aSequenceCodec
instance via given parameters.void
validateArtifactMap()
Validates the parsed artifacts.-
Methods inherited from class opennlp.tools.util.BaseToolFactory
create, create, createArtifactMap, createArtifactSerializersMap, createManifestEntries
-
-
-
-
Constructor Detail
-
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 Detail
-
create
public static TokenNameFinderFactory create(String subclassName, byte[] featureGeneratorBytes, Map<String,Object> resources, SequenceCodec<String> seqCodec) throws InvalidFormatException
Initializes 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
public void validateArtifactMap() throws InvalidFormatException
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
public SequenceCodec<String> 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:
BioCodec
,BilouCodec
-
createContextGenerator
public NameContextGenerator createContextGenerator()
Creates and configures a newNameContextGenerator
in a default combination.- Returns:
- A
NameContextGenerator
instance. - See Also:
DefaultNameContextGenerator
,AdaptiveFeatureGenerator
-
createFeatureGenerators
public AdaptiveFeatureGenerator 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:
SequenceCodec
,BioCodec
,BilouCodec
-
-