2014-07-07 06:23:46 +04:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2014-08-18 21:14:00 +04:00
|
|
|
from spacy.en import tokenize, lookup, unhash
|
2014-07-07 06:23:46 +04:00
|
|
|
|
|
|
|
from spacy import lex_of
|
|
|
|
|
|
|
|
|
|
|
|
def test_possess():
|
2014-08-18 21:14:00 +04:00
|
|
|
tokens = tokenize("Mike's")
|
2014-07-07 06:23:46 +04:00
|
|
|
assert unhash(lex_of(tokens[0])) == "Mike"
|
|
|
|
assert unhash(lex_of(tokens[1])) == "'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-18 21:14:00 +04:00
|
|
|
tokens = tokenize("schools'")
|
2014-07-07 06:23:46 +04:00
|
|
|
assert len(tokens) == 2
|
|
|
|
assert unhash(lex_of(tokens[1])) == "'"
|
|
|
|
assert unhash(lex_of(tokens[0])) == "schools"
|
|
|
|
|
|
|
|
|
|
|
|
def test_LL():
|
2014-08-18 21:14:00 +04:00
|
|
|
tokens = tokenize("we'll")
|
2014-07-07 06:23:46 +04:00
|
|
|
assert len(tokens) == 2
|
|
|
|
assert unhash(lex_of(tokens[1])) == "will"
|
|
|
|
assert unhash(lex_of(tokens[0])) == "we"
|
|
|
|
|
|
|
|
|
|
|
|
def test_aint():
|
2014-08-18 21:14:00 +04:00
|
|
|
tokens = tokenize("ain't")
|
2014-07-07 06:23:46 +04:00
|
|
|
assert len(tokens) == 2
|
|
|
|
assert unhash(lex_of(tokens[0])) == "are"
|
|
|
|
assert unhash(lex_of(tokens[1])) == "not"
|
2014-07-07 07:07:21 +04:00
|
|
|
|
|
|
|
|
|
|
|
def test_capitalized():
|
2014-08-18 21:14:00 +04:00
|
|
|
tokens = tokenize("can't")
|
2014-07-07 07:07:21 +04:00
|
|
|
assert len(tokens) == 2
|
2014-08-18 21:14:00 +04:00
|
|
|
tokens = tokenize("Can't")
|
2014-07-07 07:07:21 +04:00
|
|
|
assert len(tokens) == 2
|
2014-08-18 21:14:00 +04:00
|
|
|
tokens = tokenize("Ain't")
|
2014-07-07 07:07:21 +04:00
|
|
|
assert len(tokens) == 2
|
|
|
|
assert unhash(lex_of(tokens[0])) == "Are"
|