MCPcopy Index your code
hub / github.com/clips/pattern / synset

Method synset

pattern/text/__init__.py:1566–1583  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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,

Callers 2

__call__Method · 0.95
weightMethod · 0.80

Calls 4

loadMethod · 0.95
strFunction · 0.85
__len__Method · 0.45
getMethod · 0.45

Tested by

no test coverage detected