Class DependencyModel

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

public class DependencyModel extends BaseModel
The persisted form of a trained DependencyParserME: the transition classification model plus the standard model manifest, serialized and loaded through the same BaseModel machinery as every other tool 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:
    • PARSER_MODEL_ENTRY_NAME

      static final String PARSER_MODEL_ENTRY_NAME
      The artifact map entry holding the transition classification model.
      See Also:
  • Constructor Details

    • DependencyModel

      public DependencyModel(String languageCode, MaxentModel parserModel, Map<String,String> manifestInfoEntries)
      Initializes a DependencyModel from a trained transition model.
      Parameters:
      languageCode - The ISO language code of the training data. Must not be null.
      parserModel - The transition classification model. Must not be null.
      manifestInfoEntries - Additional entries for the manifest, or null.
      Throws:
      IllegalArgumentException - Thrown if languageCode or parserModel is null.
    • DependencyModel

      public DependencyModel(InputStream in) throws IOException
      Initializes a DependencyModel from a serialized model.
      Parameters:
      in - The stream to read the model from. Must not be null.
      Throws:
      IOException - Thrown if reading fails or the content is not a valid model.
      IllegalArgumentException - Thrown if in is null.
    • DependencyModel

      public DependencyModel(File modelFile) throws IOException
      Initializes a DependencyModel from a serialized model file.
      Parameters:
      modelFile - The file to read the model from. Must not be null.
      Throws:
      IOException - Thrown if reading fails or the content is not a valid model.
      IllegalArgumentException - Thrown if modelFile is null.
    • DependencyModel

      public DependencyModel(Path modelPath) throws IOException
      Initializes a DependencyModel from a serialized model file.
      Parameters:
      modelPath - The path to read the model from. Must not be null.
      Throws:
      IOException - Thrown if reading fails or the content is not a valid model.
      IllegalArgumentException - Thrown if modelPath is null.
  • Method Details

    • 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 transition model artifact is missing or not a supported model type.
    • getParserModel

      public MaxentModel getParserModel()
      Returns:
      The transition classification model. Never null.