2014-07-07 02:23:46 +00:00
|
|
|
from __future__ import unicode_literals
|
2014-12-21 09:41:13 +00:00
|
|
|
import pytest
|
2014-07-07 02:23:46 +00:00
|
|
|
|
2014-12-21 09:41:13 +00:00
|
|
|
from spacy.en import English
|
2014-07-07 02:23:46 +00:00
|
|
|
|
2015-05-24 23:02:03 +00:00
|
|
|
EN = English()
|
2014-07-07 02:23:46 +00:00
|
|
|
|
2015-05-24 23:02:03 +00:00
|
|
|
def test_possess():
|
|
|
|
tokens = EN("Mike's", parse=False, tag=False)
|
2015-01-22 15:08:25 +00:00
|
|
|
assert EN.vocab.strings[tokens[0].orth] == "Mike"
|
|
|
|
assert EN.vocab.strings[tokens[1].orth] == "'s"
|
2014-08-18 17:14:00 +00:00
|
|
|
assert len(tokens) == 2
|
2014-07-07 02:23:46 +00:00
|
|
|
|
|
|
|
|
2015-05-24 23:02:03 +00:00
|
|
|
def test_apostrophe():
|
|
|
|
tokens = EN("schools'", parse=False, tag=False)
|
2014-07-07 02:23:46 +00:00
|
|
|
assert len(tokens) == 2
|
2015-01-23 20:22:30 +00:00
|
|
|
assert tokens[1].orth_ == "'"
|
|
|
|
assert tokens[0].orth_ == "schools"
|
2014-07-07 02:23:46 +00:00
|
|
|
|
|
|
|
|
2015-05-24 23:02:03 +00:00
|
|
|
def test_LL():
|
2015-01-29 23:41:55 +00:00
|
|
|
tokens = EN("we'll", parse=False)
|
2014-07-07 02:23:46 +00:00
|
|
|
assert len(tokens) == 2
|
2015-01-23 20:22:30 +00:00
|
|
|
assert tokens[1].orth_ == "'ll"
|
2015-01-14 16:51:47 +00:00
|
|
|
assert tokens[1].lemma_ == "will"
|
2015-01-23 20:22:30 +00:00
|
|
|
assert tokens[0].orth_ == "we"
|
2014-07-07 02:23:46 +00:00
|
|
|
|
|
|
|
|
2015-05-24 23:02:03 +00:00
|
|
|
def test_aint():
|
2015-01-29 23:41:55 +00:00
|
|
|
tokens = EN("ain't", parse=False)
|
2014-07-07 02:23:46 +00:00
|
|
|
assert len(tokens) == 2
|
2015-01-23 20:22:30 +00:00
|
|
|
assert tokens[0].orth_ == "ai"
|
2015-01-14 16:51:47 +00:00
|
|
|
assert tokens[0].lemma_ == "be"
|
2015-01-23 20:22:30 +00:00
|
|
|
assert tokens[1].orth_ == "n't"
|
2015-01-14 16:51:47 +00:00
|
|
|
assert tokens[1].lemma_ == "not"
|
2014-07-07 03:07:21 +00:00
|
|
|
|
|
|
|
|
2015-05-24 23:02:03 +00:00
|
|
|
def test_capitalized():
|
2015-01-29 23:41:55 +00:00
|
|
|
tokens = EN("can't", parse=False)
|
2014-07-07 03:07:21 +00:00
|
|
|
assert len(tokens) == 2
|
2015-01-29 23:41:55 +00:00
|
|
|
tokens = EN("Can't", parse=False)
|
2014-07-07 03:07:21 +00:00
|
|
|
assert len(tokens) == 2
|
2015-01-29 23:41:55 +00:00
|
|
|
tokens = EN("Ain't", parse=False)
|
2014-07-07 03:07:21 +00:00
|
|
|
assert len(tokens) == 2
|
2015-01-23 20:22:30 +00:00
|
|
|
assert tokens[0].orth_ == "Ai"
|
2015-01-14 16:51:47 +00:00
|
|
|
assert tokens[0].lemma_ == "be"
|
2014-12-07 11:08:04 +00:00
|
|
|
|
|
|
|
|
2015-05-24 23:02:03 +00:00
|
|
|
def test_punct():
|
2015-01-29 23:41:55 +00:00
|
|
|
tokens = EN("We've", parse=False)
|
2014-12-07 11:08:04 +00:00
|
|
|
assert len(tokens) == 2
|
2015-01-29 23:41:55 +00:00
|
|
|
tokens = EN("``We've", parse=False)
|
2014-12-07 11:08:04 +00:00
|
|
|
assert len(tokens) == 3
|