(
        self,
        filepath: types.PathLike,
        attrs: Optional[str | Iterable[str] | Literal["auto"]] = "auto",
        store_user_data: bool = True,
    )
Save :class:`Corpus` to disk as binary data.

        Args:
            filepath: Full path to file on disk where :class:`Corpus` docs data
                will be saved as a binary file.
            attrs: List of token attributes to serialize; if "auto", an appropriate list
                is inferred from annotations found on the first ``Doc``; if None,
                spaCy's default values are used (https://spacy.io/api/docbin#init)
            store_user_data: If True, store user data and values of
                custom extension attributes along with core spaCy attributes.

        See Also:
            - :meth:`Corpus.load()`
            - :func:`textacy.io.write_spacy_docs()`
            - :class:`spacy.tokens.DocBin`
Save :class:`Corpus` to disk as binary data.
Save : class : Corpus to disk as binary data .
def save(
        self,
        filepath: types.PathLike,
        attrs: Optional[str | Iterable[str] | Literal["auto"]] = "auto",
        store_user_data: bool = True,
    ):
        """
        Save :class:`Corpus` to disk as binary data.

        Args:
            filepath: Full path to file on disk where :class:`Corpus` docs data
                will be saved as a binary file.
            attrs: List of token attributes to serialize; if "auto", an appropriate list
                is inferred from annotations found on the first ``Doc``; if None,
                spaCy's default values are used (https://spacy.io/api/docbin#init)
            store_user_data: If True, store user data and values of
                custom extension attributes along with core spaCy attributes.

        See Also:
            - :meth:`Corpus.load()`
            - :func:`textacy.io.write_spacy_docs()`
            - :class:`spacy.tokens.DocBin`
        """
        if attrs == "auto":
            doc = self[0]
            attrs = [spacy.attrs.ORTH, spacy.attrs.SPACY]
            cand_attrs = [
                "TAG",
                "POS",
                "ENT_IOB",
                "ENT_TYPE",
                "ENT_KB_ID",
                "LEMMA",
                "MORPH",
            ]
            for cand_attr in cand_attrs:
                if doc.has_annotation(cand_attr):
                    attrs.append(getattr(spacy.attrs, cand_attr))
            # just to be safe, use special handling for dependency parse annotations
            # to allow for multiple ways in which sentences may get segmented
            # *either* use DEP and HEAD or SENT_START to avoid potential conflicts
            # since HEAD implicitly sets sentence boundaries based on tree structure
            if self[0].has_annotation("DEP"):
                attrs.append(spacy.attrs.HEAD)
                attrs.append(spacy.attrs.DEP)
            elif self[0].has_annotation("SENT_START"):
                attrs.append(spacy.attrs.SENT_START)
        tio.write_spacy_docs(
            self.docs,
            filepath,
            format="binary",
            attrs=attrs,
            store_user_data=store_user_data,
        )
def save ( self , filepath : types . PathLike , attrs : Optional [ str | Iterable [ str ] | Literal [ "auto" ] ] = "auto" , store_user_data : bool = True , ) : if attrs == "auto" : doc = self [ 0 ] attrs = [ spacy . attrs . ORTH , spacy . attrs . SPACY ] cand_attrs = [ "TAG" , "POS" , "ENT_IOB" , "ENT_TYPE" , "ENT_KB_ID" , "LEMMA" , "MORPH" , ] for cand_attr in cand_attrs : if doc . has_annotation ( cand_attr ) : attrs . append ( getattr ( spacy . attrs , cand_attr ) ) # just to be safe, use special handling for dependency parse annotations # to allow for multiple ways in which sentences may get segmented # *either* use DEP and HEAD or SENT_START to avoid potential conflicts # since HEAD implicitly sets sentence boundaries based on tree structure if self [ 0 ] . has_annotation ( "DEP" ) : attrs . append ( spacy . attrs . HEAD ) attrs . append ( spacy . attrs . DEP ) elif self [ 0 ] . has_annotation ( "SENT_START" ) : attrs . append ( spacy . attrs . SENT_START ) tio . write_spacy_docs ( self . docs , filepath , format = "binary" , attrs = attrs , store_user_data = store_user_data , )