2014-07-05 18:51:42 +00:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def open_puncts():
|
|
|
|
return ['(', '[', '{', '*']
|
|
|
|
|
|
|
|
|
2015-06-07 15:24:49 +00:00
|
|
|
def test_open(open_puncts, en_tokenizer):
|
2014-07-05 18:51:42 +00:00
|
|
|
word_str = 'Hello'
|
|
|
|
for p in open_puncts:
|
|
|
|
string = p + word_str
|
2015-06-07 15:24:49 +00:00
|
|
|
tokens = en_tokenizer(string)
|
2014-07-05 18:51:42 +00:00
|
|
|
assert len(tokens) == 2
|
2015-01-23 20:22:30 +00:00
|
|
|
assert tokens[0].orth_ == p
|
|
|
|
assert tokens[1].orth_ == word_str
|
2014-07-05 18:51:42 +00:00
|
|
|
|
|
|
|
|
2015-06-07 15:24:49 +00:00
|
|
|
def test_two_different_open(open_puncts, en_tokenizer):
|
2014-07-05 18:51:42 +00:00
|
|
|
word_str = 'Hello'
|
|
|
|
for p in open_puncts:
|
|
|
|
string = p + "`" + word_str
|
2015-06-07 15:24:49 +00:00
|
|
|
tokens = en_tokenizer(string)
|
2014-07-05 18:51:42 +00:00
|
|
|
assert len(tokens) == 3
|
2015-01-23 20:22:30 +00:00
|
|
|
assert tokens[0].orth_ == p
|
|
|
|
assert tokens[1].orth_ == "`"
|
|
|
|
assert tokens[2].orth_ == word_str
|
2014-07-05 18:51:42 +00:00
|
|
|
|
|
|
|
|
2015-06-07 15:24:49 +00:00
|
|
|
def test_three_same_open(open_puncts, en_tokenizer):
|
2014-07-05 18:51:42 +00:00
|
|
|
word_str = 'Hello'
|
|
|
|
for p in open_puncts:
|
|
|
|
string = p + p + p + word_str
|
2015-06-07 15:24:49 +00:00
|
|
|
tokens = en_tokenizer(string)
|
2014-07-06 18:02:00 +00:00
|
|
|
assert len(tokens) == 4
|
2015-01-23 20:22:30 +00:00
|
|
|
assert tokens[0].orth_ == p
|
|
|
|
assert tokens[3].orth_ == word_str
|
2014-07-07 21:24:20 +00:00
|
|
|
|
|
|
|
|
2015-06-07 15:24:49 +00:00
|
|
|
def test_open_appostrophe(en_tokenizer):
|
2014-07-07 21:24:20 +00:00
|
|
|
string = "'The"
|
2015-06-07 15:24:49 +00:00
|
|
|
tokens = en_tokenizer(string)
|
2014-07-07 21:24:20 +00:00
|
|
|
assert len(tokens) == 2
|
2015-01-23 20:22:30 +00:00
|
|
|
assert tokens[0].orth_ == "'"
|