| 429 | # Older code may be using pattern.en.wordnet.sentiment[w], |
| 430 | # which yields a (positive, negative, neutral)-tuple. |
| 431 | class sentiment(object): |
| 432 | |
| 433 | def load(self, **kwargs): |
| 434 | sentiwordnet.load(**kwargs) |
| 435 | |
| 436 | def __getitem__(self, w): |
| 437 | p, s = sentiwordnet.get(w, (0.0, 0.0)) |
| 438 | return p < 0 and (0.0, -p, 1.0-s) or (p, 0.0, 1.0-s) |
| 439 | |
| 440 | def __contains__(self, w): |
| 441 | return w in sentiwordnet |
| 442 | |
| 443 | sentiment = sentiment() |
| 444 |
no outgoing calls
no test coverage detected
searching dependent graphs…