From 0b53fd7daaf0f2a7f7c221b447ec9e5c49f89f1a Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Fri, 30 Jan 2015 18:02:58 +1100 Subject: [PATCH] * Add test for parse tree navigation --- tests/test_parse_navigate.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/test_parse_navigate.py diff --git a/tests/test_parse_navigate.py b/tests/test_parse_navigate.py new file mode 100644 index 000000000..1bbfdafc2 --- /dev/null +++ b/tests/test_parse_navigate.py @@ -0,0 +1,28 @@ +from __future__ import unicode_literals +from os import path +import codecs + +from spacy.en import English + +import pytest + + +@pytest.fixture +def sun_text(): + with codecs.open(path.join(path.dirname(__file__), 'sun.txt'), 'r', 'utf8') as file_: + text = file_.read() + return text + + +@pytest.fixture +def nlp(): + return English() + + +def test_consistency(nlp, sun_text): + tokens = nlp(sun_text) + for head in tokens: + for child in head.lefts: + assert child.head is head + for child in head.rights: + assert child.head is head