Package opennlp.tools.ml.naivebayes
Class Probability<T>
- java.lang.Object
-
- opennlp.tools.ml.naivebayes.Probability<T>
-
- Type Parameters:
T- The label (category) class.
- Direct Known Subclasses:
LogProbability
public class Probability<T> extends Object
Class implementing the probability for a label.
-
-
Constructor Summary
Constructors Constructor Description Probability(T label)Instantiates aProbabilitywith a givenlabel.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddIn(double probability)Compounds the existing probability mass on the label with the new probability passed in to the method.Doubleget()TgetLabel()DoublegetLog()booleanisLarger(Probability<T> probability)Checks if a probability is greater than the old one.voidset(double probability)Assigns a probability to a label, discarding any previously assigned probability.voidset(Probability<T> probability)Assigns a probability to a label, discarding any previously assigned probability.voidsetIfLarger(double probability)Assigns a probability to a label, discarding any previously assigned probability, if the new probability is greater than the old one.voidsetIfLarger(Probability<T> probability)Assigns a probability to a label, discarding any previously assigned probability, if the new probability is greater than the old one.voidsetLog(double probability)Assigns a log probability to a label, discarding any previously assigned probability.StringtoString()
-
-
-
Constructor Detail
-
Probability
public Probability(T label)
Instantiates aProbabilitywith a givenlabel.- Parameters:
label- Thelabelto assign probabilities to.
-
-
Method Detail
-
set
public void set(double probability)
Assigns a probability to a label, discarding any previously assigned probability.- Parameters:
probability- The probability to assign.
-
set
public void set(Probability<T> probability)
Assigns a probability to a label, discarding any previously assigned probability.- 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.- Parameters:
probability- The probability to assign.
-
setIfLarger
public void setIfLarger(Probability<T> probability)
Assigns a probability to a label, discarding any previously assigned probability, if the new probability is greater than the old one.- Parameters:
probability- The probability to assign.
-
isLarger
public boolean isLarger(Probability<T> probability)
Checks if a probability is greater than the old one.- Parameters:
probability- The probability to assign.- Returns:
trueif a probability is greater than the old one,falseotherwise.
-
setLog
public void setLog(double probability)
Assigns a log probability to a label, discarding any previously assigned probability.- 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.- Parameters:
probability- The probability weight to add.
-
get
public Double get()
- Returns:
- Retrieves the probability associated with a label.
-
getLog
public Double getLog()
- Returns:
- Retrieves the log probability associated with a label.
-
getLabel
public T getLabel()
- Returns:
- Retrieves the probabilities associated with all labels.
-
-