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

Method head

pattern/text/tree.py:312–326  ·  view source on GitHub ↗

Yields the head of the chunk (usually, the last word in the chunk).

(self)

Source from the content-addressed store, hash-verified

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):

Callers

nothing calls this directly

Calls 1

findFunction · 0.70

Tested by

no test coverage detected