class documentation

A mix-in class to associate probabilities with other classes (trees, rules, etc.). To use the ProbabilisticMixIn class, define a new class that derives from an existing class and from ProbabilisticMixIn. You will need to define a new constructor for the new class, which explicitly calls the constructors of both its parent classes. For example:

>>> from nltk.probability import ProbabilisticMixIn
>>> class A:
...     def __init__(self, x, y): self.data = (x,y)
...
>>> class ProbabilisticA(A, ProbabilisticMixIn):
...     def __init__(self, x, y, **prob_kwarg):
...         A.__init__(self, x, y)
...         ProbabilisticMixIn.__init__(self, **prob_kwarg)

See the documentation for the ProbabilisticMixIn constructor<__init__> for information about the arguments it expects.

You should generally also redefine the string representation methods, the comparison methods, and the hashing method.

Method __init__ Initialize this object's probability. This initializer should be called by subclass constructors. prob should generally be the first argument for those constructors.
Method logprob Return log(p), where p is the probability associated with this object.
Method prob Return the probability associated with this object.
Method set_logprob Set the log probability associated with this object to logprob. I.e., set the probability associated with this object to 2**(logprob).
Method set_prob Set the probability associated with this object to prob.
Instance Variable __logprob Undocumented
Instance Variable __prob Undocumented
def __init__(self, **kwargs): (source)

Initialize this object's probability. This initializer should be called by subclass constructors. prob should generally be the first argument for those constructors.

Parameters
prob:floatThe probability associated with the object.
logprob:floatThe log of the probability associated with the object.
**kwargsUndocumented
def logprob(self): (source)

Return log(p), where p is the probability associated with this object.

Returns
floatUndocumented
def prob(self): (source)

Return the probability associated with this object.

Returns
floatUndocumented
def set_logprob(self, logprob): (source)

Set the log probability associated with this object to logprob. I.e., set the probability associated with this object to 2**(logprob).

Parameters
logprob:floatThe new log probability
def set_prob(self, prob): (source)

Set the probability associated with this object to prob.

Parameters
prob:floatThe new probability
__logprob = (source)

Undocumented

Undocumented