Merge pull request #6224 from explosion/fix/doc-to-json

Fix morph in Doc.to_json
This commit is contained in:
Ines Montani 2020-10-08 15:18:35 +02:00 committed by GitHub
commit 8b4cc29dbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View File

@ -10,8 +10,16 @@ def doc(en_vocab):
heads = [0, 0, 0]
deps = ["ROOT", "dobj", "dobj"]
ents = ["O", "B-ORG", "O"]
morphs = ["Feat1=A", "Feat1=B", "Feat1=A|Feat2=D"]
return Doc(
en_vocab, words=words, pos=pos, tags=tags, heads=heads, deps=deps, ents=ents
en_vocab,
words=words,
pos=pos,
tags=tags,
heads=heads,
deps=deps,
ents=ents,
morphs=morphs,
)

View File

@ -1398,8 +1398,6 @@ cdef class Doc:
attributes. Attribute values need to be JSON-serializable. Values will
be added to an "_" key in the data, e.g. "_": {"foo": "bar"}.
RETURNS (dict): The data in spaCy's JSON format.
DOCS: https://nightly.spacy.io/api/doc#to_json
"""
data = {"text": self.text}
if self.has_annotation("ENT_IOB"):
@ -1421,7 +1419,7 @@ cdef class Doc:
if include_annotation["POS"]:
token_data["pos"] = token.pos_
if include_annotation["MORPH"]:
token_data["morph"] = token.morph_
token_data["morph"] = token.morph
if include_annotation["LEMMA"]:
token_data["lemma"] = token.lemma_
if include_annotation["DEP"]: