From face0de74f716a318be1db4be56f503985025407 Mon Sep 17 00:00:00 2001 From: svlandeg Date: Fri, 12 Jun 2020 16:29:09 +0200 Subject: [PATCH] fix MORPH conversion + enable unit test --- spacy/gold/new_example.pyx | 5 ++++- spacy/tests/test_new_example.py | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/spacy/gold/new_example.pyx b/spacy/gold/new_example.pyx index e7506d697..46b8ed423 100644 --- a/spacy/gold/new_example.pyx +++ b/spacy/gold/new_example.pyx @@ -13,7 +13,7 @@ from ..errors import Errors, AlignmentError cpdef Doc annotations2doc(Doc predicted, tok_annot, doc_annot): # TODO: Improve and test this words = tok_annot.get("ORTH", [tok.text for tok in predicted]) - attrs, array = _annot2array(predicted.vocab.strings, tok_annot, doc_annot) + attrs, array = _annot2array(predicted.vocab, tok_annot, doc_annot) output = Doc(predicted.vocab, words=words) if array.size: output = output.from_array(attrs, array) @@ -117,6 +117,9 @@ def _annot2array(vocab, tok_annot, doc_annot): elif key == "SENT_START": attrs.append(key) values.append(value) + elif key == "MORPH": + attrs.append(key) + values.append([vocab.morphology.add(v) for v in value]) elif key == "ENT_IOB": iob_strings = Token.iob_strings() attrs.append(key) diff --git a/spacy/tests/test_new_example.py b/spacy/tests/test_new_example.py index 4ebafb6bb..0be78624a 100644 --- a/spacy/tests/test_new_example.py +++ b/spacy/tests/test_new_example.py @@ -60,7 +60,6 @@ def test_Example_from_dict_with_parse(annots): assert token.head.i == annots["heads"][i] -@pytest.mark.xfail(reason="TODO - fix") @pytest.mark.parametrize( "annots", [