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