* Ensure Lexeme.check_flag returns a boolean value

This commit is contained in:
Matthew Honnibal 2015-09-06 17:52:32 +02:00
parent d1eea2d865
commit e35bb36be7

View File

@ -35,7 +35,10 @@ cdef class Lexeme:
@staticmethod @staticmethod
cdef inline attr_t get_struct_attr(const LexemeC* lex, attr_id_t feat_name) nogil: cdef inline attr_t get_struct_attr(const LexemeC* lex, attr_id_t feat_name) nogil:
if feat_name < (sizeof(flags_t) * 8): if feat_name < (sizeof(flags_t) * 8):
return Lexeme.check_flag(lex, feat_name) if Lexeme.check_flag(lex, feat_name):
return 1
else:
return 0
elif feat_name == ID: elif feat_name == ID:
return lex.id return lex.id
elif feat_name == ORTH: elif feat_name == ORTH:
@ -78,7 +81,10 @@ cdef class Lexeme:
@staticmethod @staticmethod
cdef inline bint check_flag(const LexemeC* lexeme, attr_id_t flag_id) nogil: cdef inline bint check_flag(const LexemeC* lexeme, attr_id_t flag_id) nogil:
return lexeme.flags & (1 << flag_id) if lexeme.flags & (1 << flag_id):
return True
else:
return False
@staticmethod @staticmethod
cdef inline bint set_flag(LexemeC* lex, attr_id_t flag_id, int value) nogil: cdef inline bint set_flag(LexemeC* lex, attr_id_t flag_id, int value) nogil: