2014-10-14 13:25:57 +04:00
|
|
|
"""Test that tokens are created correctly for whitespace."""
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2014-12-23 03:40:32 +03:00
|
|
|
from spacy.en import English
|
2014-10-14 13:25:57 +04:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
2014-12-23 03:40:32 +03:00
|
|
|
@pytest.fixture
|
|
|
|
def EN():
|
2014-12-30 13:34:09 +03:00
|
|
|
return English()
|
2014-12-23 03:40:32 +03:00
|
|
|
|
|
|
|
|
|
|
|
def test_single_space(EN):
|
|
|
|
tokens = EN('hello possums')
|
2014-10-14 13:25:57 +04:00
|
|
|
assert len(tokens) == 2
|
|
|
|
|
|
|
|
|
2014-12-23 03:40:32 +03:00
|
|
|
def test_double_space(EN):
|
|
|
|
tokens = EN('hello possums')
|
2014-10-14 13:25:57 +04:00
|
|
|
assert len(tokens) == 3
|
2015-01-23 23:22:30 +03:00
|
|
|
assert tokens[1].orth_ == ' '
|
2014-10-14 13:25:57 +04:00
|
|
|
|
|
|
|
|
2014-12-23 03:40:32 +03:00
|
|
|
def test_newline(EN):
|
|
|
|
tokens = EN('hello\npossums')
|
2014-10-14 13:25:57 +04:00
|
|
|
assert len(tokens) == 3
|
|
|
|
|
|
|
|
|
2014-12-23 03:40:32 +03:00
|
|
|
def test_newline_space(EN):
|
|
|
|
tokens = EN('hello \npossums')
|
2014-10-14 13:25:57 +04:00
|
|
|
assert len(tokens) == 3
|
|
|
|
|
|
|
|
|
2014-12-23 03:40:32 +03:00
|
|
|
def test_newline_double_space(EN):
|
|
|
|
tokens = EN('hello \npossums')
|
2014-10-14 13:25:57 +04:00
|
|
|
assert len(tokens) == 3
|
|
|
|
|
|
|
|
|
2014-12-23 03:40:32 +03:00
|
|
|
def test_newline_space_wrap(EN):
|
|
|
|
tokens = EN('hello \n possums')
|
2014-10-14 13:25:57 +04:00
|
|
|
assert len(tokens) == 3
|