def load(self, path=None):# Backwards compatibility with pattern.en.wordnet.Sentiment.if path is not None:self._path = pathself._parse()
def _parse_path(self):""" For backwards compatibility, look for SentiWordNet*.txt in:pattern/en/parser/, patter/en/wordnet/, or the given path."""try: f = (glob(os.path.join(self.path)) + \glob(os.path.join(MODULE, self.path)) + \glob(os.path.join(MODULE, "..", "wordnet", self.path)))[0]except IndexError:raise ImportError, "can't find SentiWordnet data file"return f
@MT: Once this is fixed it should work, but I'd like to point out that the more recent releases of Pattern have sentiment analysis bundled in (I should update the example case study). In many cases it even outperforms SentiWordNet, since it focusses on adjectives that occur frequently in real-world language use instead of assigning a score to each word in a sentence, which can lead to noise in longer sentences.
Using Pattern's sentiment analysis is easy:
from pattern.en import sentiment
print sentiment("it was a terrible day")
print sentiment("it was a terribly exciting day")
print sentiment("it was not terribly exciting")
The return value is a (polarity, subjectivity) tuple, where polarity is a number between -1 and +1 indicating negative or positive tone.
Best,
Tom