2014-12-19 16:51:25 +00:00
|
|
|
from __future__ import unicode_literals
|
2014-12-21 21:54:47 +00:00
|
|
|
from spacy.en import English
|
2014-12-19 16:51:25 +00:00
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
2014-12-21 21:54:47 +00:00
|
|
|
from spacy.en import English
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def EN():
|
2014-12-30 10:34:09 +00:00
|
|
|
return English()
|
2014-12-21 21:54:47 +00:00
|
|
|
|
|
|
|
|
2014-12-19 16:51:25 +00:00
|
|
|
@pytest.fixture
|
|
|
|
def morph_exc():
|
|
|
|
return {
|
|
|
|
'PRP$': {'his': {'L': '-PRP-', 'person': 3, 'case': 2}},
|
|
|
|
}
|
|
|
|
|
2014-12-21 21:54:47 +00:00
|
|
|
def test_load_exc(EN, morph_exc):
|
2014-12-23 02:18:59 +00:00
|
|
|
EN.tagger.load_morph_exceptions(morph_exc)
|
2014-12-23 00:40:32 +00:00
|
|
|
tokens = EN('I like his style.', tag=True)
|
2014-12-19 16:51:25 +00:00
|
|
|
his = tokens[2]
|
2015-03-15 23:25:27 +00:00
|
|
|
assert his.tag_ == 'PRP$'
|
2015-01-14 16:51:47 +00:00
|
|
|
assert his.lemma_ == '-PRP-'
|