Class TokenNameFinderFactory

java.lang.Object
opennlp.tools.util.BaseToolFactory
opennlp.tools.namefind.TokenNameFinderFactory

public class TokenNameFinderFactory extends BaseToolFactory
The factory that provides TokenNameFinder default implementations and resources. That only works if that's the central class used for training/runtime.
  • Constructor Details

    • TokenNameFinderFactory

      public TokenNameFinderFactory()
      Initializes a TokenNameFinderFactory that provides the default implementation of the resources. BioCodec will be used as default SequenceCodec.
    • TokenNameFinderFactory

      public TokenNameFinderFactory(byte[] featureGeneratorBytes, Map<String,Object> resources, opennlp.tools.util.SequenceCodec<String> seqCodec)
      Initializes a TokenNameFinderFactory instance via given parameters.
      Parameters:
      featureGeneratorBytes - The byte[] representing the feature generator descriptor.
      resources - Additional resources in a mapping.
      seqCodec - The SequenceCodec to use.
  • Method Details

    • create

      public static TokenNameFinderFactory create(String subclassName, byte[] featureGeneratorBytes, Map<String,Object> resources, opennlp.tools.util.SequenceCodec<String> seqCodec) throws opennlp.tools.util.InvalidFormatException
      Initializes a TokenNameFinderFactory instance via given parameters.
      Parameters:
      subclassName - The class name used for instantiation. If null, an instance of TokenNameFinderFactory will be returned per default. Otherwise, the ExtensionLoader mechanism is applied to load the requested subclassName.
      featureGeneratorBytes - The byte[] representing the feature generator descriptor.
      resources - Additional resources in a mapping.
      seqCodec - The SequenceCodec to use.
      Returns:
      A valid TokenNameFinderFactory instance.
      Throws:
      opennlp.tools.util.InvalidFormatException - Thrown if the ExtensionLoader mechanism failed to create the factory associated with subclassName.
    • validateArtifactMap

      public void validateArtifactMap() throws opennlp.tools.util.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 class BaseToolFactory
      Throws:
      opennlp.tools.util.InvalidFormatException - Thrown if validation found invalid states.
    • createSequenceCodec

      public opennlp.tools.util.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:
    • createContextGenerator

      public opennlp.tools.namefind.NameContextGenerator createContextGenerator()
      Creates and configures a new NameContextGenerator in a default combination.
      Returns:
      A NameContextGenerator instance.
      See Also:
    • createFeatureGenerators

      public opennlp.tools.util.featuregen.AdaptiveFeatureGenerator createFeatureGenerators()
      Creates the AdaptiveFeatureGenerator. Usually this is a set of generators contained in AggregatedFeatureGenerator.

      Note: The generators are created on every call to this method.

      Returns:
      The AdaptiveFeatureGenerator or null 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 opennlp.tools.util.SequenceCodec<String> instantiateSequenceCodec(String sequenceCodecImplName) throws opennlp.tools.util.InvalidFormatException
      Initializes a SequenceCodec instance via given parameters.
      Parameters:
      sequenceCodecImplName - The class name used for instantiation. If null, an instance of BioCodec will be returned per default. Otherwise, the ExtensionLoader mechanism is applied to load the requested subclassName.
      Returns:
      A valid SequenceCodec instance.
      Throws:
      opennlp.tools.util.InvalidFormatException - Thrown if the ExtensionLoader mechanism failed to create the codec associated with sequenceCodecImplName.
      See Also: