* Add supersense data to Lexeme objects. Add simple has_sense method to check the flag.

This commit is contained in:
Matthew Honnibal 2015-07-01 18:50:37 +02:00
parent 64fafa98be
commit e23d1582a2
2 changed files with 8 additions and 1 deletions

View File

@ -6,7 +6,7 @@ from murmurhash.mrmr cimport hash64
from libc.string cimport memset
from .orth cimport word_shape
from .typedefs cimport attr_t
from .typedefs cimport attr_t, flags_t
import numpy
@ -28,6 +28,9 @@ cdef int set_lex_struct_props(LexemeC* lex, dict props, StringStore string_store
lex.sentiment = props['sentiment']
lex.flags = props['flags']
cdef flags_t sense_id
for sense_id in props.get('senses', []):
lex.senses |= 1 << sense_id
lex.repvec = empty_vec
@ -46,3 +49,6 @@ cdef class Lexeme:
cpdef bint check(self, attr_id_t flag_id) except -1:
return self.flags & (1 << flag_id)
cpdef bint has_sense(self, flags_t flag_id) except -1:
return self.senses & (1 << flag_id)

View File

@ -8,6 +8,7 @@ cdef struct LexemeC:
const float* repvec
flags_t flags
flags_t senses
attr_t id
attr_t length