mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-26 01:46:28 +03:00
Improve lemmatization tests, re #1296
This commit is contained in:
parent
c0eaba8b28
commit
644d6c9e1a
|
@ -2,12 +2,18 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from ....tokens.doc import Doc
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def en_lemmatizer(EN):
|
def en_lemmatizer(EN):
|
||||||
return EN.Defaults.create_lemmatizer()
|
return EN.Defaults.create_lemmatizer()
|
||||||
|
|
||||||
|
@pytest.mark.models('en')
|
||||||
|
def test_doc_lemmatization(EN):
|
||||||
|
doc = Doc(EN.vocab, words=['bleed'])
|
||||||
|
doc[0].tag_ = 'VBP'
|
||||||
|
assert doc[0].lemma_ == 'bleed'
|
||||||
|
|
||||||
@pytest.mark.models('en')
|
@pytest.mark.models('en')
|
||||||
@pytest.mark.parametrize('text,lemmas', [("aardwolves", ["aardwolf"]),
|
@pytest.mark.parametrize('text,lemmas', [("aardwolves", ["aardwolf"]),
|
||||||
|
@ -19,6 +25,16 @@ def test_en_lemmatizer_noun_lemmas(en_lemmatizer, text, lemmas):
|
||||||
assert en_lemmatizer.noun(text) == set(lemmas)
|
assert en_lemmatizer.noun(text) == set(lemmas)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.models('en')
|
||||||
|
@pytest.mark.parametrize('text,lemmas', [("bleed", ["bleed"]),
|
||||||
|
("feed", ["feed"]),
|
||||||
|
("need", ["need"]),
|
||||||
|
("ring", ["ring"]),
|
||||||
|
("axes", ["axis", "axe", "ax"])])
|
||||||
|
def test_en_lemmatizer_noun_lemmas(en_lemmatizer, text, lemmas):
|
||||||
|
assert en_lemmatizer.noun(text) == set(lemmas)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.xfail
|
@pytest.mark.xfail
|
||||||
@pytest.mark.models('en')
|
@pytest.mark.models('en')
|
||||||
def test_en_lemmatizer_base_forms(en_lemmatizer):
|
def test_en_lemmatizer_base_forms(en_lemmatizer):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user