markuskiller / textblob-de

German language support for TextBlob.
https://textblob-de.readthedocs.org
MIT License
104 stars 12 forks source link

Sentiment for empty texts #3

Closed Hocdoc closed 10 years ago

Hocdoc commented 10 years ago

When I try TextBlobDE(u"").sentiment I get an exception:

Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.7/site-packages/textblob/decorators.py", line 24, in get value = obj.dict[self.func.name] = self.func(obj) File "/usr/lib/python2.7/site-packages/textblob_de/blob.py", line 631, in sentiment polarity = _polarity / len(self.sentences) ZeroDivisionError: integer division or modulo by zero

I think it would be better to get a neutral sentiment back (Sentiment(polarity=0.0, subjectivity=0.0)) like in textblob.

markuskiller commented 10 years ago

Latest release on PyPI (0.2.9) reflects the changes: https://pypi.python.org/pypi/textblob-de