Package nltk :: Module cfg :: Class WeightedProduction
[hide private]
[frames] | no frames]

Class WeightedProduction

source code

                             object --+    
                                      |    
                             Production --+
                                          |
                         object --+       |
                                  |       |
     probability.ProbabilisticMixIn --+   |
                                      |   |
probability.ImmutableProbabilisticMixIn --+
                                          |
                                         WeightedProduction

A probabilistic context free grammar production. PCFG WeightedProductions are essentially just Productions that have probabilities associated with them. These probabilities are used to record how likely it is that a given production will be used. In particular, the probability of a WeightedProduction records the likelihood that its right-hand side is the correct instantiation for any given occurance of its left-hand side.


See Also: Production

Instance Methods [hide private]
 
__init__(self, lhs, rhs, **prob)
Construct a new WeightedProduction.
source code
string
__str__(self)
Returns: A verbose string representation of the Production.
source code
boolean
__eq__(self, other)
Returns: true if this Production is equal to other.
source code
 
__ne__(self, other) source code
int
__hash__(self)
Returns: A hash value for the Production.
source code

Inherited from Production: __cmp__, __repr__, lhs, rhs

Inherited from probability.ImmutableProbabilisticMixIn: set_logprob, set_prob

Inherited from probability.ProbabilisticMixIn: logprob, prob

Inherited from object: __delattr__, __getattribute__, __new__, __reduce__, __reduce_ex__, __setattr__

Instance Variables [hide private]

Inherited from Production (private): _lhs, _rhs

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, lhs, rhs, **prob)
(Constructor)

source code 

Construct a new WeightedProduction.

Parameters:
  • lhs (Nonterminal) - The left-hand side of the new WeightedProduction.
  • rhs (sequence of (Nonterminal and (terminal))) - The right-hand side of the new WeightedProduction.
  • prob - Probability parameters of the new WeightedProduction.
Overrides: Production.__init__

__str__(self)
(Informal representation operator)

source code 

str(x)

Returns: string
A verbose string representation of the Production.
Overrides: Production.__str__
(inherited documentation)

__eq__(self, other)
(Equality operator)

source code 
Returns: boolean
true if this Production is equal to other.
Overrides: Production.__eq__
(inherited documentation)

__ne__(self, other)

source code 
Overrides: Production.__ne__

__hash__(self)
(Hashing function)

source code 

hash(x)

Returns: int
A hash value for the Production.
Overrides: Production.__hash__
(inherited documentation)