2014-07-23 16:36:12 +00:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
from spacy.en import lookup, unhash
|
|
|
|
|
2014-08-22 02:20:24 +00:00
|
|
|
from spacy.en import lex_of, shape_of, norm_of, first_of, length_of
|
2014-07-23 16:36:12 +00:00
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def C3P0():
|
|
|
|
return lookup("C3P0")
|
|
|
|
|
|
|
|
|
|
|
|
def test_shape(C3P0):
|
|
|
|
assert unhash(shape_of(C3P0)) == "XdXd"
|
2014-08-02 20:26:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_length():
|
|
|
|
t = lookup('the')
|
|
|
|
assert length_of(t) == 3
|
2014-08-22 02:20:24 +00:00
|
|
|
#t = lookup('')
|
|
|
|
#assert length_of(t) == 0
|
2014-08-02 20:26:44 +00:00
|
|
|
t = lookup("n't")
|
|
|
|
assert length_of(t) == 3
|
|
|
|
t = lookup("'s")
|
|
|
|
assert length_of(t) == 2
|
|
|
|
t = lookup('Xxxx')
|
|
|
|
assert length_of(t) == 4
|