spaCy/tests/test_morph_exceptions.py

27 lines
519 B
Python
Raw Normal View History

2014-12-19 19:51:25 +03:00
from __future__ import unicode_literals
from spacy.en import English
2014-12-19 19:51:25 +03:00
import pytest
from spacy.en import English
@pytest.fixture
def EN():
2014-12-30 13:34:09 +03:00
return English()
2014-12-19 19:51:25 +03:00
@pytest.fixture
def morph_exc():
return {
'PRP$': {'his': {'L': '-PRP-', 'person': 3, 'case': 2}},
}
2015-04-19 22:39:18 +03:00
def test_load_exc(EN, morph_exc):
2014-12-23 05:18:59 +03:00
EN.tagger.load_morph_exceptions(morph_exc)
tokens = EN('I like his style.', tag=True, parse=False)
2014-12-19 19:51:25 +03:00
his = tokens[2]
2015-03-16 02:25:27 +03:00
assert his.tag_ == 'PRP$'
assert his.lemma_ == '-PRP-'