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

Method hypernyms

pattern/text/en/wordnet/__init__.py:230–242  ·  view source on GitHub ↗

Yields a list of semantically broader synsets.

(self, recursive=False, depth=None)

Source from the content-addressed store, hash-verified

228 return p
229
230 def hypernyms(self, recursive=False, depth=None):
231 """ Yields a list of semantically broader synsets.
232 """
233 p = [Synset(p.getTarget()) for p in self._synset.getPointers(wn.HYPERNYM)]
234 if depth is None and recursive is False:
235 return p
236 if depth == 0:
237 return []
238 if depth is not None:
239 depth -= 1
240 if depth is None or depth > 0:
241 [p.extend(s.hypernyms(True, depth)) for s in list(p)]
242 return p
243
244 @property
245 def hypernym(self):

Callers 3

_parentsMethod · 0.80
ancestorFunction · 0.80
test_synsetMethod · 0.80

Calls 4

getTargetMethod · 0.80
SynsetClass · 0.70
getPointersMethod · 0.45
extendMethod · 0.45

Tested by 1

test_synsetMethod · 0.64