Package opennlp.tools.ml.model

# Class AbstractModelReader

java.lang.Object
opennlp.tools.ml.model.AbstractModelReader

Direct Known Subclasses:
  `GenericModelReader`

public abstract class AbstractModelReader extends Object
An abstract, basic implementation of a model reader.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `MAX_ENTRIES_PROPERTY`
  System property for overriding the maximum number of entries (outcomes, predicates, outcome patterns, chunk counts) that may be read from a model file or training data.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `AbstractModelReader(File f)`
  Initializes a `AbstractModelReader` via a `File`.
  `AbstractModelReader(opennlp.tools.ml.model.DataReader dataReader)`
  Initializes a `AbstractModelReader` via a `DataReader`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `abstract void`
  `checkModelType()`
  Checks the model type via the the underlying `DataReader`.
  `abstract AbstractModel`
  `constructModel()`
  Constructs a `model`.
  `AbstractModel`
  `getModel()`
  `double`
  `readDouble()`
  Implement as needed for the format the model is stored in.
  `int`
  `readInt()`
  Implement as needed for the format the model is stored in.
  `String`
  `readUTF()`
  Implement as needed for the format the model is stored in.

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### MAX_ENTRIES_PROPERTY

    public static final String MAX_ENTRIES_PROPERTY
    System property for overriding the maximum number of entries (outcomes, predicates, outcome patterns, chunk counts) that may be read from a model file or training data. Set at JVM startup, e.g. `-DOPENNLP_MAX_ENTRIES=5000000`. Falls back to `10_000_000` if absent or invalid.
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### AbstractModelReader

    public AbstractModelReader(File f) throws IOException
    Initializes a `AbstractModelReader` via a `File`.
    Parameters:
      `f` - The `File` that references the model to be read.
    Throws:
      `IOException` - Thrown if IO errors occurred.

  - ### AbstractModelReader

    public AbstractModelReader(opennlp.tools.ml.model.DataReader dataReader)
    Initializes a `AbstractModelReader` via a `DataReader`.
    Parameters:
      `dataReader` - The `DataReader` that references the model to be read.

- ## Method Details

  - ### readInt

    public int readInt() throws IOException
    Implement as needed for the format the model is stored in.
    Returns:
      Reads in an `int` value from the underlying `DataReader`.
    Throws:
      `IOException`

  - ### readDouble

    public double readDouble() throws IOException
    Implement as needed for the format the model is stored in.
    Returns:
      Reads in a `double` value from the underlying `DataReader`.
    Throws:
      `IOException`

  - ### readUTF

    public String readUTF() throws IOException
    Implement as needed for the format the model is stored in.
    Returns:
      Reads in an `UTF-encoded String` value from the underlying `DataReader`.
    Throws:
      `IOException`

  - ### getModel

    public AbstractModel getModel() throws IOException
    Returns:
      Retrieves the read `AbstractModel` instance.
    Throws:
      `IOException` - Thrown if IO errors occurred constructing the model.

  - ### checkModelType

    public abstract void checkModelType() throws IOException
    Checks the model type via the the underlying `DataReader`.
    Throws:
      `IOException` - Thrown if IO errors occurred checking the model type.

  - ### constructModel

    public abstract AbstractModel constructModel() throws IOException
    Constructs a `model`.
    Returns:
      A `AbstractModel` reconstructed from a model's (read) attributes.
    Throws:
      `IOException` - Thrown if IO errors occurred during (re-)construction.