Commit 76124282 by Steven Bird

special formatting when probability = 1.0, cf issue nltk_book#37

parent a5f3da48
...@@ -398,7 +398,8 @@ class ProbabilisticProduction(Production, ImmutableProbabilisticMixIn): ...@@ -398,7 +398,8 @@ class ProbabilisticProduction(Production, ImmutableProbabilisticMixIn):
Production.__init__(self, lhs, rhs) Production.__init__(self, lhs, rhs)
def __str__(self): def __str__(self):
return Production.__unicode__(self) + ' [%.6g]' % self.prob() return Production.__unicode__(self) + \
(' [1.0]' if (self.prob() == 1.0) else ' [%.g]' % self.prob())
def __eq__(self, other): def __eq__(self, other):
return (type(self) == type(other) and return (type(self) == type(other) and
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment