Class FeedforwardDependencyModel

java.lang.Object
opennlp.tools.util.model.BaseModel
opennlp.tools.depparse.FeedforwardDependencyModel
All Implemented Interfaces:
Serializable, ArtifactProvider

public class FeedforwardDependencyModel extends BaseModel
The persisted form of a trained FeedforwardDependencyParser: the network weights plus the standard model manifest, serialized and loaded through the same BaseModel machinery as every other tool model.

The weights are not modified after construction or loading. A model can be shared between threads and between parsers; refine trains a copy and returns a new model.

Since:
3.0.0
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • COMPONENT_NAME

      private static final String COMPONENT_NAME
      The component name recorded in the model manifest.
      See Also:
    • NETWORK_ENTRY_NAME

      static final String NETWORK_ENTRY_NAME
      The artifact map entry holding the network.
      See Also:
    • NETWORK_EXTENSION

      private static final String NETWORK_EXTENSION
      The artifact extension the network serializer is registered under.
      See Also:
    • GREEDY_BEAM_SIZE

      private static final int GREEDY_BEAM_SIZE
      The beam size of a model that was not refined with beam search.
      See Also:
  • Constructor Details

  • Method Details

    • createArtifactSerializers

      protected void createArtifactSerializers(Map<String,ArtifactSerializer<?>> serializers)
      Registers all ArtifactSerializer for their artifact file name extensions. The registered serializers are used to create and serialize resources in the model package.

      Override this method to register custom serializers.

      Note: Subclasses should generally invoke super.createArtifactSerializers at the beginning of this method.

      This method is called during construction.

      Registers the network serializer.

      Overrides:
      createArtifactSerializers in class BaseModel
      Parameters:
      serializers - The key of the map is the file extension used to look up an ArtifactSerializer.
    • validateArtifactMap

      protected void validateArtifactMap() throws InvalidFormatException
      Validates the parsed artifacts. If something is not valid, subclasses should throw an InvalidFormatException.

      Note: Subclasses should generally invoke super.validateArtifactMap at the beginning of this method.

      Overrides:
      validateArtifactMap in class BaseModel
      Throws:
      InvalidFormatException - Thrown if the network artifact is missing or not a feedforward network, or the manifest records a beam size that is not a positive integer.
    • getBeamSize

      public int getBeamSize()
      Returns the beam size a parser uses when none is given: the beam size the model was refined with, which the manifest records under "BeamSize", or 1 (greedy) for a model that was not refined.
      Returns:
      The beam size. Always positive.
    • isPositiveInteger

      private static boolean isPositiveInteger(String value)
      Tells whether a manifest value is a positive decimal integer.
      Parameters:
      value - The manifest value. Must not be null.
      Returns:
      true if value parses as an int above zero.
    • network

      Returns:
      The network. Never null.