2014-12-21 20:25:43 +00:00
|
|
|
from .typedefs cimport hash_t, flags_t, id_t, len_t, tag_t, attr_t, attr_id_t
|
|
|
|
from .typedefs cimport ID, SIC, DENSE, SHAPE, PREFIX, SUFFIX, LENGTH, CLUSTER, POS_TYPE
|
2014-12-19 19:51:03 +00:00
|
|
|
from .structs cimport Lexeme
|
|
|
|
from .strings cimport StringStore
|
2014-10-09 08:53:30 +00:00
|
|
|
|
|
|
|
|
2014-10-23 13:59:17 +00:00
|
|
|
cdef Lexeme EMPTY_LEXEME
|
2014-09-10 18:41:37 +00:00
|
|
|
|
2014-12-03 00:04:00 +00:00
|
|
|
|
|
|
|
cpdef Lexeme init(id_t i, unicode string, hash_t hashed, StringStore store,
|
|
|
|
dict props) except *
|
2014-10-29 12:19:38 +00:00
|
|
|
|
2014-10-09 03:10:46 +00:00
|
|
|
|
2014-12-03 04:44:25 +00:00
|
|
|
cdef inline bint check_flag(const Lexeme* lexeme, attr_id_t flag_id) nogil:
|
2014-10-23 13:59:17 +00:00
|
|
|
return lexeme.flags & (1 << flag_id)
|
2014-12-03 00:04:00 +00:00
|
|
|
|
|
|
|
|
2014-12-04 09:46:20 +00:00
|
|
|
cdef inline attr_t get_attr(const Lexeme* lex, attr_id_t feat_name) nogil:
|
|
|
|
if feat_name < (sizeof(flags_t) * 8):
|
|
|
|
return check_flag(lex, feat_name)
|
|
|
|
elif feat_name == ID:
|
|
|
|
return lex.id
|
|
|
|
elif feat_name == SIC:
|
|
|
|
return lex.sic
|
|
|
|
elif feat_name == DENSE:
|
|
|
|
return lex.dense
|
|
|
|
elif feat_name == SHAPE:
|
|
|
|
return lex.shape
|
|
|
|
elif feat_name == PREFIX:
|
|
|
|
return lex.prefix
|
|
|
|
elif feat_name == SUFFIX:
|
|
|
|
return lex.suffix
|
|
|
|
elif feat_name == LENGTH:
|
|
|
|
return lex.length
|
|
|
|
elif feat_name == CLUSTER:
|
|
|
|
return lex.cluster
|
|
|
|
elif feat_name == POS_TYPE:
|
|
|
|
return lex.pos_type
|
|
|
|
else:
|
|
|
|
return 0
|