From 874a3cbb073b8bf79925c3c620e09245afa2157e Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sun, 23 Apr 2017 17:57:01 +0200 Subject: [PATCH] Add test for Issue #955 --- spacy/tests/regression/test_issue995.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 spacy/tests/regression/test_issue995.py diff --git a/spacy/tests/regression/test_issue995.py b/spacy/tests/regression/test_issue995.py new file mode 100644 index 000000000..715c24607 --- /dev/null +++ b/spacy/tests/regression/test_issue995.py @@ -0,0 +1,20 @@ +import pytest +from ... import load as load_spacy + +@pytest.fixture +def doc(): + nlp = load_spacy('en') + return nlp('Does flight number three fifty-four require a connecting flight' + ' to get to Boston?') + + +@pytest.mark.models +def test_issue955(doc): + '''Test that we don't have any nested noun chunks''' + seen_tokens = set() + for np in doc.noun_chunks: + print(np.text, np.root.text, np.root.dep_, np.root.tag_) + for word in np: + key = (word.i, word.text) + assert key not in seen_tokens + seen_tokens.add(key)