spaCy/tests/test_add_lemmas.py

26 lines
509 B
Python
Raw Normal View History

2014-12-21 09:58:21 +00:00
from spacy.en import English
2014-12-19 16:51:25 +00:00
import pytest
2014-12-21 09:58:21 +00:00
@pytest.fixture
def EN():
return English(pos_tag=True, parse=False)
2014-12-19 16:51:25 +00:00
@pytest.fixture
2014-12-21 09:58:21 +00:00
def tagged(EN):
2014-12-19 16:51:25 +00:00
string = u'Bananas in pyjamas are geese.'
2014-12-21 09:58:21 +00:00
tokens = EN(string, pos_tag=True)
2014-12-19 16:51:25 +00:00
return tokens
@pytest.fixture
def lemmas(tagged):
return [t.lemma for t in tagged]
def test_lemmas(lemmas):
assert lemmas[0] == 'banana'
assert lemmas[1] == 'in'
assert lemmas[2] == 'pyjama'
assert lemmas[3] == 'be'
assert lemmas[4] == 'goose'