2014-09-25 20:29:42 +04:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
2014-12-21 13:05:28 +03:00
|
|
|
from spacy.en import English
|
|
|
|
from spacy.en.attrs import IS_ALPHA, IS_DIGIT
|
2014-09-25 20:29:42 +04:00
|
|
|
|
|
|
|
|
2014-12-21 13:05:28 +03:00
|
|
|
@pytest.fixture
|
|
|
|
def EN():
|
|
|
|
return English(pos_tag=False)
|
|
|
|
|
|
|
|
|
|
|
|
def test_is_alpha(EN):
|
|
|
|
the = EN.vocab['the']
|
2014-10-23 17:59:17 +04:00
|
|
|
assert the['flags'] & (1 << IS_ALPHA)
|
2014-12-21 13:05:28 +03:00
|
|
|
year = EN.vocab['1999']
|
2014-10-23 17:59:17 +04:00
|
|
|
assert not year['flags'] & (1 << IS_ALPHA)
|
2014-12-21 13:05:28 +03:00
|
|
|
mixed = EN.vocab['hello1']
|
2014-10-23 17:59:17 +04:00
|
|
|
assert not mixed['flags'] & (1 << IS_ALPHA)
|
2014-09-25 20:29:42 +04:00
|
|
|
|
|
|
|
|
2014-12-21 13:05:28 +03:00
|
|
|
def test_is_digit(EN):
|
|
|
|
the = EN.vocab['the']
|
2014-10-23 17:59:17 +04:00
|
|
|
assert not the['flags'] & (1 << IS_DIGIT)
|
2014-12-21 13:05:28 +03:00
|
|
|
year = EN.vocab['1999']
|
2014-10-23 17:59:17 +04:00
|
|
|
assert year['flags'] & (1 << IS_DIGIT)
|
2014-12-21 13:05:28 +03:00
|
|
|
mixed = EN.vocab['hello1']
|
2014-10-23 17:59:17 +04:00
|
|
|
assert not mixed['flags'] & (1 << IS_DIGIT)
|