You can either explicitly test for 0, e.g.
result = 0
if x > 0:
result = math.log(x)
Or you can wrap the computation in a try/except:
try:
result = math.log(x)
except ZeroDivisionError as e:
x = 0
# report the error if appropriate
print e
Hope this helps,
Matt
> --
> You received this message because you are subscribed to the Google Groups "nltk-users" group.
> To post to this group, send email to
nltk-...@googlegroups.com.
> To unsubscribe from this group, send email to
nltk-users+...@googlegroups.com.
> For more options, visit this group at
http://groups.google.com/group/nltk-users?hl=en.
>