spaCy/tests/test_lexeme_flags.py

30 lines
639 B
Python
Raw Normal View History

2014-09-25 16:29:42 +00:00
from __future__ import unicode_literals
import pytest
2014-12-21 10:05:28 +00:00
from spacy.en import English
from spacy.en.attrs import *
2014-09-25 16:29:42 +00:00
2014-12-21 10:05:28 +00:00
@pytest.fixture
def EN():
2014-12-30 10:34:09 +00:00
return English()
2014-12-21 10:05:28 +00:00
def test_is_alpha(EN):
the = EN.vocab['the']
assert the.flags & (1 << IS_ALPHA)
2014-12-21 10:05:28 +00:00
year = EN.vocab['1999']
assert not year.flags & (1 << IS_ALPHA)
2014-12-21 10:05:28 +00:00
mixed = EN.vocab['hello1']
assert not mixed.flags & (1 << IS_ALPHA)
2014-09-25 16:29:42 +00:00
2014-12-21 10:05:28 +00:00
def test_is_digit(EN):
the = EN.vocab['the']
assert not the.flags & (1 << IS_DIGIT)
2014-12-21 10:05:28 +00:00
year = EN.vocab['1999']
assert year.flags & (1 << IS_DIGIT)
2014-12-21 10:05:28 +00:00
mixed = EN.vocab['hello1']
assert not mixed.flags & (1 << IS_DIGIT)