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-23 00:40:32 +00:00
|
|
|
|
2014-12-21 09:58:21 +00:00
|
|
|
@pytest.fixture
|
|
|
|
def EN():
|
2014-12-30 10:34:09 +00:00
|
|
|
return English()
|
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-23 00:40:32 +00:00
|
|
|
tokens = EN(string, tag=True)
|
2014-12-19 16:51:25 +00:00
|
|
|
return tokens
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def lemmas(tagged):
|
|
|
|
return [t.lemma for t in tagged]
|
|
|
|
|
|
|
|
|
2015-01-03 12:41:16 +00:00
|
|
|
def test_lemmas(lemmas, tagged):
|
2014-12-19 16:51:25 +00:00
|
|
|
assert lemmas[0] == 'banana'
|
|
|
|
assert lemmas[1] == 'in'
|
|
|
|
assert lemmas[2] == 'pyjama'
|
|
|
|
assert lemmas[3] == 'be'
|
2015-01-03 14:16:18 +00:00
|
|
|
if tagged[2].fine_pos == tagged[4].fine_pos:
|
|
|
|
assert lemmas[4] == 'goose'
|