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

Method _do_anchor

pattern/text/tree.py:824–839  ·  view source on GitHub ↗

Collects preposition anchors and attachments in a dictionary. Once the dictionary has an entry for both the anchor and the attachment, they are linked.

(self, anchor)

Source from the content-addressed store, hash-verified

822 self._attachment = P
823
824 def _do_anchor(self, anchor):
825 """ Collects preposition anchors and attachments in a dictionary.
826 Once the dictionary has an entry for both the anchor and the attachment, they are linked.
827 """
828 for x in (anchor and anchor.split("-") or []):
829 A, P = None, None
830 if x.startswith("A") and len(self.chunks) > 0: # anchor
831 A, P = x, x.replace("A","P")
832 self._anchors[A] = self.chunks[-1]
833 if x.startswith("P") and len(self.pnp) > 0: # attachment (PNP)
834 A, P = x.replace("P","A"), x
835 self._anchors[P] = self.pnp[-1]
836 if A in self._anchors and P in self._anchors and not self._anchors[P].anchor:
837 pnp = self._anchors[P]
838 pnp.anchor = self._anchors[A]
839 pnp.anchor.attachments.append(pnp)
840
841 def _do_custom(self, custom):
842 """ Adds the user-defined tags to the last word.

Callers 1

appendMethod · 0.95

Calls 3

lenFunction · 0.85
splitMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected