mirror of
https://github.com/explosion/spaCy.git
synced 2025-07-13 01:32:32 +03:00
further fixes to from_dict and to_dict
This commit is contained in:
parent
b68053c6c8
commit
c7c22a8dd5
|
@ -183,8 +183,8 @@ class Doc:
|
||||||
) -> Doc: ...
|
) -> Doc: ...
|
||||||
def to_bytes(self, *, exclude: Iterable[str] = ...) -> bytes: ...
|
def to_bytes(self, *, exclude: Iterable[str] = ...) -> bytes: ...
|
||||||
def from_bytes(self, bytes_data: bytes, *, exclude: Iterable[str] = ...) -> Doc: ...
|
def from_bytes(self, bytes_data: bytes, *, exclude: Iterable[str] = ...) -> Doc: ...
|
||||||
def to_dict(self, *, exclude: Iterable[str] = ...) -> bytes: ...
|
def to_dict(self, *, exclude: Iterable[str] = ...) -> Dict[str, Any]: ...
|
||||||
def from_dict(self, msg: bytes, *, exclude: Iterable[str] = ...) -> Doc: ...
|
def from_dict(self, msg: Dict[str, Any], *, exclude: Iterable[str] = ...) -> Doc: ...
|
||||||
def extend_tensor(self, tensor: Floats2d) -> None: ...
|
def extend_tensor(self, tensor: Floats2d) -> None: ...
|
||||||
def retokenize(self) -> Retokenizer: ...
|
def retokenize(self) -> Retokenizer: ...
|
||||||
def to_json(self, underscore: Optional[List[str]] = ...) -> Dict[str, Any]: ...
|
def to_json(self, underscore: Optional[List[str]] = ...) -> Dict[str, Any]: ...
|
||||||
|
|
|
@ -1362,8 +1362,7 @@ cdef class Doc:
|
||||||
"""Export the document contents to a dictionary for serialization.
|
"""Export the document contents to a dictionary for serialization.
|
||||||
|
|
||||||
exclude (Iterable[str]): String names of serialization fields to exclude.
|
exclude (Iterable[str]): String names of serialization fields to exclude.
|
||||||
RETURNS (bytes): A losslessly serialized copy of the `Doc`, including
|
RETURNS (Dict[str, Any]): A dictionary representation of the `Doc`
|
||||||
all annotations.
|
|
||||||
"""
|
"""
|
||||||
array_head = Doc._get_array_attrs()
|
array_head = Doc._get_array_attrs()
|
||||||
strings = set()
|
strings = set()
|
||||||
|
@ -1409,13 +1408,11 @@ cdef class Doc:
|
||||||
return util.to_dict(serializers, exclude)
|
return util.to_dict(serializers, exclude)
|
||||||
|
|
||||||
def from_dict(self, msg, *, exclude=tuple()):
|
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.
|
msg (Dict[str, Any]): The dictionary to load from.
|
||||||
exclude (list): String names of serialization fields to exclude.
|
exclude (Iterable[str]): String names of serialization fields to exclude.
|
||||||
RETURNS (Doc): Itself.
|
RETURNS (Doc): Itself.
|
||||||
|
|
||||||
DOCS: https://spacy.io/api/doc#from_dict
|
|
||||||
"""
|
"""
|
||||||
if self.length != 0:
|
if self.length != 0:
|
||||||
raise ValueError(Errors.E033.format(length=self.length))
|
raise ValueError(Errors.E033.format(length=self.length))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user