2015-04-07 02:52:25 +00:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
2015-07-09 15:30:58 +00:00
|
|
|
def doc(EN):
|
|
|
|
return EN('This is a sentence. This is another sentence. And a third.')
|
2015-04-07 02:52:25 +00:00
|
|
|
|
|
|
|
|
2015-07-23 07:26:43 +00:00
|
|
|
@pytest.mark.models
|
2015-04-07 02:52:25 +00:00
|
|
|
def test_sent_spans(doc):
|
|
|
|
sents = list(doc.sents)
|
|
|
|
assert sents[0].start == 0
|
|
|
|
assert sents[0].end == 5
|
|
|
|
assert len(sents) == 3
|
|
|
|
assert sum(len(sent) for sent in sents) == len(doc)
|
2015-07-09 15:30:58 +00:00
|
|
|
|
|
|
|
|
2015-07-23 07:26:43 +00:00
|
|
|
@pytest.mark.models
|
2015-07-09 15:30:58 +00:00
|
|
|
def test_root(doc):
|
|
|
|
np = doc[2:4]
|
|
|
|
assert len(np) == 2
|
|
|
|
assert np.orth_ == 'a sentence'
|
|
|
|
assert np.root.orth_ == 'sentence'
|
2015-07-13 22:08:50 +00:00
|
|
|
assert np.root.head.orth_ == 'is'
|