2014-07-05 22:51:42 +04:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2014-12-23 03:40:32 +03:00
|
|
|
from spacy.en import English
|
2014-07-05 22:51:42 +04:00
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def paired_puncts():
|
|
|
|
return [('(', ')'), ('[', ']'), ('{', '}'), ('*', '*')]
|
|
|
|
|
|
|
|
|
2014-12-23 03:40:32 +03:00
|
|
|
@pytest.fixture
|
|
|
|
def EN():
|
|
|
|
return English()
|
|
|
|
|
|
|
|
|
|
|
|
def test_token(paired_puncts, EN):
|
2014-07-05 22:51:42 +04:00
|
|
|
word_str = 'Hello'
|
|
|
|
for open_, close_ in paired_puncts:
|
|
|
|
string = open_ + word_str + close_
|
2014-12-23 03:40:32 +03:00
|
|
|
tokens = EN(string)
|
2014-07-05 22:51:42 +04:00
|
|
|
assert len(tokens) == 3
|
2015-01-23 23:22:30 +03:00
|
|
|
assert tokens[0].orth_ == open_
|
|
|
|
assert tokens[1].orth_ == word_str
|
|
|
|
assert tokens[2].orth_ == close_
|
2014-07-05 22:51:42 +04:00
|
|
|
|
|
|
|
|
2014-12-23 03:40:32 +03:00
|
|
|
def test_two_different(paired_puncts, EN):
|
2014-07-05 22:51:42 +04:00
|
|
|
word_str = 'Hello'
|
|
|
|
for open_, close_ in paired_puncts:
|
|
|
|
string = "`" + open_ + word_str + close_ + "'"
|
2014-12-23 03:40:32 +03:00
|
|
|
tokens = EN(string)
|
2014-07-05 22:51:42 +04:00
|
|
|
assert len(tokens) == 5
|
2015-01-23 23:22:30 +03:00
|
|
|
assert tokens[0].orth_ == "`"
|
|
|
|
assert tokens[1].orth_ == open_
|
|
|
|
assert tokens[2].orth_ == word_str
|
|
|
|
assert tokens[2].orth_ == word_str
|
|
|
|
assert tokens[3].orth_ == close_
|
|
|
|
assert tokens[4].orth_ == "'"
|