Package opennlp.dl

# Class AbstractDL

java.lang.Object
opennlp.dl.AbstractDL

All Implemented Interfaces:
  `AutoCloseable`

Direct Known Subclasses:
  `DocumentCategorizerDL`, `NameFinderDL`, `SentenceVectorsDL`

public abstract class AbstractDL extends Object implements AutoCloseable
Base class for OpenNLP deep-learning classes using ONNX Runtime.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `ATTENTION_MASK`
  `static final String`
  `INPUT_IDS`
  `static final String`
  `TOKEN_TYPE_IDS`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close()`
  Closes the ONNX `OrtSession` owned by this instance.
  `Map<String,Integer>`
  `loadVocab(File vocabFile)`
  Loads a vocabulary `File` from disk.

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

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

- ## Field Details

  - ### INPUT_IDS

    public static final String INPUT_IDS
    See Also:
      - Constant Field Values

  - ### ATTENTION_MASK

    public static final String ATTENTION_MASK
    See Also:
      - Constant Field Values

  - ### TOKEN_TYPE_IDS

    public static final String TOKEN_TYPE_IDS
    See Also:
      - Constant Field Values

- ## Method Details

  - ### loadVocab

    public Map<String,Integer> loadVocab(File vocabFile) throws IOException
    Loads a vocabulary `File` from disk. Supports both plain text files (one token per line) and simple JSON vocabulary files mapping tokens to integer IDs. JSON support is intentionally limited to the HuggingFace vocabulary shape; it is not a general-purpose JSON parser.
    Parameters:
      `vocabFile` - The vocabulary file.
    Returns:
      A map of vocabulary words to IDs.
    Throws:
      `IOException` - Thrown if the vocabulary file cannot be opened or read.

  - ### close

    public void close() throws ai.onnxruntime.OrtException
    Closes the ONNX `OrtSession` owned by this instance.

    The `OrtEnvironment` is deliberately not closed: `OrtEnvironment.getEnvironment()` returns a process-wide singleton shared by every deep-learning component, so closing it here would tear down the environment other live components still depend on.

    This method is idempotent: calling `close()` more than once, or calling it on a never-used but successfully constructed instance, is a no-op after the first successful close attempt. The underlying `OrtSession.close()` is only invoked once.

    Specified by:
      `close` in interface `AutoCloseable`
    Throws:
      `ai.onnxruntime.OrtException` - Thrown if the close attempt fails in the native layer.