Yields the head of the chunk (usually, the last word in the chunk).
(self)
| 310 | |
| 311 | @property |
| 312 | def head(self): |
| 313 | """ Yields the head of the chunk (usually, the last word in the chunk). |
| 314 | """ |
| 315 | w = None |
| 316 | if self.type == "NP": # "the cat" => "cat" |
| 317 | w = find(lambda w: w.type.startswith("NN"), reversed(self)) |
| 318 | if self.type == "VP": # "is watching" => "watching" |
| 319 | w = find(lambda w: w.type.startswith("VB"), reversed(self)) |
| 320 | if self.type == "PP": # "from up on" => "from" |
| 321 | w = find(lambda w: w.type.startswith(("IN", "PP")), self) |
| 322 | if self.type == "PNP": # "from up on the roof" => "roof" |
| 323 | w = find(lambda w: w.type.startswith("NN"), reversed(self)) |
| 324 | if w is None: |
| 325 | w = self[-1] |
| 326 | return w |
| 327 | |
| 328 | @property |
| 329 | def relation(self): |