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

opennlp.tools.ml.maxent.io

## Class QNModelReader

- java.lang.Object
- - opennlp.tools.ml.model.AbstractModelReader
  - - opennlp.tools.ml.maxent.io.GISModelReader
    - - opennlp.tools.ml.maxent.io.QNModelReader

- Direct Known Subclasses:
    BinaryQNModelReader

      public class QNModelReader
      extends GISModelReader

- - ### Field Summary

    - ### Fields inherited from class opennlp.tools.ml.model.AbstractModelReader

      `MAX_ENTRIES_PROPERTY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `QNModelReader(DataReader dataReader)`
    `QNModelReader(File file)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `checkModelType()`
    `QNModel` | `constructModel()` Retrieve a model from disk.

    - ### Methods inherited from class opennlp.tools.ml.model.AbstractModelReader

      `getModel, readDouble, readInt, readUTF`

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

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

- - ### Constructor Detail

    - #### QNModelReader

          public QNModelReader(DataReader dataReader)

    - #### QNModelReader

          public QNModelReader(File file)
                        throws IOException

      Throws:
        `IOException`

  - ### Method Detail

    - #### checkModelType

          public void checkModelType()
                              throws IOException

      Overrides:
        `checkModelType` in class `GISModelReader`
      Throws:
        `IOException`

    - #### constructModel

          public QNModel constructModel()
                                 throws IOException

      Description copied from class: `GISModelReader`
      Retrieve a model from disk. It assumes that models are saved in the following sequence:
      GIS (model type identifier)
      1. # of parameters (int)
      2. the correction constant (int)
      3. the correction constant parameter (double)
      4. # of outcomes (int)
      * list of outcome names (String)
      5. # of different types of outcome patterns (int)
      * list of (int int[])
      [# of predicates for which outcome pattern is true] [outcome pattern]
      6. # of predicates (int)
      * list of predicate names (String)

      If you are creating a reader for a format which won't work with this (perhaps a database or xml file), override this method and ignore the other methods provided in this abstract class.

      Overrides:
        `constructModel` in class `GISModelReader`
      Returns:
        The GISModel stored in the format and location specified to this GISModelReader (usually via its the constructor).
      Throws:
        `IOException`

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