From a61dacb4e51ed14a32bd692ff4b8a9c167e8e82c Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Tue, 3 Mar 2015 05:41:00 -0500 Subject: [PATCH] * Add tests for new subtree method --- tests/test_subtree.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/test_subtree.py diff --git a/tests/test_subtree.py b/tests/test_subtree.py new file mode 100644 index 000000000..b25ec233d --- /dev/null +++ b/tests/test_subtree.py @@ -0,0 +1,19 @@ +from __future__ import unicode_literals +from spacy.en import English + +EN = English() + + +def test_subtrees(): + sent = EN('The four wheels on the bus turned quickly') + wheels = sent[2] + bus = sent[5] + assert len(list(wheels.lefts)) == 2 + assert len(list(wheels.rights)) == 1 + assert len(list(wheels.children)) == 3 + assert len(list(bus.lefts)) == 1 + assert len(list(bus.rights)) == 0 + assert len(list(bus.children)) == 1 + + assert len(list(wheels.subtree)) == 6 +