2014-07-07 06:23:46 +04:00
|
|
|
from __future__ import unicode_literals
|
2014-12-21 12:41:13 +03:00
|
|
|
import pytest
|
2014-07-07 06:23:46 +04:00
|
|
|
|
2014-12-21 12:41:13 +03:00
|
|
|
from spacy.en import English
|
2014-07-07 06:23:46 +04:00
|
|
|
|
2014-12-21 12:41:13 +03:00
|
|
|
@pytest.fixture
|
|
|
|
def EN():
|
2014-12-30 13:34:09 +03:00
|
|
|
return English()
|
2014-07-07 06:23:46 +04:00
|
|
|
|
2014-12-21 12:41:13 +03:00
|
|
|
|
|
|
|
def test_possess(EN):
|
|
|
|
tokens = EN("Mike's")
|
2015-01-05 05:15:46 +03:00
|
|
|
assert EN.vocab.strings[tokens[0].sic] == b"Mike"
|
|
|
|
assert EN.vocab.strings[tokens[1].sic] == b"'s"
|
2014-08-18 21:14:00 +04:00
|
|
|
assert len(tokens) == 2
|
2014-07-07 06:23:46 +04:00
|
|
|
|
|
|
|
|
2014-12-21 12:41:13 +03:00
|
|
|
def test_apostrophe(EN):
|
|
|
|
tokens = EN("schools'")
|
2014-07-07 06:23:46 +04:00
|
|
|
assert len(tokens) == 2
|
2015-01-05 09:54:54 +03:00
|
|
|
assert tokens[1].string == b"'"
|
|
|
|
assert tokens[0].string == b"schools"
|
2014-07-07 06:23:46 +04:00
|
|
|
|
|
|
|
|
2014-12-21 12:41:13 +03:00
|
|
|
def test_LL(EN):
|
|
|
|
tokens = EN("we'll")
|
2014-07-07 06:23:46 +04:00
|
|
|
assert len(tokens) == 2
|
2015-01-05 09:54:54 +03:00
|
|
|
assert tokens[1].string == b"'ll"
|
|
|
|
assert tokens[1].lemma == b"will"
|
|
|
|
assert tokens[0].string == b"we"
|
2014-07-07 06:23:46 +04:00
|
|
|
|
|
|
|
|
2014-12-21 12:41:13 +03:00
|
|
|
def test_aint(EN):
|
|
|
|
tokens = EN("ain't")
|
2014-07-07 06:23:46 +04:00
|
|
|
assert len(tokens) == 2
|
2015-01-05 09:54:54 +03:00
|
|
|
assert tokens[0].string == b"ai"
|
|
|
|
assert tokens[0].lemma == b"be"
|
|
|
|
assert tokens[1].string == b"n't"
|
|
|
|
assert tokens[1].lemma == b"not"
|
2014-07-07 07:07:21 +04:00
|
|
|
|
|
|
|
|
2014-12-21 12:41:13 +03:00
|
|
|
def test_capitalized(EN):
|
|
|
|
tokens = EN("can't")
|
2014-07-07 07:07:21 +04:00
|
|
|
assert len(tokens) == 2
|
2014-12-21 12:41:13 +03:00
|
|
|
tokens = EN("Can't")
|
2014-07-07 07:07:21 +04:00
|
|
|
assert len(tokens) == 2
|
2014-12-21 12:41:13 +03:00
|
|
|
tokens = EN("Ain't")
|
2014-07-07 07:07:21 +04:00
|
|
|
assert len(tokens) == 2
|
2015-01-05 09:54:54 +03:00
|
|
|
assert tokens[0].string == b"Ai"
|
|
|
|
assert tokens[0].lemma == b"be"
|
2014-12-07 14:08:04 +03:00
|
|
|
|
|
|
|
|
2014-12-21 12:41:13 +03:00
|
|
|
def test_punct(EN):
|
|
|
|
tokens = EN("We've")
|
2014-12-07 14:08:04 +03:00
|
|
|
assert len(tokens) == 2
|
2014-12-21 12:41:13 +03:00
|
|
|
tokens = EN("``We've")
|
2014-12-07 14:08:04 +03:00
|
|
|
assert len(tokens) == 3
|