For verb phrases (VP), yields a list of the nearest adjectives and adverbs.
(self)
| 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. |