* Update tests

This commit is contained in:
Matthew Honnibal 2015-07-23 09:26:43 +02:00
parent 4af2595d99
commit bee2e77983
10 changed files with 18 additions and 0 deletions

View File

@ -1,6 +1,7 @@
import pytest import pytest
@pytest.mark.models
def test_root(EN): def test_root(EN):
tokens = EN(u"i don't have other assistance") tokens = EN(u"i don't have other assistance")
for t in tokens: for t in tokens:

View File

@ -12,6 +12,7 @@ def sun_text():
return text return text
@pytest.mark.models
def test_consistency(EN, sun_text): def test_consistency(EN, sun_text):
tokens = EN(sun_text) tokens = EN(sun_text)
for head in tokens: for head in tokens:
@ -21,6 +22,7 @@ def test_consistency(EN, sun_text):
assert child.head is head assert child.head is head
@pytest.mark.models
def test_child_consistency(EN, sun_text): def test_child_consistency(EN, sun_text):
tokens = EN(sun_text) tokens = EN(sun_text)
@ -53,6 +55,7 @@ def test_child_consistency(EN, sun_text):
assert not children assert not children
@pytest.mark.models
def test_edges(EN): def test_edges(EN):
sun_text = u"Chemically, about three quarters of the Sun's mass consists of hydrogen, while the rest is mostly helium." sun_text = u"Chemically, about three quarters of the Sun's mass consists of hydrogen, while the rest is mostly helium."
tokens = EN(sun_text) tokens = EN(sun_text)

View File

@ -1,6 +1,8 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import pytest
@pytest.mark.models
def test_subtrees(EN): def test_subtrees(EN):
sent = EN('The four wheels on the bus turned quickly') sent = EN('The four wheels on the bus turned quickly')
wheels = sent[2] wheels = sent[2]

View File

@ -9,6 +9,7 @@ def doc(EN):
return EN('This is a sentence. This is another sentence. And a third.') return EN('This is a sentence. This is another sentence. And a third.')
@pytest.mark.models
def test_sent_spans(doc): def test_sent_spans(doc):
sents = list(doc.sents) sents = list(doc.sents)
assert sents[0].start == 0 assert sents[0].start == 0
@ -17,6 +18,7 @@ def test_sent_spans(doc):
assert sum(len(sent) for sent in sents) == len(doc) assert sum(len(sent) for sent in sents) == len(doc)
@pytest.mark.models
def test_root(doc): def test_root(doc):
np = doc[2:4] np = doc[2:4]
assert len(np) == 2 assert len(np) == 2

View File

@ -17,6 +17,7 @@ def lemmas(tagged):
return [t.lemma_ for t in tagged] return [t.lemma_ for t in tagged]
@pytest.mark.models
def test_lemmas(lemmas, tagged): def test_lemmas(lemmas, tagged):
assert lemmas[0] == 'banana' assert lemmas[0] == 'banana'
assert lemmas[1] == 'in' assert lemmas[1] == 'in'

View File

@ -12,6 +12,7 @@ def morph_exc():
} }
@pytest.mark.models
def test_load_exc(morph_exc): def test_load_exc(morph_exc):
# Do this local as we want to modify it # Do this local as we want to modify it
nlp = English() nlp = English()

View File

@ -1,7 +1,9 @@
from spacy.en import English from spacy.en import English
import six import six
import pytest
@pytest.mark.models
def test_tag_names(EN): def test_tag_names(EN):
tokens = EN(u'I ate pizzas with anchovies.', parse=False, tag=True) tokens = EN(u'I ate pizzas with anchovies.', parse=False, tag=True)
pizza = tokens[2] pizza = tokens[2]

View File

@ -15,6 +15,7 @@ def test_attr_of_token(EN):
assert feats_array[0][0] != feats_array[0][1] assert feats_array[0][0] != feats_array[0][1]
@pytest.mark.models
def test_tag(EN): def test_tag(EN):
text = u'A nice sentence.' text = u'A nice sentence.'
tokens = EN(text) tokens = EN(text)
@ -26,6 +27,7 @@ def test_tag(EN):
assert feats_array[3][1] == tokens[3].tag assert feats_array[3][1] == tokens[3].tag
@pytest.mark.models
def test_dep(EN): def test_dep(EN):
text = u'A nice sentence.' text = u'A nice sentence.'
tokens = EN(text) tokens = EN(text)

View File

@ -4,6 +4,7 @@ import pytest
from spacy.parts_of_speech import ADV from spacy.parts_of_speech import ADV
@pytest.mark.models
def test_prob(EN): def test_prob(EN):
tokens = EN(u'Give it back', parse=False) tokens = EN(u'Give it back', parse=False)
give = tokens[0] give = tokens[0]

View File

@ -9,6 +9,7 @@ data_dir = os.environ.get('SPACY_DATA', LOCAL_DATA_DIR)
# Let this have its own instances, as we have to be careful about memory here # Let this have its own instances, as we have to be careful about memory here
# that's the point, after all # that's the point, after all
@pytest.mark.models
def get_orphan_token(text, i): def get_orphan_token(text, i):
nlp = English(load_vectors=False, data_dir=data_dir) nlp = English(load_vectors=False, data_dir=data_dir)
tokens = nlp(text) tokens = nlp(text)
@ -18,6 +19,7 @@ def get_orphan_token(text, i):
return token return token
@pytest.mark.models
def test_orphan(): def test_orphan():
orphan = get_orphan_token('An orphan token', 1) orphan = get_orphan_token('An orphan token', 1)
gc.collect() gc.collect()
@ -36,6 +38,7 @@ def _orphan_from_list(toks):
return lst return lst
@pytest.mark.models
def test_list_orphans(): def test_list_orphans():
# Test case from NSchrading # Test case from NSchrading
nlp = English(load_vectors=False, data_dir=data_dir) nlp = English(load_vectors=False, data_dir=data_dir)