diff --git a/spacy/tokens/doc.pyi b/spacy/tokens/doc.pyi index 09de7050f..44ab9f04f 100644 --- a/spacy/tokens/doc.pyi +++ b/spacy/tokens/doc.pyi @@ -183,8 +183,8 @@ class Doc: ) -> Doc: ... def to_bytes(self, *, exclude: Iterable[str] = ...) -> bytes: ... def from_bytes(self, bytes_data: bytes, *, exclude: Iterable[str] = ...) -> Doc: ... - def to_dict(self, *, exclude: Iterable[str] = ...) -> bytes: ... - def from_dict(self, msg: bytes, *, exclude: Iterable[str] = ...) -> Doc: ... + def to_dict(self, *, exclude: Iterable[str] = ...) -> Dict[str, Any]: ... + def from_dict(self, msg: Dict[str, Any], *, exclude: Iterable[str] = ...) -> Doc: ... def extend_tensor(self, tensor: Floats2d) -> None: ... def retokenize(self) -> Retokenizer: ... def to_json(self, underscore: Optional[List[str]] = ...) -> Dict[str, Any]: ... diff --git a/spacy/tokens/doc.pyx b/spacy/tokens/doc.pyx index fb5b41692..181c0ce0f 100644 --- a/spacy/tokens/doc.pyx +++ b/spacy/tokens/doc.pyx @@ -1362,8 +1362,7 @@ cdef class Doc: """Export the document contents to a dictionary for serialization. exclude (Iterable[str]): String names of serialization fields to exclude. - RETURNS (bytes): A losslessly serialized copy of the `Doc`, including - all annotations. + RETURNS (Dict[str, Any]): A dictionary representation of the `Doc` """ array_head = Doc._get_array_attrs() strings = set() @@ -1409,13 +1408,11 @@ cdef class Doc: return util.to_dict(serializers, exclude) def from_dict(self, msg, *, exclude=tuple()): - """Deserialize, i.e. import the document contents from a binary string. + """Deserialize the document contents from a dictionary representation. - data (bytes): The string to load from. - exclude (list): String names of serialization fields to exclude. + msg (Dict[str, Any]): The dictionary to load from. + exclude (Iterable[str]): String names of serialization fields to exclude. RETURNS (Doc): Itself. - - DOCS: https://spacy.io/api/doc#from_dict """ if self.length != 0: raise ValueError(Errors.E033.format(length=self.length))