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

opennlp.tools.ml.naivebayes

## Class LogProbability<T>

- java.lang.Object
- - opennlp.tools.ml.naivebayes.Probability<T>
  - - opennlp.tools.ml.naivebayes.LogProbability<T>

- Type Parameters:
    `T` - the label (category) class

      public class LogProbability<T>
      extends Probability<T>

  Class implementing the probability for a label.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `LogProbability(T label)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addIn(double probability)` Compounds the existing probability mass on the label with the new probability passed in to the method.
    `Double` | `get()` Returns the probability associated with a label
    `T` | `getLabel()` Returns the probabilities associated with all labels
    `Double` | `getLog()` Returns the log probability associated with a label
    `boolean` | `isLarger(Probability probability)` Checks if a probability is greater than the old one.
    `void` | `set(double probability)` Assigns a probability to a label, discarding any previously assigned probability.
    `void` | `set(Probability probability)` Assigns a probability to a label, discarding any previously assigned probability.
    `void` | `setIfLarger(double probability)` Assigns a probability to a label, discarding any previously assigned probability, if the new probability is greater than the old one.
    `void` | `setIfLarger(Probability probability)` Assigns a probability to a label, discarding any previously assigned probability, if the new probability is greater than the old one.
    `void` | `setLog(double probability)` Assigns a log probability to a label, discarding any previously assigned probability.
    `String` | `toString()`

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

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

- - ### Constructor Detail

    - #### LogProbability

          public LogProbability(T label)

  - ### Method Detail

    - #### set

          public void set(double probability)

      Assigns a probability to a label, discarding any previously assigned probability.
      Overrides:
        `set` in class `Probability<T>`
      Parameters:
        `probability` - the probability to assign

    - #### set

          public void set(Probability probability)

      Assigns a probability to a label, discarding any previously assigned probability.
      Overrides:
        `set` in class `Probability<T>`
      Parameters:
        `probability` - the probability to assign

    - #### setIfLarger

          public void setIfLarger(double probability)

      Assigns a probability to a label, discarding any previously assigned probability, if the new probability is greater than the old one.
      Overrides:
        `setIfLarger` in class `Probability<T>`
      Parameters:
        `probability` - the probability to assign

    - #### setIfLarger

          public void setIfLarger(Probability probability)

      Assigns a probability to a label, discarding any previously assigned probability, if the new probability is greater than the old one.
      Overrides:
        `setIfLarger` in class `Probability<T>`
      Parameters:
        `probability` - the probability to assign

    - #### isLarger

          public boolean isLarger(Probability probability)

      Checks if a probability is greater than the old one.
      Overrides:
        `isLarger` in class `Probability<T>`
      Parameters:
        `probability` - the probability to assign

    - #### setLog

          public void setLog(double probability)

      Assigns a log probability to a label, discarding any previously assigned probability.
      Overrides:
        `setLog` in class `Probability<T>`
      Parameters:
        `probability` - the log probability to assign

    - #### addIn

          public void addIn(double probability)

      Compounds the existing probability mass on the label with the new probability passed in to the method.
      Overrides:
        `addIn` in class `Probability<T>`
      Parameters:
        `probability` - the probability weight to add

    - #### get

          public Double get()

      Returns the probability associated with a label
      Overrides:
        `get` in class `Probability<T>`
      Returns:
        the probability associated with the label

    - #### getLog

          public Double getLog()

      Returns the log probability associated with a label
      Overrides:
        `getLog` in class `Probability<T>`
      Returns:
        the log probability associated with the label

    - #### getLabel

          public T getLabel()

      Returns the probabilities associated with all labels
      Overrides:
        `getLabel` in class `Probability<T>`
      Returns:
        the HashMap of labels and their probabilities

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Probability<T>`

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