AbstractModelReader (Apache OpenNLP Tools 1.9.5 API)
Date: 2026-06-18

opennlp.tools.ml.model

## Class AbstractModelReader

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

- Direct Known Subclasses:
    GenericModelReader, GISModelReader, NaiveBayesModelReader, PerceptronModelReader

      public abstract class AbstractModelReader
      extends Object

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static 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 and Description
    `AbstractModelReader(DataReader dataReader)`
    `AbstractModelReader(File f)`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract void` | `checkModelType()`
    `abstract AbstractModel` | `constructModel()`
    `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 Detail

    - #### 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 Detail

    - #### AbstractModelReader

          public AbstractModelReader(File f)
                              throws IOException

      Throws:
        `IOException`

    - #### AbstractModelReader

          public AbstractModelReader(DataReader dataReader)

  - ### Method Detail

    - #### readInt

          public int readInt()
                      throws IOException

      Implement as needed for the format the model is stored in.
      Throws:
        `IOException`

    - #### readDouble

          public double readDouble()
                            throws IOException

      Implement as needed for the format the model is stored in.
      Throws:
        `IOException`

    - #### readUTF

          public String readUTF()
                         throws IOException

      Implement as needed for the format the model is stored in.
      Throws:
        `IOException`

    - #### getModel

          public AbstractModel getModel()
                                 throws IOException

      Throws:
        `IOException`

    - #### checkModelType

          public abstract void checkModelType()
                                       throws IOException

      Throws:
        `IOException`

    - #### constructModel

          public abstract AbstractModel constructModel()
                                                throws IOException

      Throws:
        `IOException`

Copyright © 2026 The Apache Software Foundation. All rights reserved.