spaCy/spacy/en/attrs.pyx

22 lines
805 B
Cython
Raw Normal View History

2014-12-30 15:25:31 +03:00
# cython: embedsignature=True
2015-01-05 09:54:13 +03:00
from ..orth cimport is_alpha, is_ascii, is_digit, is_lower, is_punct, is_space
from ..orth cimport is_title, is_upper, like_url, like_number, like_email
2014-12-21 03:29:11 +03:00
from ..typedefs cimport flags_t
2015-07-27 02:51:24 +03:00
def get_flags(unicode string, is_oov=False):
2014-12-21 03:29:11 +03:00
cdef flags_t flags = 0
2015-07-27 02:51:24 +03:00
flags |= is_oov << IS_OOV
2015-01-05 09:54:13 +03:00
flags |= is_alpha(string) << IS_ALPHA
flags |= is_ascii(string) << IS_ASCII
flags |= is_digit(string) << IS_DIGIT
flags |= is_lower(string) << IS_LOWER
flags |= is_punct(string) << IS_PUNCT
flags |= is_space(string) << IS_SPACE
flags |= is_title(string) << IS_TITLE
flags |= is_upper(string) << IS_UPPER
flags |= like_url(string) << LIKE_URL
flags |= like_number(string) << LIKE_NUM
flags |= like_email(string) << LIKE_EMAIL
2014-12-21 03:29:11 +03:00
return flags