2014-07-07 06:23:46 +04:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2014-08-27 22:22:33 +04:00
|
|
|
from spacy.en import EN
|
2014-07-07 06:23:46 +04:00
|
|
|
|
|
|
|
|
|
|
|
def test_possess():
|
2014-08-27 22:22:33 +04:00
|
|
|
tokens = EN.tokenize("Mike's")
|
2014-10-29 15:19:38 +03:00
|
|
|
assert EN.lexicon.strings[tokens[0].sic] == "Mike"
|
|
|
|
assert EN.lexicon.strings[tokens[1].sic] == "'s"
|
2014-08-18 21:14:00 +04:00
|
|
|
assert len(tokens) == 2
|
2014-07-07 06:23:46 +04:00
|
|
|
|
|
|
|
|
|
|
|
def test_apostrophe():
|
2014-08-27 22:22:33 +04:00
|
|
|
tokens = EN.tokenize("schools'")
|
2014-07-07 06:23:46 +04:00
|
|
|
assert len(tokens) == 2
|
2014-08-27 22:22:33 +04:00
|
|
|
assert tokens[1].string == "'"
|
|
|
|
assert tokens[0].string == "schools"
|
2014-07-07 06:23:46 +04:00
|
|
|
|
|
|
|
|
|
|
|
def test_LL():
|
2014-08-27 22:22:33 +04:00
|
|
|
tokens = EN.tokenize("we'll")
|
2014-07-07 06:23:46 +04:00
|
|
|
assert len(tokens) == 2
|
2014-12-09 06:48:01 +03:00
|
|
|
assert tokens[1].string == "'ll"
|
|
|
|
assert tokens[1].lemma == "will"
|
2014-08-27 22:22:33 +04:00
|
|
|
assert tokens[0].string == "we"
|
2014-07-07 06:23:46 +04:00
|
|
|
|
|
|
|
|
|
|
|
def test_aint():
|
2014-08-27 22:22:33 +04:00
|
|
|
tokens = EN.tokenize("ain't")
|
2014-07-07 06:23:46 +04:00
|
|
|
assert len(tokens) == 2
|
2014-12-09 06:48:01 +03:00
|
|
|
assert tokens[0].string == "ai"
|
|
|
|
assert tokens[0].lemma == "be"
|
|
|
|
assert tokens[1].string == "n't"
|
|
|
|
assert tokens[1].lemma == "not"
|
2014-07-07 07:07:21 +04:00
|
|
|
|
|
|
|
|
|
|
|
def test_capitalized():
|
2014-08-27 22:22:33 +04:00
|
|
|
tokens = EN.tokenize("can't")
|
2014-07-07 07:07:21 +04:00
|
|
|
assert len(tokens) == 2
|
2014-08-27 22:22:33 +04:00
|
|
|
tokens = EN.tokenize("Can't")
|
2014-07-07 07:07:21 +04:00
|
|
|
assert len(tokens) == 2
|
2014-08-27 22:22:33 +04:00
|
|
|
tokens = EN.tokenize("Ain't")
|
2014-07-07 07:07:21 +04:00
|
|
|
assert len(tokens) == 2
|
2014-12-09 06:48:01 +03:00
|
|
|
assert tokens[0].string == "Ai"
|
|
|
|
assert tokens[0].lemma == "be"
|
2014-12-07 14:08:04 +03:00
|
|
|
|
|
|
|
|
|
|
|
def test_punct():
|
|
|
|
tokens = EN.tokenize("We've")
|
|
|
|
assert len(tokens) == 2
|
|
|
|
tokens = EN.tokenize("``We've")
|
|
|
|
assert len(tokens) == 3
|