mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 17:36:30 +03:00
48 lines
1.1 KiB
Python
48 lines
1.1 KiB
Python
from __future__ import unicode_literals
|
|
|
|
from spacy.en import EN
|
|
|
|
import pytest
|
|
|
|
|
|
@pytest.fixture
|
|
def close_puncts():
|
|
return [')', ']', '}', '*']
|
|
|
|
|
|
def test_close(close_puncts):
|
|
word_str = 'Hello'
|
|
for p in close_puncts:
|
|
string = word_str + p
|
|
tokens = EN.tokenize(string)
|
|
assert len(tokens) == 2
|
|
assert tokens[1].string == p
|
|
assert tokens[0].string == word_str
|
|
|
|
|
|
def test_two_different_close(close_puncts):
|
|
word_str = 'Hello'
|
|
for p in close_puncts:
|
|
string = word_str + p + "'"
|
|
tokens = EN.tokenize(string)
|
|
assert len(tokens) == 3
|
|
assert tokens[0].string == word_str
|
|
assert tokens[1].string == p
|
|
assert tokens[2].string == "'"
|
|
|
|
|
|
def test_three_same_close(close_puncts):
|
|
word_str = 'Hello'
|
|
for p in close_puncts:
|
|
string = word_str + p + p + p
|
|
tokens = EN.tokenize(string)
|
|
assert len(tokens) == 4
|
|
assert tokens[0].string == word_str
|
|
assert tokens[1].string == p
|
|
|
|
|
|
def test_double_end_quote():
|
|
assert len(EN.tokenize("Hello''")) == 2
|
|
assert len(EN.tokenize("''")) == 1
|
|
|