Beispiel #1
0
    def apply(self, doc: Document) -> Iterator[TemporaryDocumentMention]:
        """
        Generate MentionDocuments from a Document by using document.

        :param doc: The ``Document`` to parse.
        :raises TypeError: If the input doc is not of type ``Document``.
        """
        if not isinstance(doc, Document):
            raise TypeError(
                "Input Contexts to MentionDocuments.apply() must be of type Document"
            )

        yield TemporaryDocumentMention(doc)
Beispiel #2
0
    def apply(self, session, doc):
        """
        Generate MentionDocuments from a Document by using document.

        :param session: The database session
        :param doc: The ``Document`` to parse.
        :type doc: ``Document``
        :raises TypeError: If the input doc is not of type ``Document``.
        """
        if not isinstance(doc, Document):
            raise TypeError(
                "Input Contexts to MentionDocuments.apply() must be of type Document"
            )

        doc = session.query(Document).filter(Document.id == doc.id).one()
        yield TemporaryDocumentMention(doc)