mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 17:36:30 +03:00
* Add tests
This commit is contained in:
parent
b066102d2d
commit
ed2fff6128
24
tests/test_add_lemmas.py
Normal file
24
tests/test_add_lemmas.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
from spacy.en import EN
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def tagged():
|
||||
EN.load()
|
||||
string = u'Bananas in pyjamas are geese.'
|
||||
tokens = EN.tokenize(string)
|
||||
EN.set_pos(tokens)
|
||||
return tokens
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def lemmas(tagged):
|
||||
return [t.lemma for t in tagged]
|
||||
|
||||
|
||||
def test_lemmas(lemmas):
|
||||
assert lemmas[0] == 'banana'
|
||||
assert lemmas[1] == 'in'
|
||||
assert lemmas[2] == 'pyjama'
|
||||
assert lemmas[3] == 'be'
|
||||
assert lemmas[4] == 'goose'
|
19
tests/test_morph_exceptions.py
Normal file
19
tests/test_morph_exceptions.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
from __future__ import unicode_literals
|
||||
from spacy.en import EN
|
||||
|
||||
import pytest
|
||||
|
||||
@pytest.fixture
|
||||
def morph_exc():
|
||||
return {
|
||||
'PRP$': {'his': {'L': '-PRP-', 'person': 3, 'case': 2}},
|
||||
}
|
||||
|
||||
def test_load_exc(morph_exc):
|
||||
EN.load()
|
||||
EN.morphologizer.load_exceptions(morph_exc)
|
||||
tokens = EN.tokenize('I like his style.')
|
||||
EN.set_pos(tokens)
|
||||
his = tokens[2]
|
||||
assert his.pos == 'PRP$'
|
||||
assert his.lemma == '-PRP-'
|
Loading…
Reference in New Issue
Block a user