MCPcopy Create free account
hub / github.com/clips/pattern / _do_pnp

Method _do_pnp

pattern/text/tree.py:806–822  ·  view source on GitHub ↗

Attaches prepositional noun phrases. Identifies PNP's from either the PNP tag or the P-attachment tag. This does not determine the PP-anchor, it only groups words in a PNP chunk.

(self, pnp, anchor=None)

Source from the content-addressed store, hash-verified

804 self.relations[ch.type][ch.relation] = ch
805
806 def _do_pnp(self, pnp, anchor=None):
807 """ Attaches prepositional noun phrases.
808 Identifies PNP's from either the PNP tag or the P-attachment tag.
809 This does not determine the PP-anchor, it only groups words in a PNP chunk.
810 """
811 P = find(lambda x: x.startswith("P"), anchor and anchor.split("-") or [])
812 if pnp and pnp.endswith("PNP") or P is not None:
813 if (pnp and pnp != "O" \
814 and len(self.pnp) > 0 \
815 and not pnp.startswith("B") \
816 and not self.words[-2].pnp is None \
817 ) or (P is not None and P == self._attachment):
818 self.pnp[-1].append(self.words[-1])
819 else:
820 ch = PNPChunk(self, [self.words[-1]], type="PNP")
821 self.pnp.append(ch)
822 self._attachment = P
823
824 def _do_anchor(self, anchor):
825 """ Collects preposition anchors and attachments in a dictionary.

Callers 1

appendMethod · 0.95

Calls 5

lenFunction · 0.85
PNPChunkClass · 0.85
findFunction · 0.70
splitMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected