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

opennlp.tools.ml.model

## Class Context

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

- Direct Known Subclasses:
    MutableContext

      public class Context
      extends Object

  Class which associates a real valued parameter or expected value with a particular contextual predicate or feature. This is used to store maxent model parameters as well as model and empirical expected values.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Context(int[] outcomePattern, double[] parameters)` Creates a new parameters object with the specified parameters associated with the specified outcome pattern.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(Object obj)`
    `int[]` | `getOutcomes()` Returns the outcomes for which parameters exists for this context.
    `double[]` | `getParameters()` Returns the parameters or expected values for the outcomes which occur with this context.
    `int` | `hashCode()`

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

      `getClass, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Context

          public Context(int[] outcomePattern,
                         double[] parameters)

      Creates a new parameters object with the specified parameters associated with the specified outcome pattern.
      Parameters:
        `outcomePattern` - Array of outcomes for which parameters exists for this context.
        `parameters` - Parameters for the outcomes specified.

  - ### Method Detail

    - #### getOutcomes

          public int[] getOutcomes()

      Returns the outcomes for which parameters exists for this context.
      Returns:
        Array of outcomes for which parameters exists for this context.

    - #### getParameters

          public double[] getParameters()

      Returns the parameters or expected values for the outcomes which occur with this context.
      Returns:
        Array of parameters for the outcomes of this context.

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### equals

          public boolean equals(Object obj)

      Overrides:
        `equals` in class `Object`

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