From 6674d719a53d4a5af23d3e46b6dfb6b83322de97 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Tue, 7 Apr 2015 05:51:44 +0200 Subject: [PATCH] * Test for Issue #43: TAG attribute not working in array export --- tests/test_array.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tests/test_array.py b/tests/test_array.py index 76f98c4a7..b55d87eab 100644 --- a/tests/test_array.py +++ b/tests/test_array.py @@ -7,11 +7,9 @@ from spacy.en import English from spacy.en import attrs -@pytest.fixture -def EN(): - return English() +EN = English() -def test_attr_of_token(EN): +def test_attr_of_token(): text = u'An example sentence.' tokens = EN(text) example = EN.vocab[u'example'] @@ -20,3 +18,14 @@ def test_attr_of_token(EN): assert feats_array[0][0] != feats_array[0][1] +def test_tag(): + text = u'A nice sentence.' + tokens = EN(text) + assert tokens[0].tag != tokens[1].tag != tokens[2].tag != tokens[3].tag + feats_array = tokens.to_array((attrs.ORTH, attrs.TAG)) + assert feats_array[0][1] == tokens[0].tag + assert feats_array[1][1] == tokens[1].tag + assert feats_array[2][1] == tokens[2].tag + assert feats_array[3][1] == tokens[3].tag + +