diff --git a/spacy/tests/spans/test_span.py b/spacy/tests/spans/test_span.py index 14809e4dd..3619eb88a 100644 --- a/spacy/tests/spans/test_span.py +++ b/spacy/tests/spans/test_span.py @@ -1,9 +1,11 @@ from __future__ import unicode_literals +from spacy.attrs import HEAD +from spacy.en import English +import numpy as np import pytest - @pytest.fixture def doc(EN): return EN('This is a sentence. This is another sentence. And a third.') @@ -25,3 +27,13 @@ def test_root(doc): assert np.orth_ == 'a sentence' assert np.root.orth_ == 'sentence' assert np.root.head.orth_ == 'is' + + +def test_root2(): + text = 'through North and South Carolina' + EN = English(parser=False) + doc = EN(text) + heads = np.asarray([[0, 3, -1, -2, -4]], dtype='int32') + doc.from_array([HEAD], heads.T) + south_carolina = doc[-2:] + assert south_carolina.root.text == 'Carolina'