2014-12-21 12:58:21 +03:00
|
|
|
from spacy.en import English
|
2014-12-19 19:51:25 +03:00
|
|
|
import pytest
|
|
|
|
|
2014-12-23 03:40:32 +03:00
|
|
|
|
2014-12-21 12:58:21 +03:00
|
|
|
@pytest.fixture
|
|
|
|
def EN():
|
2014-12-23 03:40:32 +03:00
|
|
|
return English(tag=True, parse=False)
|
2014-12-19 19:51:25 +03:00
|
|
|
|
|
|
|
@pytest.fixture
|
2014-12-21 12:58:21 +03:00
|
|
|
def tagged(EN):
|
2014-12-19 19:51:25 +03:00
|
|
|
string = u'Bananas in pyjamas are geese.'
|
2014-12-23 03:40:32 +03:00
|
|
|
tokens = EN(string, tag=True)
|
2014-12-19 19:51:25 +03: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'
|