spaCy/tests/test_lexeme_flags.py

27 lines
636 B
Python
Raw Normal View History

2014-09-25 20:29:42 +04:00
from __future__ import unicode_literals
import pytest
from spacy.en import *
from spacy.lexeme import *
2014-09-25 20:29:42 +04:00
def test_is_alpha():
EN.load()
2014-10-30 10:15:30 +03:00
the = EN.lexicon['the']
assert the['flags'] & (1 << IS_ALPHA)
2014-10-30 10:15:30 +03:00
year = EN.lexicon['1999']
assert not year['flags'] & (1 << IS_ALPHA)
2014-10-30 10:15:30 +03:00
mixed = EN.lexicon['hello1']
assert not mixed['flags'] & (1 << IS_ALPHA)
2014-09-25 20:29:42 +04:00
def test_is_digit():
EN.load()
2014-10-30 10:15:30 +03:00
the = EN.lexicon['the']
assert not the['flags'] & (1 << IS_DIGIT)
2014-10-30 10:15:30 +03:00
year = EN.lexicon['1999']
assert year['flags'] & (1 << IS_DIGIT)
2014-10-30 10:15:30 +03:00
mixed = EN.lexicon['hello1']
assert not mixed['flags'] & (1 << IS_DIGIT)