From c6623889c127c5ec19d64b9ad63911c050ada1be Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 6 Feb 2016 23:47:51 +0100 Subject: [PATCH] * Add test for Issue #251: Incorrect right edges, caused by bad update to r_edge in del_arc, triggered from non-monotonic left-arc --- spacy/tests/tokens/test_tokens_api.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/spacy/tests/tokens/test_tokens_api.py b/spacy/tests/tokens/test_tokens_api.py index bd58e4e08..57d8c9fd8 100644 --- a/spacy/tests/tokens/test_tokens_api.py +++ b/spacy/tests/tokens/test_tokens_api.py @@ -179,3 +179,16 @@ def test_runtime_error(EN): for word in doc: print(word.idx, word.text, word.head.i, word.head.text) doc.merge(*np) + + +@pytest.mark.models +def test_right_edge(EN): + # Test for bug occurring from Unshift action, causing incorrect right edge + doc = EN(u'''I have proposed to myself, for the sake of such as live ''' + u'''under the government of the Romans, to translate those books ''' + u'''into the Greek tongue.''') + token = doc[6] + assert token.text == u'for' + subtree = [w.text for w in token.subtree] + assert subtree == [u'for' , u'the', u'sake', u'of'] + assert token.right_edge.text == u'of'