Returns a (polarity, subjectivity)-tuple for the given synset id. For example, the adjective "horrible" has id 193480 in WordNet: Sentiment.synset(193480, pos="JJ") => (-0.6, 1.0, 1.0).
(self, id, pos=ADJECTIVE)
| 1564 | dict.update(self._synsets, synsets) |
| 1565 | |
| 1566 | def synset(self, id, pos=ADJECTIVE): |
| 1567 | """ Returns a (polarity, subjectivity)-tuple for the given synset id. |
| 1568 | For example, the adjective "horrible" has id 193480 in WordNet: |
| 1569 | Sentiment.synset(193480, pos="JJ") => (-0.6, 1.0, 1.0). |
| 1570 | """ |
| 1571 | id = str(id).zfill(8) |
| 1572 | if not id.startswith(("n-", "v-", "a-", "r-")): |
| 1573 | if pos == NOUN: |
| 1574 | id = "n-" + id |
| 1575 | if pos == VERB: |
| 1576 | id = "v-" + id |
| 1577 | if pos == ADJECTIVE: |
| 1578 | id = "a-" + id |
| 1579 | if pos == ADVERB: |
| 1580 | id = "r-" + id |
| 1581 | if dict.__len__(self) == 0: |
| 1582 | self.load() |
| 1583 | return tuple(self._synsets.get(id, (0.0, 0.0))[:2]) |
| 1584 | |
| 1585 | def __call__(self, s, negation=True, **kwargs): |
| 1586 | """ Returns a (polarity, subjectivity)-tuple for the given sentence, |