mirror of
https://github.com/explosion/spaCy.git
synced 2025-07-04 03:43:09 +03:00
Modernise morph exceptions test and don't depend on models
This commit is contained in:
parent
ec7739b76e
commit
3bc082abdf
|
@ -1,23 +1,17 @@
|
||||||
|
# coding: utf-8
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from spacy.en import English
|
|
||||||
|
from ..util import get_doc
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from spacy.en import English
|
|
||||||
|
|
||||||
@pytest.fixture
|
def test_load_exc(en_tokenizer):
|
||||||
def morph_exc():
|
text = "I like his style."
|
||||||
return {
|
tags = ['PRP', 'VBP', 'PRP$', 'NN', '.']
|
||||||
'PRP$': {'his': {'L': '-PRP-', 'person': 3, 'case': 2}},
|
morph_exc = {'PRP$': {'his': {'L': '-PRP-', 'person': 3, 'case': 2}}}
|
||||||
}
|
en_tokenizer.vocab.morphology.load_morph_exceptions(morph_exc)
|
||||||
|
tokens = en_tokenizer(text)
|
||||||
|
doc = get_doc(tokens.vocab, [t.text for t in tokens], tags=tags)
|
||||||
@pytest.mark.models
|
assert doc[2].tag_ == 'PRP$'
|
||||||
def test_load_exc(morph_exc):
|
assert doc[2].lemma_ == '-PRP-'
|
||||||
# Do this local as we want to modify it
|
|
||||||
nlp = English()
|
|
||||||
nlp.vocab.morphology.load_morph_exceptions(morph_exc)
|
|
||||||
tokens = nlp('I like his style.', tag=True, parse=False)
|
|
||||||
his = tokens[2]
|
|
||||||
assert his.tag_ == 'PRP$'
|
|
||||||
assert his.lemma_ == '-PRP-'
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user