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

Method modifiers

pattern/text/tree.py:389–400  ·  view source on GitHub ↗

For verb phrases (VP), yields a list of the nearest adjectives and adverbs.

(self)

Source from the content-addressed store, hash-verified

387
388 @property
389 def modifiers(self):
390 """ For verb phrases (VP), yields a list of the nearest adjectives and adverbs.
391 """
392 if self._modifiers is None:
393 # Iterate over all the chunks and attach modifiers to their VP-anchor.
394 is_modifier = lambda ch: ch.type in ("ADJP", "ADVP") and ch.relation is None
395 for chunk in self.sentence.chunks:
396 chunk._modifiers = []
397 for chunk in filter(is_modifier, self.sentence.chunks):
398 anchor = chunk.nearest("VP")
399 if anchor: anchor._modifiers.append(chunk)
400 return self._modifiers
401
402 def nearest(self, type="VP"):
403 """ Returns the nearest chunk in the sentence with the given type.

Callers

nothing calls this directly

Calls 3

nearestMethod · 0.80
filterFunction · 0.50
appendMethod · 0.45

Tested by

no test coverage detected